/* Tug of Smarts — playful, big-tap, fixed bright theme for kids */
:root {
  --sky1: #7dd3fc; --sky2: #e0f2fe;
  --grass: #4ade80; --grass2: #22c55e; --soil: #a16207;
  --red: #ef4444; --red2: #b91c1c; --blue: #3b82f6; --blue2: #1d4ed8;
  --green: #22c55e; --green2: #15803d; --yellow: #facc15; --purple: #a855f7;
  --ink: #1e293b; --muted: #64748b; --card: #ffffff; --line: #e2e8f0;
  --radius: 22px;
  --font: 'Fredoka', 'Nunito', 'Varela Round', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink);
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 100%) fixed;
  overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
#app { min-height: 100vh; min-height: 100dvh; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; z-index: 50; }
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font-family: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
[hidden] { display: none !important; }

/* ---- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .7em 1.4em; border-radius: 999px; font-weight: 700; font-size: 1.1rem;
  background: #fff; color: var(--ink); box-shadow: 0 5px 0 #cbd5e1; transition: transform .08s, box-shadow .08s;
  min-height: 48px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }
.btn-big { font-size: 1.5rem; padding: .7em 1.6em; min-height: 64px; }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 6px 0 var(--red2); }
.btn-red:active { box-shadow: 0 1px 0 var(--red2); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 6px 0 var(--blue2); }
.btn-blue:active { box-shadow: 0 1px 0 var(--blue2); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 6px 0 var(--green2); }
.btn-green:active { box-shadow: 0 1px 0 var(--green2); }
.btn-ghost { background: rgba(255,255,255,.7); box-shadow: 0 3px 0 rgba(0,0,0,.08); font-size: 1rem; }
.btn-icon { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.85); font-size: 1.3rem; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.btn .ico { font-size: 1.3em; }

/* ---- Screens */
.screen { min-height: 100vh; min-height: 100dvh; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); display: flex; flex-direction: column; }

