:root {
  --bg: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.8);
  --accent: #22d3ee;
  --accent-dark: #0ea5e9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --success: #34d399;
  --fail: #f87171;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #1e293b, #0f172a 55%);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  gap: 1.5rem;
}

.app-header {
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.mode-tabs {
  margin: 1.25rem auto 0;
  display: inline-flex;
  gap: 0.4rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
}

.mode-tabs .mode-tab {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-tabs .mode-tab:hover,
.mode-tabs .mode-tab:focus-visible {
  color: var(--text);
}

.mode-tabs .mode-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-tabs .mode-tab.active {
  background: rgba(34, 211, 238, 0.2);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 8px 16px rgba(14, 165, 233, 0.2);
}

.app-body {
  display: grid;
  grid-template-columns: minmax(250px, 360px) 1fr;
  gap: 1.5rem;
}

.game-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border-radius: 18px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.45);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.timer {
  color: var(--accent);
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#state-input {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 2px solid transparent;
  font-size: 1rem;
  font-weight: 500;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#state-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
}

#state-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.3s;
}

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

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #0b1120;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.35);
}

button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(14, 165, 233, 0.45);
}

button.secondary {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

button.secondary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.instruction-card {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 14px;
  padding: 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

.instruction-card h2 {
  margin-top: 0;
  color: var(--text);
  font-size: 1.1rem;
}

.result-panel {
  background: rgba(15, 23, 42, 0.75);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.4);
}

.result-panel h2 {
  margin: 0;
  font-size: 1.8rem;
}

.result-panel .result-summary {
  margin: 0;
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.result-panel .result-actions button {
  min-width: 180px;
}

.copy-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2rem;
}

.copy-status.success {
  color: var(--success);
}

.copy-status.error {
  color: var(--fail);
}

.map-panel {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(14px);
  border-radius: 24px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.45);
  gap: 0.5rem;
}

.map-controls {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.4rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
}

.toggle input {
  appearance: none;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0f172a;
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle input:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.toggle input:checked::after {
  transform: translateX(20px);
  background: #0b1120;
}

#map-wrapper {
  width: 100%;
  max-width: 800px;
  aspect-ratio: 16 / 9;
}

#us-map {
  width: 100%;
  height: 100%;
}

.state-path {
  fill: #1e293b;
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 0.6;
  transition: fill 0.3s ease, stroke 0.3s ease;
}

.state-path.correct {
  fill: rgba(52, 211, 153, 0.75);
  stroke: rgba(16, 185, 129, 0.9);
}

.state-path.missed {
  fill: rgba(248, 113, 113, 0.55);
  stroke: rgba(239, 68, 68, 0.85);
}

.state-label {
  font-size: 0.55rem;
  fill: #f8fafc;
  text-anchor: middle;
  pointer-events: none;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.state-label.visible {
  opacity: 1;
}

.state-label.correct {
  fill: #052e16;
}

.state-label.missed {
  fill: #fee2e2;
}

.capital-label {
  font-size: 0.5rem;
}

#map-wrapper.show-all-labels .state-name-label {
  opacity: 0.28;
}

#map-wrapper.show-all-labels .state-name-label.visible,
#map-wrapper.show-all-labels .state-name-label.correct,
#map-wrapper.show-all-labels .state-name-label.missed {
  opacity: 1;
}


.result-summary {
  color: var(--muted);
}

@media (max-width: 960px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .map-panel {
    order: -1;
  }

  .map-controls {
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 1rem;
  }

  .mode-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .status-bar {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .action-buttons {
    width: 100%;
  }

  button {
    flex: 1;
  }

  .state-label {
    font-size: 0.45rem;
  }
}

.hidden {
  display: none !important;
}
