[hidden] { display: none !important; }
:root {
  --bg1: #7B5CFF; --bg2: #5A3FE0; --panel: #2B1E66; --ol: #1A1240; --hi: #3F2E8C; --cream: #FFF6E5; --gold: #FFC93C;
  --green: #7CFF6B; --shield: #43E8FF; --danger: #FF4D6D; --muted: #cfc5ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg1), var(--bg2)) fixed; color: var(--cream);
  font-family: Fredoka, system-ui, sans-serif; font-weight: 500; overscroll-behavior: none;
}
body[data-view="tvgame"], body[data-view="pgame"] { overflow: hidden; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
small { font-size: 14px; }

.logo {
  font-weight: 700; font-size: 56px; letter-spacing: 2px; margin: 8px 0; text-align: center; color: var(--cream);
  -webkit-text-stroke: 6px var(--ol); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ol);
}
.logo.small { font-size: 40px; }
.logo-small { font-weight: 700; font-size: 32px; -webkit-text-stroke: 4px var(--ol); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ol); }
.tag { text-align: center; margin: 0 0 16px; color: var(--cream); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 10px 20px;
  border-radius: 18px; border: 3px solid var(--ol); background: var(--hi); color: var(--cream);
  font-size: 20px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 0 var(--ol); transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ol); }
.btn.primary { background: linear-gradient(180deg, #ffd86b, var(--gold)); color: var(--ol); }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(255,255,255,0.35); }
.btn.small { min-height: 44px; font-size: 16px; padding: 6px 14px; }
.btn.huge { width: 100%; min-height: 68px; font-size: 24px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn:focus-visible, .sbtn:focus-visible, .mbtn:focus-visible, .abtn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 5px solid var(--gold); outline-offset: 4px;
}
input {
  font-family: inherit; font-size: 20px; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--ol);
  background: var(--cream); color: var(--ol); min-height: 52px; width: 100%;
}
.card { background: var(--panel); border: 3px solid var(--ol); border-radius: 22px; padding: 14px; margin: 12px 0; box-shadow: inset 0 3px 0 var(--hi); }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; }
.label { font-weight: 600; margin: 10px 0 6px; color: var(--muted); }
.label small { color: var(--muted); }

/* home */
.home { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }
.home .back { color: var(--cream); text-decoration: none; font-weight: 600; display: inline-block; padding: 8px 0; }
.home .actions { display: grid; gap: 12px; }
.home .card.big { text-align: center; }
.code { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; text-align: center; }
.profile .prow { display: flex; gap: 12px; align-items: center; }
.profile .pm { width: 88px; height: 88px; }
.profile .pf { flex: 1; position: relative; }
.profile .pf label { font-weight: 600; color: var(--muted); font-size: 14px; }
.lvchip { display: inline-block; background: var(--gold); color: var(--ol); border-radius: 10px; padding: 1px 8px; font-weight: 700; font-size: 14px; border: 2px solid var(--ol); }
.profile .pf .lvchip { position: absolute; right: 8px; bottom: 12px; }
.mascots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mascots.small .mbtn span { display: none; }
.mbtn { background: var(--hi); border: 3px solid var(--ol); border-radius: 14px; padding: 4px 0; color: var(--cream); cursor: pointer; display: flex; flex-direction: column; align-items: center; min-height: 56px; }
.mbtn img { width: 100%; max-width: 64px; }
.mbtn span { font-size: 12px; }
.mbtn.on { background: var(--gold); color: var(--ol); }
.mbtn[disabled] { opacity: .35; }
.accs { display: flex; flex-wrap: wrap; gap: 6px; }
.abtn { background: var(--hi); border: 2px solid var(--ol); border-radius: 12px; color: var(--cream); padding: 8px 10px; font-size: 14px; min-height: 44px; cursor: pointer; }
.abtn.on { background: var(--gold); color: var(--ol); }
.abtn.locked { opacity: .45; }

