/* ============================================================================
   Trivia — "How well do we know each other"
   Mobile-first, playful, warm. One stylesheet, no build.
   ========================================================================== */

:root {
  --bg-1: #ffe9f0;
  --bg-2: #eae4ff;
  --bg-3: #e0f4ff;
  --card: #ffffff;
  --ink: #2b2140;
  --ink-soft: #6b6280;
  --line: #ece7f5;
  --brand: #ff4d8d;
  --brand-ink: #ffffff;
  --accent: #7c5cff;
  --good: #1fb877;
  --bad: #ff5a5f;
  --gold: #f6b93b;
  --deybi: #3d9bff;
  --ionela: #ff5fa2;
  --deybi-text: #1f6fc4;
  --ionela-text: #d63d84;
  --radius: 20px;
  --shadow: 0 18px 40px -18px rgba(70, 40, 90, .35);
  --shadow-sm: 0 8px 20px -12px rgba(70, 40, 90, .35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-1: #2a1d33;
    --bg-2: #241d3d;
    --bg-3: #1c2740;
    --card: #2b2440;
    --ink: #f4eefe;
    --ink-soft: #b6acce;
    --line: #3b3357;
    --deybi-text: #8ec8ff;
    --ionela-text: #ff9ac6;
    --shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(150deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) 18px 40px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

[x-cloak] { display: none !important; }

/* ---- Header --------------------------------------------------------------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .heart { color: var(--brand); }

.lang-switch { display: flex; gap: 6px; }
.lang-switch button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, background .12s, color .12s;
}
.lang-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.lang-switch button:active { transform: scale(.94); }

/* ---- Screens ------------------------------------------------------------- */
.screen { flex: 1; display: flex; flex-direction: column; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 5vw, 28px);
}
.card + .card { margin-top: 14px; }

h1.title { font-size: clamp(1.5rem, 6vw, 2rem); line-height: 1.15; margin-bottom: 6px; }
p.lead { color: var(--ink-soft); margin-bottom: 18px; }
h2.section { font-size: 1.15rem; margin-bottom: 12px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px 18px;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .12s;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn.accent { background: var(--accent); }
.btn.good { background: var(--good); }
.btn + .btn { margin-top: 10px; }

.row { display: flex; gap: 10px; }
.row .btn { margin-top: 0; }

/* ---- Block list ------------------------------------------------------- */
.block {
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.block:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.block:active { transform: scale(.98); }
.block + .block { margin-top: 10px; }
.block .emoji { font-size: 1.8rem; }
.block .b-title { font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.b-mode {
  font-size: .68rem; font-weight: 800; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  color: var(--accent); border: 1px solid var(--accent);
}
.block .b-meta { color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }
.block .cover { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; }

/* ---- Character picker ------------------------------------------------- */
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 18px;
  padding: 20px 12px;
  cursor: pointer;
  text-align: center;
  transition: transform .14s, border-color .14s;
}
.who:active { transform: scale(.96); }
.who[data-who="deybi"].selected { border-color: var(--deybi); }
.who[data-who="ionela"].selected { border-color: var(--ionela); }
.who[disabled] { opacity: .4; cursor: not-allowed; }
.who .avatar {
  display: block;
  width: 76px; height: 76px; border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 10px;
  border: 3px solid var(--line);
  background: var(--line);
}
.who .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.who[data-who="deybi"] .avatar { border-color: var(--deybi); }
.who[data-who="ionela"] .avatar { border-color: var(--ionela); }
.who .name { display: block; font-weight: 800; font-size: 1rem; }
.who[data-who="deybi"] .name { color: var(--deybi-text); }
.who[data-who="ionela"] .name { color: var(--ionela-text); }

/* round avatar reused in lobby rows and result cards */
.avatar-sm {
  display: block;
  width: 34px; height: 34px; border-radius: 50%;
  overflow: hidden; flex: none; border: 2px solid var(--line); background: var(--line);
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-row[data-who="deybi"] .avatar-sm { border-color: var(--deybi); }
.player-row[data-who="ionela"] .avatar-sm { border-color: var(--ionela); }

.avatar-md {
  width: 56px; height: 56px; border-radius: 50%; display: block;
  overflow: hidden; margin: 0 auto 8px; border: 3px solid var(--line); background: var(--line);
}
.avatar-md img { width: 100%; height: 100%; object-fit: cover; display: block; }
.score-card[data-who="deybi"] .avatar-md { border-color: var(--deybi); }
.score-card[data-who="ionela"] .avatar-md { border-color: var(--ionela); }

/* ---- Inputs --------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 6px; color: var(--ink-soft); }
.input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 1.1rem;
}
.input.code {
  text-transform: uppercase;
  letter-spacing: .4em;
  text-align: center;
  font-weight: 800;
  font-size: 1.6rem;
}
.input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---- Lobby --------------------------------------------------------- */
.code-display {
  text-align: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.code-display .k { font-size: .8rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.code-display .v { font-size: 2.6rem; font-weight: 900; letter-spacing: .3em; margin-top: 4px; }

.players { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 18px; }
.player-row {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.player-row .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-soft); flex: none; }
.player-row.ready .dot { background: var(--good); }
.player-row .pname { font-weight: 800; flex: 1; }
.player-row[data-who="deybi"] .pname { color: var(--deybi-text); }
.player-row[data-who="ionela"] .pname { color: var(--ionela-text); }
.player-row .pstate { font-size: .85rem; color: var(--ink-soft); }

/* ---- Question ----------------------------------------------------- */
.q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.q-progress { font-weight: 800; color: var(--ink-soft); font-size: .9rem; }
.q-score { font-weight: 900; }

.timer-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 18px; }
.timer-fill { height: 100%; background: linear-gradient(90deg, var(--good), var(--gold)); width: 100%; transition: width 1s linear; }
.timer-fill.low { background: linear-gradient(90deg, var(--gold), var(--bad)); }

.q-image { width: 100%; border-radius: 14px; margin-bottom: 14px; max-height: 240px; object-fit: cover; }
.q-text { font-size: clamp(1.2rem, 5vw, 1.5rem); font-weight: 800; line-height: 1.25; margin-bottom: 18px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 16px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.option:active { transform: scale(.98); }
.option.picked { border-color: var(--accent); }
.option.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, var(--card)); }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, var(--card)); }
.option:disabled { cursor: default; }

/* ---- Subject tag (whose question is this) ---------------------- */
.subject-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  font-size: .8rem; font-weight: 800;
  border: 1.5px solid var(--line);
  margin-bottom: 14px;
}
.subject-tag[data-subject="deybi"]  { border-color: var(--deybi);  color: var(--deybi-text); }
.subject-tag[data-subject="ionela"] { border-color: var(--ionela); color: var(--ionela-text); }
.subject-tag[data-subject="both"]   { border-color: var(--accent); color: var(--accent); }
.subject-avatars { display: inline-flex; }
.subject-avatars img {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--card); background: var(--line);
}
.subject-avatars img + img { margin-left: -8px; }

