:root {
  --paper: #f4efe4;
  --ink: #1d1b19;
  --accent: #be4f36;
  --accent-soft: rgba(190, 79, 54, 0.16);
  --leaf: #385f48;
  --panel: rgba(255, 252, 246, 0.82);
  --border: rgba(29, 27, 25, 0.14);
  --shadow: 0 24px 80px rgba(29, 27, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(234, 166, 88, 0.22), transparent 34%),
    radial-gradient(circle at bottom right, rgba(56, 95, 72, 0.2), transparent 38%),
    linear-gradient(145deg, #ece1ca, var(--paper));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(29, 27, 25, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 27, 25, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
}

.app-shell {
  width: min(100vw - 1.5rem, 1500px);
  margin: 0 auto;
  padding: 1rem 0 1.2rem;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 252, 246, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.players-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.player-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: rgba(29, 27, 25, 0.07);
  font-size: 0.9rem;
}

.player-pill.self {
  background: rgba(56, 95, 72, 0.12);
}

.player-pill.answered {
  background: rgba(190, 79, 54, 0.13);
}

.player-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: rgba(29, 27, 25, 0.3);
}

.player-pill.answered .player-dot {
  background: var(--accent);
}

.anchors-display,
.score-pill {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(29, 27, 25, 0.08);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.play-shell {
  display: grid;
  min-height: calc(100vh - 8.7rem);
  grid-template-rows: 1fr auto;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% auto;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(190, 79, 54, 0.14), transparent 72%);
}

.setup-panel {
  padding: 1.5rem;
}

.panel-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.panel-header p {
  margin: 0;
  color: rgba(29, 27, 25, 0.72);
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.3rem;
}

.anchor-form {
  margin-top: 1.4rem;
}

.mode-picker {
  display: grid;
  gap: 0.8rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.mode-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(29, 27, 25, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
}

.mode-card:has(input:checked) {
  border-color: rgba(190, 79, 54, 0.35);
  background: rgba(190, 79, 54, 0.12);
}

.mode-card input {
  margin: 0;
  width: auto;
  padding: 0;
}

.mode-title {
  font-weight: 700;
}

.mode-copy {
  color: rgba(29, 27, 25, 0.72);
  line-height: 1.4;
}

.anchor-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.level-picker {
  margin-top: 1.4rem;
}

.section-label {
  margin-bottom: 0.8rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(29, 27, 25, 0.62);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.level-card {
  display: grid;
  gap: 0.35rem;
  text-align: left;
  padding: 1rem;
  border: 1px solid rgba(29, 27, 25, 0.12);
  border-radius: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}

.level-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.66);
}

.level-card strong {
  font-size: 1rem;
}

.level-anchors {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--leaf);
}

.level-description,
.level-empty {
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(29, 27, 25, 0.72);
}

label {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(29, 27, 25, 0.16);
  border-radius: 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  font: inherit;
  font-weight: 700;
  color: #fff7f1;
  background: linear-gradient(135deg, #c84f34, #9a2f1d);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 12px 30px rgba(154, 47, 29, 0.22);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  color: var(--ink);
  background: rgba(29, 27, 25, 0.08);
  box-shadow: none;
}

.prompt {
  margin-top: 1.4rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(56, 95, 72, 0.09);
}

.prompt-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(29, 27, 25, 0.62);
}

.feedback {
  min-height: 3.2rem;
  margin: 1rem 0 0;
  line-height: 1.5;
}

.feedback[data-tone="correct"] {
  color: var(--leaf);
}

.feedback[data-tone="wrong"] {
  color: #8c2418;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.board-stage {
  display: grid;
  place-items: center;
  padding: 0.5rem 0 0;
}

#board {
  width: min(86vw, calc(100vh - 240px), 1120px);
  height: min(86vw, calc(100vh - 240px), 1120px);
}

.board-ring {
  fill: rgba(255, 255, 255, 0.4);
  stroke: rgba(29, 27, 25, 0.18);
  stroke-width: 2;
}

.active-edge {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
}

.anchor-marker {
  fill: var(--leaf);
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 3.5;
}

.anchor-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--ink);
}

.guess-halo {
  fill: rgba(190, 79, 54, 0.12);
}

.guess-halo.guess-wrong {
  fill: rgba(140, 36, 24, 0.14);
}

.guess-halo.guess-neutral {
  fill: rgba(29, 27, 25, 0.08);
}

.guess-marker {
  fill: var(--accent);
}

.guess-correct {
  fill: var(--accent);
  stroke: rgba(255, 247, 241, 0.9);
  stroke-width: 1.8;
}

.guess-wrong {
  fill: #8c2418;
  stroke: rgba(255, 247, 241, 0.9);
  stroke-width: 1.8;
}

.guess-pending {
  fill: var(--leaf);
  stroke: rgba(255, 247, 241, 0.9);
  stroke-width: 1.8;
}

.guess-chip {
  stroke: rgba(29, 27, 25, 0.08);
  stroke-width: 1;
}

.guess-chip.guess-correct {
  fill: rgba(255, 252, 246, 0.92);
}

.guess-chip.guess-wrong {
  fill: rgba(140, 36, 24, 0.12);
}

.guess-chip.guess-neutral {
  fill: rgba(255, 252, 246, 0.88);
}

.guess-chip.guess-pending {
  fill: rgba(56, 95, 72, 0.12);
}

.guess-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  fill: var(--ink);
}

.guess-connector {
  stroke: rgba(29, 27, 25, 0.16);
  stroke-width: 1.2;
}

.hidden-opponent-dot {
  fill: rgba(29, 27, 25, 0.42);
  stroke: rgba(255, 252, 246, 0.95);
  stroke-width: 2;
}

.bottom-dock {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0 0.6rem;
}

.guess-form {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: min(720px, calc(100vw - 2.5rem));
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 252, 246, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.guess-form input {
  padding: 1rem 1.15rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.guess-form button {
  min-width: 110px;
}

.selection-bank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 0.75rem;
  width: min(980px, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 252, 246, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.bank-word {
  color: var(--ink);
  background: rgba(29, 27, 25, 0.08);
  box-shadow: none;
  padding: 0.8rem 0.95rem;
}

.bank-word:hover:not(:disabled) {
  background: rgba(190, 79, 54, 0.16);
}

.username-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(29, 27, 25, 0.38);
  backdrop-filter: blur(10px);
}

.username-modal.visible {
  display: grid;
}

.username-card {
  width: min(460px, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(255, 252, 246, 0.92);
  box-shadow: var(--shadow);
}

.username-card h2 {
  margin: 0 0 0.4rem;
}

.username-card p {
  margin: 0;
  color: rgba(29, 27, 25, 0.72);
  line-height: 1.5;
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .anchor-inputs {
    grid-template-columns: 1fr;
  }

  .guess-form {
    width: calc(100vw - 1.5rem);
  }

  .guess-form button {
    min-width: 92px;
  }

  #board {
    width: min(96vw, calc(100vh - 280px));
    height: min(96vw, calc(100vh - 280px));
  }
}
