/* Tumblefair — base look and every screen outside a minigame. Bright fairground: dark teal night, cream paper
   panels, chunky dark outlines, a yellow "do this" button. Built phone-first; nothing here scrolls the page. */
:root {
  --bg: #12323a; --ink: #0d2228; --paper: #fff8e7; --paper2: #f3e6c8; --sun: #ffd23f; --pop: #ff5f5f; --mint: #3ecf5a; --sky: #39d0e0;
  --font: "Baloo 2", "Fredoka", ui-rounded, "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 600 16px/1.3 var(--font); }
body { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#tags, #game-ui, #hud, #screen, #toasts { position: fixed; inset: 0; pointer-events: none; }
#tags { z-index: 5; overflow: hidden; } #game-ui { z-index: 10; } #hud { z-index: 15; } #screen { z-index: 20; } #toasts { z-index: 60; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--sun); font: 900 44px/1 var(--font); z-index: 99; }
#screen > *, #hud > *, #game-ui .game > * { pointer-events: auto; }
input, button { font: inherit; color: inherit; }
input[type=text], input:not([type]) { user-select: text; -webkit-user-select: text; }

/* ---- pieces ---- */
.panel { background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink); padding: 14px 16px; }
.btn { appearance: none; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 9px 14px; min-height: 44px; font-weight: 800; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--sun); } .btn.big { font-size: 20px; padding: 12px 18px; min-height: 54px; } .btn.huge { font-size: 34px; padding: 18px 44px; border-radius: 26px; border-width: 5px; box-shadow: 0 8px 0 var(--ink); }
.btn.small { min-height: 36px; padding: 5px 10px; font-size: 14px; } .btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note { margin: 6px 0 0; font-size: 14px; color: #47606a; } .err { margin: 4px 0 0; min-height: 1.2em; color: #c22; font-size: 14px; }
.shout { margin: 0; font: 900 clamp(26px, 6vw, 46px)/1 var(--font); color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); letter-spacing: .5px; text-align: center; }
.panel .shout { color: var(--sun); }
.ic { width: 1em; height: 1em; vertical-align: -0.14em; margin-right: 2px; }
.coins { color: #b07a00; white-space: nowrap; }
.pill { border: 3px solid var(--ink); border-radius: 999px; background: #fff; min-width: 44px; min-height: 40px; padding: 4px 12px; font-weight: 800; }
.pill.on { background: var(--sun); }
.count { display: inline-block; min-width: 1.2em; text-align: center; }

/* a player chip: portrait in a seat-coloured ring with the seat's shape, then the name */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: #fff; border: 3px solid var(--ink); font-weight: 800; white-space: nowrap; max-width: 100%; }
.chip .face { width: 34px; height: 34px; border-radius: 50%; background: var(--seat, #999); border: 3px solid var(--seat-dark, var(--ink)); overflow: hidden; flex: none; display: block; }
.chip[data-shape=square] .face { border-radius: 8px; } .chip[data-shape=diamond] .face { border-radius: 12px 3px; } .chip[data-shape=triangle] .face { border-radius: 50% 50% 8px 8px; }
.chip .face img { width: 100%; height: 100%; display: block; }
.chip .nm { overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.chip.me { background: #fff3b8; } .chip.off { opacity: .45; }
.chip .tagh { font-style: normal; font-size: 11px; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 6px; }
.chip .x { border: 0; background: none; font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }
.chip.tv { padding: 6px 12px; background: #dff7fa; }
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); margin: 0 1px; }

/* name tags over 3D characters */
.tag { position: absolute; left: 0; top: 0; padding: 1px 8px; border-radius: 999px; background: var(--seat, #fff); border: 2px solid var(--ink); color: #fff; font: 800 13px/1.3 var(--font); white-space: nowrap; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); will-change: transform; }
.tag.me { background: #fff; color: var(--ink); text-shadow: none; box-shadow: 0 0 0 3px var(--seat); }
.float-text { position: absolute; transform: translate(-50%, -50%); font: 900 22px/1 var(--font); color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; animation: rise 1.1s ease-out forwards; }
.float-text.bad { color: var(--pop); } .float-text.good { color: var(--sun); }
@keyframes rise { to { transform: translate(-50%, -260%); opacity: 0; } }

/* toasts */
#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: calc(var(--st) + 64px); }
.toast { background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 12px; font-weight: 700; max-width: 90vw; text-align: center; transition: opacity .4s, transform .4s; }
.toast.bad { background: #b3261e; } .toast.out { opacity: 0; transform: translateY(-10px); }

/* ---- title ---- */
#screen.title { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; padding: calc(var(--st) + 10px) 14px calc(var(--sb) + 10px); }
.logo { position: absolute; top: calc(var(--st) + 8px); left: 50%; transform: translateX(-50%); width: min(78vw, 460px); max-height: 20vh; object-fit: contain; pointer-events: none !important; }
.logo-text { position: absolute; top: calc(var(--st) + 14px); left: 0; right: 0; margin: 0; text-align: center; font: 900 clamp(34px, 11vw, 72px)/1 var(--font); color: var(--sun); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
.title-panel { width: min(100%, 400px); display: grid; gap: 10px; }
.field { display: grid; gap: 2px; font-size: 13px; color: #47606a; }
.field input, .join-row input { border: 3px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-size: 20px; font-weight: 800; background: #fff; min-width: 0; width: 100%; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.title-panel .row .btn { flex: 1; }
.title-panel.invite h2 { margin: 0; text-align: center; }
.title-panel.invite .note { margin: 0; text-align: center; }
.check { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.check input { width: 20px; height: 20px; }
.foot { margin: 0; color: #cfe6ea; font-size: 13px; text-align: center; }

/* ---- lobby ---- */
#screen.lobby { display: grid; gap: 10px; padding: calc(var(--st) + 10px) calc(var(--sr) + 12px) calc(var(--sb) + 10px) calc(var(--sl) + 12px); align-content: end; justify-items: center; grid-template-columns: minmax(0, 520px); justify-content: center; overflow-y: auto; }
.lobby-code { display: flex; gap: 12px; align-items: center; position: absolute; top: calc(var(--st) + 8px); left: calc(var(--sl) + 10px); padding: 8px 12px; }
.lobby-code .qr { width: 92px; height: 92px; flex: none; border-radius: 8px; overflow: hidden; background: #fff; }
.lobby-code .qr svg { width: 100%; height: 100%; display: block; }
.lobby-code .lbl { font-size: 12px; color: #47606a; display: block; }
.lobby-code .code { font: 900 40px/1 var(--font); letter-spacing: 6px; }
.lobby-main { width: 100%; display: grid; gap: 8px; }   /* never a scroller of its own: a scrolling box inside the page blanks the 3D view behind it on phones (Chromium) — #screen scrolls instead */
.lobby-main h2 { margin: 2px 0 0; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: #47606a; }
.lobby-main h2 small { font-weight: 600; text-transform: none; letter-spacing: 0; }
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { text-align: left; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 8px 10px; display: grid; gap: 2px; }
.mode b { font-size: 16px; } .mode span { font-size: 12px; font-weight: 600; color: #47606a; } .mode.on { background: var(--sun); } .mode[disabled] { opacity: .8; }
.opts span { font-size: 14px; } .opts .est { color: #47606a; margin-left: auto; }
@media (min-aspect-ratio: 1/1) {
  #screen.lobby { justify-content: end; align-content: center; grid-template-columns: minmax(0, 46vw); }
}
@media (max-aspect-ratio: 1/1) { .lobby-code .qr { width: 72px; height: 72px; } .lobby-code .code { font-size: 32px; } }

/* ---- match bar ---- */
.match-bar { position: absolute; top: calc(var(--st) + 6px); left: 6px; right: 48px;   /* 48: the ! button */ display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; align-items: center; }
.match-bar .round { background: var(--ink); color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.match-bar .chip { font-size: 14px; } .match-bar .chip.turn { background: var(--sun); transform: scale(1.06); }
.match-bar .sc { font-style: normal; font-weight: 900; } .sc.tk { color: #b07a00; } .sc.rb { color: #d1245e; }
@media (max-width: 520px) { .match-bar .chip .nm { display: none; } .match-bar .chip { padding-right: 8px; } }

/* ---- board ---- */
#screen.board { display: grid; align-content: end; justify-items: center; padding: 0 12px calc(var(--sb) + 18px); }
.board-foot { min-height: 70px; display: grid; place-items: center; }
.banner { background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 18px; font-size: 20px; font-weight: 800; text-align: center; max-width: 92vw; }
.banner.fx { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); background: var(--paper); color: var(--ink); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink); animation: pop .3s ease-out; width: max-content; }
.roll { animation: glow 1s ease-in-out infinite; }   /* a glow, not a bounce: a moving button is hard to hit (and never 'stable' for a test) */
@keyframes glow { 50% { box-shadow: 0 8px 0 var(--ink), 0 0 0 10px rgba(255, 210, 63, .45); } }
@keyframes bob { 50% { transform: translateY(-6px); } } @keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
.die { position: absolute; top: 38%; left: 50%; width: 110px; height: 110px; margin: -55px; display: grid; place-items: center; background: #fff; border: 6px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink); font: 900 72px/1 var(--font); animation: tumble .9s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes tumble { from { transform: rotate(-540deg) scale(.2); } }
.ask { display: grid; gap: 8px; text-align: center; } .ask h3 { margin: 0; }

/* ---- vote ---- */
#screen.vote, #screen.intro, #screen.results, #screen.final { display: grid; place-items: center; align-content: center; gap: 12px; padding: calc(var(--st) + 60px) 12px calc(var(--sb) + 12px); overflow-y: auto; }
#screen.vote { background: rgba(13, 34, 40, .55); } #screen.results { background: rgba(13, 34, 40, .45); }
.vote-cards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.vote-card { flex: 1 1 150px; max-width: 260px; padding: 0; border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; background: var(--paper); box-shadow: 0 6px 0 var(--ink); text-align: left; }
.vote-card.mine { outline: 5px solid var(--sun); } .vote-card.won { outline: 6px solid var(--mint); transform: scale(1.04); }
.gcard { display: grid; gap: 2px; } .gcard img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: #29535c; }
.gcard b { padding: 6px 10px 0; font-size: 18px; } .gcard > span { padding: 0 10px 6px; font-size: 13px; color: #47606a; font-weight: 600; } .gcard .who { padding: 0 8px 8px; min-height: 24px; text-decoration: none; }
#screen.vote .note { color: #fff; font-size: 18px; }
@media (max-aspect-ratio: 1/1) { .vote-card { flex-basis: 100%; max-width: 420px; } .vote-card .gcard { grid-template-columns: 38% 1fr; grid-template-rows: auto auto 1fr; } .vote-card .gcard img { grid-row: 1 / 4; height: 100%; aspect-ratio: auto; } }

/* ---- intro / results / final cards ---- */
.intro-card, .results-card, .final-card { width: min(100%, 460px); display: grid; gap: 8px; justify-items: center; text-align: center; }
.intro-card img { width: 100%; border-radius: 12px; border: 3px solid var(--ink); aspect-ratio: 3/2; object-fit: cover; max-height: 26vh; }
.intro-card ul { margin: 0; padding: 0 0 0 20px; text-align: left; } .intro-card .ctl { margin: 0; font-size: 14px; background: var(--paper2); border-radius: 10px; padding: 6px 10px; }
.blurb { margin: 0; font-size: 17px; }
.places { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: 100%; }
.places li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 10px 4px 6px; text-align: left; }
.places .chip { border: 0; padding-left: 0; background: none; } .places .pl { font-weight: 900; } .places .p1 { background: #fff3b8; } .places .score { font-size: 14px; color: #47606a; } .places .award { font-weight: 900; color: #b07a00; white-space: nowrap; }
#screen.final { align-content: end; } #screen.intro { align-content: center; background: rgba(13, 34, 40, .35); }
@media (min-aspect-ratio: 1/1) { #screen.final { justify-items: end; align-content: center; padding-right: 3vw; } }

/* ---- modals: look editor, costume shop ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center; padding: 42vh 8px calc(var(--sb) + 8px); background: rgba(13, 34, 40, .25); overflow-y: auto; }
.modal .panel { width: min(100%, 520px); display: grid; gap: 8px; }   /* the modal scrolls, not the panel (see .lobby-main) */
.modal h2 { margin: 0; flex: 1; }
.ed-grid { display: grid; gap: 6px; }
.ed-row { display: grid; grid-template-columns: 84px 40px minmax(0, 1fr) 40px; gap: 6px; align-items: center; font-size: 14px; }
.ed-row b { text-align: center; text-transform: capitalize; } .ed-row .sws { grid-column: 2 / -1; display: flex; gap: 5px; flex-wrap: wrap; } .ed-row input[type=range] { grid-column: 2 / -1; width: 100%; height: 36px; }
.step { border: 3px solid var(--ink); border-radius: 10px; background: #fff; min-height: 38px; font-size: 20px; font-weight: 900; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); padding: 0; } .sw.on { outline: 3px solid var(--sun); outline-offset: 1px; }
.costumes { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.costume { border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 6px; display: grid; gap: 2px; justify-items: center; font-size: 13px; }
.costume img { width: 64px; height: 64px; border-radius: 50%; background: var(--paper2); } .costume.on { background: var(--sun); } .costume:not(.own) { background: #eef3f4; } .costume[data-poor] { opacity: .6; }
body[data-net=reconnecting]::after { content: 'Reconnecting…'; position: fixed; top: calc(var(--st) + 4px); left: 50%; transform: translateX(-50%); z-index: 90; background: #b3261e; color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 13px; }

/* ---- the bug / idea button and form (js/client/feedback.js) ---- */
.fb-btn { position: fixed; z-index: 45; top: calc(var(--st) + 8px); right: calc(var(--sr) + 8px); width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; color: var(--ink); font: 900 18px/1 var(--font); box-shadow: 0 3px 0 var(--ink); opacity: .75; cursor: pointer; padding: 0; }
.fb-btn:hover { opacity: 1; }
body[data-phase=game] .fb-btn { width: 28px; height: 28px; font-size: 15px; opacity: .55; }   /* smaller during a minigame; the score bar leaves it room (games.css) */
.fb-modal { z-index: 70; padding-top: 12vh; }
.fb-modal textarea { width: 100%; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; font: 600 16px/1.3 var(--font); resize: vertical; user-select: text; -webkit-user-select: text; }
.fb-modal .pill input { display: none; } .fb-modal .pill { cursor: pointer; }
.fb-shot { flex-wrap: wrap; } .fb-shot img { width: 100%; max-height: 22vh; object-fit: contain; border-radius: 8px; border: 2px solid var(--ink); background: var(--bg); }

/* ---- modes: endless "keep going?" card, teams ---- */
.modes { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.continue-card { display: grid; gap: 10px; justify-items: center; text-align: center; width: min(100%, 460px); }
.continue-card .btn.mine { outline: 5px solid var(--mint); } .continue-card small { font-weight: 600; }
.team { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 3px solid var(--ink); font-size: 14px; white-space: nowrap; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .5); }
.team.t0 { background: linear-gradient(90deg, #ff4d4d 50%, #3ecf5a 50%); } .team.t1 { background: linear-gradient(90deg, #3d8bff 50%, #f04fd8 50%); }
.match-bar .teams { display: flex; gap: 4px; } .team-line { margin: 0; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