.brk-subject {
  display: inline-block; font-size: .68rem; font-weight: 800;
  padding: 1px 7px; border-radius: 999px; margin-right: 6px;
  border: 1px solid var(--line); vertical-align: middle;
}
.brk-subject[data-subject="deybi"]  { color: var(--deybi-text);  border-color: var(--deybi); }
.brk-subject[data-subject="ionela"] { color: var(--ionela-text); border-color: var(--ionela); }
.brk-subject[data-subject="both"]   { color: var(--accent); border-color: var(--accent); }

/* ---- Reveal reactions ------------------------------------------- */
.reaction { text-align: center; padding: 8px 0 4px; }
.reaction .face { font-size: 3.4rem; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
.reaction .msg { font-weight: 900; font-size: 1.3rem; margin-top: 4px; }
.reaction.good .msg { color: var(--good); }
.reaction.bad .msg { color: var(--bad); }
.reaction .pts { font-weight: 800; color: var(--ink-soft); margin-top: 2px; }
@keyframes pop { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: scale(1) rotate(0); } }

.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* ---- Waiting ---------------------------------------------------- */
.waiting { text-align: center; padding: 30px 0; }
.waiting .spin {
  width: 46px; height: 46px; margin: 0 auto 16px;
  border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Results -------------------------------------------------- */
.winner-banner { text-align: center; margin-bottom: 18px; }
.winner-banner .trophy { font-size: 3.2rem; }
.winner-banner .who-won { font-size: 1.5rem; font-weight: 900; margin-top: 4px; }

.score-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.score-card { border-radius: 16px; padding: 16px; text-align: center; border: 2px solid var(--line); }
.score-card[data-who="deybi"] { border-color: var(--deybi); }
.score-card[data-who="ionela"] { border-color: var(--ionela); }
.score-card.win { background: color-mix(in srgb, var(--gold) 16%, var(--card)); }
.score-card .sc-name { font-weight: 800; }
.score-card[data-who="deybi"] .sc-name { color: var(--deybi-text); }
.score-card[data-who="ionela"] .sc-name { color: var(--ionela-text); }
.score-card .sc-val { font-size: 2.2rem; font-weight: 900; }
.score-card .sc-sub { font-size: .8rem; color: var(--ink-soft); }

.breakdown { display: flex; flex-direction: column; gap: 8px; }
.brk-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.brk-q { font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.brk-players { display: flex; gap: 16px; font-size: .85rem; }
.brk-players span { display: flex; align-items: center; gap: 5px; }
.mark.ok { color: var(--good); }
.mark.no { color: var(--bad); }

/* ---- Misc ---------------------------------------------------- */
.error-box {
  background: color-mix(in srgb, var(--bad) 14%, var(--card));
  border: 1.5px solid var(--bad);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.hint { color: var(--ink-soft); font-size: .85rem; text-align: center; margin-top: 12px; }
.spacer { flex: 1; }
.center { text-align: center; }
.mt { margin-top: 14px; }
footer.foot { text-align: center; color: var(--ink-soft); font-size: .75rem; margin-top: 20px; }
footer.foot a { color: inherit; }
