:root {
  --bg: #fff8ef;
  --panel: #ffffff;
  --ink: #2a2135;
  --muted: #7a6f86;
  --line: #eadfd2;
  --brand: #ff5a5f;
  --brand-2: #7c5cff;
  --ok: #1fa86b;
  --bad: #e5484d;
  --warn: #f5a524;
  --es: #e5484d;
  --en: #3e63dd;
  --ru: #1fa86b;
  --side-a: #7c5cff;
  --side-b: #f76b15;
  --radius: 16px;
  --shadow: 0 2px 0 #eadfd2, 0 8px 24px rgba(42, 33, 53, 0.06);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.hidden { display: none !important; }

/* ---------- primitives ---------- */

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.06s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.brand { background: var(--brand); }
.btn.violet { background: var(--brand-2); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn.big { padding: 14px 22px; font-size: 18px; }

.input, select.input, textarea.input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.input:focus { border-color: var(--brand-2); }
textarea.input { resize: vertical; min-height: 64px; }
label.field { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.center { text-align: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800;
  background: #f3ece3;
}
.pill.es { background: #fde3e3; color: #a3262a; }
.pill.en { background: #e1e8fd; color: #26409a; }
.pill.ru { background: #d9f3e6; color: #16704a; }
.timer { font-variant-numeric: tabular-nums; font-weight: 900; }
.timer.low { color: var(--bad); }
.big-emoji { font-size: 56px; line-height: 1; }
.kbd { font-family: ui-monospace, monospace; background: #f3ece3; padding: 2px 8px; border-radius: 8px; }

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

.home { max-width: 520px; margin: 0 auto; padding: 32px 16px; }
.logo { font-size: 44px; font-weight: 900; letter-spacing: -1px; }
.logo span { color: var(--brand); }
.tagline { font-size: 17px; margin-top: 4px; }
.lang-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.lang-pair .arrow { padding-bottom: 12px; font-size: 22px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-weight: 900; text-align: center; }

/* ---------- room shell ---------- */

.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .logo { font-size: 22px; margin-right: auto; }
.room-code { cursor: pointer; }
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px;
  padding: 16px; max-width: 1320px; margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.stage { display: grid; gap: 16px; align-content: start; min-width: 0; }
.sidebar { display: grid; gap: 16px; align-content: start; }

.mode-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mode-bar h2 { font-size: 22px; }
.mode-bar .spacer { flex: 1; }

.players { display: grid; gap: 6px; }
.player {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 12px;
}
.player.me { background: #f6f1ff; }
.player.off { opacity: 0.45; }
.player .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; color: #fff;
}
.player .name { font-weight: 800; display: flex; gap: 6px; align-items: center; }
.player .langs { font-size: 12px; color: var(--muted); }
.player .score { font-weight: 900; font-size: 18px; }

.clock-bars { display: grid; gap: 8px; }
.clock-bar { display: grid; grid-template-columns: 70px 1fr 48px; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; }
.clock-bar .track { height: 10px; background: #f3ece3; border-radius: 99px; overflow: hidden; }
.clock-bar .fill { height: 100%; border-radius: 99px; transition: width 0.4s; }
.clock-bar.active .track { box-shadow: 0 0 0 2px var(--warn); }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { border: 0; background: transparent; font-weight: 800; padding: 4px 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: #f3ece3; color: var(--ink); }
.feed { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; font-size: 14px; }
.feed .plus { color: var(--ok); font-weight: 900; }
.feed .minus { color: var(--bad); font-weight: 900; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; }

.correction { border: 2px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; font-size: 14px; }
.correction del { color: var(--bad); }
.correction ins { color: var(--ok); text-decoration: none; font-weight: 800; }

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

.modes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mode-card {
  display: grid; gap: 8px; align-content: start; text-align: left; cursor: pointer;
  border: 2px solid var(--line); background: #fff; border-radius: var(--radius); padding: 16px;
  transition: transform 0.1s, border-color 0.15s;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.mode-card:disabled { cursor: default; transform: none; border-color: var(--line); }
.mode-card .icon { font-size: 36px; }
.mode-card h3 { font-size: 18px; }
.mode-card p { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- common game bits ---------- */

.banner {
  border-radius: var(--radius); padding: 16px 20px; background: linear-gradient(135deg, #7c5cff, #ff5a5f);
  color: #fff; font-weight: 800; font-size: 18px;
}
.banner.soft { background: #f3ece3; color: var(--ink); }
.list { display: grid; gap: 8px; }
.list-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; flex-wrap: wrap; }

/* taboo */
.taboo-card { background: #fff; border: 4px solid var(--brand-2); border-radius: 20px; padding: 20px; max-width: 360px; margin: 0 auto; text-align: center; }
.taboo-card .word { font-size: 34px; font-weight: 900; }
.taboo-card .forbidden { display: grid; gap: 4px; margin-top: 12px; padding-top: 12px; border-top: 2px dashed var(--line); }
.taboo-card .forbidden span { color: var(--bad); font-weight: 800; font-size: 18px; }

/* pictionary */
.canvas-wrap { position: relative; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; aspect-ratio: 4 / 3; max-width: 100%; touch-action: none; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.hint { font-family: ui-monospace, monospace; font-size: 26px; letter-spacing: 2px; font-weight: 800; }
.pic-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; }
@media (max-width: 700px) { .pic-grid { grid-template-columns: minmax(0, 1fr); } }
.guess-log { max-height: 320px; overflow-y: auto; display: grid; gap: 4px; font-size: 14px; }

/* differences */
.diff-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; }
@media (max-width: 760px) { .diff-layout { grid-template-columns: minmax(0, 1fr); } }
.scene { display: grid; gap: 4px; }
.scene-grid { display: grid; gap: 6px; }
.scene-label { display: grid; place-items: center; font-weight: 900; color: var(--muted); font-size: 13px; }
.cell {
  aspect-ratio: 1; background: #fff; border-radius: 12px; border: 3px solid var(--line); cursor: pointer;
  display: grid; place-items: center; position: relative; padding: 4px; overflow: hidden;
}
.cell .items { font-size: clamp(14px, 3.2vw, 30px); line-height: 1; text-align: center; }
.cell svg { width: 70%; height: 70%; }
.cell svg.small { width: 40%; height: 40%; }
.cell.mine { border-color: var(--side-a); box-shadow: inset 0 0 0 3px var(--side-a); }
.cell.theirs::after { content: '👀'; position: absolute; top: 2px; right: 4px; font-size: 14px; }
.cell.side-b.mine { border-color: var(--side-b); box-shadow: inset 0 0 0 3px var(--side-b); }
.cell.found { border-color: var(--ok); background: #e5f7ee; }
.cell.found::before { content: '✓'; position: absolute; top: 0; left: 6px; color: var(--ok); font-weight: 900; }
.cell.diff { border-color: var(--warn); background: #fff4dc; }
.cell.shake { animation: shake 0.4s; border-color: var(--bad); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.vocab { font-size: 14px; display: grid; gap: 10px; }
.vocab h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
.vocab .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.vocab .chips span { background: #f3ece3; padding: 2px 8px; border-radius: 8px; }
.scenes-end { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .scenes-end { grid-template-columns: 1fr; } }

/* escape */
.locks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.lock { display: grid; gap: 10px; align-content: start; border: 3px solid var(--line); }
.lock.solved { border-color: var(--ok); background: #f1fbf6; }
.lock.shake { animation: shake 0.4s; border-color: var(--bad); }
.lock h3 { display: flex; gap: 8px; align-items: center; }
.clue { background: #fffbe8; border: 2px dashed var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 17px; font-weight: 700; display: grid; gap: 6px; }
.clue.native { background: #f3ece3; border-color: var(--line); font-weight: 600; font-size: 14px; }
.shelf { background: #c89f6f; border-radius: 10px; padding: 8px; display: flex; flex-wrap: wrap; gap: 2px; font-size: 26px; box-shadow: inset 0 -6px 0 #9c7448; }
.digits { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 6px; }
.digits input { text-align: center; font-size: 22px; font-weight: 900; }
.wires { display: grid; gap: 8px; }
.wire { height: 22px; border-radius: 99px; border: 2px solid rgba(0, 0, 0, 0.2); cursor: pointer; position: relative; }
.wire.cut { background-image: linear-gradient(90deg, transparent 46%, var(--bg) 46%, var(--bg) 54%, transparent 54%) !important; opacity: 0.6; cursor: default; }
.clock-ctl { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.clock-face { width: 120px; height: 120px; }

/* truth or lie / telephone */
.statement { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; border: 2px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.statement .num { font-size: 22px; font-weight: 900; color: var(--brand-2); }
.statement.lie { border-color: var(--bad); background: #fff1f1; }
.statement.truth { border-color: var(--ok); }
.statement .text { font-size: 18px; font-weight: 700; }
.vote-btn { text-align: left; width: 100%; }
.chain { display: grid; gap: 8px; }
.chain-step { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; animation: pop 0.3s; }
.chain-step .who { font-size: 12px; color: var(--muted); font-weight: 800; }
.chain-step .txt { font-size: 17px; font-weight: 700; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }

/* pronunciation */
.phrase { font-size: 28px; font-weight: 900; text-align: center; padding: 20px; line-height: 1.3; }
.stars { display: flex; gap: 6px; justify-content: center; }
.stars button { font-size: 34px; background: none; border: 0; cursor: pointer; filter: grayscale(1); opacity: 0.5; transition: transform 0.1s; }
.stars button.on, .stars button:hover { filter: none; opacity: 1; transform: scale(1.1); }
.rec-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.meter { height: 14px; background: #f3ece3; border-radius: 99px; overflow: hidden; }
.meter div { height: 100%; background: linear-gradient(90deg, var(--bad), var(--warn), var(--ok)); }

/* ---------- modal & toasts ---------- */

.modal-backdrop { position: fixed; inset: 0; background: rgba(42, 33, 53, 0.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 20px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; display: grid; gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.flashcard { border: 3px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; display: grid; gap: 10px; }
.flashcard .front { font-size: 22px; font-weight: 800; }
.flashcard .back { font-size: 24px; font-weight: 900; color: var(--ok); }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 800; animation: pop 0.2s; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
