﻿:root {
  --bg: #fff8dc;
  --paper: #ffffff;
  --ink: #171717;
  --muted: #5e6673;
  --line: #e8dfc8;
  --brand: #ff3131;
  --brand-dark: #b41420;
  --honey: #ffd21f;
  --mint: #20d64b;
  --blue: #1688ff;
  --shadow: 0 18px 50px rgba(28, 31, 38, 0.13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(32, 214, 75, 0.22), transparent 30rem),
    radial-gradient(circle at top right, rgba(22, 136, 255, 0.2), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(255, 210, 31, 0.34), transparent 26rem),
    linear-gradient(135deg, #fffdf2 0%, var(--bg) 56%, #ffeec7 100%);
  font-family: Arial, Helvetica, sans-serif;
}
body.home-route {
  background:
    linear-gradient(90deg, rgba(255, 248, 220, 0.95) 0%, rgba(255, 248, 220, 0.78) 42%, rgba(255, 248, 220, 0.32) 100%),
    url("assets/home-table-games-bg.jpg") center center / cover fixed no-repeat;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.66);
  border-bottom: 1px solid rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(10px);
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
}
.logo-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(15, 18, 24, 0.22);
}
.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topbar-status,
.topbar-code,
.topbar-resync,
.topbar-install,
.topbar-reset {
  margin: 0;
  border: 1px solid rgba(22, 136, 255, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  color: #0d5aad;
  background: rgba(255, 255, 255, 0.84);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}
.topbar-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  background: #171717;
  border-color: #171717;
}
.topbar-install img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}
.topbar-install:hover {
  background: #333;
  border-color: #333;
}
.topbar-status {
  display: none;
  pointer-events: none;
}
.topbar-code {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
.topbar-resync {
  color: #fff;
  background: #20b84d;
  border-color: #20b84d;
}
.topbar-reset:hover {
  border-color: rgba(255, 49, 49, 0.32);
  color: var(--brand-dark);
}
.screen {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) 0 56px;
}
.home-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
  gap: clamp(24px, 5vw, 70px);
  align-items: center;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 16px;
  font-size: clamp(2.7rem, 9vw, 6.7rem);
  line-height: 0.9;
  letter-spacing: 0;
}
h2 { margin-bottom: 12px; font-size: clamp(1.45rem, 3vw, 2.6rem); line-height: 1; }
p, .lead { color: var(--muted); font-size: 1.05rem; line-height: 1.58; }
.hero-copy p { max-width: 660px; font-size: clamp(1.08rem, 2vw, 1.35rem); }
body.home-route .hero-copy {
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 250, 242, 0.68);
  backdrop-filter: blur(5px);
}