/* Home */
.home { align-items: center; justify-content: center; text-align: center; gap: 22px; }
.logo { font-size: clamp(64px, 16vmin, 120px); line-height: 1; filter: drop-shadow(0 8px 0 rgba(0,0,0,.12)); }
.rope-emoji { display: inline-block; animation: sway 2.4s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.home h1 { font-size: clamp(2.4rem, 9vmin, 4.5rem); color: #fff; text-shadow: 0 4px 0 var(--blue2), 0 8px 0 rgba(0,0,0,.12); letter-spacing: .5px; }
.home h1 span { color: var(--yellow); }
.tagline { margin: 6px 0 0; font-size: 1.2rem; font-weight: 600; color: var(--blue2); }
.mode-buttons { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.mode-buttons .btn { min-width: 240px; }
.subject-strip { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.subject-strip span { background: #fff; border-radius: 999px; padding: 5px 12px; font-weight: 600; border: 3px solid var(--c); font-size: .95rem; }
.home-foot { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.stats-line { margin: 0; color: var(--blue2); font-weight: 600; }

/* Setup */
.setup { gap: 12px; max-width: 760px; margin: 0 auto; width: 100%; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.topbar h2 { font-size: 1.5rem; text-align: center; color: var(--blue2); }
.topbar .back { justify-self: start; white-space: nowrap; }
.setup-body { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 6px 0 rgba(0,0,0,.08); }
.card h3 { font-size: 1.05rem; color: var(--muted); margin: 0 0 10px; }
.card h3 + * + h3 { margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 1.05rem; background: #f1f5f9; border: 3px solid transparent; min-height: 48px; }
.chip.active { background: var(--c, var(--blue)); color: #fff; border-color: var(--c, var(--blue)); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: #f1f5f9; padding: 6px; border-radius: 999px; }
.seg button { padding: 10px 6px; border-radius: 999px; font-weight: 700; font-size: 1rem; min-height: 46px; }
.seg button.active { background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue2); }
.players { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.player-edit { border: 3px dashed var(--line); border-radius: 18px; padding: 10px; }
.player-edit.p0 { border-color: #fca5a5; } .player-edit.p1 { border-color: #93c5fd; }
.player-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.big-avatar { display: inline-flex; line-height: 0; }
.name { flex: 1; font-size: 1.2rem; font-weight: 700; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--line); min-width: 0; }
.name:focus { outline: none; border-color: var(--blue); }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.av { width: 52px; height: 52px; border-radius: 14px; background: #f1f5f9; border: 3px solid transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 0; }
.av.active { border-color: var(--yellow); background: #fef9c3; transform: scale(1.08); }
.toggle { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-weight: 600; }
.toggle input { width: 24px; height: 24px; accent-color: var(--blue); }
.hint { margin: 10px 0 0; color: var(--muted); font-size: .95rem; }
.setup-foot { display: flex; justify-content: center; position: sticky; bottom: 0; padding: 10px 0 calc(10px + var(--sab)); margin: 0 -16px -16px; background: linear-gradient(180deg, rgba(224,242,254,0) 0%, rgba(224,242,254,.95) 40%); z-index: 2; }

/* ---- Game layout */
.game {
  height: 100vh; height: 100dvh; padding: var(--sat) var(--sar) var(--sab) var(--sal);
  display: grid; gap: 8px; overflow: hidden; position: relative;
  grid-template-rows: minmax(170px, 40%) 1fr; grid-template-columns: 1fr 1fr;
  grid-template-areas: "arena arena" "p0 p1";
}
.game.robot { grid-template-columns: 1fr; grid-template-rows: minmax(170px, 44%) 1fr; grid-template-areas: "arena" "p0"; }
.panel.p0 { grid-area: p0; } .panel.p1 { grid-area: p1; } .arena { grid-area: arena; }
@media (orientation: portrait) {
  .game.duel { grid-template-rows: minmax(170px, 32%) 1fr; }
}
/* Narrow screens: two panels still side by side, choices stack in one column */
@media (max-width: 640px) {
  .game.duel { gap: 6px; }
  .game.duel .panel { margin: 0 4px 6px; padding: 8px 6px; gap: 6px; border-width: 3px; }
  .game.duel .panel.p0 { margin-left: 6px; } .game.duel .panel.p1 { margin-right: 6px; }
  .game.duel .choices { grid-template-columns: 1fr; gap: 6px; }
  .game.duel .choice { min-height: 50px; padding: 6px 8px; }
  .game.duel .choices.size-s .choice { font-size: clamp(1.1rem, 5.5vw, 1.6rem); }
  .game.duel .choices.size-m .choice { font-size: clamp(1rem, 4.4vw, 1.3rem); }
  .game.duel .choices.size-l .choice { font-size: clamp(.85rem, 3.6vw, 1.1rem); }
  .game.duel .choices.size-xl .choice { font-size: clamp(.8rem, 3.2vw, 1rem); }
  .game.duel .prompt { font-size: clamp(1.3rem, 7.5vw, 2.4rem); }
  .game.duel .prompt.long { font-size: clamp(.95rem, 4.2vw, 1.3rem); }
  .game.duel .prompt.xlong { font-size: clamp(.85rem, 3.6vw, 1.1rem); }
  .game.duel .pname { font-size: 1rem; } .game.duel .pscore, .game.duel .pstreak { padding: 2px 8px; font-size: .9rem; }
  .game.duel .float { font-size: clamp(1rem, 4.5vw, 1.6rem); white-space: normal; text-align: center; max-width: 92%; }
}

.arena {
  position: relative; border-radius: 0 0 28px 28px; overflow: hidden;
  background: linear-gradient(180deg, #38bdf8 0%, #bae6fd 70%);
  display: grid; grid-template-rows: auto 1fr;
}
.hud { display: flex; align-items: center; gap: 10px; padding: 8px 10px; z-index: 2; }
.timer { flex: 1; height: 34px; border-radius: 999px; background: rgba(255,255,255,.55); position: relative; overflow: hidden; }
.timer .bar { position: absolute; inset: 0; width: 100%; background: linear-gradient(90deg, #22c55e, #86efac); transition: width 1s linear; }
.timer.urgent .bar { background: linear-gradient(90deg, #ef4444, #fca5a5); }
.timer.urgent .time { animation: pulse .5s infinite alternate; }
.timer .time { position: relative; display: block; text-align: center; line-height: 34px; font-weight: 700; font-size: 1.15rem; }
.timer.nolimit .bar { background: linear-gradient(90deg, #a855f7, #d8b4fe); }
.topic-tag { background: #fff; border: 3px solid var(--c); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .95rem; white-space: nowrap; max-width: 44%; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.15); } }

.banner { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); background: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: clamp(1.1rem, 4vmin, 2rem); font-weight: 700; box-shadow: 0 6px 0 rgba(0,0,0,.15); z-index: 5; white-space: nowrap; animation: popin .4s cubic-bezier(.3,1.5,.5,1); max-width: 94%; overflow: hidden; text-overflow: ellipsis; }
@keyframes popin { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* Panels */
.panel {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; gap: 8px; min-height: 0;
  background: #fff; border-radius: var(--radius); padding: 10px; margin: 0 8px 8px; box-shadow: 0 6px 0 rgba(0,0,0,.1);
  border: 4px solid var(--team);
}
.panel.fresh .qbox { animation: popq .25s ease-out; }
@keyframes popq { from { transform: scale(.9); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.panel.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { translate: 0; } 20% { translate: -8px; } 40% { translate: 8px; } 60% { translate: -6px; } 80% { translate: 6px; } }
.phead { display: flex; align-items: center; gap: 8px; }
.pavatar { display: inline-flex; line-height: 0; }
.pname { font-weight: 700; font-size: 1.15rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pscore { background: #f1f5f9; border-radius: 999px; padding: 4px 10px; font-weight: 700; }
.pstreak { background: #fff7ed; color: #c2410c; border-radius: 999px; padding: 4px 10px; font-weight: 700; }
.qbox { display: flex; align-items: center; justify-content: center; min-height: 0; text-align: center; padding: 4px; }
.prompt { font-weight: 700; font-size: clamp(1.6rem, 6vmin, 3rem); line-height: 1.15; }
.prompt.long { font-size: clamp(1.15rem, 3.6vmin, 1.8rem); }
.prompt.xlong { font-size: clamp(1rem, 3vmin, 1.4rem); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  min-height: 60px; border-radius: 16px; background: #f1f5f9; font-weight: 700; font-size: clamp(1.2rem, 4.2vmin, 1.9rem);
  box-shadow: 0 5px 0 #cbd5e1; padding: 8px 10px; line-height: 1.1; transition: transform .08s, box-shadow .08s, background .15s;
  border: 3px solid transparent; word-break: break-word;
}
.choices.size-s .choice { font-size: clamp(1.3rem, 4.6vmin, 2.1rem); }
.choices.size-m .choice { font-size: clamp(1.1rem, 3.6vmin, 1.6rem); }
.choices.size-l .choice { font-size: clamp(.95rem, 2.9vmin, 1.25rem); }
.choices.size-xl .choice { font-size: clamp(.85rem, 2.5vmin, 1.05rem); }
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }
.choice:disabled { cursor: default; }
.choice.right { background: #dcfce7; border-color: var(--green); color: var(--green2); }
.choice.wrong { background: #fee2e2; border-color: var(--red); color: var(--red2); }
.float { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.5); opacity: 0; pointer-events: none;
  font-weight: 700; font-size: clamp(1.4rem, 5vmin, 2.4rem); padding: 8px 18px; border-radius: 999px; background: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.15); transition: transform .25s cubic-bezier(.3,1.6,.5,1), opacity .2s; z-index: 3; white-space: nowrap; }
.float.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.float.good { color: var(--green2); } .float.bad { color: var(--red2); } .float.power { color: #c2410c; background: #fff7ed; }

.robot-status { position: absolute; top: 54px; right: 14px; max-width: calc(100% - 28px); display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; color: var(--blue2); background: rgba(255,255,255,.9); border-radius: 999px; padding: 4px 12px 4px 6px; z-index: 3; pointer-events: none; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.robot-status .rs-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.robot-status .rs-avatar { display: inline-flex; }
.robot-status.got { color: var(--green2); } .robot-status.missed { color: var(--red2); }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { to { content: '...'; } }

/* Countdown + overlays */
.countdown { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .35); z-index: 20; }
.countdown span { font-size: clamp(5rem, 22vmin, 12rem); font-weight: 700; color: #fff; text-shadow: 0 6px 0 var(--blue2), 0 12px 0 rgba(0,0,0,.2); }
.countdown.pop span { animation: popin2 .5s cubic-bezier(.3,1.5,.5,1); }
@keyframes popin2 { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .5); z-index: 30; }
.dialog { background: #fff; border-radius: 28px; padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: center; min-width: 260px; box-shadow: 0 10px 0 rgba(0,0,0,.2); }
.dialog h2 { font-size: 2rem; color: var(--blue2); }

/* Result */
.result { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.trophy { font-size: clamp(64px, 18vmin, 140px); line-height: 1; animation: bounce .6s ease-in-out infinite alternate; filter: drop-shadow(0 8px 0 rgba(0,0,0,.12)); }
.result h1 { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: clamp(2rem, 8vmin, 3.6rem); color: #fff; text-shadow: 0 4px 0 var(--blue2), 0 8px 0 rgba(0,0,0,.12); }
.cheer { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--blue2); }
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 560px); }
.score { background: #fff; border-radius: var(--radius); padding: 14px; border: 4px solid var(--team); box-shadow: 0 6px 0 rgba(0,0,0,.1); }
.score.winner { background: #fefce8; box-shadow: 0 0 0 4px var(--yellow), 0 6px 0 rgba(0,0,0,.1); }
.savatar { display: flex; justify-content: center; line-height: 0; }
.sname { font-weight: 700; font-size: 1.2rem; margin: 6px 0 10px; }
.score dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; text-align: left; }
.score dt { color: var(--muted); font-weight: 600; } .score dd { margin: 0; font-weight: 700; }
.actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }

@media (max-width: 480px) {
  .topic-tag { display: none; }
}
@media (max-width: 420px) {
  .scoreboard { grid-template-columns: 1fr; }
  .btn-big { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- Arena scene (SVG) */
.scene { position: relative; min-height: 0; overflow: hidden; }
.arena-svg { display: block; width: 100%; height: 100%; }
.arena-svg .rope-shadow { fill: none; stroke: rgba(0,0,0,.18); stroke-width: 9; stroke-linecap: round; transform: translateY(4px); }
.arena-svg .rope-base { fill: none; stroke: #92400e; stroke-width: 8; stroke-linecap: round; }
.arena-svg .rope-twist { fill: none; stroke: #f59e0b; stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 7 7; }
.arena-svg .marker { fill: #ef4444; stroke: #7f1d1d; stroke-width: 1; }
.arena-svg text { font-family: var(--font); }
.arena-svg .crowd.cheer .fan { animation: fanjump .5s ease-out; }
@keyframes fanjump { 0% { translate: 0 0; } 40% { translate: 0 -9px; } 100% { translate: 0 0; } }

.portrait { border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.win-portrait { display: inline-flex; line-height: 0; }
.win-portrait .portrait { box-shadow: 0 0 0 4px var(--yellow); }

/* ---- Tablets: a little larger type and roomier targets */
@media (min-width: 820px) and (min-height: 600px) {
  html { font-size: 18px; }
  .choice { min-height: 72px; }
  .seg button, .chip { min-height: 52px; }
}
/* ---- Short screens (phones in landscape): compact everything so the field, question and answers all fit */
@media (max-height: 500px) and (orientation: landscape) {
  .game, .game.robot, .game.duel { grid-template-rows: minmax(104px, 30%) 1fr; gap: 4px; }
  .hud { padding: 4px 6px; gap: 6px; }
  .timer { height: 26px; } .timer .time { line-height: 26px; font-size: .95rem; }
  .btn-icon { width: 34px; height: 34px; font-size: 1rem; }
  .topic-tag { font-size: .8rem; padding: 2px 10px; }
  .robot-status { top: 40px; right: auto; left: 8px; max-width: 55%; font-size: .8rem; padding: 2px 8px 2px 4px; }
  .robot-status .portrait { width: 20px; height: 20px; }
  .panel { padding: 6px 8px; gap: 4px; margin: 0 4px 4px; border-width: 3px; }
  .phead { gap: 6px; } .pavatar .portrait { width: 26px; height: 26px; } .pname { font-size: 1rem; }
  .pscore, .pstreak { padding: 2px 8px; font-size: .9rem; }
  .qbox { padding: 0; }
  .prompt { font-size: clamp(1.1rem, 9vh, 1.9rem); }
  .prompt.long { font-size: clamp(.9rem, 5.5vh, 1.2rem); }
  .prompt.xlong { font-size: clamp(.8rem, 4.5vh, 1rem); }
  .choices { gap: 6px; }
  .choice { min-height: 42px; padding: 4px 8px; }
  .choices.size-s .choice { font-size: clamp(1rem, 7vh, 1.5rem); }
  .choices.size-m .choice { font-size: clamp(.9rem, 5.5vh, 1.2rem); }
  .choices.size-l .choice { font-size: clamp(.8rem, 4.6vh, 1rem); }
  .choices.size-xl .choice { font-size: clamp(.72rem, 4vh, .9rem); }
  .float { font-size: clamp(1rem, 7vh, 1.6rem); padding: 4px 12px; }
  .banner { font-size: clamp(.9rem, 6vh, 1.4rem); padding: 6px 14px; }
  .countdown span { font-size: clamp(3rem, 40vh, 7rem); }
  .home { gap: 12px; } .logo { font-size: 48px; } .home h1 { font-size: 2.2rem; } .tagline { font-size: 1rem; }
  .mode-buttons .btn { min-width: 200px; font-size: 1.2rem; min-height: 52px; }
  .subject-strip { display: none; }
  .result { gap: 6px; padding-top: calc(14px + var(--sat)); padding-bottom: calc(10px + var(--sab)); }
  .trophy { display: none; } .cheer { display: none; }
  .result h1 { font-size: 1.6rem; gap: 8px; } .win-portrait .portrait { width: 36px; height: 36px; }
  .scoreboard { gap: 8px; width: min(100%, 640px); } .score { padding: 6px 12px; border-width: 3px; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; text-align: left; }
  .savatar { grid-row: 1 / 3; } .savatar .portrait { width: 44px; height: 44px; } .sname { margin: 0; font-size: 1rem; }
  .score dl { grid-column: 2; grid-template-columns: auto 1fr auto 1fr; gap: 0 8px; font-size: .85rem; }
  .actions { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .actions .btn-big { font-size: 1.1rem; min-height: 46px; padding: .5em 1.2em; }
}
/* ---- Small phones: tighter home and setup */
@media (max-width: 400px) {
  .mode-buttons .btn { min-width: 0; width: 100%; }
  .card { padding: 12px; }
  .chip { padding: 8px 12px; font-size: .95rem; }
  .seg button { font-size: .9rem; padding: 8px 4px; }
  .av { width: 46px; height: 46px; }
}

/* ---- Home extras */
.me-strip { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.me-strip .btn { gap: 8px; }
.loading { align-items: center; justify-content: center; gap: 16px; color: var(--blue2); font-weight: 700; font-size: 1.2rem; }
.spinner { width: 52px; height: 52px; border-radius: 50%; border: 6px solid rgba(255,255,255,.6); border-top-color: var(--blue); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translate(-50%, 20px); background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-card { max-width: 480px; text-align: center; }
.error-card h2 { color: var(--red2); margin-bottom: 8px; } .error-card .actions { margin-top: 14px; }
.muted { color: var(--muted); font-weight: 600; margin: 6px 0; }
.tiny { font-size: .85rem; min-height: 36px; padding: .4em 1em; }

/* ---- Character studio */
.studio-screen { gap: 12px; max-width: 980px; margin: 0 auto; width: 100%; }
.studio { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .studio { grid-template-columns: 1fr; } }
.preview-card { position: sticky; top: 8px; }
.preview-wrap { display: flex; align-items: flex-end; justify-content: center; gap: 12px; background: linear-gradient(180deg, #bae6fd, #e0f2fe); border-radius: 18px; padding: 12px; }
.preview-portrait .portrait { box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.figure-preview { width: 150px; height: 152px; display: block; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-weight: 700; color: var(--muted); }
.field input { font-size: 1.15rem; font-weight: 700; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--line); width: 100%; }
.field input:focus { outline: none; border-color: var(--blue); }
.name-error { color: var(--red2); font-weight: 700; margin: 8px 0 0; }
.preview-card h3 { margin-top: 14px; } .preview-card h3 small { font-weight: 500; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag-btn { font-size: 1.5rem; width: 44px; height: 40px; border-radius: 10px; background: #f1f5f9; border: 3px solid transparent; }
.flag-btn.active { border-color: var(--blue); background: #dbeafe; }
.options-card h3 { margin-top: 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 2px #cbd5e1, 0 3px 0 rgba(0,0,0,.1); }
.swatch.active { box-shadow: 0 0 0 4px var(--blue), 0 3px 0 rgba(0,0,0,.1); transform: scale(1.1); }
.chips .chip.active[style*="#475569"] { background: #475569; border-color: #475569; }

/* ---- Lobby */
.lobby { gap: 12px; max-width: 820px; margin: 0 auto; width: 100%; }
.lobby .topbar .me-btn { justify-self: end; gap: 6px; }
.lobby-body { display: flex; flex-direction: column; gap: 12px; }
.quick-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quick-text { display: flex; flex-direction: column; gap: 2px; } .quick-text b { color: var(--blue2); font-size: 1.1rem; } .quick-hint { color: var(--muted); font-weight: 600; }
.searching { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-weight: 700; color: var(--blue2); }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse-dot 1s ease-in-out infinite alternate; }
@keyframes pulse-dot { from { transform: scale(.7); opacity: .5; } to { transform: scale(1.2); opacity: 1; } }
.pulse-row { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--blue2); margin: 8px 0; }
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-card { display: flex; align-items: center; gap: 12px; background: #f8fafc; border-radius: 16px; padding: 8px 10px; }
.player-card.playing { opacity: .7; }
.pc-info { flex: 1; display: flex; flex-direction: column; min-width: 0; } .pc-info b { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pc-info small { color: var(--muted); font-weight: 600; }
.challenge-btn { font-size: 1rem; padding: .5em 1.1em; min-height: 44px; }
.lobby .chips.topics { margin-top: 8px; } .lobby .seg[data-key] { margin-top: 10px; }
.board-seg { margin-bottom: 10px; }
.board { display: flex; flex-direction: column; gap: 6px; }
.board-row { display: flex; align-items: center; gap: 10px; background: #f8fafc; border-radius: 12px; padding: 6px 10px; }
.board-row.me { background: #fef9c3; }
.board-row .rank { width: 32px; text-align: center; font-weight: 700; font-size: 1.1rem; }
.board-row .bname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .bwins { font-weight: 700; color: var(--blue2); }
.safe-hint { text-align: center; }
.ch-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.ch-head h2 { font-size: 1.5rem; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dialog .muted { text-align: center; }

/* ---- Online match: opponent panel, emotes, bubbles */
.panel.opp { grid-template-rows: auto 1fr auto; }
.opp-body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; text-align: center; }
.opp-face .portrait { box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.opp-status { font-weight: 700; font-size: clamp(1.1rem, 4vmin, 1.8rem); color: var(--muted); transition: color .2s; }
.opp-status.good { color: var(--green2); } .opp-status.bad { color: var(--red2); }
.emotes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.emote { min-height: 44px; padding: 6px 12px; border-radius: 999px; background: #f1f5f9; font-weight: 700; font-size: 1.1rem; box-shadow: 0 3px 0 #cbd5e1; }
.emote:active { transform: translateY(3px); box-shadow: none; }
.emote-bubble { position: absolute; top: 44px; background: #fff; border-radius: 16px; padding: 6px 12px; font-weight: 700; font-size: clamp(1rem, 3.5vmin, 1.5rem); box-shadow: 0 4px 0 rgba(0,0,0,.15); opacity: 0; transform: translateY(8px) scale(.8); transition: opacity .2s, transform .25s cubic-bezier(.3,1.5,.5,1); z-index: 4; pointer-events: none; }
.emote-bubble.side0 { left: 14%; } .emote-bubble.side1 { right: 14%; }
.emote-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.countdown.text span { font-size: clamp(1.2rem, 5vmin, 2rem); text-shadow: 0 3px 0 var(--blue2); padding: 0 16px; text-align: center; }
.game.online .quit { font-size: 1.1rem; }

/* ---- Idea Box */
.idea-card { background: #fff; border-radius: var(--radius); padding: 14px; width: min(100%, 560px); box-shadow: 0 6px 0 rgba(0,0,0,.1); border: 4px solid #99f6e4; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.idea-head { display: flex; gap: 10px; align-items: center; }
.idea-face { font-size: 2.4rem; line-height: 1; }
.idea-head b { color: #0f766e; } .idea-head p { margin: 2px 0 0; font-weight: 600; }
.idea-chips .chip { font-size: .95rem; padding: 6px 12px; min-height: 40px; }
.idea-text { width: 100%; font-family: inherit; font-size: 1.05rem; font-weight: 600; padding: 10px 12px; border-radius: 14px; border: 3px solid var(--line); resize: vertical; min-height: 56px; }
.idea-text:focus { outline: none; border-color: #14b8a6; }
.idea-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.idea-thanks { font-weight: 700; color: #0f766e; }
.idea-dialog { max-width: 600px; width: calc(100% - 32px); }
.idea-overlay { position: fixed; }
.result .idea-card { margin-top: 6px; }

/* ---- Sound picker */
.sound-list { display: flex; flex-direction: column; gap: 8px; width: min(100%, 360px); }
.sound-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f1f5f9; border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 1.1rem; border: 3px solid transparent; }
.sound-opt.active { border-color: var(--blue); background: #dbeafe; }
.sound-opt small { color: var(--muted); font-weight: 600; }
