/* Blanks: game night on a blue table. The cards are the stars; names and codes are label-maker tape. */

:root {
  --table: #2230a6;        /* the table everything sits on */
  --table-deep: #18237e;   /* inputs, bars */
  --chalk: #c9cef5;        /* secondary text on the table */
  --line: rgba(255, 255, 255, .18);
  --paper: #ffffff;        /* answer cards */
  --ink: #000000;          /* prompt cards, tape */
  --pink: #ff5c9a;         /* you: your tape, your actions */
  --pink-deep: #b8155a;
  --marker: #ffe14d;       /* highlighter where answers fill the blank */
  --danger: #ff8a8a;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bagel Fat One", "Schibsted Grotesk", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--table); color: #fff; }

body {
  font: 17px/1.45 var(--font);
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 540px; margin: 0 auto; padding: 0 16px calc(124px + var(--safe-bottom)); }

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 3px; }

/* ---------- tape: player names and game codes ---------- */

.tape {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff;
  padding: 5px 11px 4px;
  font-weight: 800; font-size: 14px; letter-spacing: .14em; text-transform: uppercase;
  /* embossed letters, like a label maker */
  text-shadow: 0 1px 0 rgba(0, 0, 0, .9), 0 -1px 0 rgba(255, 255, 255, .28);
  border-radius: 3px;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tape.mine { background: var(--pink); text-shadow: 0 1px 0 var(--pink-deep), 0 -1px 0 rgba(255, 255, 255, .4); }

/* ---------- buttons & fields ---------- */

.btn {
  display: block; width: 100%; min-height: 58px; padding: 14px 20px;
  border: 0; border-radius: 16px;
  background: var(--pink); color: var(--ink);
  font-weight: 800; font-size: 19px;
  box-shadow: 0 5px 0 var(--pink-deep);
  transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--pink-deep); }
.btn:disabled { background: var(--table-deep); color: var(--chalk); box-shadow: none; cursor: default; }
.btn.plain { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55); }
.btn.plain:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 0 0 2px #fff; }
.link {
  border: 0; background: none; padding: 12px 0; min-height: 48px;
  color: var(--chalk); font-weight: 600; text-decoration: underline; text-underline-offset: 4px;
}

.field {
  display: block; width: 100%; min-height: 58px; padding: 14px 16px;
  background: var(--table-deep); border: 2px solid transparent; border-radius: 14px;
  font-size: 19px; font-weight: 600; outline: none;
}
.field::placeholder { color: rgba(201, 206, 245, .6); font-weight: 400; }
.field:focus { border-color: var(--marker); }
.field.code { text-transform: uppercase; letter-spacing: .25em; font-weight: 800; }
.field.code::placeholder { letter-spacing: normal; text-transform: none; }

.label { display: block; font-weight: 600; color: var(--chalk); margin-bottom: 8px; font-size: 15px; }
.hint { font-size: 15px; color: var(--chalk); }
.row { display: flex; gap: 10px; align-items: center; }

/* ---------- cards ---------- */

