/* ==================== 1. デザインシステム ＆ 変数定義 ==================== */
:root {
  --bg-dark: #070913;
  --bg-panel: rgba(13, 17, 33, 0.65);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 122, 255, 0.4);
  
  --text-main: #f5f6fa;
  --text-muted: #8a92b2;
  
  --primary: #007aff;
  --primary-hover: #3395ff;
  --success: #34c759;
  --success-hover: #5ad579;
  --warning: #ffcc00;
  --warning-hover: #ffe066;
  --danger: #ff3b30;
  --danger-hover: #ff665e;
  
  --glow-primary: 0 0 15px rgba(0, 122, 255, 0.5);
  --glow-success: 0 0 15px rgba(52, 199, 89, 0.5);
  --glow-warning: 0 0 15px rgba(255, 204, 0, 0.5);
  --glow-danger: 0 0 15px rgba(255, 59, 48, 0.5);
  
  --glass-bg: rgba(18, 22, 41, 0.6);
  --glass-blur: blur(20px) saturate(160%);
  --glass-border: 1px solid rgba(255, 255, 255, 0.07);
}

/* 全体リセットと基本設定 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* モバイルブラウザのアドレスバーを除いた実際の高さ */
  width: 100vw;
  position: relative;
}

/* ==================== 2. 背景ネオンデコレーション ==================== */
.bg-decorations {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-decorations .circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
  animation: pulseBg 12s infinite alternate ease-in-out;
}

.bg-decorations .c1 {
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, #5856d6 0%, rgba(88, 86, 214, 0) 70%);
  top: -10vw;
  left: -10vw;
}

.bg-decorations .c2 {
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #007aff 0%, rgba(0, 122, 255, 0) 70%);
  bottom: -15vw;
  right: -10vw;
  animation-delay: -6s;
}

@keyframes pulseBg {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.15) translate(30px, -20px); }
}

/* ==================== 3. 画面・レイアウト管理 ==================== */
#app-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 10;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  z-index: 20;
}

/* ガラスマージムパネル */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  padding: 40px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.glass.max-panel {
  max-width: 1000px;
  width: 95%;
}

.glass-sub {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 20px;
}

/* ==================== 4. UIパーツ: タイポグラフィ・入力・ボタン ==================== */
h1, h2, h3, h4, .logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-text {
  font-size: 3rem;
  text-align: center;
  background: linear-gradient(135deg, #007aff, #ff2d55);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
  text-shadow: 0 4px 20px rgba(0, 122, 255, 0.15);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 30px;
}

.section-title {
  font-size: 1.8rem;
  margin-bottom: 25px;
  border-left: 4px solid var(--primary);
  padding-left: 12px;
}

/* フォームグループ */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}

/* ボタン */
.btn {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #3549ff);
  color: white;
  box-shadow: var(--glow-primary);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #4d5eff);
  transform: translateY(-2px);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn.success {
  background: linear-gradient(135deg, var(--success), #289c44);
  color: white;
}
.btn.success:hover {
  background: linear-gradient(135deg, var(--success-hover), #33b151);
  transform: translateY(-2px);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger), #cc2f26);
  color: white;
}
.btn.danger:hover {
  background: linear-gradient(135deg, var(--danger-hover), #e63e35);
}

.btn.warning {
  background: linear-gradient(135deg, var(--warning), #cca300);
  color: #070913;
  box-shadow: var(--glow-warning);
}
.btn.warning:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--warning-hover), #e6b800);
  transform: scale(1.05);
}
.btn.warning:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn.pulse {
  animation: startPulse 2s infinite alternate;
}

@keyframes startPulse {
  0% { box-shadow: 0 0 10px rgba(52, 199, 89, 0.4); }
  100% { box-shadow: 0 0 25px rgba(52, 199, 89, 0.8); }
}

.action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  margin-top: 30px;
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
}

/* ==================== 5. ユーザー設定（アバター・チーム・スタイル） ==================== */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

/* アバター選択 */
/* チーム選択 */
.team-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 25px;
}

.team-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}
.team-dot.active {
  border-color: white;
  box-shadow: 0 0 10px currentColor;
  transform: scale(1.15);
}

