/* Catchphrase (OddPom). The whole phone screen is the handheld: dark body, grey panel, light buttons, white swoosh. */

@font-face { font-family: 'Bricolage Grotesque'; src: url('fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('fonts/pixelify-sans-700.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  /* The four player colors. app.js overwrites these (and the ink colors) from saved settings. */
  --body: #202329;
  --panel: #3a3e46;
  --buttons: #dcdcd8;
  --accent: #7fa8a4;
  --ink-body: #f5f5f2;     /* text on the body */
  --ink-panel: #f5f5f2;    /* text on the panel, and the swoosh line */
  --ink-btn: #14151a;      /* text on buttons */

  --font: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --pixel: 'Pixelify Sans', ui-monospace, monospace;
  --serif: Georgia, 'Times New Roman', serif;   /* the handheld's little printed labels */

  --btn-hi: color-mix(in srgb, var(--buttons) 55%, #ffffff);
  --btn-lo: color-mix(in srgb, var(--buttons) 70%, #000000);
  --tempo: 1s;    /* time between beeps, set by app.js while the timer runs */
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { background: var(--body); }
body { font-family: var(--font); -webkit-tap-highlight-color: transparent; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------------------------------------------------------------- the body: the OddPom aurora, tinted by the body color */
body::before, body::after { content: ''; position: fixed; z-index: -1; pointer-events: none; }
body::before {
  inset: -22%;
  background:
    radial-gradient(38% 34% at 24% 26%, color-mix(in srgb, var(--body) 66%, #8a5fd6) 0%, transparent 70%),
    radial-gradient(42% 38% at 76% 22%, color-mix(in srgb, var(--body) 62%, #2f8f92) 0%, transparent 72%),
    radial-gradient(46% 42% at 70% 82%, color-mix(in srgb, var(--body) 66%, #c0527e) 0%, transparent 70%),
    radial-gradient(38% 34% at 18% 80%, color-mix(in srgb, var(--body) 70%, #4568c9) 0%, transparent 72%),
    var(--body);
  filter: blur(42px) saturate(1.15);
  animation: aurora 48s ease-in-out infinite alternate;
}
body::after {
  inset: -35%;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(0, 0, 0, .45) 100%),
    conic-gradient(from 0deg at 50% 50%, transparent 0 22%, color-mix(in srgb, var(--body) 45%, #fff) 28%, transparent 34%, transparent 52%, color-mix(in srgb, var(--body) 45%, var(--accent)) 58%, transparent 64%);
  opacity: .12;
  filter: blur(38px);
  animation: tide 110s linear infinite;
}
body.running::after { animation-duration: 16s; opacity: .2; }
@keyframes aurora {
  0% { transform: translate(-3%, -2%) rotate(0deg) scale(1); }
  50% { transform: translate(2%, 3%) rotate(8deg) scale(1.08); }
  100% { transform: translate(4%, -3%) rotate(-6deg) scale(1.03); }
}
@keyframes tide { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- stage: one phone-shaped screen */
.stage {
  position: relative; width: 100vw; height: 100dvh;
  overflow: hidden; container-type: size;
  user-select: none; -webkit-user-select: none;
  /* The unit everything on the handheld is sized in: 1% of the width on a phone, and on a wide screen (desktop, TV)
     0.72% of the height, which is as big as the score can get and still sit above the swoosh. */
  --u: min(1cqw, .72cqh);
}
.stage.buzzed { animation: buzz .09s linear 7; }
.stage::after { content: ''; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.stage.buzzed::after { animation: flash .65s ease-out; }
@keyframes buzz { 0%, 100% { translate: 0 0; } 25% { translate: calc(-1.6 * var(--u)) 0; } 75% { translate: calc(1.6 * var(--u)) 0; } }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* ---------------------------------------------------------------- the shell: panel + swoosh (paths are laid out in px by app.js) */
.shell { position: absolute; inset: 0; width: 100%; height: 100%; }
.s-panel-hi { stop-color: color-mix(in srgb, var(--panel) 86%, #fff); }
.s-panel { stop-color: var(--panel); }
.s-panel-lo { stop-color: color-mix(in srgb, var(--panel) 78%, #000); }
.panel-fill { fill: url(#g-panel); }
.swoosh-shadow { fill: none; stroke: rgba(0, 0, 0, .5); stroke-width: 16; filter: blur(7px); translate: 4px 5px; }
.swoosh { fill: none; stroke: var(--ink-panel); stroke-width: 5; stroke-linecap: round; transition: stroke-width .12s; }
.stage.beat .swoosh:not(.glow) { stroke-width: 7.5; transition: none; }
/* While the timer runs, light flows along the swoosh, faster as the beeps speed up. */
.swoosh.glow {
  stroke: color-mix(in srgb, var(--accent) 55%, #fff); stroke-width: 12; opacity: 0;
  stroke-dasharray: 110 390; filter: blur(5px); transition: opacity .4s;
}
.stage[data-phase="running"] .swoosh.glow { opacity: .95; animation: flow calc(var(--tempo) * 3) linear infinite; }
.stage[data-phase="won"] .swoosh.glow { opacity: 1; stroke-dasharray: 30 70; animation: flow 1.4s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -500; } }

/* ---------------------------------------------------------------- top: the score, on the body */
.top { position: absolute; left: 0; right: 0; top: max(1.4cqh, env(safe-area-inset-top)); display: flex; justify-content: center; color: var(--ink-body); }
.score { display: flex; align-items: flex-start; gap: calc(3.5 * var(--u)); }
.digit { background: none; border: 0; padding: 0 calc(1.5 * var(--u)); display: grid; justify-items: center; line-height: 1; transition: color .25s, text-shadow .25s, scale .15s; }
.digit b { font-size: calc(15 * var(--u)); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.digit small { font-family: var(--serif); font-weight: 700; font-size: calc(3.1 * var(--u)); opacity: .7; margin-top: calc(.3 * var(--u)); }
.digit:active { scale: .92; }
.digit.lit { color: color-mix(in srgb, var(--accent) 65%, var(--ink-body)); text-shadow: 0 0 calc(5 * var(--u)) var(--accent); }
.digit.pop b { animation: pop .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { 0% { scale: 1.6; } 100% { scale: 1; } }
.score[data-teams="3"], .score[data-teams="4"] { gap: calc(4 * var(--u)); }
.score[data-teams="3"] .digit b { font-size: calc(13 * var(--u)); }
.score[data-teams="4"] .digit b { font-size: calc(11.5 * var(--u)); }
.dash { font-size: calc(12 * var(--u)); font-weight: 800; line-height: 1.2; opacity: .8; }

.top-btns { position: absolute; right: calc(3.5 * var(--u)); top: calc(1 * var(--u)); display: grid; gap: calc(2.4 * var(--u)); }
.mini {
  width: calc(11 * var(--u)); height: calc(7.6 * var(--u)); border: 0; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: radial-gradient(70% 60% at 45% 35%, var(--btn-hi), var(--buttons) 55%, var(--btn-lo));
  box-shadow: 0 calc(.55 * var(--u)) 0 color-mix(in srgb, var(--buttons) 35%, #000), 0 calc(.9 * var(--u)) calc(1.6 * var(--u)) rgba(0, 0, 0, .5);
}
.mini svg { width: calc(4.4 * var(--u)); height: calc(4.4 * var(--u)); fill: var(--ink-btn); }
.mini:active { translate: 0 calc(.45 * var(--u)); box-shadow: 0 calc(.1 * var(--u)) 0 color-mix(in srgb, var(--buttons) 35%, #000); }

/* ---------------------------------------------------------------- the panel: category + phrase, front and center */
.content {
  position: absolute; left: 10cqw; right: 10cqw; top: 27cqh; bottom: 24cqh;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 1.6cqh;
  color: var(--ink-panel);
}
.stage.panic .content { animation: panic .12s linear infinite; }
@keyframes panic { 0%, 100% { translate: 0 0; } 25% { translate: calc(-.5 * var(--u)) calc(.3 * var(--u)); } 75% { translate: calc(.5 * var(--u)) calc(-.3 * var(--u)); } }

.wordmark { font-weight: 800; font-size: calc(11.5 * var(--u)); line-height: 1; letter-spacing: -.02em; white-space: nowrap; rotate: -3deg; margin-bottom: 1cqh; }
.wordmark span { font-family: var(--pixel); font-size: .78em; letter-spacing: .02em; margin-right: .06em; }
.wordmark b { display: inline-block; translate: 0 .18em; }

.cat { background: none; border: 0; padding: 0; display: flex; align-items: baseline; justify-content: center; gap: calc(2 * var(--u)); }
.cat i { font-family: var(--serif); font-size: calc(6 * var(--u)); text-transform: capitalize; opacity: .9; }
.cat em { font-style: normal; font-size: calc(3 * var(--u)); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: calc(.5 * var(--u)) calc(1.8 * var(--u)); border-radius: 99px; color: var(--ink-panel); background: color-mix(in srgb, var(--accent) 45%, transparent); }
.cat .caret { font-size: calc(4 * var(--u)); opacity: .6; }
.cat:disabled { cursor: default; }
.cat:disabled .caret { display: none; }

.phrase-box { width: 100%; }
.phrase { font-weight: 800; line-height: 1.02; letter-spacing: -.025em; text-wrap: balance; text-shadow: 0 calc(.5 * var(--u)) 0 rgba(0, 0, 0, .22); }
.phrase.in { animation: phrase-in .26s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes phrase-in { from { opacity: 0; translate: var(--from, 14%) 0; } }

.sub { margin: 0; font-size: calc(3.7 * var(--u)); line-height: 1.4; opacity: .78; }
.sub:empty { display: none; }

.chip {
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); background: color-mix(in srgb, currentColor 8%, transparent);
  padding: 8px 14px; border-radius: 999px; font-weight: 650; font-size: 14px;
}
.chip small { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-left: 2px; }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #14151a; }

/* ---------------------------------------------------------------- NEXT, in its pod at the bottom of the swoosh */
.next {
  position: absolute; left: 50cqw; bottom: max(2.4cqh, env(safe-area-inset-bottom)); translate: -50% 0;
  width: calc(46 * var(--u)); height: 10.5cqh; min-height: 64px; border: 0; border-radius: 50%; padding: 0;
  font-weight: 800; font-size: calc(10 * var(--u)); letter-spacing: -.03em; color: var(--ink-btn); white-space: nowrap;
  background: radial-gradient(65% 55% at 45% 30%, #fff, var(--btn-hi) 30%, var(--buttons) 62%, var(--btn-lo));
  box-shadow: 0 calc(1.2 * var(--u)) 0 color-mix(in srgb, var(--buttons) 30%, #000), 0 calc(2 * var(--u)) calc(3.4 * var(--u)) rgba(0, 0, 0, .6), inset 0 calc(-1 * var(--u)) calc(1.6 * var(--u)) rgba(0, 0, 0, .2), inset 0 calc(.8 * var(--u)) calc(1 * var(--u)) rgba(255, 255, 255, .6);
  transition: box-shadow .08s, translate .08s;
}
.next.long { font-size: calc(6.6 * var(--u)); }
.next:active, .next.pressed { translate: -50% calc(1 * var(--u)); box-shadow: 0 calc(.2 * var(--u)) 0 color-mix(in srgb, var(--buttons) 30%, #000), 0 calc(.6 * var(--u)) calc(1.2 * var(--u)) rgba(0, 0, 0, .5), inset 0 calc(-.5 * var(--u)) calc(1 * var(--u)) rgba(0, 0, 0, .2); }
.stage[data-phase="running"] .next { animation: breathe calc(var(--tempo) * 2) ease-in-out infinite; }
@keyframes breathe { 50% { filter: brightness(1.08) drop-shadow(0 0 calc(2.4 * var(--u)) color-mix(in srgb, var(--accent) 60%, #fff)); } }

/* ---------------------------------------------------------------- online: lobby and roles */
.next.off { filter: grayscale(.4) brightness(.62); box-shadow: 0 calc(.6 * var(--u)) 0 color-mix(in srgb, var(--buttons) 30%, #000), 0 calc(1 * var(--u)) calc(2 * var(--u)) rgba(0, 0, 0, .5); cursor: default; }
.next.off:active { translate: -50% 0; }
.stage[data-phase="running"] .next.off { animation: none; }
.stage[data-role="guess"] .phrase { color: color-mix(in srgb, var(--accent) 55%, var(--ink-panel)); }
.stage[data-role="wait"] .phrase { opacity: .55; }
.digit.mine small { opacity: 1; text-decoration: underline; text-underline-offset: calc(.6 * var(--u)); }

.lobby { width: 100%; display: grid; justify-items: center; gap: 1.4cqh; max-height: 100%; overflow-y: auto; }
.room { background: none; border: 0; padding: 0; display: grid; justify-items: center; line-height: 1; }
.room small { font-family: var(--serif); font-style: italic; font-size: calc(4 * var(--u)); opacity: .8; }
.room b { font-size: calc(15 * var(--u)); font-weight: 800; letter-spacing: .08em; margin-right: -.08em; }
.room span { font-size: calc(3.2 * var(--u)); opacity: .65; margin-top: calc(.4 * var(--u)); }
.teams { width: 100%; max-width: calc(84 * var(--u)); display: grid; gap: 1cqh; }
.team-row { display: grid; grid-template-columns: calc(13 * var(--u)) 1fr; align-items: center; gap: calc(2 * var(--u)); text-align: left; }
.team-row small { font-family: var(--serif); font-weight: 700; font-size: calc(3.3 * var(--u)); opacity: .75; }
.team-row > div { display: flex; flex-wrap: wrap; gap: calc(1.4 * var(--u)); }
.chip.name { padding: 5px 11px; font-size: 13px; }
.chip.name.away { opacity: .45; }
.empty { font-size: calc(3.2 * var(--u)); opacity: .5; font-style: italic; }

.sheet input[type="text"] { font: inherit; font-size: 15px; color: inherit; background: #0b0c10; border: 1px solid rgba(255, 255, 255, .2); border-radius: 10px; padding: 8px 10px; min-width: 0; width: 60%; }
.sheet input.code { width: 6.5em; text-transform: uppercase; letter-spacing: .25em; font-weight: 800; text-align: center; }
.sheet .chip.on { font-size: 15px; padding: 9px 18px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.error { color: #ff9c8a; font-size: 14px; min-height: 1.3em; margin: 10px 0 0; }

/* ---------------------------------------------------------------- TV view (/party/CODE): the room's screen, no buttons */
body.party .next, body.party #btn-random { display: none; }
.sound { position: absolute; left: calc(12 * var(--u)); top: calc(1 * var(--u)); color: var(--ink-body); }
.invite { display: grid; justify-items: center; gap: 1cqh; }
.qr { width: calc(30 * var(--u)); padding: calc(1.6 * var(--u)); background: #fff; border-radius: calc(2 * var(--u)); line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
body.party .room span { display: none; }
@media (orientation: landscape) {
  body.party .lobby { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: calc(8 * var(--u)); max-width: calc(170 * var(--u)); }
  body.party .team-row small { font-size: calc(4.4 * var(--u)); }
  body.party .team-row { grid-template-columns: calc(17 * var(--u)) 1fr; }
  body.party .chip.name { font-size: calc(4 * var(--u)); padding: calc(1 * var(--u)) calc(2.6 * var(--u)); }
  body.party .sub { font-size: calc(4.4 * var(--u)); }
}

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); translate: -50% 140%; visibility: hidden;
  background: #111217; color: #f5f5f2; border: 1px solid rgba(255, 255, 255, .18);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; text-align: center; z-index: 30;
  transition: translate .3s cubic-bezier(.3, 1.4, .5, 1), visibility 0s .3s;
}
.toast.show { translate: -50% 0; visibility: visible; transition: translate .3s cubic-bezier(.3, 1.4, .5, 1); }

/* ---------------------------------------------------------------- sheets (category picker, customize) */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 20; }
.sheet {
  position: fixed; left: 50%; bottom: 0; translate: -50% 0; z-index: 21;
  width: min(520px, 100vw); max-height: 86dvh; overflow: auto;
  color: #f5f5f2; background: color-mix(in srgb, var(--body) 30%, #0e0f14);
  border: 1px solid rgba(255, 255, 255, .14); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 16px 18px max(22px, env(safe-area-inset-bottom));
  animation: sheet-up .3s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes sheet-up { from { translate: -50% 100%; } }
.sheet header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .65; }
.x { background: none; border: 0; font-size: 18px; padding: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip { text-transform: capitalize; }
.presets { display: flex; gap: 10px; flex-wrap: wrap; }
.preset { display: grid; justify-items: center; gap: 4px; background: none; border: 0; padding: 0; font-size: 12px; opacity: .85; }
.preset i { width: 46px; height: 46px; border-radius: 50%; display: block; border: 2px solid transparent; }
.preset.on i { border-color: #fff; }
.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.colors label { display: grid; justify-items: center; gap: 4px; font-size: 12px; opacity: .85; }
.colors input { width: 46px; height: 46px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.colors input::-webkit-color-swatch-wrapper { padding: 0; }
.colors input::-webkit-color-swatch { border: 2px solid rgba(255, 255, 255, .25); border-radius: 50%; }
.colors input::-moz-color-swatch { border: 2px solid rgba(255, 255, 255, .25); border-radius: 50%; }
.rows { display: grid; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; }
.row select { font: inherit; font-size: 14px; color: inherit; background: #0b0c10; border: 1px solid rgba(255, 255, 255, .2); border-radius: 10px; padding: 6px 10px; max-width: 60%; }
.row.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.sheet-actions { margin-top: 16px; }
.credit { font-size: 12px; opacity: .65; margin: 14px 0 0; line-height: 1.4; }
.credit a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .stage, .stage * { animation: none !important; }
}
