/* ==========================================================================
   Hitster Online – design system "B – Színes kártyák"
   Cream paper, thick ink outlines, hard offset shadows, bright player
   colours, slightly tilted cards. Phone-first; `body.tv` = big-screen layout.
   Fonts (load in <head>):
   https://fonts.googleapis.com/css2?family=Rammetto+One&family=Bricolage+Grotesque:opsz,wght@12..96,400..800&display=swap
   ========================================================================== */

/* ---------- Tokens ------------------------------------------------------- */
:root {
  --cream: #fff4e0;
  --cream-deep: #ffe9c2;
  --paper: #fffdf7;
  --ink: #1b1b1b;
  --ink-soft: #4a4238;

  --coral: #ff6b6b;
  --teal: #4ecdc4;
  --yellow: #ffd23f;
  --lavender: #a29bfe;
  --mint: #7bed9f;
  --orange: #ff9f43;
  --pink: #fd79a8;
  --sky: #74b9ff;
  --lime: #c8e65a;
  --peach: #ffb38a;

  --ok: #2ecc71;
  --bad: #ff4757;

  --border: 3px;
  --border-thin: 2.5px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  --font-display: 'Rammetto One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-text: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --gap: 1rem;
  --gutter: 16px;
  --maxw: 34rem;

  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);

  color-scheme: light; /* the cream theme is the brand: no dark mode */
}

/* Player colours: give an element class `p-0`…`p-9` (or set --pc) and use
   var(--pc) for its fill. Order matters: index = player seat. */
.p-0 { --pc: var(--coral); }
.p-1 { --pc: var(--teal); }
.p-2 { --pc: var(--yellow); }
.p-3 { --pc: var(--lavender); }
.p-4 { --pc: var(--mint); }
.p-5 { --pc: var(--orange); }
.p-6 { --pc: var(--pink); }
.p-7 { --pc: var(--sky); }
.p-8 { --pc: var(--lime); }
.p-9 { --pc: var(--peach); }

.bg-coral { background: var(--coral); }
.bg-teal { background: var(--teal); }
.bg-yellow { background: var(--yellow); }
.bg-lavender { background: var(--lavender); }
.bg-mint { background: var(--mint); }
.bg-orange { background: var(--orange); }
.bg-pink { background: var(--pink); }
.bg-sky { background: var(--sky); }
.bg-paper { background: var(--paper); }
.bg-player { background: var(--pc, var(--paper)); }

/* ---------- Base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--cream);
  /* faint halftone dots, like printed card stock */
  background-image: radial-gradient(rgba(27, 27, 27, .07) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: .005em;
  margin: 0 0 .4em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.4rem, 9vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 6vw, 2.2rem); }
h3 { font-size: 1.3rem; }

p { margin: 0 0 .75em; text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--yellow);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

.muted { color: var(--ink-soft); }
.center { text-align: center; }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

