* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #0c0e18; color: #fff;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }

.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; overflow-y: auto; padding: 18px;
}

/* ---------- タイトル ---------- */
#screenTitle { justify-content: center; background: radial-gradient(ellipse at center, #1c2140 0%, #0a0b14 75%); }
.bgGlow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 30% 20%, rgba(93,168,255,0.18), transparent 45%),
              radial-gradient(circle at 75% 75%, rgba(255,93,93,0.16), transparent 45%);
}
.titleWrap { text-align: center; z-index: 1; }
.logo { font-size: 3.4rem; letter-spacing: 3px; margin: 0; font-weight: 900; color: #fff; text-shadow: 0 0 24px rgba(93,168,255,0.6); }
.logo span { color: #ffd23f; text-shadow: 0 0 24px rgba(255,210,63,0.7); }
.tagline { color: #9aa0c0; margin: 10px 0 34px; font-size: 0.95rem; }
.titleButtons { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.bigBtn {
  background: linear-gradient(180deg, #ffd23f, #ff9d1f); color: #2a1c00; font-weight: 800;
  font-size: 1.15rem; padding: 15px 46px; border-radius: 14px; box-shadow: 0 6px 0 #b06d0a, 0 10px 20px rgba(0,0,0,0.4);
  transition: transform 0.08s;
}
.bigBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b06d0a; }
.bigBtn:disabled { opacity: 0.4; cursor: default; }
.smallBtn {
  background: rgba(255,255,255,0.08); color: #fff; font-size: 0.95rem; padding: 10px 26px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.15);
}
.smallBtn:active { background: rgba(255,255,255,0.18); }
.versionTagWrap { margin-top: 26px; color: #555b7a; font-size: 0.75rem; }

/* ---------- 共通ヘッダー ---------- */
.headerBar { width: 100%; max-width: 900px; display: flex; align-items: center; gap: 14px; padding: 6px 0 16px; }
.headerBar h2 { flex: 1; margin: 0; font-size: 1.3rem; }
.backBtn { background: rgba(255,255,255,0.08); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; }
.trophyTotal { color: #ffd23f; font-weight: 700; }

/* ---------- ファイター選択 ---------- */
.brawlerGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; width: 100%; max-width: 900px; }
.brawlerCard {
  --bcolor: #888; background: #171a2a; border: 2px solid #262a44; border-radius: 14px; padding: 12px 6px;
  text-align: center; transition: 0.15s; cursor: pointer;
}
.brawlerCard:not(.locked):hover { border-color: var(--bcolor); transform: translateY(-3px); }
.brawlerCard.selected { border-color: var(--bcolor); background: linear-gradient(180deg, #232852, #171a2a); box-shadow: 0 0 18px -4px var(--bcolor); }
.brawlerCard.locked { opacity: 0.45; cursor: default; }
.bcIcon { font-size: 2rem; }
.bcName { font-weight: 700; margin-top: 4px; font-size: 0.9rem; }
.bcTrophy { color: #ffd23f; font-size: 0.75rem; margin-top: 2px; }
.brawlerDetail {
  display: flex; gap: 14px; align-items: center; max-width: 900px; width: 100%;
  background: #171a2a; border-radius: 14px; padding: 16px; margin-top: 14px;
}
.bdIcon { font-size: 2.6rem; }
.bdName { font-weight: 800; font-size: 1.1rem; }
.bdRole { font-size: 0.7rem; color: #9aa0c0; background: rgba(255,255,255,0.08); padding: 2px 8px; border-radius: 8px; margin-left: 8px; }
.bdDesc { color: #c4c8e0; font-size: 0.85rem; margin: 6px 0; }
.bdStats { color: #9aa0c0; font-size: 0.8rem; }
.bottomBtn { margin-top: 18px; }

/* ---------- モード選択 ---------- */
.modeGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; width: 100%; max-width: 780px; }
.modeCard { background: #171a2a; border: 2px solid #262a44; border-radius: 16px; padding: 18px; cursor: pointer; transition: 0.15s; }
.modeCard:hover { transform: translateY(-3px); }
.modeCard.selected { border-color: #ffd23f; box-shadow: 0 0 18px -4px #ffd23f; }
.mcIcon { font-size: 2rem; }
.mcName { font-weight: 800; margin: 6px 0; }
.mcDesc { color: #9aa0c0; font-size: 0.8rem; line-height: 1.4; }
.diffTitle { margin: 20px 0 10px; color: #c4c8e0; }
.diffGrid { display: flex; gap: 10px; }
.diffBtn { background: #171a2a; border: 2px solid #262a44; color: #fff; padding: 10px 20px; border-radius: 10px; }
.diffBtn.selected { border-color: #5da8ff; background: #202850; }

/* ---------- 設定/遊び方 ---------- */
.settingsBox, .howToBox { width: 100%; max-width: 640px; background: #171a2a; border-radius: 14px; padding: 20px; }
.settingRow { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; font-size: 0.95rem; }
.settingRow input[type=range] { width: 60%; }
.checkRow { justify-content: flex-start; }
.howToBox h3 { color: #ffd23f; margin-bottom: 4px; }
.howToBox p { color: #c4c8e0; font-size: 0.88rem; line-height: 1.6; margin-top: 0; margin-bottom: 16px; }

/* ---------- ゲーム画面 ---------- */
#hud { padding: 0; background: #000; overflow: hidden; }
#gameCanvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #1b1d2b; }
.hudTopBar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 12px; z-index: 5; pointer-events: none; }
.hudTopScore { background: rgba(10,12,24,0.7); padding: 8px 16px; border-radius: 20px; font-weight: 800; font-size: 1rem; }
.hudTimer { background: rgba(10,12,24,0.7); padding: 8px 14px; border-radius: 20px; font-weight: 700; }
.pauseBtn { margin-left: auto; background: rgba(10,12,24,0.7); color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 1rem; pointer-events: all; }
.teamA { color: #5da8ff; } .teamB { color: #ff5d5d; }

.hudBottomBar { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-end; z-index: 5; pointer-events: none; }
.hudPlayerBox { display: flex; align-items: center; gap: 8px; background: rgba(10,12,24,0.7); padding: 8px 12px; border-radius: 14px; }
.hudPlayerIcon { font-size: 1.6rem; }
.hudBars { display: flex; flex-direction: column; gap: 4px; }
.healthBarOuter { width: 130px; height: 14px; background: rgba(255,255,255,0.1); border-radius: 8px; position: relative; overflow: hidden; }
.healthBarFill { height: 100%; background: linear-gradient(180deg, #7ee87f, #3fbf49); transition: width 0.15s; }
.healthText { position: absolute; inset: 0; text-align: center; font-size: 0.65rem; line-height: 14px; text-shadow: 0 1px 2px #000; }
.ammoPips { display: flex; gap: 4px; }
.pip { width: 10px; height: 10px; border-radius: 3px; background: rgba(255,255,255,0.15); }
.pip.full { background: #ffd23f; box-shadow: 0 0 6px #ffd23f; }
.superBox { text-align: center; pointer-events: none; }
.superBarOuter { width: 140px; height: 16px; background: rgba(255,255,255,0.1); border-radius: 8px; overflow: hidden; border: 1px solid rgba(255,255,255,0.15); }
.superBarFill { height: 100%; background: linear-gradient(180deg, #ffe98a, #ffb020); transition: width 0.15s; }
.superBox.ready .superBarOuter { box-shadow: 0 0 14px 2px #ffd23f; }
.superLabel { font-size: 0.75rem; margin-top: 4px; color: #ffd23f; }
.superBox.ready .superLabel { animation: pulse 0.6s infinite alternate; }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; text-shadow: 0 0 10px #ffd23f; } }

.countdownOverlay, .respawnOverlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35); z-index: 6; pointer-events: none;
}
#countdownText { font-size: 5rem; font-weight: 900; color: #ffd23f; text-shadow: 0 0 30px rgba(255,210,63,0.8); }
#respawnText { font-size: 1.4rem; font-weight: 800; background: rgba(10,12,24,0.8); padding: 14px 26px; border-radius: 16px; }

/* タッチ操作 */
.joyBase, .touchSuperBtn { display: none; }
body.touchMode .joyBase, body.touchMode .touchSuperBtn { display: block; }
.joyBase {
  position: absolute; bottom: 90px; width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.2); z-index: 5;
}
.joyLeft { left: 26px; } .joyRight { right: 26px; }
.joyKnob {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgba(255,255,255,0.35); transition: transform 0.05s linear;
}
.touchSuperBtn {
  position: absolute; right: 40px; bottom: 210px; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle, #ffe98a, #ff9d1f); font-size: 1.6rem; box-shadow: 0 0 16px rgba(255,157,31,0.7); z-index: 5;
}

.pauseModal { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
.pauseBox { background: #171a2a; padding: 30px 40px; border-radius: 18px; text-align: center; display: flex; flex-direction: column; gap: 12px; }

/* ---------- 結果画面 ---------- */
#screenResults { justify-content: center; background: radial-gradient(ellipse at center, #1c2140 0%, #0a0b14 75%); }
.resultsBox { text-align: center; background: #171a2a; padding: 34px 44px; border-radius: 20px; max-width: 420px; }
#resultTitle { font-size: 2.2rem; margin: 0 0 8px; }
#resultTitle.win { color: #ffd23f; text-shadow: 0 0 20px rgba(255,210,63,0.6); }
#resultTitle.lose { color: #9aa0c0; }
.resultReason { color: #c4c8e0; margin-bottom: 14px; }
.resultTrophy { font-size: 1.6rem; font-weight: 800; margin-bottom: 18px; }
.resultTrophy.gain { color: #5ce065; } .resultTrophy.loss { color: #ff5d5d; }
.resultStats { color: #9aa0c0; font-size: 0.85rem; margin-bottom: 22px; display: flex; flex-direction: column; gap: 4px; }
#btnRematch { display: block; width: 100%; margin-bottom: 12px; }
#btnResultsMenu { display: block; width: 100%; }

/* ---------- オンライン対戦 ---------- */
.onlineDuelBtn { margin-top: 10px; }
.onlineHint { color: #9aa0c0; font-size: 0.85rem; max-width: 640px; text-align: center; line-height: 1.6; }
.onlineMenuGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; width: 100%; max-width: 680px; margin-top: 10px; }
.onlineMenuCard { background: #171a2a; border: 2px solid #262a44; border-radius: 16px; padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.omcIcon { font-size: 2.2rem; }
.onlineMenuCard h3 { margin: 0; }
.onlineMenuCard p { color: #9aa0c0; font-size: 0.8rem; margin: 0; }
.codeInput {
  width: 100%; text-align: center; letter-spacing: 6px; font-size: 1.3rem; font-weight: 800;
  background: #0c0e18; border: 2px solid #262a44; color: #ffd23f; border-radius: 10px; padding: 10px; text-transform: uppercase;
}
.onlineError { color: #ff8080; min-height: 1.4em; margin-top: 12px; }
.onlineRoomCodeWrap { font-size: 1.1rem; color: #c4c8e0; margin-top: 6px; }
.onlineRoomCodeWrap b { color: #ffd23f; font-size: 1.5rem; letter-spacing: 4px; margin-left: 8px; }
.onlineStatus { color: #9aa0c0; margin: 10px 0 20px; }
.onlinePlayers { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.onlinePlayerCard { background: #171a2a; border: 2px solid #262a44; border-radius: 14px; padding: 20px 24px; text-align: center; min-width: 140px; opacity: 0.6; }
.onlinePlayerCard.active { opacity: 1; border-color: #ffd23f; }
.opcLabel { color: #9aa0c0; font-size: 0.8rem; margin-bottom: 8px; }
.opcBrawler { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; }
.opcBrawler .obIcon { font-size: 2rem; }
.opcVs { color: #ff5b45; font-weight: 900; font-size: 1.3rem; }

@media (max-width: 640px) {
  .logo { font-size: 2.4rem; }
  .healthBarOuter, .superBarOuter { width: 100px; }
}
