/* ==========================================================================
   GuessPaint - design tokens, reset and shared components
   ========================================================================== */

:root {
  /* surfaces */
  --ink:        #0d0b14;
  --surface-0:  #14111d;
  --surface-1:  #1b1727;
  --surface-2:  #241f33;
  --surface-3:  #2f2942;
  --line:       #362f4c;
  --line-soft:  rgba(255 255 255 / 0.07);

  /* type */
  --text:       #f2eefb;
  --text-dim:   #b3a9c9;
  --text-faint: #776d90;

  /* accents */
  --brand:      #ff7a59;
  --brand-2:    #ffb457;
  --mint:       #3ddc97;
  --sky:        #5cc8ff;
  --violet:     #a583ff;
  --rose:       #ff6b9d;
  --warn:       #ffcf5c;
  --danger:     #ff5f6d;

  --radius-sm:  10px;
  --radius:     16px;
  --radius-lg:  24px;
  --radius-xl:  32px;

  --shadow-sm:  0 2px 8px rgb(0 0 0 / 0.25);
  --shadow:     0 12px 32px -12px rgb(0 0 0 / 0.55);
  --shadow-lg:  0 32px 64px -24px rgb(0 0 0 / 0.7);

  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", Inter, system-ui, -apple-system,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 220ms;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------ backdrop ---- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -20%, #241a37 0%, transparent 60%),
    var(--ink);
}

.blob {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  will-change: transform;
}
.blob-a { background: var(--brand);  top: -16vmax; left: -10vmax; animation: drift-a 26s var(--ease) infinite alternate; }
.blob-b { background: var(--violet); bottom: -22vmax; right: -12vmax; animation: drift-b 32s var(--ease) infinite alternate; }
.blob-c { background: var(--sky);    top: 38%; left: 52%; opacity: 0.13; animation: drift-c 38s var(--ease) infinite alternate; }

@keyframes drift-a { to { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-9vmax, -5vmax, 0) scale(1.1); } }
@keyframes drift-c { to { transform: translate3d(-6vmax, 8vmax, 0) scale(0.9); } }

/* -------------------------------------------------------------- screens --- */

.screen { display: none; }
body[data-screen="home"]  #screen-home,
body[data-screen="lobby"] #screen-lobby,
body[data-screen="game"]  #screen-game { display: block; }
body[data-screen="game"]  #screen-game { display: flex; flex-direction: column; height: 100dvh; }

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

.card {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.04), rgb(255 255 255 / 0.015));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.hint { margin-top: 12px; font-size: 0.84rem; color: var(--text-faint); }

.pill {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

/* --------------------------------------------------------------- inputs --- */

input[type="text"] {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(0 0 0 / 0.28);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
input[type="text"]::placeholder { color: var(--text-faint); }
input[type="text"]:focus {
  border-color: var(--brand);
  background: rgb(0 0 0 / 0.4);
  outline: none;
}
input[type="text"]:disabled { opacity: 0.45; cursor: not-allowed; }

.field { display: grid; gap: 8px; }
.field > label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* -------------------------------------------------------------- buttons --- */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 120ms var(--ease), filter var(--dur) var(--ease),
              opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--brand), var(--brand-2));
  --btn-fg: #23150f;
  box-shadow: 0 10px 26px -12px var(--brand);
}
.btn-ghost { --btn-bg: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet { --btn-bg: transparent; --btn-fg: var(--text-dim); min-height: 40px; padding: 0 14px; }
.btn-quiet:hover { --btn-fg: var(--text); }
.btn-chip { min-height: 34px; padding: 0 14px; border-radius: 999px; font-size: 0.82rem; --btn-bg: var(--surface-2); }

.btn-lg {
  min-height: 62px;
  border-radius: var(--radius-lg);
  font-size: 1.05rem;
  flex-direction: column;
  gap: 2px;
}
.btn-lg small { font-size: 0.76rem; font-weight: 600; opacity: 0.65; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--text-dim);
  background: rgb(255 255 255 / 0.04);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: rgb(255 255 255 / 0.1); color: var(--text); }

/* -------------------------------------------------------------- avatars --- */

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background: var(--surface-3);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: inset 0 0 0 2px var(--ring, transparent);
}

/* -------------------------------------------------------------- overlay --- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(8 6 14 / 0.72);
  backdrop-filter: blur(10px);
  animation: fade-in 200ms var(--ease);
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(560px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop-in 320ms var(--ease);
}
.overlay-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.overlay-title {
  margin: 6px 0 18px;
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.overlay-title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.score-rows { display: grid; gap: 8px; text-align: left; }
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.04);
}
.score-row .who { flex: 1; font-weight: 700; }
.score-row .pts { font-weight: 800; color: var(--mint); font-variant-numeric: tabular-nums; }
.score-row .pts.is-down { color: var(--danger); }
.score-row .tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 8px 0 22px; }
.podium-step { display: grid; justify-items: center; gap: 8px; flex: 1; max-width: 130px; }
.podium-bar {
  width: 100%;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-1));
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 10px 0;
}
.podium-step[data-rank="1"] .podium-bar { height: 116px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #241206; }
.podium-step[data-rank="2"] .podium-bar { height: 88px; }
.podium-step[data-rank="3"] .podium-bar { height: 66px; }
.podium-name { font-size: 0.86rem; font-weight: 700; }
.podium-score { font-size: 0.78rem; color: var(--text-dim); }

/* --------------------------------------------------------------- toasts --- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-in 260ms var(--ease);
}
.toast[data-kind="error"] { border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: #ffd9dc; }
.toast[data-kind="good"]  { border-color: color-mix(in srgb, var(--mint) 55%, transparent); color: #d6ffef; }

/* ----------------------------------------------------------------- boot --- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--ink);
  color: var(--text-faint);
  transition: opacity 320ms var(--ease), visibility 320ms;
}
.boot-mark { font-size: 3rem; animation: bob 1.4s ease-in-out infinite; }
body:not([data-screen="loading"]) .boot { opacity: 0; visibility: hidden; }

/* ------------------------------------------------------------ keyframes --- */

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-10px) rotate(6deg); }
}

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