/* ---------- Layout ------------------------------------------------------- */
.page {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: max(var(--gutter), env(safe-area-inset-top)) var(--gutter)
           max(calc(var(--gutter) * 2), env(safe-area-inset-bottom));
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack--lg { gap: calc(var(--gap) * 1.75); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Card --------------------------------------------------------- */
.card {
  position: relative;
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.15rem 1.25rem;
}
.card--lg { box-shadow: var(--shadow-lg); padding: 1.5rem 1.35rem 1.6rem; }
.card--flat { box-shadow: none; }

/* A Hitster song card: big year, small artist/title. */
.song-card {
  display: grid;
  place-items: center;
  gap: .1rem;
  min-width: 5.5rem;
  padding: .55rem .8rem .6rem;
  background: var(--pc, var(--paper));
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.song-card__year {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
}
.song-card__meta {
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.2;
  max-width: 12rem;
  overflow-wrap: anywhere;
}

/* Tilt helpers (±1–3°). */
.tilt-l { transform: rotate(-2deg); }
.tilt-r { transform: rotate(2deg); }
.tilt-l1 { transform: rotate(-1deg); }
.tilt-r1 { transform: rotate(1deg); }
.tilt-l3 { transform: rotate(-3deg); }
.tilt-r3 { transform: rotate(3deg); }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  --btn-bg: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 3rem;
  padding: .6rem 1.2rem;
  background: var(--btn-bg);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-family: var(--font-text);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s;
}
@media (hover: hover) {
  .btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
}
.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}
.btn:disabled, .btn[aria-disabled='true'] {
  cursor: not-allowed;
  background: #e9dfcc;
  color: #7d7365;
  border-color: #7d7365;
  box-shadow: 2px 2px 0 #7d7365;
  transform: none;
}

.btn--big {
  width: 100%;
  min-height: 4rem;
  padding: .85rem 1.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.55rem;
  letter-spacing: .01em;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.btn--big:active { transform: translate(7px, 7px); }

.btn--primary { --btn-bg: var(--coral); }
.btn--teal { --btn-bg: var(--teal); }
.btn--yellow { --btn-bg: var(--yellow); }
.btn--lavender { --btn-bg: var(--lavender); }
.btn--mint { --btn-bg: var(--mint); }
.btn--player { --btn-bg: var(--pc, var(--paper)); }
.btn--ghost {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
}
.btn--ghost:active { transform: translate(1px, 1px); }
.btn--sm { min-height: 2.4rem; padding: .35rem .8rem; font-size: .92rem; box-shadow: var(--shadow-sm); }

/* ---------- Chips (player names, tags, genre toggles) -------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  max-width: 100%;
  padding: .3rem .8rem;
  background: var(--pc, var(--paper));
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 750;
  font-size: .95rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip--off { background: var(--paper); color: var(--ink-soft); box-shadow: none; border-style: dashed; }
button.chip { cursor: pointer; font-family: inherit; }
button.chip[aria-pressed='true'] { background: var(--pc, var(--yellow)); }

/* Token coin (Hitster tokens) */
.token {
  display: inline-grid;
  place-items: center;
  width: 1.6em; height: 1.6em;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4 0 18%, var(--yellow) 19%);
  box-shadow: 1.5px 1.5px 0 var(--ink);
  font-weight: 800;
  font-size: .8em;
  line-height: 1;
}

/* ---------- Timeline + drop slot ----------------------------------------- */
.timeline {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .55rem;
}
.timeline--row { flex-direction: row; align-items: center; flex-wrap: wrap; }

/* The dashed "IDE?" drop slot. Add .is-active for the chosen slot. */
.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: 2.6rem;
  padding: .4rem .9rem;
  background: var(--paper);
  border: var(--border-thin) dashed var(--ink);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
  cursor: pointer;
  transform: rotate(-1.5deg);
  transition: transform .15s var(--ease-pop), background-color .15s;
}
.slot::after { content: 'IDE?'; }
.slot:not(:empty)::after { content: none; }
.slot--quiet { min-height: 1.4rem; padding: .1rem; border-color: rgba(27, 27, 27, .35); font-size: .8rem; }
.slot--quiet::after { content: '+'; }
.slot.is-active {
  background: var(--yellow);
  border-style: solid;
  box-shadow: var(--shadow-sm);
  transform: rotate(-1.5deg) scale(1.04);
}
.slot.is-ok { background: var(--mint); border-style: solid; }
.slot.is-bad { background: var(--coral); border-style: solid; }

/* ---------- Forms -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.label { font-weight: 800; font-size: .98rem; }
.help { font-size: .85rem; color: var(--ink-soft); }

.input {
  width: 100%;
  min-height: 3.25rem;
  padding: .6rem .9rem;
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: inset 3px 3px 0 rgba(27, 27, 27, .08);
  font-size: 1.15rem;
  font-weight: 650;
  outline: none;
  transition: box-shadow .12s, background-color .12s;
}
.input::placeholder { color: #9b8f7e; font-weight: 500; }
.input:focus { background: #fff; box-shadow: var(--shadow-sm); }
.input:focus-visible { outline: none; box-shadow: var(--shadow-sm), 0 0 0 5px var(--yellow); }
.input[aria-invalid='true'] { border-color: var(--bad); }

/* Room code input: one big yellow tile, wide tracking, like the TV code. */
.code-input {
  width: 100%;
  min-height: 4.4rem;
  padding: .35rem .5rem .35rem .85rem; /* extra left pad balances the tracking */
  background: var(--yellow);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: .38em;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(-1.2deg);
  caret-color: var(--ink);
}
.code-input::placeholder { color: rgba(27, 27, 27, .28); font-weight: 400; }
.code-input:focus { background: var(--yellow); box-shadow: var(--shadow-lg); }
.code-input:focus-visible { box-shadow: var(--shadow-lg), 0 0 0 5px var(--paper), 0 0 0 8px var(--ink); }

