/* IQRival — one stylesheet for every screen.
   Stage: a deep violet studio. The four answer colours carry the game; everything else stays quiet. */
:root {
  --stage: #1B1446;
  --stage-2: #241B5C;
  --panel: #2D2470;
  --line: #43399A;
  --ink: #F7F4FF;
  --muted: #B9B0EA;
  --dark: #1B1446;
  --a1: #FF6B3D;
  --a2: #1FB6E8;
  --a3: #F5B700;
  --a4: #33D69F;
  --gold: #F5B700;
  --good: #33D69F;
  --bad: #FF6B3D;
  --radius-lg: 22px;
  --radius-sm: 12px;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(120% 80% at 50% -10%, #2E2380 0%, var(--stage) 60%);
  background-color: var(--stage);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
a { color: inherit; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .45em; font-weight: 800; letter-spacing: -.01em; text-decoration: none; direction: ltr; }
.brand__iq {
  display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: .45em;
  background: var(--gold); color: var(--dark); font-weight: 900; font-size: .9em; transform: rotate(-6deg);
}
.brand__name { font-size: 1.15em; }

/* ---------- layout ---------- */
.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; }
.topbar__right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

.panel { background: var(--stage-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: .95rem; }
.input, .select {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-sm); border: 2px solid var(--line);
  background: var(--stage); font-size: 1.1rem;
}
.input:focus, .select:focus { border-color: var(--ink); outline: none; }
.input--code { font-size: 2rem; font-weight: 800; letter-spacing: .25em; text-align: center; direction: ltr; }
.select--small { width: auto; padding: 8px 12px; font-size: .95rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; border-radius: var(--radius-sm); border: 2px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 1.05rem; text-decoration: none; transition: transform .08s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary { background: var(--gold); color: var(--dark); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--block { width: 100%; }
.btn--big { padding: 18px 30px; font-size: 1.25rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line);
  color: var(--muted); font-weight: 500;
}
.chip input:checked + span { background: var(--ink); color: var(--dark); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.chip small { opacity: .7; margin-inline-start: 4px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--gold); }

.error { color: #FFB199; min-height: 1.4em; margin: 4px 0 0; }

/* ---------- landing ---------- */
.landing { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.landing__main { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding: 32px 0 64px; }
.landing__title { font-size: clamp(2.6rem, 6vw, 4.6rem); line-height: 1.02; font-weight: 900; margin: 0 0 18px; letter-spacing: -.02em; }
.landing__title .vs { display: block; color: var(--muted); font-weight: 800; }
.landing__lead { font-size: 1.2rem; color: var(--muted); max-width: 32ch; margin: 0 0 28px; }
.landing__numbers { display: flex; gap: 10px; }
.landing__numbers span {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 16px; font-weight: 900;
  font-size: 1.6rem; color: var(--dark);
}
.landing__numbers span:nth-child(1) { background: var(--a1); transform: rotate(-4deg); }
.landing__numbers span:nth-child(2) { background: var(--a2); transform: rotate(3deg); }
.landing__numbers span:nth-child(3) { background: var(--a3); transform: rotate(-2deg); }
.landing__numbers span:nth-child(4) { background: var(--a4); transform: rotate(5deg); }
.landing__host { margin-top: 18px; text-align: center; color: var(--muted); }
.footer { padding: 18px 0; color: var(--muted); font-size: .9rem; }
@media (max-width: 820px) {
  .landing__main { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
}

/* ---------- game screen (host + overlay) ---------- */
.game { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.stage { display: grid; align-content: center; gap: 28px; padding: 12px 0 40px; }
.meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 500; flex-wrap: wrap; }
.meta__cat { background: var(--panel); color: var(--ink); padding: 6px 14px; border-radius: 999px; }
.question { font-size: clamp(1.7rem, 3.6vw, 3rem); font-weight: 800; line-height: 1.15; margin: 0; letter-spacing: -.01em; max-width: 28ch; }
.qimg { max-height: 30vh; max-width: min(460px, 100%); border-radius: var(--radius-sm); box-shadow: 0 0 0 6px var(--stage-2); justify-self: start; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  position: relative; display: flex; align-items: center; gap: 16px; min-height: 92px; padding: 16px 20px;
  border-radius: var(--radius-lg); border: 0; color: var(--dark); font-weight: 700; font-size: clamp(1.1rem, 2vw, 1.6rem);
  text-align: start; transition: opacity .25s ease, transform .25s ease, filter .25s ease;
}
.tile--1 { background: var(--a1); } .tile--2 { background: var(--a2); }
.tile--3 { background: var(--a3); } .tile--4 { background: var(--a4); }
.tile__num {
  flex: none; display: grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%;
  background: var(--dark); color: var(--ink); font-weight: 900; font-size: 1.25em;
}
.tile__text { flex: 1; overflow-wrap: anywhere; }
.tile__count { flex: none; font-weight: 900; font-size: 1.2em; background: rgba(27, 20, 70, .18); padding: 4px 12px; border-radius: 999px; }
.tile.is-wrong { background: var(--panel); color: var(--muted); }
.tile.is-wrong .tile__num { background: var(--stage); color: var(--muted); }
.tile.is-wrong .tile__count { background: var(--stage); color: var(--ink); }
.tile.is-correct { transform: scale(1.02); box-shadow: 0 0 0 5px var(--ink); }

.timer { display: flex; align-items: center; gap: 16px; }
.timer__track { flex: 1; height: 14px; border-radius: 999px; background: var(--panel); overflow: hidden; }
.timer__bar { height: 100%; background: var(--ink); transform-origin: left center; border-radius: inherit; }
[dir="rtl"] .timer__bar { transform-origin: right center; }
.timer__bar.is-urgent { background: var(--a1); }
.timer__num { font-weight: 900; font-size: 1.6rem; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.progress { color: var(--muted); font-weight: 500; }

.fastest { color: var(--muted); font-size: 1.1rem; }

/* lobby */
.lobby { display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: center; }
.lobby__join { display: grid; gap: 10px; justify-items: start; }
.lobby__url { font-size: 1.5rem; font-weight: 700; direction: ltr; }
.lobby__code { font-size: clamp(3.4rem, 9vw, 6.5rem); font-weight: 900; letter-spacing: .12em; line-height: 1; direction: ltr; }
.lobby__qr { width: 220px; height: 220px; border-radius: var(--radius-lg); background: #fff; padding: 10px; }
.lobby__players { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; min-height: 120px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--panel); font-weight: 700; animation: pop .25s ease;
}
.pill.is-off { opacity: .45; }
.pill__lang { font-size: .75rem; color: var(--muted); font-weight: 500; }
.pill__x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 999px; }
.pill__x:hover { background: var(--line); color: var(--ink); }
.lobby__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.count { font-size: 1.4rem; font-weight: 800; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (max-width: 820px) {
  .lobby { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
}

/* leaderboard */
.board { display: grid; gap: 8px; max-width: 760px; width: 100%; margin-inline: auto; padding: 0; list-style: none; }
.board__row {
  display: grid; grid-template-columns: 3ch 1fr auto; align-items: center; gap: 16px;
  padding: 14px 20px; border-radius: var(--radius-sm); background: var(--stage-2); border: 1px solid var(--line);
  font-size: 1.25rem; font-weight: 700;
}
.board__row.is-first { background: var(--gold); color: var(--dark); border-color: transparent; }
.board__rank { font-weight: 900; color: var(--muted); }
.board__row.is-first .board__rank { color: var(--dark); }
.board__score { font-variant-numeric: tabular-nums; }
.board__streak { font-size: .85rem; font-weight: 500; opacity: .8; margin-inline-start: 8px; }
.heading { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 900; margin: 0; text-align: center; }

/* podium */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; max-width: 760px; margin: 0 auto; width: 100%; }
.podium__step { display: grid; justify-items: center; gap: 10px; text-align: center; }
.podium__name { font-weight: 800; font-size: 1.3rem; overflow-wrap: anywhere; }
.podium__score { color: var(--muted); }
.podium__block { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; display: grid; place-items: center; font-size: 3rem; font-weight: 900; color: var(--dark); }
.podium__step--1 .podium__block { height: 200px; background: var(--gold); }
.podium__step--2 .podium__block { height: 140px; background: var(--a2); }
.podium__step--3 .podium__block { height: 100px; background: var(--a1); }
.podium__step--1 { order: 2; } .podium__step--2 { order: 1; } .podium__step--3 { order: 3; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hostbar { display: flex; gap: 12px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* setup */
.setup { display: grid; gap: 22px; max-width: 760px; margin: 0 auto 60px; }
.setup h1 { margin: 0; font-size: 2rem; }
.setup__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.setup fieldset { border: 0; padding: 0; margin: 0; }
.setup legend { color: var(--muted); margin-bottom: 8px; padding: 0; }
@media (max-width: 640px) { .setup__row { grid-template-columns: 1fr; } }

.links { display: grid; gap: 8px; }
.linkrow { display: flex; gap: 8px; align-items: center; }
.linkrow code { flex: 1; background: var(--stage); padding: 10px 12px; border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; font-size: .9rem; }

/* ---------- player (phone) ---------- */
.phone { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.phone .topbar { padding: 12px 0; }
.phone__body { display: grid; align-content: center; gap: 18px; padding-bottom: 24px; }
.phone__q { font-size: 1.3rem; font-weight: 700; margin: 0; }
.phone .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
.phone .tile { min-height: 120px; flex-direction: column; align-items: flex-start; justify-content: space-between; font-size: 1.05rem; padding: 14px; cursor: pointer; }
.phone .tile__num { font-size: 1.4rem; }
.phone .tile:disabled { cursor: default; }
.phone .tile.is-picked { box-shadow: 0 0 0 5px var(--ink); }
.phone .tile.is-dim { opacity: .3; }
.phone .qimg { max-height: 22vh; justify-self: center; }
.status { text-align: center; display: grid; gap: 10px; justify-items: center; }
.status__big { font-size: 2.4rem; font-weight: 900; margin: 0; line-height: 1.1; }
.status__sub { color: var(--muted); font-size: 1.15rem; margin: 0; }
.status__points { font-size: 1.6rem; font-weight: 800; }
.status--good .status__big { color: var(--good); }
.status--bad .status__big { color: var(--bad); }
.badge { display: inline-block; background: var(--panel); padding: 6px 14px; border-radius: 999px; font-weight: 700; }
.me { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.me__score { color: var(--muted); font-variant-numeric: tabular-nums; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--panel); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast + offline ---------- */
.toast {
  position: fixed; inset-inline: 16px; bottom: 16px; margin-inline: auto; max-width: 480px; padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--dark); font-weight: 600; transform: translateY(150%); transition: transform .25s ease; z-index: 50;
}
.toast.is-on { transform: translateY(0); }
.offline { position: fixed; top: 0; inset-inline: 0; background: var(--a1); color: var(--dark); text-align: center; padding: 8px; font-weight: 700; z-index: 60; }

/* ---------- OBS overlay: transparent page, compact card ---------- */
body.overlay { background: transparent; }
.ov { position: fixed; bottom: 24px; inset-inline-start: 24px; width: min(560px, calc(100vw - 48px)); display: grid; gap: 10px; }
.ov--right { inset-inline-start: auto; inset-inline-end: 24px; }
.ov__card { background: rgba(27, 20, 70, .94); border: 2px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 12px; }
.ov__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; color: var(--muted); }
.ov .question { font-size: 1.35rem; max-width: none; }
.ov .tiles { gap: 8px; }
.ov .tile { min-height: 54px; padding: 8px 12px; font-size: 1rem; border-radius: 14px; gap: 10px; }
.ov .tile__num { font-size: 1rem; }
.ov .qimg { max-height: 120px; }
.ov .timer__track { height: 8px; }
.ov .timer__num { font-size: 1.1rem; }
.ov .board__row { padding: 8px 12px; font-size: 1rem; }
.ov__join { display: flex; align-items: center; gap: 14px; }
.ov__join img { width: 96px; height: 96px; border-radius: 12px; background: #fff; padding: 6px; }
.ov__code { font-size: 2.2rem; font-weight: 900; letter-spacing: .1em; direction: ltr; }

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

.subgroup { display: grid; gap: 8px; margin-bottom: 14px; }
.subgroup > strong { font-size: .9rem; opacity: .8; }
.chip--sub span { font-size: .9rem; padding-block: 6px; }
.qimg { background: #fff; border-radius: 16px; padding: 16px; }
.tile--mine { outline: 4px solid var(--ink); }
.answer-card { display: grid; gap: 8px; width: min(340px, 100%); text-align: center; }
.answer-card small { opacity: .75; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.sfx { background: var(--panel); border: 0; border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; color: inherit; }
.sfx:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.board--mini { gap: 6px; max-width: 420px; margin-top: 14px; }
.board--mini .board__row { padding: 8px 12px; font-size: 1rem; }
.board__row.is-me { outline: 3px solid var(--ink); }
.board__row em { font-style: normal; opacity: .7; font-size: .85em; }
.board__gap { text-align: center; opacity: .5; line-height: .6; }
.delta { font-weight: 800; font-size: 1.05rem; }
.delta--up { color: var(--good); }
.delta--down { color: var(--bad); }
.rules { border: 0; border-radius: 20px; padding: 24px; max-width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); }
.rules::backdrop { background: rgba(10, 6, 40, .7); }
.rules h2 { margin-top: 0; }
.rules__list { padding-inline-start: 1.2em; display: grid; gap: 10px; }
.rules__example { background: var(--stage); padding: 10px 14px; border-radius: 12px; font-weight: 700; }
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; opacity: .85; padding: 8px 0; }
.me-result { font-weight: 800; font-size: 1.15rem; padding: 10px 16px; border-radius: 12px; background: var(--panel); }
.me-result.is-good { color: var(--good); }
.me-result.is-bad { color: var(--bad); }
.tile.is-mine { outline: 5px solid var(--ink); outline-offset: 2px; }
button.tile { cursor: pointer; border: 0; font: inherit; color: inherit; text-align: start; }
.tile.is-right { outline: 5px solid var(--good); outline-offset: 2px; }

/* Quiz pages and footer links (internal linking for search engines) */
.quiz { max-width: 720px; margin: 0 auto; padding: 8px 0 24px; }
.quiz__title { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.15; margin: 12px 0; }
.quiz__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 28px; }
.quiz__more h2, .footer--links h2 { font-size: 1.05rem; color: var(--muted); margin: 0 0 10px; }
.quiz__feedback { text-align: center; margin-top: 18px; }
.quiz .tile[disabled] { cursor: default; }
.linklist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 10px; }
.linklist a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; }
.linklist a:hover, .linklist a:focus-visible { background: var(--panel); }
.linklist small { color: var(--muted); }
.linklist--big a { padding: 12px 18px; font-weight: 700; }
.footer--links { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
.footer__row a { color: var(--muted); }
.landing .quiz__more { grid-column: 1 / -1; }
.linklist--plain li { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; }
.quiz__start h2, .quiz > section > h2 { font-size: 1.05rem; color: var(--muted); margin: 22px 0 10px; }
.sample { padding-inline-start: 1.2em; display: grid; gap: 10px; }
.sample li span { display: block; color: var(--muted); }
.sample img { vertical-align: middle; border-radius: 6px; margin-inline-end: 8px; }
.footer__langs { margin: 14px 0 6px; } .footer__langs a { color: var(--muted); } .footer__langs a[aria-current] { color: var(--ink); font-weight: 700; }