/* スタイルカード */
.style-selector {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.style-card {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.style-card:hover {
  background: rgba(255, 255, 255, 0.03);
  transform: translateX(5px);
}
.style-card.active {
  border-color: var(--primary);
  background: rgba(0, 122, 255, 0.08);
  box-shadow: var(--glow-primary);
}

.style-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.style-card h4 {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.style-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==================== 6. ロビー画面 ==================== */
.lobby-columns {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  align-items: start;
}

.lobby-right-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 768px) {
  .lobby-columns {
    grid-template-columns: 1fr;
  }
}

.lobby-players {
  max-height: 450px;
  display: flex;
  flex-direction: column;
}

.player-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 5px;
}

.player-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.player-card.self {
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}

.player-card .avatar-icon {
  margin-bottom: 8px;
}

.player-card .p-name {
  font-size: 0.8rem;
  font-weight: 600;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card .p-badge {
  font-size: 0.65rem;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 10px;
}
.player-card .p-ready-badge {
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
}
.player-card .p-ready-badge.ready { filter: none; }
.player-card .p-ready-badge.waiting { opacity: 0.45; }
.player-card .p-ready-badge.host { filter: drop-shadow(0 0 4px gold); }
.btn.active-ready { background: var(--warning); color: #000; }

.bot-info-notice {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 15px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

/* ==================== 7. メインゲーム画面 ==================== */
#game-screen {
  flex-direction: column;
  padding: 0;
  justify-content: space-between;
}

/* ゲームHUD */
.game-hud {
  width: 98%;
  max-width: 1800px;
  height: 60px;
  margin: 10px auto 0 auto;
  border-radius: 16px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.game-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: bold;
  letter-spacing: 1px;
}

.timer-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1;
}

.shuffle-counter {
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shuffle-label {
  font-size: 0.5rem;
  color: var(--danger);
  font-weight: bold;
}

.shuffle-value {
  font-size: 0.9rem;
  font-weight: bold;
  line-height: 1;
}

/* HUD 占有率プログレスバー */
.hud-center {
  flex-grow: 1;
  max-width: 800px;
  margin: 0 20px;
}

.occupy-bar-container {
  height: 20px;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.occupy-segment {
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.65rem;
  font-weight: bold;
  color: #000;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sound-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-label {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--text-muted);
}

.volume-sliders {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.vol-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.vol-label {
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--text-muted);
  width: 26px;
  text-align: right;
}

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

.vol-val {
  font-size: 0.6rem;
  color: var(--text-muted);
  width: 22px;
  text-align: left;
}

/* トグルスイッチスタイル */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: var(--glow-primary);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 22px;
}

.slider.round:before {
  border-radius: 50%;
}

/* キャンバスエリア */
#canvas-container {
  flex-grow: 1;
  width: 98%;
  max-width: 1800px;
  margin: 10px auto;
  position: relative;
  background: #030408;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  display: block;
}

/* 演出オーバーレイ */
.event-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#effect-overlay {
  background: transparent;
}

#fever-overlay {
  font-size: 5rem;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 59, 48, 0.8), 0 0 40px rgba(255, 59, 48, 0.4);
  animation: feverTextAnim 1s infinite alternate;
}

#shuffle-overlay {
  font-size: 4rem;
  color: var(--warning);
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.8);
}

@keyframes feverTextAnim {
  0% { transform: scale(0.95); opacity: 0.9; }
  100% { transform: scale(1.05); opacity: 1; }
}

