:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fb;
  color: #1f2937;
}

/* ── Landing screen ── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: calc(100vh - 96px);
  padding: 40px 24px;
  text-align: center;
  max-width: none;
}

.landing-map-wrap {
  width: min(900px, 100%);
  margin: 0 auto 28px;
  pointer-events: none;
}

.landing-world-map {
  min-height: 200px;
}

.landing-logo {
  display: block;
  width: min(640px, 92vw);
  height: auto;
  margin: 0 0 48px;
  pointer-events: none;
}

.landing-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  position: relative;
  z-index: 1;
}

.landing-daily-countdown {
  margin: 14px 0 0;
  color: #334155;
  font-size: 0.98rem;
  font-weight: 600;
}

.landing-btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2937;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.landing-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
}

.landing-btn--play {
  background: #60a5fa;
  color: #ffffff;
  border-color: #60a5fa;
  font-size: 1.3rem;
  padding: 18px 24px;
}

.landing-btn--play:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.35);
}

body.app-open .landing {
  display: none;
}

/* ── App shell ── */
.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.back-btn {
  border: none;
  background: none;
  color: #3b82f6;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.back-btn:hover {
  text-decoration: underline;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 72px 24px 24px;
}

.header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.theme-toggle-btn {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px 12px;
  background: #ffffff;
  color: #111827;
  font-weight: 600;
  cursor: pointer;
}

.global-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
}

.theme-toggle-btn:hover {
  background: #f8fafc;
}

.header p {
  margin-top: 6px;
  color: #4b5563;
}

.tabs {
  margin-top: 18px;
  display: flex;
  gap: 8px;
}

body.app-open .tabs {
  display: none;
}

.tab-btn {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 9px 12px;
  background: #ffffff;
  color: #1f2937;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn:hover {
  background: #f8fafc;
}

.tab-btn.active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.tab-btn--play {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #ffffff;
  border-color: transparent;
}

.tab-btn--play:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
}

.tab-btn--play.active {
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
  border-color: #1d4ed8;
}

.tab-panel {
  display: none;
  margin-top: 12px;
}

.tab-panel.active {
  display: block;
}

body.dark-mode {
  background: #1e293b;
  color: #f1f5f9;
}

body.dark-mode .landing-btn {
  background: #263447;
  border-color: #4b5f79;
  color: #f1f5f9;
}

body.dark-mode .landing-btn:hover {
  background: #32465f;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

body.dark-mode .landing-btn--play {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

body.dark-mode .landing-btn--play:hover {
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.45);
}

body.dark-mode .landing-daily-countdown {
  color: #dbe7f5;
}

body.dark-mode .back-btn {
  color: #93c5fd;
}

body.dark-mode .tab-btn--play {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  border-color: transparent;
  color: #ffffff;
}

body.dark-mode .tab-btn--play:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
}

body.dark-mode .tab-btn--play.active {
  background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
  border-color: #7c3aed;
}

body.dark-mode .header p,
body.dark-mode .map-attribution,
body.dark-mode .explorer-subtitle,
body.dark-mode .country-header p,
body.dark-mode .country-flag-source,
body.dark-mode .data-term,
body.dark-mode .bonus-question-prompt,
body.dark-mode .train-label,
body.dark-mode .train-fieldset legend,
body.dark-mode .train-inline-check,
body.dark-mode .train-hint-list,
body.dark-mode .train-hardest-list,
body.dark-mode .train-hint-list-empty {
  color: #dbe7f5;
}

body.dark-mode .train-status,
body.dark-mode #trainPrompt,
body.dark-mode #trainSummaryMetrics,
body.dark-mode #trainSummaryHardest {
  color: #f8fbff;
}

body.dark-mode #trainStatus {
  color: #111827;
}

body.dark-mode #trainStatus.success {
  color: #166534;
}

body.dark-mode #trainStatus.error {
  color: #991b1b;
}

body.dark-mode .country-header h2,
body.dark-mode .category-card h3,
body.dark-mode .data-value {
  color: #f8fbff;
}

body.dark-mode .country-flag-source a,
body.dark-mode .data-rank {
  color: #93c5fd;
}

body.dark-mode .data-toggle-btn {
  background: #35548f;
  border-color: #7fb2ff;
  color: #eff6ff;
}

body.dark-mode .data-toggle-btn:hover {
  background: #46649b;
}

body.dark-mode .data-info-btn {
  background: #334155;
  border-color: #64748b;
  color: #94a3b8;
}

