:root {
  --primary-color: #2f9e44;
  --primary-strong: #237032;
  --ink: #17201a;
  --muted: #667085;
  --soft: #f5f7f2;
  --panel: #ffffff;
  --line: #dce4d8;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --green: #16a34a;
  --shadow: 0 18px 50px rgba(20, 40, 24, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(47, 158, 68, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    #fbfcf9;
  background-size: 44px 44px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 92px 0 32px;
}

.intro-band {
  display: flex;
  align-items: flex-end;
  min-height: 190px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.title-stack {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(47, 158, 68, 0.28);
  border-radius: 999px;
  color: var(--primary-strong);
  background: rgba(47, 158, 68, 0.08);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2.7rem, 7vw, 6.2rem);
  letter-spacing: 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.setup-panel,
.score-panel,
.quiz-panel,
.status-panel,
.final-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.setup-panel {
  padding: 18px;
}

.setup-panel.wide {
  grid-column: span 2;
}

.panel-heading,
.score-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin-bottom: 14px;
}

.panel-heading i,
.score-title i {
  color: var(--primary-color);
}

.panel-heading h2,
.score-title h2 {
  font-size: 1rem;
}

.segmented,
.number-grid,
.scope-grid,
.mode-stack {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(4, 1fr);
}

.number-grid {
  grid-template-columns: repeat(3, 1fr);
}

.choice,
.scope-card,
.mode-card,
.primary-button,
.secondary-button,
.start-button,
.option-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.choice:hover,
.scope-card:hover,
.mode-card:hover,
.secondary-button:hover,
.option-button:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 158, 68, 0.5);
}

.choice.active,
.scope-card.active,
.mode-card.active {
  border-color: var(--primary-color);
  background: #eaf7ed;
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px rgba(47, 158, 68, 0.16);
}

.choice:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.scope-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scope-card {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px;
  text-align: left;
}

.scope-card span {
  font-weight: 800;
}

.scope-card small {
  color: var(--muted);
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  font-weight: 750;
}

.player-fields {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.player-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-field span {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

.player-field input,
.type-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.player-field input:focus,
.type-input:focus {
  outline: 3px solid rgba(47, 158, 68, 0.16);
  border-color: var(--primary-color);
}

.limit-note {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.start-button {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  color: #fff;
  background: var(--primary-color);
  border-color: var(--primary-color);
  font-size: 1.05rem;
  font-weight: 850;
}

.start-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  background: var(--primary-strong);
}

.game-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 230px;
  gap: 14px;
  min-height: calc(100vh - 124px);
}

.score-panel,
.status-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.score-list {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.score-row.active {
  border-color: var(--blue);
  background: #eff6ff;
}

.score-row.winner {
  border-color: rgba(47, 158, 68, 0.55);
  background: #ecfdf3;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 850;
  background: var(--blue);
}

.score-name {
  min-width: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.score-points {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary-strong);
}

.quiz-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.quiz-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e8eee5;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--blue));
  transition: width 0.2s ease;
}

.country-block {
  min-height: 250px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px 18px;
  border: 1px solid #cfdccb;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.82)),
    radial-gradient(circle at 20% 25%, rgba(37, 99, 235, 0.12), transparent 28%),
    radial-gradient(circle at 78% 70%, rgba(47, 158, 68, 0.15), transparent 30%),
    #f8fbf4;
}

.turn-pill {
  min-height: 30px;
  max-width: 100%;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 0.85rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-label {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.country-block h2 {
  max-width: 100%;
  text-align: center;
  font-size: clamp(2.2rem, 7vw, 5rem);
  overflow-wrap: anywhere;
}

.country-meta {
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.answer-area {
  display: grid;
  gap: 10px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-button {
  min-height: 64px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.option-button.correct {
  border-color: var(--green);
  background: #ecfdf3;
  color: #166534;
}

.option-button.wrong {
  border-color: var(--red);
  background: #fef2f2;
  color: #991b1b;
}

.type-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 850;
}

.primary-button {
  color: #fff;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.secondary-button {
  color: var(--ink);
  background: #fff;
}

.score-panel .secondary-button {
  margin-top: auto;
  width: 100%;
}

.feedback {
  min-height: 58px;
  display: grid;
  align-content: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  background: #f4f6f1;
  border: 1px solid var(--line);
  font-weight: 750;
}

.feedback.good {
  color: #166534;
  border-color: #bbf7d0;
  background: #ecfdf3;
}

.feedback.bad {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.feedback.steal {
  color: #92400e;
  border-color: #fed7aa;
  background: #fff7ed;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  min-height: 44px;
}

.metric {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric strong {
  font-size: 1.05rem;
}

.history {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.history-item {
  border-left: 4px solid var(--line);
  padding: 8px 0 8px 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-item strong {
  display: block;
  color: var(--ink);
}

.history-item.good {
  border-color: var(--green);
}

.history-item.bad {
  border-color: var(--red);
}

.final-view {
  min-height: calc(100vh - 124px);
  display: grid;
  place-items: center;
}

.final-panel {
  width: min(620px, 100%);
  padding: 24px;
  box-shadow: var(--shadow);
}

.final-panel h2 {
  margin: 12px 0 18px;
  font-size: clamp(2rem, 6vw, 3.4rem);
}

.final-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-panel.wide {
    grid-column: span 2;
  }

  .game-view {
    grid-template-columns: 1fr;
  }

  .score-panel,
  .status-panel {
    order: 2;
  }

  .quiz-panel {
    order: 1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 78px;
  }

  .intro-band {
    min-height: auto;
    padding-bottom: 18px;
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  .setup-panel.wide,
  .start-button {
    grid-column: auto;
  }

  .scope-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-grid,
  .type-row {
    grid-template-columns: 1fr;
  }

  .country-block {
    min-height: 210px;
  }

  .final-actions {
    flex-direction: column;
  }
}