/* 下部操作パネル */
.game-controls {
  width: 98%;
  max-width: 1800px;
  height: 70px;
  margin: 0 auto 10px auto;
  border-radius: 16px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.player-status-panel {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-preview-small {
  width: 38px;
  height: 38px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.player-details .p-name {
  font-weight: bold;
  font-size: 0.85rem;
}

.player-details .badge {
  font-size: 0.65rem;
  background: var(--primary);
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-block;
  margin-top: 2px;
}

/* バフコンテナ */
.buffs-container {
  display: flex;
  gap: 8px;
}

.buff-icon {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
}

.buff-timer {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.buff-icon-em {
  font-size: 1rem;
  line-height: 1;
  /* CSS color に影響されないよう emoji をリセット */
  font-style: normal;
  -webkit-text-fill-color: initial;
  color: initial;
}

/* アクションボタン・スタンプ */
.action-buttons {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-bomb {
  position: relative;
  font-size: 0.9rem !important;
  padding: 10px 20px !important;
}

.badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.65rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.stamp-palette {
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 10px;
}

.btn-stamp {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-stamp:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ==================== 8. 観戦画面 ==================== */
/* ==================== 観戦モード全体 ==================== */
#spectator-screen {
  flex-direction: column;
  padding: 12px;
  justify-content: flex-start;
  gap: 10px;
  overflow: hidden;
  height: 100vh;
  box-sizing: border-box;
}

/* 上部HUD */
.spectator-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-radius: 12px;
  flex-shrink: 0;
}

.spec-hud-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.spectator-title {
  font-size: 1rem;
  font-weight: 800;
  color: #ff3b30;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-lbl {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-val {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
}

.timer-val { color: #ffcc00; }

.spec-fever {
  padding: 3px 12px;
  border-radius: 20px;
  background: rgba(255,60,0,0.2);
  border: 1px solid rgba(255,60,0,0.5);
  color: #ff6030;
  font-size: 0.78rem;
  font-weight: 800;
  animation: bannerPulse 0.7s infinite alternate;
}

/* メインレイアウト */
.spectator-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1024px) {
  .spectator-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* マップコンテナ */
.spectator-map-container {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: #0a0c14;
  border-radius: 14px;
  position: relative;
  min-height: 0;
}

.spectator-map-container canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 10px;
}

/* 凡例 */
.spec-map-legend {
  position: absolute;
  bottom: 10px;
  left: 12px;
  display: flex;
  gap: 12px;
  background: rgba(0,0,0,0.55);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  color: #ccc;
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.player-dot { background: #fff; border: 2px solid #007aff; }
.bot-dot { background: rgba(255,255,255,0.4); border: 1.5px solid rgba(255,255,255,0.3); }

/* サイドパネル */
.spectator-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
  min-height: 0;
  border-radius: 14px;
}

.spec-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* ランキングリスト */
.spec-ranking-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ranking-list { display: flex; flex-direction: column; gap: 5px; }

.ranking-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}

.ranking-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ranking-num { font-size: 0.7rem; color: var(--text-muted); min-width: 18px; }
.ranking-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ranking-name { font-size: 0.78rem; font-weight: 700; }
.ranking-pct { font-size: 0.72rem; font-weight: 800; text-align: right; min-width: 40px; }

.ranking-right {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 24px;
}

/* スコアバー */
.score-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* チャートエリア */
.spec-chart-section {
  flex-shrink: 0;
}

.chart-wrapper {
  height: 130px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

.chart-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ranking-num {
  font-weight: bold;
  font-family: 'Outfit', sans-serif;
  margin-right: 8px;
}

.ranking-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 8px;
}

.ranking-name {
  font-weight: 600;
}

.ranking-pct {
  font-family: 'Outfit', sans-serif;
  font-weight: bold;
}

/* ==================== 9. マップエディタ ==================== */
/* ==================== 9. マップエディタ画面 ==================== */

#editor-screen {
  flex-direction: column;
  padding: 10px 14px;
  gap: 8px;
  justify-content: flex-start;
  position: relative; /* ヘルプモーダルの基準 */
}

/* ---- トップバー ---- */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.editor-topbar h2 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}
.editor-topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---- ボディ：サイドバー＋キャンバスエリア ---- */
.editor-body {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

/* ---- 縦サイドバー ---- */
.editor-sidebar {
  width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 5px;
  gap: 3px;
  border-radius: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}
.editor-sidebar::-webkit-scrollbar { width: 3px; }
.editor-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-section-label {
  font-size: 0.52rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
  padding: 2px 0 1px;
  width: 100%;
}

.sidebar-divider {
  width: 70%;
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 3px 0;
}

/* ---- 地形ツールボタン（アイコンのみ正方形） ---- */
.btn-tool {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.btn-tool:hover { background: rgba(255, 255, 255, 0.13); }
.btn-tool.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--glow-primary);
}
.btn-tool.eraser-tool { border-color: rgba(255, 100, 100, 0.35); }
.btn-tool.eraser-tool.active { background: #a02020; border-color: #cc3333; box-shadow: 0 0 8px rgba(200,50,50,0.5); }

/* ---- 描画モードボタン ---- */
.btn-mode {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.btn-mode:hover { background: rgba(255, 255, 255, 0.13); }
.btn-mode.active {
  background: #b05818;
  border-color: #e07030;
  box-shadow: 0 0 8px rgba(220, 110, 40, 0.5);
}

/* ---- サイドバーアイコンボタン（インポート・ヘルプ） ---- */
.btn-sidebar-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  text-align: center;
  box-sizing: border-box;
}
.btn-sidebar-icon:hover { background: rgba(255, 255, 255, 0.13); }

/* ---- ブラシサイズセレクト（縦用） ---- */
.editor-select-v {
  width: 38px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 4px 2px;
  border-radius: 7px;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
}
.editor-select-v:focus { outline: 1px solid var(--primary); }

/* ---- キャンバスエリア（ズームバー＋キャンバス） ---- */
.editor-canvas-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

/* ---- ズームバー ---- */
.editor-zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  border-radius: 10px;
  flex-shrink: 0;
}
#editor-zoom {
  flex: 1;
  max-width: 240px;
  accent-color: var(--primary);
  cursor: pointer;
}
#editor-zoom-label {
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 38px;
  text-align: right;
  color: var(--text-main);
}
.btn-zoom-ctrl {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.73rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-zoom-ctrl:hover { background: rgba(255,255,255,0.15); }

/* ---- キャンバスコンテナ（スクロール可） ---- */
.editor-canvas-container {
  flex: 1;
  background: #030408;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  border-radius: 14px;
  min-height: 0;
}

/* オーバーレイ用スタック（メインCanvas＋プレビューCanvasを重ねる） */
.canvas-stack {
  display: grid;
  line-height: 0;
}
.canvas-stack > * { grid-area: 1 / 1; }

#editor-canvas { background: #030408; display: block; }
#editor-overlay { display: block; pointer-events: none; }

/* ---- ヘルプモーダル ---- */
.editor-help-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  border-radius: inherit;
}
.editor-help-overlay.hidden { display: none; }

