/* Puffball — the game page (name → room list → room → match). Builds on site.css tokens. */
.game-body { height: 100svh; min-height: 0; overflow: hidden; touch-action: manipulation; }
[hidden] { display: none !important; }

/* the pitch canvas fills the window behind everything */
.pitch { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; opacity: 0; transition: opacity .5s var(--ease-glide); }
.pitch.on { opacity: 1; }
.pitch.dim { filter: saturate(.85) brightness(.92); }

.screen { position: fixed; inset: 0; z-index: 5; overflow-y: auto; overscroll-behavior: contain; padding: max(16px, env(safe-area-inset-top)) 16px 24px;
  display: flex; flex-direction: column; align-items: center; }
.screen.over-game { background: rgba(14,30,70,.38); backdrop-filter: blur(3px); }

/* ---------- shared bits ---------- */
.card { background: var(--surface); border-radius: 30px; color: var(--ink-2);
  box-shadow: inset 0 3px 0 #fff, 0 8px 0 var(--surface-lip), 0 22px 40px var(--shade); }
.pop-in { animation: pop-in .5s var(--ease-boing) both; }
@keyframes pop-in { from { transform: translateY(18px) scale(.94); opacity: 0; } }
h1, h2 { font-family: var(--display); color: var(--ink); font-weight: 700; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font: 700 17px/1.2 var(--display); color: var(--ink); padding: 0; margin-bottom: 10px; }
.mini-logo img { display: block; height: 54px; width: auto; transition: transform .4s var(--ease-boing); }
.mini-logo:hover img { transform: rotate(-3deg) scale(1.05); }

.chip { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--raised); color: var(--ink); font: 600 16px/1 var(--display); white-space: nowrap;
  box-shadow: inset 0 2px 0 #fff, 0 4px 0 var(--surface-lip); transition: transform .3s var(--ease-pop), box-shadow .3s var(--ease-pop), background .2s; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { .chip:hover { transform: translateY(-2px); box-shadow: inset 0 2px 0 #fff, 0 6px 0 var(--surface-lip); } }
.chip:active { transform: translateY(3px) scale(1.03, .95); box-shadow: inset 0 2px 0 #fff, 0 1px 0 var(--surface-lip); transition-duration: 80ms; }
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--aqua); color: var(--on-aqua); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 4px 0 var(--aqua-lip); }
.chip-danger { color: var(--red-lip); }
.chip:disabled { opacity: .45; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px 8px; }

.btn-red { --face: var(--red); --lipc: var(--red-lip); --fg: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn-gold { --face: var(--gold); --lipc: var(--gold-lip); --fg: var(--on-gold); }
.btn-aqua { --face: var(--aqua); --lipc: var(--aqua-lip); --fg: var(--on-aqua); }
.btn-pop { --face: var(--pop); --lipc: var(--pop-lip); --fg: var(--on-pop); }
.btn:disabled { filter: grayscale(.7); opacity: .6; pointer-events: none; }

.stepper { display: inline-flex; align-items: center; gap: 6px; padding: 5px; border-radius: 999px; background: var(--well); box-shadow: inset 0 3px 0 rgba(20,32,90,.08); }
.stepper output { min-width: 2.2em; text-align: center; font: italic 900 26px/1 var(--body); color: var(--ink); font-variant-numeric: tabular-nums; }
.step-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer; font: 700 24px/1 var(--display); color: var(--ink);
  background: #fff; box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--surface-lip); transition: transform .25s var(--ease-pop); }
.step-btn:disabled, .seg button:disabled { opacity: .4; pointer-events: none; }
.step-btn:active { transform: translateY(2px) scale(.95); box-shadow: 0 1px 0 var(--surface-lip); transition-duration: 80ms; }
.stepper.sm output { font-size: 20px; min-width: 2.4em; }
.stepper.sm .step-btn { width: 36px; height: 36px; font-size: 20px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 5px; border-radius: 22px; background: var(--well); }
.seg button { border: 0; border-radius: 18px; min-height: 40px; padding: 6px 14px; cursor: pointer; background: transparent; color: var(--ink-2);
  font: 600 16px/1.15 var(--display); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: background .2s, transform .3s var(--ease-pop); }
.seg button small { font: 500 13px/1.2 var(--body); color: var(--ink-3); }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 3px 0 var(--surface-lip); }
.seg button:active { transform: scale(.96); }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }

.tog { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font: 600 15px/1 var(--display); color: var(--ink-2); min-height: 44px; }
.tog input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--well); position: relative; margin: 0; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(20,32,90,.1); transition: background .25s; }
.tog input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 0 var(--surface-lip); transition: inset-inline-start .3s var(--ease-pop); }
.tog input:checked { background: var(--volt); } .tog input:checked::after { inset-inline-start: 21px; }

/* ---------- 1. name ---------- */
#scr-name { justify-content: safe center; }
.name-card { width: min(760px, 100%); padding: 20px clamp(18px, 4vw, 40px) 26px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.name-card h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); line-height: 1.1; }
.name-preview { display: flex; align-items: center; gap: 18px; padding: 12px 22px 12px 14px; border-radius: 26px; background: var(--raised); }
.name-preview canvas { width: 104px; height: 104px; }
.name-preview > div { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.name-out { font: 700 clamp(26px, 4vw, 34px)/1.1 var(--display); color: var(--ink); }
.pickers { display: flex; flex-direction: column; gap: 12px; width: 100%; text-align: start; }
.pickers .chips { max-height: 156px; overflow-y: auto; padding: 4px 2px 8px; }
.pickers .chip { min-height: 38px; padding: 0 12px; font-size: 15px; }
.pickers .chips { gap: 7px; }
.num-field { display: flex; align-items: center; gap: 12px; font: 700 16px/1.2 var(--display); color: var(--ink); }
.safe-note { margin: 0; font-size: 15px; color: var(--ink-3); }

/* ---------- 2. room list ---------- */
.game-top { width: min(1100px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; position: relative; z-index: 2; }
.me-chip { display: flex; align-items: center; gap: 10px; border: 0; cursor: pointer; padding: 5px 16px 5px 6px; border-radius: 999px; background: #fff; color: var(--ink);
  font: 700 18px/1 var(--display); box-shadow: inset 0 2px 0 #fff, 0 5px 0 var(--surface-lip); transition: transform .3s var(--ease-pop); }
.me-chip canvas { width: 44px; height: 44px; }
.me-chip small { font: 600 13px/1 var(--body); color: var(--focus); }
.me-chip:hover { transform: translateY(-2px); }
.list-wrap { width: min(1100px, 100%); display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; position: relative; z-index: 2; }
.list-actions { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }
.list-actions .btn { width: 100%; justify-content: flex-start; }
.act-quick { --h: 76px; font-size: 27px; }
.act-create { --face: var(--aqua); --lipc: var(--aqua-lip); --fg: var(--on-aqua); }
.act-code { --face: var(--gold); --lipc: var(--gold-lip); --fg: var(--on-gold); }
.act-practice { --face: var(--pop); --lipc: var(--pop-lip); --fg: var(--on-pop); }
.list-card { padding: 22px clamp(14px, 2.4vw, 26px) 26px; min-height: 380px; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 14px; }
.list-head h1 { margin: 0; font-size: 30px; }
.online { margin: 0; font: 600 15px/1.3 var(--body); color: var(--ink-3); flex-basis: 100%; order: 3; }
.list-head h1 { flex: 1; }
.online b { color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.room-item { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 22px;
  background: var(--raised); box-shadow: inset 0 2px 0 #fff, 0 4px 0 var(--well); animation: pop-in .4s var(--ease-boing) both; }
.room-badge { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; font-size: 26px; background: var(--pitch);
  box-shadow: inset 0 -4px 0 var(--turf), inset 0 2px 0 rgba(255,255,255,.35); }
.room-info { min-width: 0; }
.room-info h3 { margin: 0 0 4px; font: 700 20px/1.15 var(--display); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-info p { margin: 0; font: 500 14px/1.3 var(--body); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font: 600 13px/1.4 var(--display); background: var(--well); color: var(--ink-2); }
.tag.live { background: var(--volt); color: var(--on-volt); }
.tag.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.fill { display: flex; flex-direction: column; align-items: center; gap: 4px; font: italic 900 20px/1 var(--body); color: var(--ink); font-variant-numeric: tabular-nums; }
.fill small { font: 500 12px/1 var(--body); color: var(--ink-3); font-style: normal; }
.bar { width: 64px; height: 8px; border-radius: 99px; background: var(--well); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--aqua); border-radius: inherit; }
.room-item.full .bar i { background: var(--red); }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-3); }
.empty .pi.big { display: block; margin: 0 auto 6px; }

/* ---------- 3. room ---------- */
.room-screen { justify-content: safe center; }
.room-panel { width: min(1060px, 100%); padding: 22px clamp(14px, 2.6vw, 30px) 24px; display: flex; flex-direction: column; gap: 16px; }
.room-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.room-title h1 { margin: 0; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.1; }
.room-sub { margin: 4px 0 0; font: 500 14px/1.3 var(--body); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.room-sub .code { font: 700 15px/1 var(--display); letter-spacing: .12em; color: var(--ink); background: var(--well); padding: 4px 10px; border-radius: 999px; direction: ltr; }
.room-head-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.teams { display: grid; grid-template-columns: 1fr .82fr 1fr; gap: 14px; }
.team { border-radius: 24px; padding: 14px 12px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 230px; min-width: 0; }
.team h2 { margin: 0; font-size: 21px; display: flex; align-items: center; gap: 8px; }
.team h2 .cnt { margin-inline-start: auto; font: italic 900 18px/1 var(--body); opacity: .7; }
.team .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -3px 0 var(--cl); }
.team-red { --c: var(--red); --cl: var(--red-lip); background: #FFE5E8; box-shadow: inset 0 0 0 3px #FFC9CF; }
.team-blue { --c: var(--blue); --cl: var(--blue-lip); background: #E2EDFF; box-shadow: inset 0 0 0 3px #C5DAFF; }
.team-spec { background: var(--raised); box-shadow: inset 0 0 0 3px var(--well); }
.team-red .join-team { --face: var(--red); --lipc: var(--red-lip); --fg: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.team-blue .join-team { --face: var(--blue); --lipc: var(--blue-lip); --fg: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.team-spec .join-team { --face: #fff; --lipc: var(--surface-lip); --fg: var(--ink); }
.join-team { margin-top: auto; align-self: center; --h: 46px !important; font-size: 18px !important; }
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.member { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 6px; min-height: 44px; border-radius: 999px; background: rgba(255,255,255,.8);
  font: 600 16px/1.1 var(--display); color: var(--ink); border: 0; width: 100%; text-align: start; animation: pop-in .35s var(--ease-boing) both; }
button.member { cursor: pointer; transition: transform .25s var(--ease-pop); }
button.member:hover { transform: translateX(-3px); }
.member canvas { width: 34px; height: 34px; flex: none; }
.member .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .ic { margin-inline-start: auto; display: flex; gap: 3px; font-size: 15px; }
.member.me { box-shadow: inset 0 0 0 3px var(--volt); }
.admin-tools { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 22px; background: var(--raised); }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-row .chip { background: #fff; min-height: 40px; font-size: 15px; padding: 0 13px; }
.tool-row .chip[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 4px 0 var(--gold-lip); }
.settings-row { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; }
.set { display: flex; align-items: center; gap: 9px; font: 600 15px/1.1 var(--display); color: var(--ink-2); }
.set .seg button { min-height: 36px; padding: 4px 12px; font-size: 15px; }
.settings-view { margin: -4px 0 0; font: 500 15px/1.4 var(--body); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px; }
.room-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.feed { list-style: none; margin: 0; padding: 10px 14px; height: 112px; overflow-y: auto; border-radius: 18px; background: var(--well);
  display: flex; flex-direction: column; gap: 3px; font: 500 15px/1.35 var(--body); color: var(--ink-2); scroll-behavior: smooth; }
.feed li { animation: feed-in .3s var(--ease-glide) both; } .feed li b { color: var(--ink); font-weight: 700; }
.feed li.goal { color: var(--ink); font-weight: 700; } .feed li.react { font-size: 16px; }
@keyframes feed-in { from { opacity: 0; transform: translateY(6px); } }
.room-go { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wait { margin: 0; font: 600 16px/1.3 var(--display); color: var(--ink-3); text-align: center; max-width: 260px; }

/* ---------- 4. HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.hud > * { pointer-events: auto; }
.scoreboard { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; height: 54px;
  border-radius: 999px; background: #fff; box-shadow: inset 0 2px 0 #fff, 0 5px 0 var(--surface-lip), 0 12px 20px var(--shade); overflow: hidden; direction: ltr; pointer-events: none; }
.sb-team { display: grid; place-items: center; min-width: 66px; padding: 0 14px; font: italic 900 32px/1 var(--body); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.sb-red { background: linear-gradient(180deg, #FF7482, var(--red)); box-shadow: inset 0 -4px 0 var(--red-lip); }
.sb-blue { background: linear-gradient(180deg, #6BA6FF, var(--blue)); box-shadow: inset 0 -4px 0 var(--blue-lip); }
.sb-team b.bump { animation: bump .6s var(--ease-boing); display: inline-block; }
@keyframes bump { 30% { transform: scale(1.6); } }
.sb-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 92px; padding: 0 12px; font: italic 900 24px/1 var(--body); color: var(--ink); font-variant-numeric: tabular-nums; }
.sb-mid em { font: 700 12px/1 var(--display); font-style: normal; color: var(--pop-lip); margin-top: 2px; direction: rtl; }
.hud-btns { position: absolute; top: max(10px, env(safe-area-inset-top)); inset-inline-end: 12px; display: flex; gap: 8px; }
.round-btn { width: 50px; height: 50px; border: 0; border-radius: 50%; cursor: pointer; font-size: 22px; background: #fff; color: var(--ink);
  box-shadow: inset 0 2px 0 #fff, 0 4px 0 var(--surface-lip), 0 10px 16px var(--shade); transition: transform .3s var(--ease-pop); }
.round-btn:active { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 var(--surface-lip); transition-duration: 80ms; }
.reactions { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 62px); inset-inline-end: 12px; display: grid; grid-template-columns: repeat(2, auto); gap: 8px;
  padding: 10px; border-radius: 24px; background: #fff; box-shadow: 0 6px 0 var(--surface-lip), 0 16px 30px var(--shade); animation: pop-in .35s var(--ease-boing) both; }
.reactions button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--raised); cursor: pointer; font: 600 15px/1 var(--display); color: var(--ink);
  display: flex; align-items: center; gap: 6px; box-shadow: 0 3px 0 var(--well); }
.reactions button kbd { font: 700 11px/1 var(--body); color: var(--ink-3); background: #fff; padding: 3px 5px; border-radius: 6px; }
.banner { position: absolute; left: 0; right: 0; top: 36%; text-align: center; pointer-events: none; }
.banner .goal-word { display: inline-block; font: 700 clamp(64px, 13vw, 150px)/1 var(--display); color: #fff; letter-spacing: .02em;
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); animation: goal-in 1.6s var(--ease-boing) both; }
.banner .goal-word.red { color: var(--red); } .banner .goal-word.blue { color: var(--blue); }
.banner .goal-who { display: block; margin-top: 12px; font: 700 clamp(20px, 3vw, 28px)/1.2 var(--display); color: #fff; text-shadow: 0 3px 0 var(--ink), 0 0 12px rgba(20,32,90,.4); animation: rise .5s var(--ease-boing) .25s both; }
@keyframes goal-in { 0% { transform: scale(.2) rotate(-8deg); opacity: 0; } 30% { transform: scale(1.12) rotate(2deg); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.05); opacity: 0; } }
.banner .small-word { display: inline-block; padding: 12px 26px; border-radius: 999px; background: #fff; font: 700 clamp(24px, 4vw, 38px)/1 var(--display); color: var(--ink);
  box-shadow: 0 6px 0 var(--surface-lip), 0 16px 26px var(--shade); animation: pop-in .5s var(--ease-boing) both; }
.paused { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%); padding: 14px 30px; border-radius: 999px; background: var(--gold); color: var(--on-gold);
  font: 700 30px/1 var(--display); box-shadow: inset 0 3px 0 rgba(255,255,255,.5), 0 6px 0 var(--gold-lip), 0 16px 24px var(--shade); pointer-events: none; }
.toasts { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; pointer-events: none; width: max-content; max-width: 90vw; }
.toast { padding: 8px 16px; border-radius: 999px; background: rgba(255,255,255,.94); color: var(--ink); font: 600 15px/1.2 var(--display); box-shadow: 0 4px 0 var(--surface-lip);
  animation: pop-in .35s var(--ease-boing) both; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.spec-tag { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 66px); left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px;
  background: rgba(255,255,255,.9); font: 600 14px/1 var(--display); color: var(--ink-2); pointer-events: none; }

/* touch controls */
.touch { position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: none; direction: ltr; }
.stick { position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 136px; height: 136px; border-radius: 50%;
  background: rgba(255,255,255,.28); box-shadow: inset 0 0 0 3px rgba(255,255,255,.55); pointer-events: auto; touch-action: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%; background: #fff;
  box-shadow: inset 0 -5px 0 var(--surface-lip), 0 6px 12px var(--shade); }
.kick-btn { position: absolute; right: max(22px, env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 112px; height: 112px; border: 0; border-radius: 50%;
  pointer-events: auto; touch-action: none; background: radial-gradient(circle at 35% 30%, #E4FF9A, var(--volt) 55%); color: var(--on-volt); font: 700 21px/1 var(--display);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.5), 0 8px 0 var(--volt-lip), 0 16px 22px var(--shade); }
.kick-btn.on { transform: translateY(6px) scale(1.04, .94); box-shadow: inset 0 3px 0 rgba(255,255,255,.5), 0 2px 0 var(--volt-lip); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(20,32,90,.42); backdrop-filter: blur(2px); overflow-y: auto; }
.modal-card { width: min(620px, 100%); padding: 24px clamp(18px, 3vw, 30px) 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-card.narrow { width: min(440px, 100%); }
.modal-card h2 { margin: 0; font-size: 28px; line-height: 1.15; }
.modal-card p { margin: 0; }
.modal-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 4px; }
.two { display: flex; flex-wrap: wrap; gap: 18px 30px; }
.code-in { width: 100%; height: 72px; border: 0; border-radius: 22px; background: var(--well); text-align: center; font: 700 40px/1 var(--display); letter-spacing: .3em; color: var(--ink);
  text-transform: uppercase; box-shadow: inset 0 4px 0 rgba(20,32,90,.08); padding-inline-start: .3em; }
.code-in:focus { outline: 3px solid var(--focus); }
.err { color: var(--red-lip); font: 600 15px/1.3 var(--display); min-height: 1.3em; }
.menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msg-emoji { font-size: 56px; line-height: 1; text-align: center; }
#m-msg .modal-card { text-align: center; align-items: center; }

.connecting { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(142,219,255,.82); backdrop-filter: blur(3px); }
.connecting p { margin: 0; font: 700 24px/1.2 var(--display); color: var(--ink); }
.hopper { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #fff 30%, #E7EEFF);
  box-shadow: inset 0 -5px 0 var(--surface-lip); animation: hop .5s var(--ease-snap) infinite alternate; }

.victory { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(255,255,255,.4), transparent 60%); }
.v-card { padding: 26px 46px 30px; border-radius: 36px; background: #fff; text-align: center; box-shadow: 0 10px 0 var(--surface-lip), 0 30px 50px var(--shade); }
.v-trophy { font-size: 80px; line-height: 1; animation: float 2.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-4deg); } }
.v-card h2 { margin: 8px 0 4px; font-size: clamp(34px, 6vw, 54px); }
.v-card h2.red { color: var(--red-lip); } .v-card h2.blue { color: var(--blue-lip); }
.v-score { margin: 0; font: italic 900 34px/1 var(--body); color: var(--ink); direction: ltr; }
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; border-radius: 4px; z-index: 9; pointer-events: none; }

.rotate-hint { position: fixed; z-index: 15; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 66px); transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font: 600 15px/1.2 var(--display); width: max-content; max-width: 92vw; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .list-wrap { grid-template-columns: 1fr; }
  .list-actions { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
  .list-actions .act-quick { grid-column: 1 / -1; justify-content: center; }
  .list-actions .btn--m { --h: 50px; font-size: 17px; padding: 0 14px; justify-content: center; }
  .list-actions .act-practice { grid-column: 1 / -1; }
  .teams { grid-template-columns: 1fr 1fr; }
  .team-spec { grid-column: 1 / -1; order: 3; min-height: 0; }
  .room-foot { grid-template-columns: 1fr; }
  .room-go { order: -1; }
}
@media (max-width: 560px) {
  .screen { padding-inline: 10px; }
  .room-item { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; padding: 10px; }
  .room-item .btn { grid-column: 1 / -1; width: 100%; }
  .room-badge { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
  .room-info h3 { font-size: 18px; }
  .team { padding: 10px 8px; min-height: 160px; }
  .team h2 { font-size: 18px; }
  .member { font-size: 14px; gap: 6px; } .member canvas { width: 28px; height: 28px; }
  .name-preview { padding: 10px 14px 10px 10px; gap: 12px; } .name-preview canvas { width: 80px; height: 80px; }
  .mini-logo img { height: 42px; }
  .menu-list { grid-template-columns: 1fr; }
  .scoreboard { height: 46px; } .sb-team { min-width: 52px; font-size: 26px; } .sb-mid { min-width: 76px; font-size: 20px; }
  .round-btn { width: 44px; height: 44px; font-size: 19px; }
  .hud-btns { inset-inline-end: 8px; gap: 8px; flex-direction: column; }
  .reactions { top: auto; bottom: calc(180px + env(safe-area-inset-bottom)); inset-inline-end: 50%; transform: translateX(-50%); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .stick { width: 116px; height: 116px; } .kick-btn { width: 96px; height: 96px; }
}

/* ---------- free text: names, room names, chat ---------- */
.text-in { width: 100%; min-height: 48px; padding: 0 16px; border: 0; border-radius: 16px; background: var(--well); color: var(--ink);
  font: 600 18px/1.2 var(--display); box-shadow: inset 0 3px 0 rgba(20,32,90,.08); }
.text-in::placeholder { color: var(--ink-3); opacity: .75; }
.text-in:focus { outline: 3px solid var(--focus); outline-offset: 1px; background: #fff; }
.text-in.big { min-height: 60px; font-size: clamp(22px, 3.4vw, 28px); border-radius: 20px; text-align: center; }
.text-in.bad { outline: 3px solid var(--red); }
.name-preview { width: 100%; max-width: 560px; }
.name-field { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch !important; gap: 6px; text-align: start; }
.name-field label { font: 700 16px/1.2 var(--display); color: var(--ink); }
.name-field .err { margin: 0; min-height: 1.3em; font-size: 14px; }
.name-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 26px; }
.sugg { margin-top: 10px; } .sugg .chip { min-height: 36px; font-size: 14px; padding: 0 12px; }
#m-create .err { margin: 6px 0 0; }

.chat-box { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chat-box .feed { height: 150px; }
.chat-form { display: flex; gap: 8px; align-items: center; }
.chat-form .text-in { min-height: 44px; font-size: 16px; font-family: var(--body); font-weight: 500; }
.chip-send { width: 48px; padding: 0; flex: none; background: var(--aqua); color: var(--on-aqua); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 4px 0 var(--aqua-lip); font-size: 18px; transform: scaleX(-1); }
.chip-send:active { transform: scaleX(-1) translateY(3px); }
.feed li.chat { color: var(--ink); } .feed li.chat b.red { color: var(--red-lip); } .feed li.chat b.blue { color: var(--blue-lip); }
.feed li.sys { color: var(--ink-3); font-size: 14px; }

.game-chat { position: absolute; inset-inline-start: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.chat-log li { max-width: 100%; padding: 5px 12px; border-radius: 14px; background: rgba(20,32,90,.62); color: #fff; font: 500 15px/1.35 var(--body);
  overflow-wrap: anywhere; animation: feed-in .3s var(--ease-glide) both; transition: opacity .6s; }
.chat-log li b { font-family: var(--display); font-weight: 700; } .chat-log li b.red { color: #FFB1BA; } .chat-log li b.blue { color: #B5D2FF; }
.chat-log li.old { opacity: 0; }
.game-chat .chat-form { pointer-events: auto; padding: 6px; border-radius: 20px; background: #fff; box-shadow: 0 5px 0 var(--surface-lip), 0 12px 22px var(--shade); }
.game-chat.typing .chat-log li { opacity: 1 !important; }
@media (pointer: coarse) and (orientation: portrait) { .game-chat { top: calc(max(10px, env(safe-area-inset-top)) + 116px) !important; } }
@media (pointer: coarse) { .game-chat { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 64px); width: min(340px, calc(100vw - 90px)); } }

/* ---------- Puffball icons (sprite in play.html) ---------- */
.pi { display: inline-block; width: 1.3em; height: 1.3em; flex: none; vertical-align: -0.32em; overflow: visible; }
.pi.big { width: 76px; height: 76px; vertical-align: middle; }
.pi.huge { width: 104px; height: 104px; vertical-align: middle; }
.btn .pi { width: 1.25em; height: 1.25em; }
.btn--m .pi { width: 1.3em; height: 1.3em; }
.round-btn { display: grid; place-items: center; }
.round-btn .pi { width: 30px; height: 30px; }
.room-badge .pi { width: 36px; height: 36px; }
.chip .pi { width: 24px; height: 24px; }
.chip-send .pi { width: 24px; height: 24px; }
.member .ic .pi { width: 20px; height: 20px; }
.team h2 .pi { width: 28px; height: 28px; }
.feed .pi, .chat-log .pi, .toast .pi { width: 20px; height: 20px; vertical-align: -5px; }
.reactions button .pi { width: 24px; height: 24px; }
.tag .pi { width: 17px; height: 17px; vertical-align: -3px; }
.room-sub .pi, .room-info p .pi { width: 18px; height: 18px; vertical-align: -4px; }
.wait .pi { width: 22px; height: 22px; vertical-align: -5px; }
.seg button b .pi { width: 22px; height: 22px; vertical-align: -5px; }
.paused .pi { width: 32px; height: 32px; vertical-align: -7px; }
.spec-tag .pi, .rotate-hint .pi { width: 20px; height: 20px; vertical-align: -5px; }
.banner .small-word .pi { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
.v-card h2 .pi { width: .9em; height: .9em; vertical-align: -0.1em; }
.safe-note .pi { width: 20px; height: 20px; vertical-align: -5px; }
.v-trophy { animation: float 2.4s ease-in-out infinite; }
.msg-emoji { display: grid; place-items: center; }
.feed li.chat .pi, .chat-log li .pi { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- quick reactions: emoji only ---------- */
.reactions { grid-template-columns: repeat(4, auto) !important; gap: 8px; padding: 12px; }
.reactions button { width: 62px; height: 62px; min-height: 0; padding: 0; border-radius: 20px; justify-content: center; position: relative; background: var(--raised);
  box-shadow: inset 0 2px 0 #fff, 0 4px 0 var(--surface-lip); transition: transform .3s var(--ease-boing); }
.reactions button .pi { width: 42px !important; height: 42px !important; }
.reactions button:hover { transform: translateY(-3px) scale(1.08) rotate(-4deg); }
.reactions button:active { transform: scale(.92); }
.reactions button kbd { position: absolute; bottom: 3px; inset-inline-end: 5px; font: 700 10px/1 var(--body); color: var(--ink-3); background: none; padding: 0; }
@media (pointer: coarse) { .reactions button kbd { display: none; } }
.feed .emote-feed .pi { width: 26px; height: 26px; vertical-align: -8px; }

/* ---------- chat: a side panel that opens with Enter ---------- */
.chat-panel { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 70px); bottom: calc(16px + env(safe-area-inset-bottom)); inset-inline-start: 12px;
  width: min(340px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 24px; background: rgba(255,255,255,.97);
  box-shadow: 0 6px 0 var(--surface-lip), 0 18px 34px var(--shade); animation: chat-in .35s var(--ease-glide) both; z-index: 3; }
@keyframes chat-in { from { opacity: 0; transform: translateX(30px); } }
.chat-panel header { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.chat-panel header b { font: 700 18px/1 var(--display); color: var(--ink); display: flex; align-items: center; gap: 6px; }
.chat-x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--raised); color: var(--ink); font: 700 16px/1 var(--body); cursor: pointer; }
.chat-list { list-style: none; margin: 0; padding: 4px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-list li { align-self: flex-start; max-width: 92%; padding: 7px 12px 8px; border-radius: 16px 16px 16px 4px; background: var(--raised); font: 500 15px/1.4 var(--body); color: var(--ink); overflow-wrap: anywhere; animation: feed-in .25s var(--ease-glide) both; }
.chat-list li b { display: block; font: 700 13px/1.3 var(--display); color: var(--ink-2); }
.chat-list li b.red { color: var(--red-lip); } .chat-list li b.blue { color: var(--blue-lip); }
.chat-list li.mine { align-self: flex-end; background: #E9FBC8; border-radius: 16px 16px 4px 16px; }
.chat-list li .pi { width: 16px; height: 16px; vertical-align: -3px; }
.chat-panel .chat-form .text-in { background: var(--well); }
.chat-hint { margin: 0; font: 500 12px/1.3 var(--body); color: var(--ink-3); text-align: center; }
kbd { font: 700 11px/1 var(--body); background: var(--well); color: var(--ink-2); padding: 2px 6px; border-radius: 6px; box-shadow: 0 2px 0 var(--surface-lip); }
.chat-peek { position: absolute; inset-inline-start: 12px; bottom: calc(52px + env(safe-area-inset-bottom)); width: min(360px, calc(100vw - 24px)); list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; pointer-events: none; }
.chat-peek li { max-width: 100%; padding: 5px 12px; border-radius: 14px; background: rgba(20,32,90,.62); color: #fff; font: 500 15px/1.35 var(--body); overflow-wrap: anywhere;
  animation: feed-in .3s var(--ease-glide) both; transition: opacity .7s; }
.chat-peek li b { font-family: var(--display); font-weight: 700; } .chat-peek li b.red { color: #FFB1BA; } .chat-peek li b.blue { color: #B5D2FF; }
.chat-peek li.old { opacity: 0; } .chat-peek .pi { width: 16px; height: 16px; vertical-align: -3px; }
.chat-tip { position: absolute; inset-inline-start: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.85);
  font: 600 13px/1 var(--display); color: var(--ink-2); pointer-events: none; }
@media (pointer: coarse) { .chat-peek { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 64px); }
  .chat-panel { top: 8px; bottom: 8px; width: min(340px, calc(100vw - 16px)); inset-inline-start: 8px; } }