.black-card {
  background: var(--ink); color: #fff; border-radius: 14px;
  padding: 22px 22px 14px; min-height: 176px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
  font-size: 24px; font-weight: 800; line-height: 1.28;
  box-shadow: 0 10px 24px rgba(5, 10, 60, .45);
}
.card-foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: #9a9a9a; white-space: normal; }
.card-foot .mark { font-family: var(--display); font-size: 15px; color: #fff; font-weight: 400; }
.card-foot .pick { color: #fff; font-weight: 800; font-size: 15px; }
.blank { display: inline-block; width: 3.4em; border-bottom: 3px solid currentColor; transform: translateY(-.15em); }
.black-card .fill { color: var(--marker); }

.hand { display: grid; gap: 10px; }

.white-card {
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 12px;
  padding: 17px 56px 17px 18px; min-height: 66px;
  font-size: 19px; font-weight: 800; line-height: 1.3;
  box-shadow: 0 2px 0 rgba(5, 10, 60, .35);
  transition: transform .12s ease-out, box-shadow .12s ease-out;
}
.white-card.selected {
  transform: translateY(-3px);
  box-shadow: 0 0 0 4px var(--pink), 0 10px 18px rgba(5, 10, 60, .5);
}
.white-card .order {
  position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
  background: var(--pink); color: #fff; font-size: 14px; padding: 3px 9px;
  border-radius: 3px; font-weight: 800;
}

/* an answer is the whole sentence, so the judge can read it out loud */
.answer {
  display: block; width: 100%; text-align: left;
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 12px; padding: 18px;
  font-size: 19px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 2px 0 rgba(5, 10, 60, .35);
  transition: transform .12s ease-out, box-shadow .12s ease-out;
}
.answer.pickable.selected { transform: translateY(-3px); box-shadow: 0 0 0 4px var(--pink), 0 10px 18px rgba(5, 10, 60, .5); }
.answer:not(.pickable) { cursor: default; }
.answer .fill {
  font-weight: 800; padding: 0 .14em; margin: 0 -.04em;
  background: linear-gradient(101deg, rgba(255, 225, 77, .25) 0, var(--marker) .3em, var(--marker) calc(100% - .25em), rgba(255, 225, 77, .35) 100%);
  border-radius: .2em .45em .3em .5em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.answer .by { display: flex; align-items: center; gap: 8px; margin-top: 12px; white-space: normal; }

.white-card, .black-card, .answer { white-space: pre-line; }

/* ---------- home ---------- */

.home { padding-top: max(6vh, 28px); display: grid; gap: 14px; }

.hero { position: relative; height: 270px; margin: 0 4px 18px; }
.home { overflow-x: clip; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.hero .black-card {
  position: absolute; left: 0; top: 0; width: 76%; min-height: 200px;
  transform: rotate(-5deg); font-size: 23px;
}
.hero .logo-card {
  position: absolute; right: 0; bottom: 0; width: 62%;
  background: var(--paper); color: var(--ink); border-radius: 14px;
  padding: 20px 20px 14px; transform: rotate(4deg);
  box-shadow: 0 14px 28px rgba(5, 10, 60, .5);
  animation: drop .55s cubic-bezier(.2, .9, .3, 1.2) .25s both;
}
.logo-card h1 { font-family: var(--display); font-weight: 400; font-size: 54px; line-height: 1; }
.logo-card p { margin-top: 24px; font-size: 13px; font-weight: 600; color: #6b6b6b; }
@keyframes drop {
  from { transform: translate(30px, -70px) rotate(16deg); opacity: 0; }
  to { transform: rotate(4deg); opacity: 1; }
}

.lede { font-size: 18px; color: var(--chalk); margin-bottom: 8px; }
.join { margin-top: 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.join .row .field { flex: 1; min-width: 0; }
.join .row .btn { width: auto; flex: none; padding: 0 26px; }

.credits { margin-top: 32px; font-size: 13px; line-height: 1.55; color: var(--chalk); display: grid; gap: 8px; }
.credits a { color: inherit; }
.credits strong { color: #fff; font-weight: 600; }

/* ---------- lobby ---------- */

.lobby { padding-top: 28px; }

.code-block { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; }
.code-block .tape { font-size: 40px; letter-spacing: .2em; padding: 10px 10px 8px 18px; transform: rotate(-1.5deg); border-radius: 4px; }
.code-block .btn { width: auto; flex: none; min-height: 52px; padding: 0 18px; font-size: 17px; }
.code-help { color: var(--chalk); padding-bottom: 22px; }

.group { padding: 22px 0; border-top: 1px solid var(--line); }
.group h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.group h2 .count { color: var(--chalk); font-weight: 600; }

.players { display: flex; flex-wrap: wrap; gap: 10px 8px; }
.tape .role { font-size: 11px; opacity: .75; letter-spacing: .1em; }

.stepper { display: flex; align-items: center; gap: 16px; }
.stepper button {
  width: 52px; height: 52px; border-radius: 14px; border: 0;
  background: var(--table-deep); font-size: 26px; font-weight: 800;
}
.stepper button:active { background: var(--ink); }
.stepper .value { font-size: 34px; font-weight: 800; min-width: 1.4em; text-align: center; }
.stepper .unit { color: var(--chalk); }

.pack-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.pack-row:last-of-type { border-bottom: 0; }
.pack {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px;
  text-align: left; border: 0; background: none; padding: 14px 0; min-height: 64px;
}
.pack:disabled { cursor: default; }
.switch {
  flex: none; width: 46px; height: 28px; border-radius: 99px; background: var(--table-deep);
  position: relative; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--chalk); transition: transform .15s, background .15s;
}
.pack.on .switch { background: var(--pink); }
.pack.on .switch::after { transform: translateX(18px); background: #fff; }
.pack .name { display: block; font-weight: 800; overflow-wrap: anywhere; }
.pack .meta { display: block; font-size: 14px; color: var(--chalk); }
.flag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 3px; background: var(--danger); color: var(--ink); font-size: 12px; font-weight: 800; }
.remove {
  flex: none; min-width: 48px; height: 48px; border: 0; background: none; padding: 0 4px;
  color: var(--chalk); font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

.crcast { margin-top: 18px; }
.crcast .row .field { flex: 1; min-width: 0; }
.crcast .row .btn { width: auto; flex: none; padding: 0 24px; }
.crcast .hint { margin-top: 8px; }

/* ---------- scoreboard: always on screen ---------- */

.scorebar {
  position: sticky; top: 0; z-index: 10;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--table-deep);
  box-shadow: 0 6px 16px rgba(5, 10, 60, .35);
}
.scorebar-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 15px; color: var(--chalk); }
.scorebar-top strong { color: #fff; font-weight: 800; }
.menu-btn {
  border: 0; background: none; color: #fff; font-weight: 600; min-height: 36px; padding: 0 2px;
  text-decoration: underline; text-underline-offset: 4px;
}

.scores { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.scores::-webkit-scrollbar { display: none; }
.score { flex: none; display: flex; align-items: center; gap: 8px; }
.score.offline { opacity: .4; }
.score .tape { max-width: 9.5em; }
.score .pts { font-size: 24px; font-weight: 800; line-height: 1; min-width: .7em; }


/* ---------- game ---------- */

.status { margin: 20px 0 14px; }
.status h2 { font-size: 24px; font-weight: 800; line-height: 1.2; }
.status p { color: var(--chalk); margin-top: 4px; }

.game .black-card { margin-bottom: 16px; }

.result-head { margin: 22px 0 16px; }
.result-head h2 { font-family: var(--display); font-weight: 400; font-size: 44px; line-height: 1.02; overflow-wrap: anywhere; }
.result-head p { color: var(--chalk); margin-top: 6px; }

.answer.winner { box-shadow: 0 0 0 4px var(--marker), 0 14px 26px rgba(5, 10, 60, .55); transform: rotate(-1.2deg); margin: 6px 4px 8px; }
.answer.winner.new { animation: stamp .45s cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes stamp {
  from { transform: scale(1.12) rotate(-6deg); opacity: 0; }
  to { transform: rotate(-1.2deg); opacity: 1; }
}

.standings { margin-bottom: 18px; }
.standings .line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.standings .line:last-child { border-bottom: 0; }
.standings .pts { font-size: 22px; font-weight: 800; }

.section { font-size: 17px; font-weight: 800; margin: 22px 0 12px; }

/* ---------- bottom bar, in thumb reach ---------- */

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 18px 16px calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--table) 72%, rgba(34, 48, 166, 0));
}
.actionbar > * { max-width: 508px; margin: 0 auto; }
.waiting { text-align: center; color: var(--chalk); padding: 16px 8px; font-weight: 600; }

/* ---------- menu, toast, connection ---------- */

dialog.sheet {
  width: 100%; max-width: 540px; margin: auto auto 0; border: 0;
  padding: 24px 16px calc(20px + var(--safe-bottom));
  background: var(--table-deep); color: #fff; border-radius: 22px 22px 0 0;
}
dialog.sheet::backdrop { background: rgba(5, 10, 60, .6); }
dialog.sheet .stack { display: grid; gap: 12px; }
dialog.sheet .leave { color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }

#toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); z-index: 50;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); width: max-content;
  background: var(--paper); color: var(--ink); font-weight: 800; padding: 13px 18px 13px 22px; border-radius: 12px;
  box-shadow: inset 6px 0 0 var(--danger), 0 10px 24px rgba(5, 10, 60, .5);
  transition: opacity .18s, transform .18s;
}
#toast.ok { box-shadow: inset 6px 0 0 #39c27a, 0 10px 24px rgba(5, 10, 60, .5); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; text-align: center;
  background: var(--marker); color: var(--ink); font-size: 14px; font-weight: 800;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px;
}
.connecting { padding-top: 40vh; text-align: center; color: var(--chalk); }

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

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- bots and winning cards ---------- */

.bot-controls { display: flex; align-items: center; gap: 18px; margin-top: 16px; }
.btn.small { width: auto; min-height: 46px; padding: 0 18px; font-size: 16px; }
.lobby .group > .hint { margin-top: 10px; }

.winners .round-no { display: block; font-size: 13px; font-weight: 600; color: #6b6b6b; margin-bottom: 4px; white-space: normal; }
dialog.sheet.tall { max-height: 88dvh; overflow-y: auto; }
.sheet-title { font-size: 22px; font-weight: 800; }