.home-actions { display: grid; gap: 16px; }
.big-action {
  display: flex;
  min-height: 148px;
  flex-direction: column;
  justify-content: center;
  border-radius: 14px;
  padding: 24px;
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.big-action:hover { transform: translateY(-3px); box-shadow: 0 24px 60px rgba(84, 47, 24, 0.2); }
.big-action span { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 900; }
.big-action small { margin-top: 8px; font-size: 1rem; font-weight: 800; opacity: 0.86; }
.big-action.create { background: linear-gradient(135deg, var(--brand), #ff8a22); }
.big-action.join { background: linear-gradient(135deg, var(--blue), var(--mint)); }
.game-preview {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  background: rgba(255, 250, 242, 0.9);
  backdrop-filter: blur(8px);
}
.game-badge {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 8px 12px;
  color: #63370b;
  background: #ffe0a3;
  font-weight: 900;
}
.site-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.site-counter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  padding: 9px 13px;
  color: #0d5aad;
  background: #e7f4ff;
  font-weight: 900;
}
.site-counter strong {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
}
.site-counter span {
  font-size: 0.95rem;
}
.visits-counter {
  color: #63370b;
  background: #fff0a7;
}
.visits-counter strong {
  background: var(--honey);
  color: #3f2a00;
}

.split-screen, .host-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr); gap: 24px; align-items: start; }
.form-screen { display: grid; place-items: center; }
.access-screen {
  display: grid;
  min-height: calc(100vh - 92px);
  place-items: center;
}
.access-card h1 {
  font-size: clamp(2.4rem, 8vw, 4.4rem);
}
.form-card, .panel, .question-card, .answer-box, .code-panel, .round-result {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: var(--shadow);
}
.game-switcher {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(255, 250, 242, 0.86);
  box-shadow: var(--shadow);
}
.game-switcher .panel-heading {
  margin-bottom: 10px;
}
.game-switcher h2 {
  font-size: 1.1rem;
}
.form-card { width: min(520px, 100%); padding: clamp(20px, 4vw, 34px); }
.field { display: grid; gap: 8px; margin-bottom: 16px; font-weight: 900; }
.field span { color: var(--ink); }
input, select {
  width: 100%;
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font-size: 1.08rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(185, 71, 45, 0.12); }
.primary-button, .secondary-button, .danger-button {
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 900;
}
.primary-button { color: #fff; background: var(--brand); box-shadow: 0 14px 30px rgba(255, 49, 49, 0.22); }
.secondary-button { color: #113f89; background: #dff0ff; }
.danger-button { color: #fff; background: #22252b; }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { cursor: not-allowed; opacity: 0.46; box-shadow: none; }
.start-game-button {
  flex: 1 1 220px;
}
.start-game-button:not(:disabled) {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #20b84d);
  box-shadow: 0 14px 30px rgba(22, 136, 255, 0.22);
}
.full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

.hidden { display: none !important; }

.game-icons {
  display: grid;
  grid-template-columns: repeat(9, minmax(58px, 1fr));
  gap: 10px;
  margin: 6px 0 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.game-icon-button {
  display: grid;
  min-width: 0;
  min-height: 58px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(28, 31, 38, 0.08);
}
.game-icon-button:hover {
  border-color: rgba(255, 49, 49, 0.5);
}
.game-icon-button.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
  box-shadow: 0 12px 26px rgba(255, 49, 49, 0.2);
}
.memory-game-icon {
  display: grid;
  width: min(38px, 72%);
  aspect-ratio: 1;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.memory-game-icon-square {
  border-radius: 5px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}
.game-icon-button.active .memory-game-icon-square {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: -1px;
}

.code-panel {
  display: grid;
  gap: 4px;
  margin: 20px 0;
  padding: 22px;
  text-align: center;
}
.code-panel span { color: var(--muted); font-weight: 900; text-transform: uppercase; }
.code-panel strong { font-size: clamp(3rem, 10vw, 5rem); line-height: 1; letter-spacing: 0; }
.code-panel.small { min-width: 140px; margin: 0; padding: 14px; }
.code-panel.small strong { font-size: 2.2rem; }

.panel { padding: 20px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 1.35rem; }
.panel-heading span { color: var(--brand); font-weight: 900; }
.player-list, .answers-list, .ranking-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.player-list li, .answers-list li, .ranking-list li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
.player-list li, .ranking-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ranking-list { counter-reset: rank; }
.ranking-list li::before {
  counter-increment: rank;
  content: counter(rank);
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}
.ranking-list li { justify-content: flex-start; }
.ranking-list strong { margin-left: auto; }

.round-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.host-title-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(28, 31, 38, 0.08);
}
.host-title-band span {
  color: var(--brand-dark);
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  font-weight: 900;
  text-transform: uppercase;
}
.host-title-band strong {
  color: var(--muted);
  font-size: 0.98rem;
  white-space: nowrap;
}
.player-title-band {
  margin-bottom: 12px;
}
.pill { border-radius: 999px; padding: 10px 14px; color: #fff; background: var(--blue); font-weight: 900; }
.question-card { margin-bottom: 16px; padding: 22px; }
.question-card span { color: var(--brand); font-weight: 900; text-transform: uppercase; }
.question-card p, .current-question { margin: 10px 0 0; color: var(--ink); font-size: clamp(1.25rem, 4vw, 2.2rem); font-weight: 900; line-height: 1.12; }
.round-result {
  margin-bottom: 12px;
  padding: 16px;
  border-color: rgba(45, 155, 98, 0.36);
  background: #f1fff8;
}
.round-result span {
  color: #1f7a4b;
  font-weight: 900;
  text-transform: uppercase;
}
.round-result p {
  margin: 8px 0 0;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.flag-question {
  display: grid;
  gap: 12px;
}
.flag-visual {
  display: block;
  width: min(300px, 100%);
  max-height: 160px;
  object-fit: contain;
  border-radius: 10px;
  color: var(--ink);
  font-size: clamp(5rem, 16vw, 9rem);
  line-height: 1;
}
.flag-prompt {
  color: var(--ink);
  font-size: clamp(1.05rem, 3vw, 1.6rem);
  line-height: 1.25;
  text-transform: none;
}
.calculation-question {
  display: inline-grid;
  min-width: 190px;
  justify-items: end;
  gap: 6px;
  border: 3px solid #1688ff;
  border-radius: 16px;
  padding: 20px 24px 16px;
  background:
    linear-gradient(#ffffff 0 0) padding-box,
    repeating-linear-gradient(0deg, rgba(22, 136, 255, 0.1) 0 1px, transparent 1px 30px);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 900;
  line-height: 1;
}
.calculation-bottom {
  display: grid;
  width: 100%;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: end;
  border-bottom: 6px solid var(--ink);
  padding-bottom: 8px;
}
.calculation-bottom strong {
  font: inherit;
  text-align: right;
}
.date-question {
  display: grid;
  gap: 14px;
  border-left: 8px solid var(--honey);
  border-radius: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #fff, #fff7c7);
}
.date-event {
  color: var(--ink);
  font-size: clamp(1.45rem, 4vw, 2.6rem);
  font-weight: 900;
  line-height: 1.12;
}
.date-prompt {
  color: #0d5aad;
  font-size: 1rem;
  font-weight: 900;
  text-transform: none;
}
.price-question {
  display: grid;
  gap: 12px;
  border-left: 8px solid var(--blue);
  border-radius: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #fff, #e7f4ff);
}
.price-prompt {
  color: var(--brand-dark);
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: uppercase;
}
.price-object {
  color: var(--ink);
  font-size: clamp(1.45rem, 4vw, 2.7rem);
  line-height: 1.08;
}
.price-hint {
  color: #0d5aad;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.3;
  text-transform: none;
}
.whoami-question,
.place-question {
  display: grid;
  gap: 14px;
}
.whoami-hint,
.place-prompt {
  color: #0d5aad;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.35;
  text-transform: none;
}
.place-image {
  width: min(420px, 100%);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(28, 31, 38, 0.18);
}
.round-signals {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.yes-no-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.yes-no-button {
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}
.yes-no-button.yes { background: #20b84d; }
.yes-no-button.no { background: #e33131; }
.signals-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}
.answer-box { padding: 18px; }
.number-pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}
.number-key {
  min-height: 46px;
  border: 2px solid #b9d8f4;
  border-radius: 10px;
  color: #12345a;
  background: #eef8ff;
  box-shadow: 0 4px 0 #c8deef;
  font-size: 1.12rem;
  font-weight: 900;
}
.number-key.delete {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 0 var(--brand-dark);
}
.number-key.submit {
  color: #fff;
  background: #20b84d;
  border-color: #138237;
  box-shadow: 0 4px 0 #138237;
}
.attempts { border-radius: 12px; padding: 14px; color: #4f3800; background: #fff0a7; font-weight: 900; }
.form-message { min-height: 26px; margin: 12px 0 0; font-weight: 800; }
.compact-panel { margin-top: 20px; }

.host-grid { grid-template-columns: 1.1fr 0.8fr; }
.question-panel, .answers-panel { grid-column: span 1; }
.host-screen {
  padding-top: 14px;
}
.host-screen .game-icons {
  grid-template-columns: repeat(9, minmax(44px, 1fr));
  gap: 8px;
  margin: 0;
  padding-bottom: 0;
}
.host-screen .game-icon-button {
  min-height: 48px;
  border-radius: 10px;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
}
.host-screen .host-grid {
  gap: 12px;
}
.host-screen .panel {
  padding: 14px;
}
.host-screen .panel-heading {
  margin-bottom: 8px;
}
.host-screen .panel-heading h2 {
  font-size: 1.05rem;
}
.host-screen .current-question {
  margin-top: 6px;
  font-size: clamp(1.2rem, 2.8vw, 1.9rem);
  line-height: 1.08;
}
.host-screen .answer-details {
  margin: 10px 0;
  padding: 10px;
}
.host-screen .answer-details p {
  margin-top: 6px;
  font-size: 0.94rem;
  line-height: 1.28;
}
.host-screen .primary-button,
.host-screen .secondary-button,
.host-screen .danger-button {
  min-height: 46px;
  padding: 0 12px;
  font-size: 0.94rem;
}
.host-screen .player-list,
.host-screen .answers-list,
.host-screen .ranking-list {
  gap: 7px;
}
.host-screen .player-list li,
.host-screen .ranking-list li {
  padding: 8px 10px;
}
.host-screen .answer-text {
  margin-top: 3px;
  font-size: 0.98rem;
}
.host-screen .answer-meta {
  font-size: 0.82rem;
}
.host-screen .answer-icon {
  width: 40px;
  height: 40px;
}
.player-screen {
  padding-top: 14px;
}
.player-screen .round-header {
  margin-bottom: 10px;
}
.player-screen #playerGameName {
  font-size: clamp(1.05rem, 3vw, 1.45rem);
}
.player-screen .question-card,
.player-screen .answer-box,
.player-screen .compact-panel {
  margin-bottom: 12px;
}
.player-screen .question-card {
  padding: 16px;
}
.player-screen .question-card p {
  font-size: clamp(1.08rem, 4vw, 1.6rem);
  line-height: 1.12;
}
.player-screen .answer-box {
  padding: 14px;
}
.player-screen .attempts {
  margin-bottom: 10px;
}
.answers-panel,
.host-screen .panel {
  min-height: 0;
}
.answers-panel .answers-list,
.host-screen .ranking-list,
.host-screen .player-list {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.answer-details {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}
.answer-details summary {
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 900;
}
.answer-details p {
  margin: 10px 0 0;
  overflow-wrap: anywhere;
}
.answers-list .answer-content {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  color: inherit;
  background: transparent;
  text-align: left;
}
.answers-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 0;
  overflow: hidden;
}
.answers-list li.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(185, 71, 45, 0.12); }
.answers-list li.validated { border-color: var(--mint); background: #f1fff8; }
.answers-list li.rejected { border-color: #b8aaa2; background: #f6f0eb; }
.answer-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.9rem; font-weight: 800; }
.answer-text { display: block; margin-top: 6px; font-size: 1.05rem; font-weight: 900; }
.answer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px;
}
.answer-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}
.answer-icon.reject { background: #d33f2f; }
.answer-icon.accept { background: #2d9b62; }
.empty-state { color: var(--muted); font-weight: 800; }

.letters-screen {
  max-width: 760px;
}
.letters-board {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(18px, 5vw, 32px);
  background: rgba(255, 250, 242, 0.92);
  box-shadow: var(--shadow);
}
.letters-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.letters-topline span {
  font-size: clamp(1.2rem, 5vw, 2rem);
  font-weight: 900;
}
#lettersTimer {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border: 4px solid var(--blue);
  border-radius: 50%;
  color: #0d5aad;
  background: #fff;
  font-size: 2rem;
  font-weight: 900;
}
#lettersTimer.warning {
  border-color: #ff8a22;
  color: #b75500;
  animation: timerPulse 700ms ease-in-out infinite alternate;
}
#lettersTimer.danger {
  border-color: var(--brand);
  color: var(--brand);
  animation: timerPulse 360ms ease-in-out infinite alternate;
}
.letters-ruler {
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
  margin: 14px -8px 18px;
  border: 1px solid #d7b15a;
  border-radius: 12px;
  padding: 18px 10px 20px;
  background:
    repeating-linear-gradient(90deg, rgba(123, 84, 14, 0.22) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, #fff7d6, #f2d987);
  box-shadow: inset 0 2px 8px rgba(95, 66, 8, 0.12);
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.letters-ruler.arranging {
  scroll-snap-type: none;
  touch-action: none;
}
.letters-ruler.editable {
  touch-action: none;
}
.letters-ruler::before,
.letters-ruler::after {
  content: "";
  position: sticky;
  z-index: 2;
  top: 0;
  display: block;
  width: 18px;
  flex: 0 0 18px;
}
.letters-ruler::-webkit-scrollbar {
  height: 0;
}
.letters-ruler::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(123, 84, 14, 0.34);
}
.letter-tiles {
  display: inline-flex;
  width: 100%;
  min-height: 82px;
  align-items: center;
  justify-content: center;
  gap: var(--letter-gap, 8px);
  padding: 0 8px;
}
.letter-tiles.editable {
  touch-action: none;
}
.letter-tile {
  display: grid;
  flex: 0 1 auto;
  width: var(--letter-size, 58px);
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #c69a20;
  border-radius: 8px;
  color: #111;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 44%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 7px),
    #f4c842;
  box-shadow: 0 6px 0 #b88416, 0 14px 22px rgba(36, 28, 10, 0.18);
  font-size: var(--letter-font-size, 2.1rem);
  font-weight: 900;
  scroll-snap-align: center;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
}
.letter-tile.new {
  animation: letterPop 180ms ease-out both;
}
.letter-tile.movable {
  cursor: grab;
}
.letter-tile.dragging {
  z-index: 4;
  cursor: grabbing;
  opacity: 0.92;
  transition: none;
  box-shadow: 0 8px 0 #9e7110, 0 22px 36px rgba(36, 28, 10, 0.28);
}
.letter-tiles.editable .letter-tile {
  border-color: #9f7412;
}
.letter-empty,
.letters-status {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}
.letters-status {
  min-height: 28px;
  margin: 0 0 16px;
}
.letters-entry {
  margin-top: 16px;
}
.letter-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.letters-actions {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: stretch;
}
.letter-back-button {
  min-width: 58px;
  padding: 0;
  font-size: 1.45rem;
  line-height: 1;
}
.letter-pick {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 2px solid #c69a20;
  border-radius: 8px;
  color: #111;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 44%),
    #f4c842;
  box-shadow: 0 4px 0 #b88416;
  font-size: 1.15rem;
  font-weight: 900;
}
.letter-pick.selected {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
  box-shadow: 0 4px 0 var(--brand-dark);
}
.letter-pick:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}
.player-list li.current-turn {
  border-color: var(--blue);
  background: #eef8ff;
  box-shadow: 0 0 0 3px rgba(22, 136, 255, 0.1);
}
@keyframes letterPop {
  from { opacity: 0; transform: translateY(8px) scale(0.82); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.memory-screen {
  max-width: 860px;
  padding-top: 14px;
}
.memory-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.memory-dashboard div,
.memory-host-tools,
.memory-player-tools {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: 0 8px 18px rgba(28, 31, 38, 0.08);
}
.memory-dashboard span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}
.memory-dashboard strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  line-height: 1;
}
.memory-message {
  min-height: 34px;
  border-radius: 12px;
  padding: 12px 14px;
  color: #3f2a00;
  background: #fff0a7;
}
.memory-host-tools,
.memory-player-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.memory-sequence-preview {
  display: flex;
  min-height: 54px;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.memory-sequence-preview .empty-state {
  width: 100%;
  list-style: none;
}
.memory-chip {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18);
}
.memory-pads {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 10px;
  height: clamp(300px, 54vh, 520px);
  margin: 12px 0;
}
.memory-pad {
  min-width: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.14), 0 14px 28px rgba(28, 31, 38, 0.14);
  transition: filter 120ms ease, transform 120ms ease, opacity 120ms ease;
  touch-action: manipulation;
}
.memory-pad:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.55;
}
.memory-pad.flash {
  filter: brightness(1.35) saturate(1.28);
  transform: translateY(-4px) scale(1.02);
  opacity: 1;
}
.memory-red { background: #e33131; }
.memory-green { background: #20b84d; }
.memory-blue { background: #1688ff; }
.memory-yellow {
  color: #332400;
  background: #ffd21f;
}
.memory-player-tools {
  padding: 12px;
}
.memory-players-panel {
  margin-top: 12px;
}
.player-list li.memory-out {
  opacity: 0.55;
  text-decoration: line-through;
}

@media (max-width: 860px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 6px;
    justify-content: space-between;
    padding: 7px 8px;
  }
  .logo {
    gap: 7px;
    font-size: 0.86rem;
  }
  .logo-icon {
    width: 30px;
    height: 30px;
  }
  .logo span {
    display: none;
  }
  .topbar-actions {
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .topbar-code,
  .topbar-resync,
  .topbar-install,
  .topbar-reset {
    padding: 6px 7px;
    font-size: 0.68rem;
  }
  .home-screen, .split-screen, .host-grid { grid-template-columns: 1fr; }
  .host-screen .host-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .host-screen .question-panel,
  .host-screen .answers-panel {
    grid-column: 1 / -1;
  }
  .host-title-band {
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
  }
  .host-title-band span {
    min-width: 0;
    overflow: hidden;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .host-title-band strong {
    font-size: 0.72rem;
  }
  .host-screen .game-switcher {
    margin-bottom: 8px;
    padding: 8px;
  }
  .host-screen .game-icons {
    grid-template-columns: repeat(9, minmax(28px, 1fr));
    gap: 5px;
  }
  .host-screen .game-icon-button {
    min-height: 34px;
    border-width: 1px;
    border-radius: 8px;
    font-size: 1.05rem;
  }
  .player-screen {
    padding-top: 10px;
  }
  .player-title-band {
    margin-bottom: 8px;
    padding: 6px 8px;
  }
  .player-title-band span,
  .player-title-band strong {
    font-size: 0.72rem;
  }
  .player-screen .question-card {
    margin-bottom: 10px;
    padding: 12px;
  }
  .player-screen .question-card span,
  .player-screen .field span {
    font-size: 0.86rem;
  }
  .player-screen .question-card p {
    font-size: 1.12rem;
  }
  .player-screen .answer-box {
    margin-bottom: 10px;
    padding: 12px;
  }
  .player-screen input,
  .player-screen .primary-button {
    min-height: 48px;
  }
  .player-screen .attempts {
    margin: 0 0 10px;
    padding: 10px 12px;
    font-size: 0.92rem;
  }
  .round-header { flex-direction: column; }
  .code-panel.small { width: 100%; }
}

.embedded-view .topbar {
  display: none;
}
.embedded-view .screen {
  width: min(100% - 18px, 1160px);
  padding: 14px 0 22px;
}
.embedded-view h1 {
  font-size: clamp(1.6rem, 5vw, 3rem);
}
.embedded-view h2 {
  font-size: clamp(1.15rem, 3vw, 1.8rem);
}
.embedded-view .host-grid {
  gap: 12px;
}
.embedded-view .game-switcher {
  margin-bottom: 12px;
  padding: 10px;
}
.embedded-view .game-icons {
  grid-template-columns: repeat(9, minmax(48px, 1fr));
  gap: 8px;
}
.embedded-view .game-icon-button {
  border-radius: 10px;
  min-height: 48px;
  font-size: 1.65rem;
}
.embedded-view .panel,
.embedded-view .question-card,
.embedded-view .answer-box {
  padding: 14px;
}
.embedded-view .answers-panel .answers-list,
.embedded-view .host-screen .ranking-list,
.embedded-view .host-screen .player-list {
  max-height: 210px;
}

@media (max-width: 520px) {
  .screen { width: min(100% - 22px, 1160px); padding-top: 20px; }
  .topbar {
    gap: 6px;
    padding: 7px 8px;
    justify-content: space-between;
  }
  .topbar-actions {
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .topbar-code,
  .topbar-resync,
  .topbar-install,
  .topbar-reset {
    padding: 6px 7px;
    font-size: 0.68rem;
  }
  .logo-icon {
    width: 30px;
    height: 30px;
  }
  .logo span {
    display: none;
  }
  .host-screen {
    padding-top: 10px;
  }
  .host-screen .host-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .host-screen .question-panel,
  .host-screen .answers-panel {
    grid-column: 1 / -1;
  }
  .host-screen .game-switcher {
    margin-bottom: 8px;
    padding: 8px;
  }
  .host-screen .game-icons {
    grid-template-columns: repeat(9, minmax(28px, 1fr));
    gap: 5px;
  }
  .host-title-band {
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
  }
  .host-title-band span {
    min-width: 0;
    overflow: hidden;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .host-title-band strong {
    font-size: 0.72rem;
  }
  .host-screen .game-icon-button {
    min-height: 34px;
    border-width: 1px;
    border-radius: 8px;
    font-size: 1.05rem;
  }
  .host-screen .panel {
    padding: 9px;
  }
  .host-screen .panel-heading {
    margin-bottom: 5px;
  }
  .host-screen .panel-heading h2 {
    font-size: 0.88rem;
  }
  .host-screen .panel-heading span {
    font-size: 0.78rem;
  }
  .host-screen .current-question {
    font-size: 1.12rem;
  }
  .host-screen .answer-details {
    margin: 7px 0;
    padding: 8px;
  }
  .host-screen .answer-details p {
    font-size: 0.84rem;
  }
  .host-screen .button-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
  .host-screen .primary-button,
  .host-screen .secondary-button,
  .host-screen .danger-button {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.78rem;
  }
  .host-screen .answers-panel .answers-list,
  .host-screen .ranking-list,
  .host-screen .player-list {
    max-height: 128px;
  }
  .host-screen .player-list li,
  .host-screen .ranking-list li {
    padding: 6px;
    font-size: 0.82rem;
  }
  .host-screen .ranking-list li::before {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }
  .host-screen .answer-content {
    padding: 8px;
  }
  .host-screen .answer-actions {
    gap: 5px;
    padding: 8px;
  }
  .host-screen .answer-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
  h1 { font-size: 2.8rem; }
  .big-action { min-height: 126px; }
  .game-icons { grid-template-columns: repeat(3, 1fr); }
  .letters-topline { align-items: flex-start; flex-direction: column; }
  #lettersTimer { width: 70px; height: 70px; }
  .button-row { display: grid; }
  .start-game-button { min-height: 68px; font-size: 1.12rem; }
  .primary-button, .secondary-button, .danger-button, input, select { min-height: 56px; }
  .panel, .form-card, .question-card, .answer-box { border-radius: 12px; padding: 16px; }
  .answers-list li { grid-template-columns: 1fr; }
  .answer-actions { justify-content: flex-start; padding-top: 0; }
}