.editor-help-box {
  width: min(520px, 88%);
  max-height: 82vh;
  overflow-y: auto;
  border-radius: 18px;
  padding: 22px 26px;
}
.editor-help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.editor-help-header h3 { font-size: 1rem; }
.btn-help-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-help-close:hover { background: rgba(255,255,255,0.1); }

.editor-help-body h4 {
  font-size: 0.8rem;
  color: var(--primary);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.help-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 5px 0;
  font-size: 0.8rem;
  line-height: 1.4;
}
.help-row > span {
  min-width: 34px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.help-row kbd {
  font-size: 0.68rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
}

.help-text {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==================== 10. 表彰・結果画面 ==================== */
#result-screen {
  z-index: 500;
}

.center-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.winner-title {
  font-size: 3rem;
  background: linear-gradient(135deg, var(--warning), #ff5e3a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2px;
}

.winner-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 40px;
}

/* 表彰台 */
.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 20px;
  height: 180px;
  margin-bottom: 40px;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.podium-avatar {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.podium-pedestal {
  width: 80px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: #000;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.3);
}

.podium-place.first .podium-pedestal {
  height: 100px;
  background: linear-gradient(to top, #cca300, #ffcc00);
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
}

.podium-place.second .podium-pedestal {
  height: 70px;
  background: linear-gradient(to top, #8e8e93, #c7c7cc);
}

.podium-place.third .podium-pedestal {
  height: 50px;
  background: linear-gradient(to top, #a25624, #d57d45);
}

.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  width: 100%;
  margin-bottom: 30px;
}

@media (max-width: 768px) {
  .result-details {
    grid-template-columns: 1fr;
  }
}

.result-box {
  text-align: left;
  display: flex;
  flex-direction: column;
  padding: 20px;
  max-height: 340px;
  overflow: hidden;
}

.result-box .indiv-rankings {
  overflow-y: auto;
  flex-grow: 1;
}

.result-box h3 {
  font-size: 1rem;
  margin-bottom: 15px;
}

.result-list {
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-size: 0.9rem;
}

.chart-wrapper-small {
  height: 150px;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}
.chart-wrapper-small canvas {
  width: 100%;
  height: 100%;
}
.result-map-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 8px;
  min-height: 120px;
}
#result-map-canvas {
  border-radius: 8px;
  image-rendering: pixelated;
  max-width: 100%;
  max-height: 260px;
}

/* ==================== ロビー スタイル選択 ==================== */
.lobby-style-select {
  padding: 16px;
  border-radius: 16px;
  margin-top: 12px;
}
.lobby-style-select h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lobby-style-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lobby-style-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: rgba(0,0,0,0.2);
  cursor: pointer;
  transition: all 0.2s ease;
}
.lobby-style-card:hover {
  background: rgba(255,255,255,0.04);
}
.lobby-style-card.active {
  border-color: var(--primary);
  background: rgba(0,122,255,0.12);
  box-shadow: var(--glow-primary);
}
.lobby-style-card.disabled-card {
  opacity: 0.35;
  pointer-events: none;
}
.lsc-icon {
  font-size: 1.4rem;
  width: 36px;
  text-align: center;
}
.lsc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lsc-info strong {
  font-size: 0.85rem;
  font-weight: 700;
}
.lsc-info span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==================== HUD フィーバー/シャッフルバナー ==================== */
.hud-event-banner {
  padding: 5px 14px;
  border-radius: 20px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  animation: bannerPulse 0.8s infinite alternate;
  white-space: nowrap;
}
.hud-event-banner.fever {
  background: rgba(255, 59, 48, 0.2);
  border: 1px solid rgba(255, 59, 48, 0.6);
  color: #ff5e57;
  box-shadow: 0 0 12px rgba(255,59,48,0.4);
}
.hud-event-banner.shuffle {
  background: rgba(255, 204, 0, 0.15);
  border: 1px solid rgba(255, 204, 0, 0.5);
  color: #ffd60a;
  box-shadow: 0 0 12px rgba(255,204,0,0.3);
  animation: none;
}
@keyframes bannerPulse {
  0% { opacity: 0.85; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.02); }
}