.center-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.dots { display: flex; gap: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--cream); animation: bob 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* phone lobby */
.lobby { max-width: 520px; margin: 0 auto; padding: 14px 16px 40px; }
.lobby-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.pill { background: var(--panel); border: 3px solid var(--ol); border-radius: 30px; padding: 6px 14px; font-weight: 600; }
.pill b { color: var(--gold); letter-spacing: 3px; }
.lobby h2 { margin: 16px 0 8px; }
.plist { display: grid; gap: 8px; }
.prow-l { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 3px solid var(--ol); border-radius: 16px; padding: 4px 10px; }
.prow-l.off { opacity: .55; }
.prow-l img { width: 52px; height: 52px; }
.prow-l .nm { flex: 1; font-weight: 600; font-size: 18px; }
.hosttag { background: var(--cream); color: var(--ol); font-weight: 700; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.tbtn { border: 2px solid var(--ol); border-radius: 10px; padding: 6px 10px; font-weight: 700; color: var(--ol); min-height: 40px; }
.tbtn.t0 { background: #FF6B6B; } .tbtn.t1 { background: #4DB5FF; } .tbtn.t2 { background: #FFD23F; }
.settings { margin: 10px 0 16px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.sbtn { flex: 1; min-height: 48px; border-radius: 14px; border: 3px solid var(--ol); background: var(--hi); color: var(--cream); font-size: 16px; font-weight: 600; cursor: pointer; }
.sbtn.on { background: var(--gold); color: var(--ol); }

/* TV lobby */
.tv-lobby { width: 100vw; min-height: 100vh; padding: 3vh 5vw; display: flex; flex-direction: column; gap: 2vh; }
.tvl-head { display: flex; align-items: center; justify-content: space-between; }
.tv-lobby .logo { font-size: 110px; margin: 0; -webkit-text-stroke: 12px var(--ol); text-shadow: 0 12px 0 var(--ol); }
.joinbox { display: flex; gap: 20px; align-items: center; }
.codepill { background: var(--panel); border: 6px solid var(--ol); border-radius: 30px; padding: 8px 32px; display: flex; flex-direction: column; align-items: center; box-shadow: inset 0 3px 0 var(--hi); }
.codepill span { color: var(--muted); font-size: 22px; }
.codepill b { font-size: 96px; letter-spacing: 10px; color: var(--gold); line-height: 1; }
.qr { background: #fff; border: 6px solid var(--ol); border-radius: 22px; padding: 10px; display: flex; flex-direction: column; align-items: center; color: var(--ol); font-weight: 700; }
.qr img { width: 150px; height: 150px; }
.tvl-hint { font-size: 26px; margin: 0; }
.tv-cards { display: flex; gap: 20px; flex-wrap: wrap; min-height: 260px; align-items: flex-start; }
.ocard { width: 240px; background: var(--panel); border: 6px solid var(--ol); border-radius: 28px; padding: 10px; text-align: center; box-shadow: inset 0 3px 0 var(--hi); border-top: 10px solid var(--c); }
.ocard.drop { animation: drop .45s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes drop { from { transform: translateY(-120px) scale(.6); opacity: 0; } }
.ocard img { width: 150px; height: 150px; }
.ocard .onm { font-size: 30px; font-weight: 700; }
.ocard .ometa { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 6px; }
.empty { font-size: 32px; color: var(--muted); padding: 60px 0; }
.tvl-bottom { display: flex; gap: 40px; align-items: flex-end; margin-top: auto; }
.settings.tvset { flex: 1; }
.settings.tvset .sbtn { font-size: 26px; min-height: 64px; }
.settings.tvset .label { font-size: 24px; }
.settings.tvset p { font-size: 22px; }
.tvl-actions { width: 520px; display: grid; gap: 16px; }
.tvl-actions .row { flex-wrap: wrap; }
.soundhint { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 4px solid var(--ol); padding: 8px 20px; border-radius: 20px; font-size: 22px; }

/* TV game */
.tv { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg2); }
.tv canvas { display: block; }
.tvbtns { position: fixed; top: 2vh; right: 2vw; display: flex; gap: 12px; }

/* phone game */
.pg { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.topbar { height: 56px; display: flex; align-items: center; gap: 6px; padding: 0 6px; background: var(--panel); border-bottom: 3px solid var(--ol); }
.topbar .tm { width: 46px; height: 46px; }
.stat { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 18px; }
.stat.gold b { color: var(--gold); } .stat.cores b { color: var(--green); } .stat.shield b { color: var(--shield); }
.stat.timer { margin-left: 2px; }
.ico { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }
.ico.coin { border-radius: 50%; background: var(--gold); border: 2px solid var(--ol); }
.ico.xcore { background: var(--green); transform: rotate(45deg) scale(.8); border: 2px solid var(--ol); box-shadow: 0 0 8px var(--green); }
.ico.shd { background: var(--shield); border: 2px solid var(--ol); border-radius: 4px 4px 10px 10px; }
.ico.hg { width: 14px; background: var(--cream); clip-path: polygon(0 0,100% 0,50% 50%,100% 100%,0 100%,50% 50%); }
.chips { margin-left: auto; display: flex; gap: 2px; }
.chip { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--c); background: var(--hi); padding: 0; cursor: pointer; }
.chip img { width: 100%; height: 100%; }
.tb { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--ol); background: var(--hi); color: var(--cream); font-size: 20px; cursor: pointer; }
.chips:empty + .tb { margin-left: auto; }
.action { min-height: 40px; line-height: 20px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 18px; font-weight: 600; background: rgba(26,18,64,0.45); padding: 4px 8px; }
.action.bad { background: var(--danger); }
.action.good { background: #2fbf5f; }
.field { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.field canvas { position: absolute; inset: 0; touch-action: manipulation; }
.pausedov { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; background: rgba(26,18,64,0.6); }
.bottom { min-height: 88px; padding: 8px; background: var(--panel); border-top: 3px solid var(--ol); display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.bottom .row { width: 100%; }
.bottom .ready { flex: 1; }
.bottom .ping { flex: 0 0 auto; }
.prev { display: flex; align-items: center; gap: 2px; font-weight: 600; flex-wrap: nowrap; overflow: hidden; }
.prev img { width: 36px; height: 36px; }
.rhead { font-size: 15px; text-align: center; }
.rhead b { color: var(--gold); }
.rrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.rcard { position: relative; background: var(--cream); color: var(--ol); border: 3px solid var(--ol); border-radius: 12px; padding: 2px; display: flex; flex-direction: column; align-items: center; font-family: inherit; cursor: pointer; min-height: 56px; }
.rcard img { width: 34px; height: 34px; }
.rcard .rn { font-size: 11px; font-weight: 700; line-height: 1.1; text-align: center; }
.rcard .rp, .rcard .ri { font-size: 12px; font-weight: 600; }
.rcard .ri { color: #2f8f3f; }
.rcard .rc { position: absolute; top: -8px; right: -6px; background: var(--danger); color: #fff; border-radius: 50%; min-width: 24px; height: 24px; line-height: 20px; border: 2px solid var(--ol); font-weight: 700; }
.rcard .rm { position: absolute; top: -8px; left: -6px; background: var(--ol); color: #fff; border-radius: 50%; width: 28px; height: 28px; line-height: 26px; font-weight: 700; font-size: 20px; }
.rcard.poor { opacity: .5; } .rcard.locked { opacity: .35; }
.scrim { position: absolute; inset: 0; background: rgba(26,18,64,0.35); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto; background: var(--panel);
  border: 3px solid var(--ol); border-radius: 24px 24px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
.sh-h { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.sh-h .x { margin-left: auto; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--ol); background: var(--hi); color: var(--cream); font-size: 20px; }
.sh-h .shi { width: 44px; height: 44px; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tcard { position: relative; display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto auto; column-gap: 6px; text-align: left; align-items: center;
  background: var(--hi); color: var(--cream); border: 3px solid var(--ol); border-radius: 16px; padding: 6px; min-height: 76px; cursor: pointer; box-shadow: 0 4px 0 var(--ol); }
.tcard img { grid-row: 1 / 4; width: 52px; height: 52px; }
.tcard .tn { font-weight: 700; font-size: 18px; }
.tcard .tp { font-weight: 700; color: var(--gold); font-size: 16px; }
.tcard .tb1 { font-size: 14px; color: var(--muted); }
.tcard .bdg { position: absolute; top: -9px; right: 6px; background: var(--green); color: var(--ol); font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 8px; border: 2px solid var(--ol); }
.tcard.badge { border-color: var(--green); }
.tcard.poor { opacity: .5; }
.more { margin-top: 8px; background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 16px; min-height: 44px; }
.stats { width: 100%; font-size: 14px; border-collapse: collapse; }
.stats td, .stats th { padding: 3px; text-align: center; border-bottom: 1px solid var(--hi); }
.abig { width: 100%; display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 2px 8px; background: var(--hi); color: var(--cream); border: 3px solid var(--ol); border-radius: 16px; padding: 10px 14px; margin: 6px 0; min-height: 60px; box-shadow: 0 4px 0 var(--ol); cursor: pointer; }
.abig b { font-size: 19px; } .abig span { font-weight: 700; color: var(--gold); } .abig small { grid-column: 1 / 3; color: var(--muted); }
.abig.poor { opacity: .5; }
.abig.sell span { color: var(--cream); }
.finals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fin { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; border: 3px solid var(--ol); border-radius: 16px; padding: 8px 6px; cursor: pointer; box-shadow: 0 4px 0 var(--ol); color: var(--ol); }
.fin.human { background: var(--cream); }
.fin.alien { background: #c8ffbf; box-shadow: 0 4px 0 var(--ol), 0 0 18px var(--green); }
.fin img { width: 56px; height: 56px; }
.fin b { font-size: 17px; } .fin span { font-weight: 700; } .fin small { font-size: 13px; } .fin em { font-style: normal; font-weight: 700; font-size: 12px; text-transform: uppercase; opacity: .7; }
.fin.poor { opacity: .5; }
.gifts, .pings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gbtn, .pbtn { min-height: 60px; border-radius: 16px; border: 3px solid var(--ol); background: var(--hi); color: var(--cream); font-size: 20px; font-weight: 700; box-shadow: 0 4px 0 var(--ol); cursor: pointer; }
.gbtn.poor { opacity: .5; }
.pbtn:last-child { grid-column: 1 / 3; }
.tip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(26,18,64,0.6); padding: 20px; }
.tipcard { background: var(--cream); color: var(--ol); border: 4px solid var(--ol); border-radius: 22px; padding: 18px; max-width: 360px; text-align: center; font-size: 18px; }
.tipcard b { font-size: 22px; }

/* cheer */
.cheer { max-width: 480px; margin: 0 auto; padding: 24px 16px; text-align: center; }
.cheer .pm { width: 140px; }
.cheers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.cbtn { min-height: 110px; border-radius: 24px; border: 4px solid var(--ol); background: var(--panel); color: var(--cream); font-size: 20px; font-weight: 700; box-shadow: 0 6px 0 var(--ol); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cbtn span { font-size: 44px; }
.cbtn.pop { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.12); } }

/* phone results */
.results { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }
.verdict { text-align: center; font-size: 38px; margin: 10px 0; -webkit-text-stroke: 6px var(--ol); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ol); animation: pop .5s; }
.verdict.lose { color: #ffb3c1; }
.stars { text-align: center; font-size: 56px; }
.stars span { color: rgba(255,255,255,0.25); -webkit-text-stroke: 3px var(--ol); display: inline-block; animation: stamp .4s both; }
.stars span.on { color: var(--gold); }
@keyframes stamp { from { transform: scale(2.5); opacity: 0; } }
.me-res { display: flex; gap: 14px; align-items: center; }
.me-res img { width: 100px; }
.place { font-size: 48px; font-weight: 700; -webkit-text-stroke: 5px var(--ol); paint-order: stroke fill; }
.place.p1 { color: var(--gold); } .place.p2 { color: #bdebff; } .place.p3 { color: #ff9fd0; }
.award { margin-top: 4px; color: var(--gold); font-weight: 600; }
.xp { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.xp small { grid-column: 2; color: var(--muted); }
.bar { height: 14px; background: var(--ol); border-radius: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9f1c); border-radius: 8px; animation: grow 1.2s ease-out; }
@keyframes grow { from { width: 0 !important; } }
.lvup { margin-top: 8px; font-weight: 700; color: var(--gold); font-size: 22px; text-align: center; animation: pop .6s 3; }
.unlock { margin-top: 8px; text-align: center; color: var(--green); }
.tracks { display: grid; gap: 8px; margin: 12px 0; }
.track { background: var(--panel); border: 3px solid var(--ol); border-radius: 16px; padding: 8px 12px; }
.track .bar { margin: 6px 0 2px; height: 10px; }
.track small { color: var(--muted); }
.milestone { background: #2fbf5f; border: 3px solid var(--ol); border-radius: 16px; padding: 10px; text-align: center; font-weight: 700; margin: 8px 0; }
.results .actions { display: grid; gap: 10px; margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ol); color: var(--cream); padding: 12px 20px; border-radius: 16px; font-weight: 600; z-index: 50; max-width: 90vw; text-align: center; }
.conn { position: fixed; top: 0; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 4px 14px; border-radius: 0 0 12px 12px; font-weight: 600; z-index: 60; }
@media (max-width: 380px) { .stat { font-size: 16px; } .topbar .tm { width: 38px; height: 38px; } .tcard .tb1 { font-size: 13px; } }