/* ---------- Autocomplete (assets/js/autocomplete.js) --------------------- */
.ac { position: relative; }
.ac__menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0;
  padding: .3rem;
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--paper);
  border: var(--border) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: pop .18s var(--ease-pop) both;
}
.ac__item {
  padding: .7rem .75rem;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.ac__item + .ac__item { border-top: 1.5px dashed rgba(27, 27, 27, .18); }
.ac__item.is-active, .ac__item:hover { background: var(--yellow); }
.ac__hint {
  margin: .35rem 0 0;
  font-size: .88rem;
  font-weight: 750;
  color: #c0392b;
}
.ac.is-picked .input { background: #eafff0; border-color: var(--ink); }

/* ---------- Alerts ------------------------------------------------------- */
.alert {
  padding: .7rem .9rem;
  background: #ffd9d4;
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 750;
  animation: pop .25s var(--ease-pop) both;
}
.alert--info { background: var(--sky); }
.alert--ok { background: var(--mint); }

/* Countdown bar: set --p from 1 → 0 via JS (style.setProperty). */
.meter {
  height: 1rem;
  background: var(--paper);
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  width: calc(var(--p, 1) * 100%);
  background: var(--teal);
  border-right: var(--border-thin) solid var(--ink);
  transition: width .25s linear;
}
.meter.is-low .meter__fill { background: var(--coral); }

/* ---------- Animations --------------------------------------------------- */
/* flip: card turns over to reveal (use on the front face element). */
@keyframes flip {
  0% { transform: perspective(700px) rotateY(90deg) scale(.9); }
  60% { transform: perspective(700px) rotateY(-12deg) scale(1.04); }
  100% { transform: perspective(700px) rotateY(0) scale(1); }
}
/* pop: springy entrance. */
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  70% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}
/* confetti: a piece falls and spins (see .confetti__piece). */
@keyframes confetti {
  0% { transform: translate3d(0, -10vh, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0px), 110vh, 0) rotate(var(--spin, 720deg)); opacity: 1; }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-1.5deg) translateY(0); }
  50% { transform: rotate(1.5deg) translateY(-3px); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.anim-flip { animation: flip .6s var(--ease-pop) both; backface-visibility: hidden; }
.anim-pop { animation: pop .35s var(--ease-pop) both; }
.anim-wobble { animation: wobble 1.6s ease-in-out infinite; }
.anim-shake { animation: shake .4s ease both; }

/* Confetti layer: JS appends .confetti__piece elements with inline
   --x (left %), --dx, --spin, --d (duration), --delay, background colour. */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}
.confetti__piece {
  position: absolute;
  top: 0;
  left: var(--x, 50%);
  width: .7rem;
  height: 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--yellow);
  animation: confetti var(--d, 2.4s) cubic-bezier(.2, .6, .4, 1) var(--delay, 0s) both;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .confetti { display: none; }
}

/* ---------- Landing (index.php) ------------------------------------------ */
.landing {
  max-width: 68rem;
  display: grid;
  gap: 2.25rem;
  align-items: center;
}