/* ==================== 個人ランキング (結果画面) ==================== */
.indiv-rankings { display: flex; flex-direction: column; gap: 7px; }

.indiv-rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-light);
}
.indiv-rank-row canvas { border-radius: 50%; flex-shrink: 0; }
.indiv-medal { font-size: 1.1rem; min-width: 28px; text-align: center; }
.indiv-name {
  font-size: 0.8rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.indiv-bar-track {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.indiv-bar-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease; }
.indiv-pct { font-size: 0.72rem; font-weight: 800; min-width: 42px; text-align: right; color: var(--text-muted); }

.result-box-wide { grid-column: 1 / -1; }

/* ==================== お邪魔アイテム UI ==================== */
.buff-icon.debuff {
  background: rgba(255, 60, 60, 0.18) !important;
  border-color: rgba(255, 60, 60, 0.5) !important;
  color: #ff6060 !important;
}

.blind-overlay-el {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.82);
  z-index: 10;
  align-items: center;
  justify-content: center;
}

.debuff-notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 900;
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255,0,0,0.8), 0 2px 4px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  transition: opacity 0.5s;
}
.debuff-notice.fade-out { opacity: 0; }

/* アイテム設定トグル */
.item-config-details { margin-top: 10px; }
.item-config-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 0;
}
.item-toggle-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
}
.item-toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.item-toggle-row:hover { background: rgba(255,255,255,0.07); }
.item-toggle-row span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-toggle-row.nuisance span { color: #ff9090; }
.item-toggle-row input[type=checkbox] { accent-color: var(--primary); flex-shrink: 0; }
.sel-item-weight {
  flex-shrink: 0;
  width: 48px;
  font-size: 0.68rem;
  padding: 2px 2px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.25);
  background: #1a1e30;
  color: #c8d0f0;
  cursor: pointer;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
}
.sel-item-weight:focus {
  outline: 1px solid var(--primary);
}
.sel-item-weight option {
  background: #1a1e30;
  color: #c8d0f0;
}