body.dark-mode .data-info-btn:hover {
  background: #3b4f6b;
  border-color: #7fb2ff;
  color: #93c5fd;
}

body.dark-mode .data-info-btn-active {
  background: #2d4466;
  border-color: #60a5fa;
  color: #93c5fd;
}

body.dark-mode .field-info-overlay {
  background: rgba(0, 0, 0, 0.6);
}

body.dark-mode .field-info-modal {
  background: #263447;
  border-color: #4b5f79;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

body.dark-mode .field-info-header {
  border-bottom-color: #4b5f79;
}

body.dark-mode .field-info-title {
  color: #f8fbff;
}

body.dark-mode .field-info-close {
  color: #94a3b8;
}

body.dark-mode .field-info-close:hover {
  background: #334155;
  color: #f1f5f9;
}

body.dark-mode .field-info-desc {
  color: #dbe7f5;
}

body.dark-mode .field-info-source {
  color: #a5b4fc;
}

body.dark-mode .theme-toggle-btn,
body.dark-mode .tab-btn,
body.dark-mode .search-panel,
body.dark-mode .game-panel,
body.dark-mode .country-header,
body.dark-mode .category-card,
body.dark-mode .empty-state,
body.dark-mode .game-map-panel,
body.dark-mode .bonus-question-card,
body.dark-mode .game-fact,
body.dark-mode .explorer-table,
body.dark-mode .explorer-select,
body.dark-mode .search-input,
body.dark-mode .search-results,
body.dark-mode .train-fieldset,
body.dark-mode .country-flag,
body.dark-mode .train-flag {
  background: #263447;
  border-color: #4b5f79;
  color: #f1f5f9;
}

body.dark-mode .tab-btn.active {
  border-color: #7fb2ff;
  background: #35548f;
  color: #eff6ff;
}

body.dark-mode .tab-btn:hover,
body.dark-mode .theme-toggle-btn:hover,
body.dark-mode .search-result-item:hover,
body.dark-mode .search-result-item.active,
body.dark-mode .explorer-table tbody tr:hover {
  background: #32465f;
}

body.dark-mode .game-btn {
  background: #263447;
  border-color: #3b82f6;
  color: #eff6ff;
}

body.dark-mode .game-score {
  background: #35548f;
  border-color: #2563eb;
  color: #eff6ff;
}

body.dark-mode #gameScore {
  background: transparent;
  border: 0;
  color: #dbeafe;
}

body.dark-mode #gameLives {
  color: #f87171;
}

body.dark-mode .world-map {
  background: linear-gradient(180deg, #2a3b53 0%, #243447 100%);
  border-color: #4b5f79;
}

body.dark-mode .game-map-panel {
  background: transparent;
  border: 0;
}

body.dark-mode .map-country {
  stroke: #1f2937;
}

body.dark-mode .map-country.is-highlighted {
  fill: #3b82f6;
}

body.dark-mode .map-country.is-dimmed {
  fill: #4b5f79;
}

body.dark-mode .explorer-table th {
  background: #32465f;
  color: #f1f5f9;
}

body.dark-mode .explorer-sort-btn {
  color: #f1f5f9;
}

body.dark-mode .explorer-sort-btn:hover {
  color: #93c5fd;
}

body.dark-mode .explorer-table th,
body.dark-mode .explorer-table td {
  border-bottom-color: #4b5f79;
}

body.dark-mode .train-hint-remove-btn {
  border-color: #be123c;
  background: #3f0f1c;
  color: #fecdd3;
}

body.dark-mode .game-fact-meta {
  color: #bfdbfe;
}

body.dark-mode .game-fact-value {
  color: #f8fbff;
}

body.dark-mode .game-fact-rank {
  background: #59421a;
  border-color: #d4a857;
  color: #fde68a;
}

body.dark-mode .game-guess-title {
  color: #dbeafe;
}

body.dark-mode .game-guess-mode-toggle .game-btn.active {
  background: #35548f;
  border-color: #7fb2ff;
}

body.dark-mode .game-subtabs .game-btn.active {
  background: #35548f;
  border-color: #7fb2ff;
}

body.dark-mode .game-end-screen {
  background: #263447;
  border-color: #4b5f79;
}

body.dark-mode .game-end-title {
  color: #dbeafe;
}

body.dark-mode .game-end-tabs .game-btn.active {
  background: #35548f;
  border-color: #7fb2ff;
}

body.dark-mode .game-summary-table th,
body.dark-mode .game-summary-table td {
  border-bottom-color: #4b5f79;
  color: #f1f5f9;
}

body.dark-mode .game-summary-table th {
  color: #dbeafe;
}

body.dark-mode .game-summary-source {
  color: #cbd5e1;
}

body.dark-mode .game-summary-hints-country {
  background: #32465f;
  border-color: #4b5f79;
}

body.dark-mode .game-summary-hints-country h3,
body.dark-mode .game-summary-hints-country li {
  color: #f8fbff;
}

body.dark-mode .distribution-meta,
body.dark-mode .distribution-empty,
body.dark-mode .distribution-axis-label,
body.dark-mode .distribution-bar-x,
body.dark-mode .distribution-bar-value {
  color: #cbd5e1;
}

body.dark-mode .distribution-chart {
  border-color: #4b5f79;
  background: #2c3b4f;
}

body.dark-mode .distribution-y-line {
  border-top-color: #4b5f79;
}

body.dark-mode .distribution-bar {
  background: #7fb2ff;
}

body.dark-mode .distribution-bars {
  border-left-color: #4b5f79;
  border-bottom-color: #4b5f79;
}

.search-panel {
  margin-top: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}

.howto-panel {
  max-width: 860px;
}

.markdown-content h2 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  color: #1e3a8a;
}