.brand {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: .14em;
  margin: .5rem 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 11.2vw, 5.4rem);
  line-height: .9;
}
.brand__tile {
  display: inline-grid;
  place-items: center;
  min-width: .82em;
  padding: .04em .08em .08em;
  background: var(--pc);
  border: var(--border) solid var(--ink);
  border-radius: .14em;
  box-shadow: var(--shadow);
  animation: pop .45s var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.brand__tile:nth-child(odd) { rotate: -3deg; }
.brand__tile:nth-child(even) { rotate: 2.5deg; translate: 0 -.06em; }
.brand__sub {
  flex-basis: 100%;
  margin-top: .3rem;
  font-size: .42em;
  rotate: -1.5deg;
  transform-origin: left;
}

.lede { font-size: 1.15rem; max-width: 30rem; }

/* Demo timeline in the hero: the game in one glance. */
.demo-line {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 1.4rem 0 .25rem;
  padding: .25rem 0 .5rem;
}
.demo-line .song-card { min-width: 0; flex: 1 1 0; padding: .45rem .3rem; }
.demo-line .song-card__year { font-size: clamp(1.2rem, 5.2vw, 1.75rem); }
.demo-line .song-card__meta { font-size: .68rem; font-weight: 600; }
.demo-line .slot {
  flex: 1 1 0;
  align-self: stretch;
  font-size: clamp(.95rem, 4vw, 1.25rem);
  background: var(--paper);
  animation: wobble 1.8s ease-in-out .8s infinite;
}
.demo-line > * { animation: pop .4s var(--ease-pop) both; }
.demo-line > :nth-child(1) { animation-delay: .35s; }
.demo-line > :nth-child(2) { animation-delay: .45s; }
.demo-line > :nth-child(4) { animation-delay: .55s; }

.mystery {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .9rem .45rem .5rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: .95rem;
  rotate: 1.5deg;
}
.mystery__disc {
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--coral) 0 22%, var(--ink) 23% 28%, transparent 29%),
    repeating-radial-gradient(circle, #333 0 1.5px, #1b1b1b 1.5px 3px);
  border: 2px solid var(--paper);
  animation: spin 2.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.join-card { padding: 1.4rem 1.25rem 1.5rem; }
.join-card h2 { margin-bottom: .9rem; }
.join-card .stack { gap: 1.1rem; }

.host-cta {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .9rem 1rem;
  background: var(--teal);
  text-decoration: none;
}
.host-cta__icon {
  flex: none;
  width: 3rem; height: 2.2rem;
  border: var(--border) solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  position: relative;
}
.host-cta__icon::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -.55rem;
  width: 1.2rem; height: .3rem;
  translate: -50% 0;
  background: var(--ink);
  border-radius: 2px;
}
.host-cta__text { display: flex; flex-direction: column; gap: .1rem; }
.host-cta__title { font-family: var(--font-display); font-size: 1.12rem; line-height: 1.05; }
.host-cta__sub { font-size: .9rem; font-weight: 600; }

.footer-note { margin-top: 2rem; font-size: .85rem; color: var(--ink-soft); text-align: center; }

@media (min-width: 900px) {
  .landing {
    grid-template-columns: 1.15fr .85fr;
    gap: 4rem;
    min-height: calc(100dvh - 4rem);
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
  .brand { font-size: clamp(3rem, 4.6vw, 4.4rem); }
  .brand__sub { font-size: .36em; }
  .lede { font-size: 1.3rem; }
  .demo-line { max-width: 34rem; }
}

/* ---------- TV layout (host screen) -------------------------------------- */
/* Everything is rem-based, so scaling the root font scales the whole UI. */
:root:has(> body.tv), html.tv { font-size: clamp(18px, 1.45vw, 34px); }

body.tv {
  overflow: hidden;
  font-size: 1.05rem;
}
body.tv .page,
.tv-page {
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2.2rem 3rem;
}
body.tv h1 { font-size: 4.4rem; }
body.tv h2 { font-size: 2.6rem; }
body.tv .card { box-shadow: var(--shadow-lg); }
body.tv .song-card__year { font-size: 2.4rem; }
body.tv .timeline { flex-direction: row; flex-wrap: wrap; align-items: center; }
body.tv .chip { font-size: 1.1rem; padding: .35rem 1rem; }

/* Two-column TV grid: main stage + side scoreboard. */
.tv-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 26rem);
  gap: 2.5rem;
  align-items: start;
}

/* Big room code (TV lobby). */
.room-code {
  display: inline-block;
  padding: .1em .35em .16em;
  background: var(--yellow);
  border: var(--border) solid var(--ink);
  border-radius: .18em;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-display);
  font-size: 5rem;
  line-height: 1;
  letter-spacing: .12em;
  transform: rotate(-2deg);
}

/* Scoreboard rows (player colour fill). */
.scoreboard { display: flex; flex-direction: column; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.score {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .9rem;
  background: var(--pc, var(--paper));
  border: var(--border-thin) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}
.score__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score__pts { font-family: var(--font-display); font-size: 1.4em; }
.score.is-offline { opacity: .55; filter: grayscale(.6); }
.score.is-turn { transform: rotate(-1.5deg) scale(1.03); box-shadow: var(--shadow); }