/* ==================== ロビー タイトル行 ==================== */
.lobby-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.role-badge {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.role-badge.host {
  background: rgba(255, 204, 0, 0.2);
  border: 1px solid rgba(255, 204, 0, 0.5);
  color: #ffd60a;
}
.role-badge.guest {
  background: rgba(138, 146, 178, 0.15);
  border: 1px solid rgba(138, 146, 178, 0.3);
  color: var(--text-muted);
}

/* ==================== カスタムアバター アップロード行 ==================== */
.custom-avatar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.avatar-upload-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==================== アイコン選択グリッド ==================== */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.icon-choice {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  background: rgba(255,255,255,0.05);
}
.icon-choice:hover { border-color: var(--primary-hover); }
.icon-choice.active { border-color: var(--warning); box-shadow: 0 0 8px rgba(255,204,0,0.5); }

/* ==================== バーチャルジョイスティック（タッチ操作） ==================== */

.vjoy-base {
  position: fixed;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
  z-index: 900;
  display: none; /* JS で表示 */
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
}

.vjoy-knob {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.85);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* 4方向ガイドマーク */
.vjoy-dir {
  position: absolute;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  line-height: 1;
}
.vjoy-n { top: 6px;  left: 50%; transform: translateX(-50%); }
.vjoy-s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.vjoy-w { left: 6px;  top: 50%; transform: translateY(-50%); }
.vjoy-e { right: 6px; top: 50%; transform: translateY(-50%); }

/* ボムボタン */
.vjoy-bomb-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(200, 50, 50, 0.72);
  border: 2px solid rgba(255, 100, 100, 0.8);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  z-index: 900;
  display: none; /* JS で管理 */
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.vjoy-bomb-btn:active { background: rgba(240, 80, 80, 0.9); transform: scale(0.93); }

/* タッチデバイスのみ自動表示（CSSレベル） */
@media (pointer: coarse) {
  .vjoy-bomb-btn { display: flex; }
}

/* ホスト待機メッセージ（リザルト画面） */
.host-waiting-msg {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* ==================== パスワード・観戦・途中参加UI ==================== */

.password-error {
  display: block;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}
.password-error.hidden { display: none; }

.p-ready-badge.spectating {
  background: rgba(90, 200, 250, 0.2);
  color: #5AC8FA;
  border: 1px solid rgba(90, 200, 250, 0.4);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.mid-game-notice {
  background: rgba(255, 149, 0, 0.15);
  border: 1px solid rgba(255, 149, 0, 0.4);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  color: #FF9500;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 16px 8px;
}
.mid-game-notice.hidden { display: none; }

.btn.active-spectator {
  background: rgba(90, 200, 250, 0.25) !important;
  border-color: rgba(90, 200, 250, 0.6) !important;
  color: #5AC8FA !important;
}

/* ==================== モバイル最適化（スマホ向けゲーム画面） ==================== */

/* タッチデバイスではボトムのボムボタンを非表示（vjoy-bomb-btn を使用） */
@media (pointer: coarse) {
  #btn-use-bomb { display: none !important; }
}

/* スマホ縦持ち（〜768px）*/
@media screen and (max-width: 768px) {

  /* ---- HUD 上部をコンパクトに ---- */
  .game-hud {
    height: auto;
    min-height: 40px;
    padding: 5px 10px;
    margin: 4px auto 0;
    border-radius: 10px;
    gap: 6px;
  }
  .timer-label   { display: none; }
  .timer-value   { font-size: 1.05rem; }
  .shuffle-counter { display: none !important; }
  .sound-label   { display: none; }
  .hud-center    { margin: 0 8px; }
  .occupy-bar-container { height: 14px; }
  .occupy-segment { font-size: 0.52rem; }
  .hud-event-banner { font-size: 0.65rem; padding: 2px 6px; }
  .hud-right     { gap: 10px; }
  #btn-quit-game { font-size: 0.7rem !important; padding: 4px 8px !important; }

  /* ---- キャンバスコンテナ：余白を詰める ---- */
  #canvas-container {
    margin: 4px auto;
    border-radius: 10px;
  }

  /* ---- 下部コントロールをコンパクトに ---- */
  .game-controls {
    height: auto;
    min-height: 44px;
    padding: 5px 10px;
    /* iOS ホームインジケーター分の余白 */
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    margin: 0 auto 4px;
    border-radius: 10px;
    gap: 5px;
  }

  /* アバター・プレイヤー名は省略（スペース節約） */
  .player-status-panel { display: none; }

  /* バフアイコン：タイマーテキスト省略 */
  .buffs-container { gap: 3px; }
  .buff-icon {
    padding: 3px 5px;
    gap: 2px;
    border-radius: 7px;
    font-size: 0.7rem;
  }
  .buff-timer   { display: none; }
  .buff-icon-em { font-size: 0.85rem; }

  /* アクションボタン */
  .action-buttons { gap: 5px; }

  /* スタンプ：アイコンのみ（テキスト非表示） */
  .stamp-text   { display: none; }
  .btn-stamp    { padding: 5px 7px; font-size: 1.05rem; }
  .stamp-palette { padding: 2px 3px; gap: 2px; }
}

/* ==================== 初期設定画面（セットアップ）モバイル最適化 ==================== */
@media screen and (max-width: 540px) {

  /* パネル：パディングを縮小して有効幅を確保 */
  #setup-screen .glass {
    padding: 22px 16px 18px;
    width: 94%;
    max-height: 100dvh;
    border-radius: 16px;
  }

  /* ロゴ・サブタイトル */
  .logo-text   { font-size: 2.1rem; margin-bottom: 2px; }
  .subtitle    { font-size: 0.82rem; margin-bottom: 4px; }

  /* フォームグループ間隔を縮小 */
  .form-group  { margin-bottom: 12px; }

  /* iOSのズームイン防止（16px未満だとズームが発生する） */
  #setup-screen input[type="text"],
  #setup-screen input[type="password"],
  #setup-screen select {
    font-size: 16px;
  }

  /* チームカラー選択ドット */
  .team-selector { gap: 6px; margin-bottom: 14px; }
  .team-dot      { width: 28px; height: 28px; }

  /* アクションバー：縦積み・全幅ボタン */
  #setup-screen .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    justify-content: flex-start;
  }

  /* ボタン：タップしやすい高さ・全幅 */
  #setup-screen .action-bar .btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    border-radius: 12px;
  }
}