.markdown-content h3 {
  margin: 16px 0 6px;
  font-size: 1.05rem;
  color: #1d4ed8;
}

.markdown-content p {
  margin: 0 0 10px;
  color: #334155;
}

.markdown-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.markdown-content li {
  margin: 4px 0;
  color: #334155;
}

.markdown-content strong {
  color: #0f172a;
}

.markdown-content code {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 1px 5px;
}

body.dark-mode .markdown-content h2 {
  color: #dbeafe;
}

body.dark-mode .markdown-content h3 {
  color: #93c5fd;
}

body.dark-mode .markdown-content p,
body.dark-mode .markdown-content li {
  color: #dbe7f5;
}

body.dark-mode .markdown-content strong {
  color: #f8fbff;
}

body.dark-mode .markdown-content code {
  background: #2d4466;
  border-color: #4b5f79;
}

.game-panel {
  margin-top: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #dbe4f0;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.08);
}

#gameScore {
  display: block;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #1e3a8a;
}

#gameLives {
  margin: 4px 0 0;
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 0.16em;
  color: #dc2626;
  min-height: 1.5rem;
}

.game-btn {
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.game-btn:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #60a5fa;
  transform: translateY(-1px);
}

.game-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-score {
  margin: 12px 0 0;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  display: inline-block;
  padding: 6px 12px;
}

