:root {
  --ink: #160e08;          /* dark wood */
  --wood: #3a2718;         /* keyaki */
  --wood2: #2a190f;
  --vermilion: #e94b3c;    /* torii red */
  --vermilion2: #ff6b52;
  --gold: #e8b64c;         /* kin */
  --jade: #4bbf8f;
  --sky: #5ac8e6;
  --sakura: #ff9fb8;
  --paper: #efe6cd;        /* washi */
  --text: #f6eeda;
  --muted: #c3b191;
  --card: rgba(42, 27, 15, 0.9);
  --border: rgba(232, 182, 76, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: "Fredoka", "Zen Maru Gothic", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea {
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
  pointer-events: auto;
}

#app { position: fixed; inset: 0; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 96px 24px 24px; z-index: 20;
  animation: fade 0.28s ease;
  pointer-events: auto;
}
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.menu-grid {
  display: flex; gap: 22px; align-items: stretch;
  max-width: 96vw; max-height: 92vh;
}
@media (max-width: 820px) { .menu-grid { flex-direction: column; align-items: center; } .menu-card.side { display: none; } }

.menu-card {
  width: min(440px, 94vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 24px;
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  max-height: 92vh; overflow-y: auto;
  position: relative;
}
.menu-card::before {
  content: ""; position: absolute; inset: 6px; border-radius: 13px;
  border: 1px solid rgba(232,182,76,0.10); pointer-events: none;
}
/* a strip of washi tape holding the card up — handmade touch */
.menu-card::after {
  content: ""; position: absolute; top: -11px; left: 50%;
  width: 116px; height: 24px; transform: translateX(-50%) rotate(-2.2deg);
  background: repeating-linear-gradient(46deg, rgba(233,75,60,.5), rgba(233,75,60,.5) 7px, rgba(255,208,107,.5) 7px, rgba(255,208,107,.5) 14px);
  border: 1px solid rgba(255,255,255,.22); border-radius: 2px;
  box-shadow: 0 3px 8px rgba(0,0,0,.35); pointer-events: none;
}
.menu-card.wide { width: min(680px, 96vw); }
.menu-card.side { width: min(320px, 90vw); }

.title-wrap { position: relative; text-align: center; margin-bottom: 8px; padding-top: 6px; }
#menu-mascot { width: 96px; height: 96px; margin-bottom: -6px; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 8px 14px rgba(0,0,0,.5)); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.hanko {
  position: absolute; top: 0; right: 4px;
  font-family: "Yuji Syuku", serif; font-size: 22px; color: #fff;
  width: 54px; height: 54px; display: flex; align-items: center; justify-content: center;
  background: var(--vermilion); border-radius: 12px; transform: rotate(-8deg);
  border: 2px solid #fff3; box-shadow: 0 4px 14px rgba(233,75,60,.5);
  writing-mode: vertical-rl; letter-spacing: -2px; line-height: 1;
}
.title {
  font-family: "Fredoka", "Zen Maru Gothic", sans-serif;
  font-size: 62px; font-weight: 700; letter-spacing: -1px;
  color: var(--gold); line-height: 1;
  text-shadow: 0 6px 30px rgba(233, 75, 60, 0.35), 3px 3px 0 rgba(0, 0, 0, 0.3);
  transform: rotate(-1.5deg);
}
.title .dot { color: var(--vermilion); }
.subtitle { text-align: center; color: var(--muted); margin: 6px 0 14px; font-size: 14px; }

h2 { font-size: 25px; margin-bottom: 14px; font-weight: 700; font-family: "Fredoka", sans-serif; }
h2::after {
  content: ""; display: block; width: 74px; height: 8px; margin-top: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='8'%3E%3Cpath d='M1 5 Q 6 1 11 5 T 21 5 T 31 5 T 41 5' fill='none' stroke='%23e94b3c' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center;
}
.settings-card h2::after { margin-left: auto; margin-right: auto; }
h2 small, h2 .lb-sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.section-h { margin: 20px 0 10px; font-size: 15px; color: var(--gold); font-weight: 700; }

.menu-buttons { display: flex; flex-direction: column; gap: 11px; }

/* Cartoony menu buttons with icon + subtitle */
.menu-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 16px; border-radius: 16px;
  background: linear-gradient(120deg, var(--vermilion), var(--vermilion2));
  color: #fff; border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 6px 0 #a5321f, 0 10px 22px rgba(233,75,60,0.32);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s ease;
}
.menu-btn:hover { filter: brightness(1.07); }
.menu-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #a5321f, 0 4px 12px rgba(233,75,60,0.3); }
.menu-btn .mb-ico { font-size: 26px; width: 34px; text-align: center; flex: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.menu-btn .mb-txt { display: flex; flex-direction: column; line-height: 1.2; }
.menu-btn .mb-txt b { font-size: 16px; font-weight: 800; }
.menu-btn .mb-txt small { font-size: 11px; opacity: 0.85; font-weight: 600; }
.menu-btn.ghost-btn {
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 2px solid var(--border); box-shadow: 0 5px 0 rgba(0,0,0,0.35), 0 8px 18px rgba(0,0,0,0.25);
}
.menu-btn.ghost-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.menu-btn.ghost-btn .mb-txt small { color: var(--muted); opacity: 1; }

/* Online create / join cards */
.online-options { display: flex; gap: 12px; margin: 8px 0; }
@media (max-width: 520px) { .online-options { flex-direction: column; } }
.online-opt {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 14px; border-radius: 16px; text-align: center;
  background: rgba(255,255,255,0.05); border: 2px solid var(--border); cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s, background 0.15s;
}
button.online-opt:hover, .online-opt.joincard:hover { border-color: var(--gold); background: rgba(232,182,76,0.1); }
button.online-opt:active { transform: translateY(2px); }
.oo-ico { font-size: 40px; }
.oo-title { font-weight: 800; font-size: 17px; }
.oo-sub { font-size: 12px; color: var(--muted); }
.online-opt.joincard { cursor: default; justify-content: center; }
.online-opt.joincard .join-row { width: 100%; margin-top: 6px; }

/* Connecting spinner in status line */
.status-line.loading { color: var(--gold); display: flex; align-items: center; justify-content: center; gap: 8px; }
.status-line.loading::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(232,182,76,0.3); border-top-color: var(--gold);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Lobby avatars */
.lobby-av { width: 40px; height: 40px; border-radius: 10px; background: rgba(0,0,0,.25); flex: none; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  padding: 13px 18px; font-weight: 700; color: var(--text);
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
button:active { transform: translateY(1px) scale(0.99); }
.primary {
  background: linear-gradient(120deg, var(--vermilion), var(--vermilion2));
  color: #fff; border: 2px solid rgba(255,255,255,0.14);
  box-shadow: 0 5px 0 #a5321f, 0 9px 20px rgba(233, 75, 60, 0.32);
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 #a5321f; }
.primary.big { font-size: 18px; padding: 16px; }
.secondary { background: rgba(255, 255, 255, 0.06); border: 2px solid var(--border); box-shadow: 0 5px 0 rgba(0,0,0,0.32); }
.secondary:hover { background: rgba(255, 255, 255, 0.12); }
.secondary:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.32); }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.ghost:hover { color: var(--text); }
.small { padding: 5px 11px; font-size: 12px; border-radius: 8px; }

.opt-label { display: block; margin: 15px 0 8px; font-weight: 700; font-size: 13px; color: var(--gold); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 8px 0; }
.hint b, .hint code { color: var(--text); }
code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

input[type="text"], input:not([type]), #name-input, #join-code {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border);
  color: var(--text); font: inherit; outline: none;
}
#join-code { text-transform: uppercase; letter-spacing: 4px; font-weight: 800; text-align: center; }
input:focus { border-color: var(--gold); }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 52px; padding: 12px 8px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,0.06); border: 2px solid var(--border);
  color: var(--text); font: inherit; font-weight: 700; font-size: 16px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25);
}
.choice small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); margin-top: 3px; }
.choice:hover { background: rgba(255,255,255,0.1); }
.choice.active {
  border-color: var(--gold); background: rgba(232,182,76,0.16);
  box-shadow: 0 3px 0 rgba(168,120,30,0.45);
}
.choice { pointer-events: auto; z-index: 2; }