/* スマホ横持ち：さらにコンパクト */
@media screen and (max-width: 900px) and (orientation: landscape) {
  .game-hud {
    min-height: 34px;
    padding: 3px 10px;
    margin: 2px auto 0;
  }
  .timer-value { font-size: 0.9rem; }
  #canvas-container { margin: 2px auto; }
  .game-controls {
    min-height: 36px;
    padding: 3px 8px;
    padding-bottom: max(3px, env(safe-area-inset-bottom));
    margin: 0 auto 2px;
  }
}

/* ==================== ルーム選択・カラー選択画面 ==================== */

.panel-narrow {
  max-width: 480px;
}

.panel-medium {
  max-width: 680px;
}

.full-width-btn {
  width: 100%;
}

/* ルーム選択画面 */
.room-select-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.player-name-badge {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 6px 14px;
  white-space: nowrap;
}

.room-list-wrapper {
  min-height: 140px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 12px;
}

.room-list-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 30px 0;
}

.room-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
  transition: background 0.2s;
}
.room-list-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.room-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-item-name {
  font-weight: 700;
  font-size: 1rem;
}

.room-item-code {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
  letter-spacing: 1px;
}

.room-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.room-item-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.room-item-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--success);
}

.room-create-section {
  margin-bottom: 16px;
}

.room-join-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.room-code-input {
  flex: 1;
  text-transform: uppercase;
  font-family: monospace;
  letter-spacing: 2px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

/* カラー選択画面 */
.room-label-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-family: monospace;
  letter-spacing: 1px;
}

.style-select-row {
  display: flex;
  gap: 10px;
}

.style-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s;
}
.style-opt:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}
.style-opt.active {
  border-color: var(--primary);
  background: rgba(0, 122, 255, 0.15);
  box-shadow: var(--glow-primary);
}
.style-opt-icon {
  font-size: 1.5rem;
}
.style-opt-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.style-opt.active .style-opt-name {
  color: var(--text-main);
}