.game-map-panel {
  margin-top: 12px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.world-map {
  margin-top: 0;
  width: 100%;
  min-height: 240px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
  overflow: hidden;
}

.world-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-country {
  fill: #93c5fd;
  stroke: #ffffff;
  stroke-width: 0.45;
  transition: fill 0.15s ease, opacity 0.15s ease;
}

.map-country.is-highlighted {
  fill: #60a5fa;
}

.map-country.is-guessed {
  fill: #f59e0b;
}

.map-country.is-dimmed {
  fill: #cbd5e1;
  opacity: 0.45;
}

.map-country.is-target {
  fill: #10b981;
}

.map-country.flash-correct {
  fill: #22c55e !important;
}

.map-country.flash-incorrect {
  fill: #ef4444 !important;
}

.bonus-question-card {
  margin-top: 12px;
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 10px;
}

.bonus-question-card h3 {
  margin: 0;
  font-size: 0.98rem;
  color: #1d4ed8;
}

body.dark-mode .bonus-question-card h3 {
  color: #bfdbfe;
}

.bonus-question-prompt {
  margin: 8px 0 0;
  color: #334155;
}

.bonus-question-card.is-active {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.game-bonus-question-actions {
  grid-template-columns: repeat(2, minmax(170px, 1fr));
}

.game-facts {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.game-subtabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-subtabs .game-btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
}

.game-subtab-panel {
  margin-top: 12px;
}

.game-subtab-panel .game-facts {
  margin-top: 0;
}

.game-end-screen {
  margin-top: 14px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #ffffff;
  padding: 14px;
}

.game-end-title {
  margin: 0;
  color: #1d4ed8;
}

.game-end-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.game-end-tabs {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.game-end-tabs .game-btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
}

.game-end-panel {
  margin-top: 12px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.game-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.game-summary-table th,
.game-summary-table td {
  border-bottom: 1px solid #dbeafe;
  text-align: left;
  vertical-align: top;
  padding: 8px 6px;
  color: #0f172a;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.game-summary-table th {
  font-weight: 700;
  color: #1e3a8a;
}

.game-summary-source {
  color: #475569;
  font-size: 0.85rem;
}

.game-summary-hints-country {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  padding: 10px;
}

.game-summary-hints-country + .game-summary-hints-country {
  margin-top: 10px;
}

.game-summary-hints-country h3 {
  margin: 0;
  color: #1e3a8a;
  font-size: 1rem;
}

.game-summary-hints-country ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.game-summary-hints-country li {
  margin: 4px 0;
  color: #0f172a;
}

.distribution-empty {
  margin: 0;
  color: #475569;
}

.distribution-meta {
  margin: 0;
  color: #334155;
}

.distribution-chart {
  margin-top: 10px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  padding: 12px;
}

.distribution-axis-label {
  margin: 0;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 600;
}

.distribution-bars-wrap {
  margin-top: 10px;
}

.distribution-grid {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: repeat(5, 26px);
}

.distribution-y-label {
  display: inline-flex;
  align-items: center;
  color: #475569;
  font-size: 0.78rem;
}

.distribution-y-line {
  border-top: 1px solid #dbeafe;
  align-self: center;
}

.distribution-bars {
  grid-column: 2;
  grid-row: 1 / span 5;
  min-height: 100%;
  border-left: 1px solid #dbeafe;
  border-bottom: 1px solid #dbeafe;
  padding: 0 6px;
  display: flex;
  gap: 8px;
  align-items: stretch;
  overflow-x: auto;
  z-index: 1;
}

.distribution-bar-col {
  flex: 0 0 44px;
  min-width: 44px;
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.distribution-bar-area {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.distribution-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: #3b82f6;
}

.distribution-bar-x {
  margin-top: 6px;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
}

.distribution-bar-value {
  margin-top: 2px;
  color: #475569;
  font-size: 0.72rem;
}

.game-fact {
  background: #f8fbff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 11px 12px;
  box-shadow: 0 4px 10px rgba(30, 64, 175, 0.06);
}

.game-fact-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.game-fact-meta .data-info-btn {
  margin-left: 0;
}

.game-fact-value {
  margin-top: 6px;
  color: #0f172a;
  line-height: 1.45;
}

.game-fact-rank {
  margin-top: 8px;
  display: inline-block;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.game-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
}

#guessInput {
  grid-column: 1 / span 2;
}

.game-guess-wrap {
  grid-column: 1 / span 2;
}

.game-bonus-actions {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.game-primary-guess-actions {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.game-primary-guess-actions .game-guess-wrap,
.game-primary-guess-actions .game-region-select {
  grid-column: 1;
}

.game-primary-guess-actions #submitGuessBtn {
  grid-column: 2;
}

.game-guess-section {
  margin-top: 12px;
}

.game-guess-title {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
  color: #1e3a8a;
}

.game-guess-mode-toggle {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.game-guess-mode-toggle .game-btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
}

#regionGuessSelect {
  grid-column: 1;
}

#submitGuessBtn {
  grid-column: 3;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  border-color: #0f766e;
  color: #ffffff;
}

#submitGuessBtn:hover:not(:disabled) {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  border-color: #0f766e;
}

#nextRoundBtn {
  grid-column: 1 / -1;
}

#nextRoundBtn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

#bonusAboveBtn:hover:not(:disabled),
#bonusUnderBtn:hover:not(:disabled),
#guessModeRegionBtn:hover:not(:disabled),
#guessModeCountryBtn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body.dark-mode #nextRoundBtn:hover:not(:disabled) {
  background: #2b3c52;
  border-color: #4b5f79;
}

body.dark-mode #bonusAboveBtn:hover:not(:disabled),
body.dark-mode #bonusUnderBtn:hover:not(:disabled),
body.dark-mode #guessModeRegionBtn:hover:not(:disabled),
body.dark-mode #guessModeCountryBtn:hover:not(:disabled) {
  background: #2b3c52;
  border-color: #4b5f79;
}

.game-status {
  margin: 12px 0 0;
  color: #334155;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.game-status.success {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.game-status.error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

@media (max-width: 860px) {
  .game-actions {
    grid-template-columns: 1fr;
  }

  #guessInput,
  #submitGuessBtn {
    grid-column: auto;
  }

  .game-end-header {
    flex-wrap: wrap;
  }

  .game-end-tabs {
    flex-wrap: wrap;
  }

  .game-summary-table {
    font-size: 0.88rem;
  }

  .game-summary-table th,
  .game-summary-table td {
    padding: 6px 4px;
  }

  .distribution-grid {
    grid-template-columns: 40px 1fr;
  }

  .distribution-bar-col {
    flex: 0 0 36px;
    min-width: 36px;
  }
}