input[type="range"] { display: none; }

.row-buttons { display: flex; gap: 11px; margin-top: 20px; flex-wrap: wrap; }
.row-buttons button { flex: 1; min-width: 120px; }

.footer-note { text-align: center; color: var(--muted); font-size: 11px; margin-top: 16px; opacity: 0.7; }

.or-divider { text-align: center; margin: 18px 0; position: relative; color: var(--muted); font-size: 12px; }
.or-divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.or-divider span { background: var(--card); padding: 0 12px; position: relative; }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; }
.join-row button { flex: none; padding: 12px 22px; }

/* ---------- Online count ---------- */
.online-count {
  text-align: center; font-size: 13px; color: var(--jade);
  margin-bottom: 16px; font-weight: 700;
}
.online-count .pulse {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--jade); box-shadow: 0 0 8px var(--jade);
  animation: blink 1.6s infinite; vertical-align: middle; margin-right: 4px;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.queue-card { text-align: center; }
.queue-spinner {
  width: 52px; height: 52px; margin: 8px auto 12px;
  border: 4px solid var(--border); border-top-color: var(--vermilion2);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.queue-timer {
  font-family: "Yuji Syuku", serif; font-size: 64px; font-weight: 900;
  color: var(--vermilion2); line-height: 1; margin: 6px 0 12px;
  text-shadow: 0 0 24px rgba(233,75,60,.4);
}
.queue-sub { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

/* ---------- Leaderboard ---------- */
.lb-title { display: flex; flex-direction: column; gap: 2px; }
.leaderboard { display: flex; flex-direction: column; gap: 7px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  font-size: 14px;
}
.lb-row.me { background: rgba(233, 75, 60, 0.14); border-color: var(--vermilion); margin-top: 8px; }
.lb-rank { font-family: "Yuji Syuku", serif; font-size: 15px; width: 32px; text-align: center; color: var(--gold); flex: none; }
.lb-row:nth-child(1) .lb-rank { color: #ffd700; }
.lb-av { width: 34px; height: 34px; border-radius: 8px; background: rgba(0,0,0,.25); flex: none; }
.lb-name { flex: 1; font-weight: 700; min-width: 0; }
.lb-lvl { font-size: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-coins { color: var(--gold); font-weight: 800; font-size: 13px; }

/* ---------- Profile bar ---------- */
#profile-bar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 10px 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 34px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  max-width: 94vw;
}
.pf-avatar { width: 48px; height: 48px; border-radius: 12px; overflow: hidden; flex: none; background: rgba(0,0,0,.3); border: 2px solid var(--gold); }
.pf-avatar canvas { width: 100%; height: 100%; display: block; }
.pf-info { min-width: 156px; }
.pf-name { font-weight: 800; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.pf-rank { font-size: 10px; color: var(--ink); background: linear-gradient(120deg, var(--gold), #ffd06b); padding: 2px 8px; border-radius: 999px; font-weight: 800; letter-spacing: .3px; }
.pf-xpwrap { position: relative; height: 13px; background: rgba(0,0,0,.42); border-radius: 999px; overflow: hidden; margin-top: 5px; border: 1px solid rgba(0,0,0,.3); }
.pf-xp { height: 100%; width: 0%; background: linear-gradient(90deg, var(--jade), var(--sky)); transition: width 0.4s ease; }
.pf-xptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.pf-stats { display: flex; gap: 9px; }
.pf-stat { display: flex; flex-direction: column; align-items: center; background: rgba(0,0,0,.28); border: 1px solid var(--border); border-radius: 11px; padding: 4px 13px; min-width: 60px; }
.pf-stat-label { font-size: 9px; letter-spacing: 1.2px; color: var(--muted); font-weight: 800; }
.pf-stat-val { font-size: 16px; font-weight: 900; color: var(--text); white-space: nowrap; }
.pf-stat.coins .pf-stat-val { color: var(--gold); }
@media (max-width: 620px) { .pf-info { min-width: 110px; } .pf-avatar { width: 40px; height: 40px; } .pf-stat { min-width: 50px; padding: 4px 8px; } }

/* ---------- Avatars gallery ---------- */
.avatar-gallery, .bao-grid, .char-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; padding: 12px; max-height: 48vh; overflow-y: auto;
  background: rgba(0,0,0,0.22);
  border-radius: 16px;
  border: 2px solid var(--border);
}
.bao-card, .av-card {
  position: relative; border-radius: 16px; padding: 8px 4px 8px;
  background: rgba(255,255,255,0.06); border: 3px solid transparent;
  cursor: pointer; text-align: center; color: var(--text);
  box-shadow: 0 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}
.bao-card:hover, .av-card:hover { transform: translateY(-2px); }
.bao-card.active, .av-card.active {
  border-color: var(--gold); background: rgba(232,182,76,0.16);
}
.bao-card.locked, .av-card.locked { filter: grayscale(0.55) brightness(0.85); }
.bao-card canvas, .av-card canvas { width: 78px; height: 78px; display: block; margin: 0 auto; }
.av-name { font-size: 13px; font-weight: 700; margin-top: 2px; color: var(--text); }
.av-req { font-size: 10px; font-weight: 700; color: var(--muted); }
.bao-card.active .av-req { color: var(--gold); }
.av-lock { position: absolute; top: 6px; right: 8px; font-size: 15px; }
.picked-banner {
  text-align: center; font-size: 15px; margin: 4px 0 12px;
  background: rgba(255,255,255,0.08); border: 2px dashed var(--gold);
  border-radius: 12px; padding: 8px 12px;
}
.pick-hint { text-align: center; margin-bottom: 10px; }
.pf-avatar { cursor: pointer; }

/* ---------- Customize ---------- */
.customize-grid { display: grid; grid-template-columns: 240px 1fr; gap: 20px; }
@media (max-width: 560px) { .customize-grid { grid-template-columns: 1fr; } }
.preview-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#avatar-preview { background: radial-gradient(circle at 50% 40%, #223, #0c1024); border-radius: 16px; border: 1px solid var(--border); }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch { width: 36px; height: 36px; border-radius: 9px; cursor: pointer; border: 3px solid transparent; transition: transform 0.1s; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.swatches.faces .swatch { display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.08); font-size: 20px; }

.class-row { display: flex; gap: 10px; }
.class-btn {
  flex: 1; padding: 12px 8px; border-radius: 12px; text-align: center;
  background: rgba(255, 255, 255, 0.05); border: 2px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 14px;
}
.class-btn.active { border-color: var(--gold); background: rgba(232,182,76,0.12); }
.class-btn small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; margin-top: 4px; }

/* Named opponent cards */
.persona-row { display: flex; gap: 10px; }
.persona {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 12px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 2px solid transparent;
  transition: transform 0.08s ease, border-color 0.15s, background 0.15s;
}
.persona:hover { transform: translateY(-3px) rotate(-1deg); }
.persona.active { border-color: var(--gold); background: rgba(232,182,76,0.12); box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.persona-av { width: 62px; height: 62px; }
.persona-name { font-weight: 700; font-size: 15px; }
.persona-skill { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.persona-skill.s-easy { color: #0d0f1a; background: var(--jade); }
.persona-skill.s-normal { color: #0d0f1a; background: var(--sky); }
.persona-skill.s-hard { color: #fff; background: var(--vermilion); }
.opp-blurb { text-align: center; min-height: 18px; font-style: italic; color: var(--sakura); }

/* ---------- Lobby / results ---------- */
.room-code-box {
  text-align: center; padding: 12px; border-radius: 12px; margin-bottom: 14px;
  background: rgba(0,0,0,0.3); border: 1px dashed var(--gold); font-size: 15px;
}
.room-code-box span { font-family: "Yuji Syuku", serif; font-size: 26px; letter-spacing: 6px; color: var(--gold); margin: 0 6px; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 42vh; overflow-y: auto; }
.lobby-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
}
.lobby-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.lobby-name { font-weight: 700; flex: 1; }
.lobby-tag { font-size: 12px; color: var(--muted); }
.lobby-tag.ready { color: var(--jade); }
.lobby-tag.win { color: var(--gold); }

.status-line { margin-top: 14px; font-size: 13px; color: var(--muted); min-height: 18px; }
.status-line.error { color: var(--vermilion2); }
.status-line.ok { color: var(--jade); }

.howto-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.howto-list li { padding-left: 20px; position: relative; line-height: 1.5; font-size: 14px; color: var(--muted); }
.howto-list li b { color: var(--text); }
.howto-list li::before { content: "⛩️"; position: absolute; left: 0; font-size: 12px; }

/* ---------- Rewards ---------- */
.reward-box {
  margin-top: 14px; padding: 16px; border-radius: 14px;
  background: rgba(232,182,76,0.1); border: 1px solid var(--gold);
  display: flex; flex-direction: column; gap: 8px; text-align: center;
}
.reward-row { font-size: 16px; }
.reward-row b { color: var(--gold); }
.levelup { color: var(--jade); font-weight: 800; font-size: 15px; animation: pop 0.4s ease; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud-top {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; align-items: center;
  background: rgba(26, 16, 9, 0.7); padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); backdrop-filter: blur(6px); font-weight: 800; font-size: 14px;
}
#hud-top #btn-settings { pointer-events: auto; }
#alive-info { color: var(--sky); }
#round-info { color: var(--vermilion2); }

#scoreboard { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.score-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 999px;
  background: rgba(26, 16, 9, 0.66); border: 1px solid var(--border);
}
.score-chip .cdot { width: 14px; height: 14px; border-radius: 50%; }
.score-chip.dead { opacity: 0.4; }
.score-chip .wins { color: var(--gold); font-weight: 800; }
.team-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.6px; padding: 1px 6px; border-radius: 999px; }
.team-tag.t0 { color: #fff; background: var(--vermilion); }
.team-tag.t1 { color: #0d0f1a; background: var(--sky); }

#ability-bars {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; width: 240px;
}
.ability-bar {
  position: relative;
  height: 16px; background: rgba(0,0,0,.45); border-radius: 999px;
  border: 1px solid var(--border); overflow: hidden;
}
#dash-bar, #push-bar { height: 100%; width: 100%; transition: width 0.05s linear; }
#dash-bar { background: linear-gradient(90deg, var(--vermilion), var(--gold)); }
#push-bar { background: linear-gradient(90deg, #5ac8e6, #c0ff5e); }
.ability-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #0d0f1a; }

#round-banner {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  font-family: "Yuji Syuku", serif; font-size: 56px; font-weight: 900; text-align: center;
  color: var(--vermilion2); text-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 28px rgba(233,75,60,.55); white-space: nowrap;
  animation: pop 0.4s ease;
}
@keyframes pop { from { transform: translate(-50%,-50%) scale(0.6); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }

/* ---------- Between-round recap ---------- */
#round-recap {
  position: absolute; inset: 0; z-index: 28;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 7, 4, 0.58); backdrop-filter: blur(5px);
  pointer-events: auto; animation: fade 0.2s ease;
}
#round-recap.hidden { display: none; }
.recap-card {
  width: min(460px, 94vw); background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px 22px 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.recap-kicker { text-align: center; font-size: 11px; letter-spacing: 2px; font-weight: 800; color: var(--vermilion2); text-transform: uppercase; }
.recap-card h2 { text-align: center; margin: 6px 0 4px; font-size: 28px; color: var(--vermilion2); }
.recap-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.recap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recap-table th {
  text-align: left; font-size: 10px; letter-spacing: 1px; color: var(--muted);
  padding: 6px 8px; border-bottom: 1px solid var(--border); font-weight: 800;
}
.recap-table th:not(:first-child), .recap-table td.num, .recap-table td.status { text-align: right; }
.recap-table td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); font-weight: 700; }
.recap-table td:first-child { display: flex; align-items: center; gap: 8px; }
.recap-row.you { background: rgba(233, 75, 60, 0.14); }
.recap-row.win td.status { color: var(--vermilion2); }
.recap-next { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 8px; }
.recap-card .primary { width: 100%; }

/* ---------- Controls hint (in-game) ---------- */
#controls-hint {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--muted); background: rgba(26, 16, 9, 0.55);
  padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap;
}
#controls-hint b { color: var(--vermilion2); }

/* ---------- Settings / pause overlay ---------- */
#settings-overlay {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 7, 4, 0.72); backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}
.settings-card {
  width: min(400px, 92vw); background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.settings-card h2 { text-align: center; }
.keybinds { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 6px; }
.kb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; border-radius: 10px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); font-size: 14px;
}
.kb-row span { color: var(--muted); }
.kb-row b { color: var(--gold); }

/* ---------- Touch ---------- */
#touch-controls { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
#joystick { position: absolute; bottom: 30px; left: 30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.06); border: 1px solid var(--border); pointer-events: auto; }
#stick { position: absolute; top: 35px; left: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.25); }
#touch-dash { position: absolute; bottom: 44px; right: 34px; width: 92px; height: 92px; border-radius: 50%; background: linear-gradient(120deg, var(--vermilion), var(--vermilion2)); font-weight: 800; pointer-events: auto; }
#touch-push { position: absolute; bottom: 52px; right: 140px; width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(120deg, #3aa8c9, #7bffce); color: #0d0f1a; font-weight: 800; pointer-events: auto; }

#save-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #fff4d4; color: #3a2a18; font-weight: 800; font-family: Fredoka, sans-serif;
  padding: 10px 18px; border-radius: 999px; border: 3px solid #e85d00;
  opacity: 0; pointer-events: none; z-index: 80; transition: opacity .2s, transform .2s;
}
#save-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Edge-only gate ---------- */
#edge-gate {
  position: fixed; inset: 0; z-index: 200;
  align-items: center; justify-content: center;
  padding: 28px 18px;
  background: rgba(10, 7, 4, 0.28);
  user-select: text;
  -webkit-user-select: text;
}
.edge-gate-card {
  width: min(520px, 94vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 28px 26px;
  text-align: center;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
}
.edge-gate-card::before {
  content: ""; position: absolute; inset: 7px; border-radius: 16px;
  border: 1px solid rgba(232,182,76,0.12); pointer-events: none;
}
.edge-gate-card::after {
  content: ""; position: absolute; top: -11px; left: 50%;
  width: 116px; height: 24px; transform: translateX(-50%) rotate(-2.2deg);
  background: repeating-linear-gradient(46deg, rgba(233,75,60,.5), rgba(233,75,60,.5) 7px, rgba(255,208,107,.5) 7px, rgba(255,208,107,.5) 14px);
  border: 1px solid rgba(255,255,255,.22); border-radius: 2px;
  box-shadow: 0 3px 8px rgba(0,0,0,.35); pointer-events: none;
}
.edge-gate-icon {
  width: 72px; height: 72px; margin: 8px auto 10px; display: block;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.45));
}
.edge-gate-kicker {
  color: var(--gold); font-weight: 700; font-size: 13px; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 8px;
}
.edge-gate-card h1 {
  font-family: "Fredoka", "Zen Maru Gothic", sans-serif;
  font-size: clamp(26px, 5vw, 34px); font-weight: 700; color: var(--gold);
  line-height: 1.15; margin-bottom: 14px;
  text-shadow: 0 6px 30px rgba(233, 75, 60, 0.28);
}
.edge-gate-lead, .edge-gate-body {
  color: var(--text); font-size: 16px; line-height: 1.5; margin: 0 0 10px;
  text-align: center;
}
.edge-gate-body { color: var(--muted); }
.edge-gate-actions {
  display: flex; flex-direction: column; gap: 10px; margin: 18px 0 8px;
}
.edge-gate-actions a {
  display: block; text-decoration: none; text-align: center;
  font-family: inherit; font-weight: 700; font-size: 16px;
  padding: 14px 18px; border-radius: 12px;
}
.edge-gate-actions a.primary {
  color: #fff;
  background: linear-gradient(120deg, var(--vermilion), var(--vermilion2));
  border: 2px solid rgba(255,255,255,0.14);
  box-shadow: 0 5px 0 #a5321f, 0 9px 20px rgba(233, 75, 60, 0.32);
}
.edge-gate-actions a.primary:hover { filter: brightness(1.08); }
.edge-gate-actions a.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--border);
  box-shadow: 0 5px 0 rgba(0,0,0,0.32);
}
.edge-gate-actions a.secondary:hover { background: rgba(255, 255, 255, 0.12); }
.edge-gate-note {
  font-size: 13px; color: var(--muted); margin-top: 6px;
}

/* ---------- Mobile unsupported popup ---------- */
#mobile-gate {
  position: fixed; inset: 0; z-index: 220;
  align-items: center; justify-content: center;
  padding: 24px 16px;
  background: rgba(10, 7, 4, 0.28);
}
.mobile-gate-pop {
  width: min(420px, 94vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: mobile-pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.mobile-gate-pop::before {
  content: ""; position: absolute; inset: 7px; border-radius: 16px;
  border: 1px solid rgba(232,182,76,0.12); pointer-events: none;
}
.mobile-gate-pop h1 {
  font-family: "Fredoka", "Zen Maru Gothic", sans-serif;
  font-size: clamp(24px, 6vw, 30px); font-weight: 700; color: var(--gold);
  line-height: 1.15; margin-bottom: 12px;
  text-shadow: 0 6px 30px rgba(233, 75, 60, 0.28);
}
@keyframes mobile-pop {
  from { opacity: 0; transform: scale(0.9) translateY(18px); }
  to { opacity: 1; transform: none; }
}
