@font-face { font-family: 'Fredoka'; src: url(../fonts/fredoka.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }
:root {
  --ink: #2B2350; --cream: #FFF6E5; --sun: #FFB627; --pink: #FF4F8B; --teal: #1FB5C9; --green: #3DD68C;
  --purple: #7B5CFF; --orange: #FF8A3D; --card: #fff; --line: #F1DFC0;
  --r: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif; color: var(--ink); font-size: 18px;
  background: var(--cream);
  background-image: radial-gradient(#ffd9a0 2px, transparent 2.5px), radial-gradient(#ffc9de 2px, transparent 2.5px);
  background-size: 46px 46px, 46px 46px; background-position: 0 0, 23px 23px;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
h2 { margin: .2em 0 .4em; font-weight: 700; }
.muted { color: #7a6f99; } .small { font-size: 14px; }
.top { text-align: center; padding: calc(10px + env(safe-area-inset-top)) 12px 0; }
.logo { height: 92px; max-width: 92%; animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
main { max-width: 560px; margin: 0 auto; padding: 6px 14px 20px; }
.tab { display: none; } .tab.active { display: block; animation: slideUp .25s ease; }
.section-title { font-size: 28px; text-align: center; }
.card { background: var(--card); border: 3px solid var(--ink); border-radius: var(--r); padding: 16px; margin: 12px 0; box-shadow: 0 6px 0 var(--ink); }
.empty { text-align: center; padding: 26px 18px; }
.big-emoji { font-size: 64px; }

/* buttons */
.btn { font: inherit; font-weight: 700; font-size: 20px; color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
  padding: 14px 18px; min-height: 58px; background: #fff; box-shadow: 0 6px 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; }
.btn-xl { font-size: 24px; min-height: 70px; width: 100%; }
.btn-green { background: var(--green); } .btn-pink { background: var(--pink); color: #fff; } .btn-yellow { background: var(--sun); }
.btn-ghost { background: transparent; box-shadow: none; border-style: dashed; width: 100%; margin-top: 12px; font-size: 18px; min-height: 52px; }
.btn-ghost.danger { color: #c22; border-color: #c22; }

/* game */
.status-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pill { background: #fff; border: 3px solid var(--ink); border-radius: 99px; padding: 6px 14px; font-weight: 600; }
.pill.live { background: var(--pink); color: #fff; animation: pulse 1.2s infinite; }
.pill.paused { background: var(--sun); }
.clock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.now-talking { text-align: center; font-size: 22px; min-height: 40px; margin: 10px 0 4px; font-weight: 600; }
.now-talking .who { display: inline-block; animation: wiggle .5s infinite; }
.lanes { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 14px; }
.lane { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: var(--r); padding: 10px 12px 12px; box-shadow: 0 5px 0 var(--ink); transition: transform .2s, box-shadow .2s; }
.lane.talking { transform: scale(1.03); box-shadow: 0 0 0 5px var(--c), 0 5px 0 var(--ink); }
.lane-head { display: flex; align-items: center; gap: 10px; }
.lane-avatar { font-size: 40px; line-height: 1; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--c); border: 3px solid var(--ink); flex: none; }
.lane.talking .lane-avatar { animation: wiggle .45s infinite; }
.lane-name { font-size: 22px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-badge { font-size: 13px; font-weight: 700; background: var(--sun); border: 2px solid var(--ink); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.lane-badge.mouse { background: #E3DBFF; }
.lane-time { text-align: right; font-variant-numeric: tabular-nums; }
.lane-time b { font-size: 26px; display: block; line-height: 1; }
.lane-time span { font-size: 15px; color: #7a6f99; }
.track { position: relative; height: 26px; margin-top: 10px; border-radius: 99px; background: repeating-linear-gradient(90deg, #F6EBD5 0 18px, #FFF6E5 18px 36px); border: 3px solid var(--ink); overflow: visible; }
.track-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: var(--c); transition: width .5s cubic-bezier(.3,1.4,.5,1); }
.track-runner { position: absolute; top: 50%; left: 0; transform: translate(-50%, -55%); font-size: 26px; transition: left .5s cubic-bezier(.3,1.4,.5,1); filter: drop-shadow(0 2px 0 rgba(0,0,0,.25)); }
.lane.talking .track-runner { animation: hop .35s infinite; }
.track-flag { position: absolute; right: -6px; top: -20px; font-size: 22px; }
.bubble-pop { position: absolute; right: 14px; top: -16px; font-size: 26px; animation: floatUp 1s ease-out forwards; pointer-events: none; }
.level { height: 10px; border-radius: 99px; background: #fff; border: 2px solid var(--ink); overflow: hidden; margin-bottom: 14px; }
.level i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--sun), var(--pink)); transition: width .15s; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.privacy-note { font-size: 14px; text-align: center; color: #7a6f99; margin-top: 16px; }

/* players */
.player-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.player { display: flex; align-items: center; gap: 12px; background: #fff; border: 3px solid var(--ink); border-radius: var(--r); padding: 10px 12px; box-shadow: 0 5px 0 var(--ink); }
.player .lane-avatar { cursor: pointer; }
.player-info { flex: 1; min-width: 0; } .player-info b { font-size: 22px; } .player-info small { display: block; color: #7a6f99; }
.icon-btn { font-size: 22px; width: 52px; height: 52px; border-radius: 16px; border: 3px solid var(--ink); background: var(--cream); }
.hint { font-size: 15px; color: #7a6f99; text-align: center; }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(43,35,80,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade .2s; }
.sheet-card { background: var(--cream); width: 100%; max-width: 560px; border-radius: 28px 28px 0 0; border: 3px solid var(--ink); border-bottom: none; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; animation: slideUp .3s cubic-bezier(.2,1.3,.4,1); }
.input { font: inherit; font-size: 24px; width: 100%; padding: 14px 16px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); }
.label { font-weight: 600; margin: 14px 0 6px; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-grid button { font-size: 32px; aspect-ratio: 1; border-radius: 16px; border: 3px solid transparent; background: #fff; padding: 0; }
.avatar-grid button.sel { border-color: var(--ink); background: var(--sun); transform: scale(1.08); }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; } .sheet-actions .btn { flex: 1; }
.prompt-box { background: #fff; border: 3px dashed var(--teal); border-radius: 16px; padding: 12px 14px; font-size: 20px; text-align: center; }
.ring-wrap { position: relative; width: 150px; height: 150px; margin: 14px auto 4px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: #fff; stroke: #F1DFC0; stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .25s; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 700; }
.ring-wrap.hot .ring-label { animation: wiggle .5s infinite; }
.voice-msg { text-align: center; font-weight: 600; min-height: 26px; }

/* history */
.session { background: #fff; border: 3px solid var(--ink); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; box-shadow: 0 5px 0 var(--ink); }
.session-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.session-head b { font-size: 19px; } .session-head small { color: #7a6f99; }
.srow { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.srow .e { font-size: 26px; } .srow .bar { height: 14px; border-radius: 99px; background: #F6EBD5; border: 2px solid var(--ink); overflow: hidden; }
.srow .bar i { display: block; height: 100%; background: var(--c); }
.srow .nm { font-weight: 600; font-size: 16px; } .srow .tm { font-variant-numeric: tabular-nums; text-align: right; font-size: 16px; }
.session .del { display: block; margin: 6px 0 0 auto; font-size: 14px; background: none; border: none; color: #c22; padding: 8px; }

/* settings */
.row-toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row-toggle input { width: 30px; height: 30px; accent-color: var(--green); }
input[type=range] { width: 100%; accent-color: var(--pink); height: 34px; }
.range-labels { display: flex; justify-content: space-between; color: #7a6f99; }

/* results */
.results { position: fixed; inset: 0; z-index: 30; background: rgba(43,35,80,.6); display: flex; align-items: center; justify-content: center; padding: 14px; animation: fade .2s; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.results-card { position: relative; background: var(--cream); border: 3px solid var(--ink); border-radius: 28px; padding: 18px; width: 100%; max-width: 520px; max-height: 94vh; overflow: auto; text-align: center; box-shadow: 0 8px 0 var(--ink); animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.results-title { font-size: 32px; margin: 0; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 18px 0 10px; }
.pod { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; }
.pod .pa { font-size: 46px; animation: bounce 1s infinite; } .pod.p1 .pa { font-size: 58px; }
.pod .pn { font-weight: 700; font-size: 17px; margin: 2px 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pt { font-size: 15px; }
.pod .blk { width: 100%; border: 3px solid var(--ink); border-radius: 14px 14px 0 0; background: var(--c); display: grid; place-items: center; font-size: 30px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.pod.p1 .blk { height: 120px; } .pod.p2 .blk { height: 84px; } .pod.p3 .blk { height: 58px; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; z-index: 40; font-weight: 600; max-width: 90vw; text-align: center; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 3px solid var(--ink); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); background: none; border: none; padding: 8px 0 10px; min-height: 68px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 26px; transition: transform .2s; }
.tabs button.active { color: var(--pink); } .tabs button.active span { transform: scale(1.25) rotate(-8deg); }

@keyframes wiggle { 0%,100% { transform: rotate(-8deg) scale(1.05); } 50% { transform: rotate(8deg) scale(1.12); } }
@keyframes hop { 0%,100% { transform: translate(-50%, -55%); } 50% { transform: translate(-50%, -95%); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,79,139,.6); } 50% { box-shadow: 0 0 0 10px rgba(255,79,139,0); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes floatUp { from { transform: translateY(0) scale(.6); opacity: 1; } to { transform: translateY(-40px) scale(1.2); opacity: 0; } }
.bounce { animation: bounce 1.2s infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.srow { text-align: left; }

/* mode picker + turns */
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.mode-picker button { font: inherit; font-weight: 700; font-size: 19px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 6px; min-height: 64px; box-shadow: 0 5px 0 var(--ink); }
.mode-picker button small { display: block; font-weight: 500; font-size: 13px; color: #7a6f99; }
.mode-picker button.sel { background: var(--teal); color: #fff; } .mode-picker button.sel small { color: #e9fbff; }
.mode-picker.locked button:not(.sel) { opacity: .4; }
.turns-setup .row-toggle { margin-top: 12px; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.chips button { font: inherit; font-weight: 700; font-size: 17px; min-height: 52px; border-radius: 14px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink); }
.chips button.sel { background: var(--sun); transform: scale(1.05); }
.custom-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 600; }
.small-input { width: 84px; font-size: 22px; padding: 8px 10px; text-align: center; }
.per-person-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.pp-row { display: flex; align-items: center; gap: 8px; } .pp-row .e { font-size: 28px; } .pp-row .n { flex: 1; font-weight: 600; }
.pp-row button { width: 48px; height: 48px; font-size: 24px; font-weight: 700; border-radius: 14px; border: 3px solid var(--ink); background: #fff; color: var(--ink); }
.pp-row .v { min-width: 58px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.link-btn { font: inherit; font-weight: 700; color: var(--purple); background: none; border: none; padding: 8px; }
.turn-stage { text-align: center; }
.turn-title { font-size: 30px; font-weight: 700; margin-top: 4px; }
.turn-ring-wrap { position: relative; width: 250px; height: 250px; margin: 6px auto; }
.turn-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.tr-bg { fill: #fff; stroke: var(--ink); stroke-width: 20; }
.tr-fg { fill: none; stroke: var(--green); stroke-width: 14; stroke-linecap: round; stroke-dasharray: 553; stroke-dashoffset: 0; transition: stroke-dashoffset .3s linear, stroke .3s; }
.turn-ring-wrap.low .tr-fg { stroke: var(--orange); } .turn-ring-wrap.crit .tr-fg { stroke: var(--pink); }
.turn-ring-wrap.crit { animation: pulseScale .6s infinite; }
.turn-avatar { position: absolute; inset: 0; display: grid; place-items: center; font-size: 104px; padding-bottom: 40px; }
.turn-ring-wrap.talking .turn-avatar { animation: wiggle .45s infinite; }
.turn-left { position: absolute; left: 0; right: 0; bottom: 46px; font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.turn-hint { font-weight: 600; min-height: 28px; }
.oops { display: inline-block; background: var(--pink); color: #fff; font-weight: 700; font-size: 20px; padding: 8px 16px; border-radius: 99px; border: 3px solid var(--ink); margin: 8px 0; animation: shake .5s; }
.turn-queue { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.tq { position: relative; width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); display: grid; place-items: center; font-size: 30px; }
.tq.done { opacity: .45; } .tq.now { transform: scale(1.18); box-shadow: 0 0 0 4px var(--sun); }
.tq .oo { position: absolute; right: -8px; top: -8px; background: var(--pink); color: #fff; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 1px 6px; border: 2px solid var(--ink); }
.timesup { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(255,79,139,.35); animation: flash .25s 3; padding: 16px; }
.ts-card { background: var(--sun); border: 4px solid var(--ink); border-radius: 30px; padding: 22px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 8px 0 var(--ink); animation: pop .4s cubic-bezier(.2,1.8,.4,1), shake .5s .4s; }
.ts-emoji { font-size: 84px; animation: wiggle .3s infinite; } .ts-title { font-size: 44px; font-weight: 700; } .ts-sub { font-size: 19px; margin: 6px 0 16px; }
.rrow { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; text-align: left; margin-top: 10px; }
.rrow .e { font-size: 30px; } .rrow .nm { font-weight: 700; } .rrow .bar { position: relative; height: 16px; border-radius: 99px; background: #F6EBD5; border: 2px solid var(--ink); overflow: hidden; }
.rrow .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); } .rrow .bar u { position: absolute; top: 0; bottom: 0; background: var(--pink); opacity: .7; }
.rrow .tm { text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; } .rrow .tags { font-size: 13px; color: #7a6f99; }
.mode-tag { font-size: 13px; font-weight: 700; background: var(--cream); border: 2px solid var(--ink); border-radius: 99px; padding: 1px 8px; margin-left: 6px; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-8px) rotate(-2deg); } 40%,80% { transform: translateX(8px) rotate(2deg); } }
@keyframes flash { 50% { background: rgba(255,182,39,.5); } }
@keyframes pulseScale { 50% { transform: scale(1.04); } }

.top { position: relative; }
.share-fab { position: absolute; right: 12px; top: calc(14px + env(safe-area-inset-top)); width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; font-size: 24px; box-shadow: 0 4px 0 var(--ink); }
.share-fab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.turn-round { display: inline-block; font-weight: 700; font-size: 14px; background: var(--purple); color: #fff; border: 2px solid var(--ink); border-radius: 99px; padding: 2px 10px; }
.penalty-note { display: inline-block; margin-top: 6px; background: #FFE1EC; border: 3px dashed var(--pink); border-radius: 14px; padding: 6px 12px; font-weight: 700; color: #c8235f; animation: shake .6s; }
.tq .pen { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); background: var(--ink); color: #FFD45C; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 1px 6px; white-space: nowrap; border: 2px solid #fff; }
.turn-queue { margin-bottom: 22px; }