.search-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.search-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.search-results:empty {
  display: none;
}

.search-result-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.active {
  background: #eff6ff;
}

.country-header {
  margin-top: 18px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}

.country-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.country-flag {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  object-fit: cover;
  background: #f8fafc;
  flex-shrink: 0;
}

.country-header h2 {
  margin: 0;
}

.country-header p {
  margin: 5px 0 0;
  color: #4b5563;
}

.country-flag-source {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #6b7280;
}

.country-flag-source a {
  color: #1d4ed8;
}

.content-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.category-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
}

.category-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.data-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  row-gap: 8px;
  column-gap: 8px;
}

.data-term {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-weight: 600;
  color: #374151;
}

.data-term-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.data-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.data-info-btn:hover {
  background: #e0e7ff;
  border-color: #93c5fd;
  color: #2563eb;
}

.data-info-btn-active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

/* Field Info Modal Overlay */
.field-info-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  animation: fadeInOverlay 0.15s ease-out;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.field-info-modal {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  width: 90%;
  max-width: 420px;
  overflow: hidden;
  animation: scaleInModal 0.18s ease-out;
}

@keyframes scaleInModal {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.field-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #e5e7eb;
}

.field-info-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.field-info-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.field-info-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.field-info-body {
  padding: 14px 18px 18px;
}

.field-info-desc {
  margin: 0 0 10px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #374151;
}

.field-info-source {
  margin: 0;
  font-size: 0.82rem;
  color: #6366f1;
  font-weight: 600;
}

.data-value {
  margin: 0;
  color: #111827;
  overflow-wrap: anywhere;
}

.data-value-collapsible .data-value-text {
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.data-value-collapsible.expanded .data-value-text {
  display: block;
  overflow: visible;
}

.data-toggle-btn {
  margin-top: 0;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 4px 8px;
  cursor: pointer;
}

.data-toggle-btn:hover {
  background: #dbeafe;
}

.data-rank {
  margin-top: 3px;
  font-size: 0.84rem;
  color: #2563eb;
}

.empty-state {
  margin-top: 14px;
  background: #ffffff;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  padding: 18px;
  color: #4b5563;
}

.explorer-title {
  margin: 0;
  font-size: 1.2rem;
}

.explorer-subtitle {
  margin: 6px 0 0;
  color: #4b5563;
}

.explorer-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

.explorer-select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px;
  font-size: 0.95rem;
  background: #ffffff;
}

.explorer-filter-input {
  margin: 6px 0 8px;
}

.explorer-table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.explorer-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}

.explorer-table th,
.explorer-table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 10px;
  vertical-align: top;
}

.explorer-table th {
  background: #f8fafc;
  font-weight: 700;
  white-space: nowrap;
}

.explorer-sort-btn {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

.explorer-sort-btn:hover {
  color: #1d4ed8;
}

.explorer-sort-indicator {
  font-size: 0.78rem;
  margin-left: 4px;
  opacity: 0.85;
}

.explorer-table tbody tr:hover {
  background: #f8fafc;
}

.train-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.train-grid[hidden] {
  display: none !important;
}

.train-fieldset {
  margin: 0;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}

.train-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  color: #1e3a8a;
}

.train-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.train-inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2937;
  font-size: 0.95rem;
}

.train-label {
  margin-top: 6px;
  margin-bottom: 4px;
  display: block;
  font-weight: 600;
  color: #374151;
}

.train-conditional {
  margin-top: 10px;
}

.train-play {
  margin-top: 14px;
}

.train-hints-config {
  margin-top: 12px;
}

.train-hints-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) auto;
  gap: 10px;
  align-items: end;
}

.train-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.train-hints-create-wrap {
  display: flex;
  align-items: center;
}

.train-hint-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #0f172a;
}

.train-hint-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.train-hint-remove-btn {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #be123c;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.train-hint-remove-btn:hover {
  background: #ffe4e6;
}

.train-hint-list-empty {
  color: #64748b;
  list-style: none;
  margin-left: -18px;
}

.train-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.train-flag {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  object-fit: cover;
  background: #f8fafc;
}

.train-hardest-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #0f172a;
}

.train-hardest-list li {
  margin-bottom: 4px;
}

@media (max-width: 860px) {
  .explorer-controls {
    grid-template-columns: 1fr;
  }

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

  .train-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .train-hints-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}
