:root {
  --bg: #0f2a36;
  --surface: #1a3a4a;
  --surface-light: #233d4d;
  --accent: #e59c45;
  --accent-light: #f0b860;
  --text: #f0f4f8;
  --text-secondary: #b8c5d6;
  --muted: #6b8a9a;
  --ok: #2e9e5b;
  --ok-light: #3fbb72;
  --danger: #c0392b;
  --warning: #e67e22;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
}

.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

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

/* Home Screen */
#screen-home {
  justify-content: flex-start;
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.route-list {
  display: grid;
  gap: 16px;
}

.route-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.route-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.route-card h3 {
  margin-bottom: 8px;
  color: var(--accent);
}

.route-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.route-meta {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  background: rgba(229, 156, 69, 0.15);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.live {
  background: rgba(46, 158, 91, 0.15);
  color: var(--ok);
}

/* Mode Selection */
#screen-mode {
  justify-content: center;
  align-items: center;
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 500px;
  width: 100%;
}

.mode-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid var(--surface-light);
}

.mode-card:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.mode-card h3 {
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.mode-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.mode-icon {
  font-size: 2.5rem;
  margin-bottom: 15px;
}

/* Join Screen */
#screen-join {
  justify-content: center;
  align-items: center;
}

.join-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.join-form h2 {
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 2px solid var(--surface-light);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(229, 156, 69, 0.05);
}

.input-field::placeholder {
  color: var(--muted);
}

/* Game Screen */
#screen-game {
  justify-content: flex-start;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--surface);
}

.game-header h2 {
  font-size: 1.4rem;
}

.progress-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.3s ease;
}

.progress-dot.active {
  background: var(--accent);
  width: 12px;
}

.progress-dot.done {
  background: var(--ok);
}

.gps-section {
  margin-bottom: 30px;
}

.gps-display {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.gps-compass {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}

.gps-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--surface-light);
  transition: all 0.3s ease;
}

.gps-circle.near {
  border-color: var(--ok);
  box-shadow: 0 0 30px rgba(46, 158, 91, 0.5);
}

.gps-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    var(--ok) 0deg,
    var(--ok) var(--fill-angle, 0deg),
    rgba(46, 158, 91, 0.1) var(--fill-angle, 0deg)
  );
  transition: --fill-angle 0.3s ease;
}

.gps-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.gps-status {
  margin-top: 20px;
}

.gps-distance {
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 5px;
}

.gps-message {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.gps-message.success {
  color: var(--ok);
}

.gps-message.error {
  color: var(--danger);
}

.step-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.step-title {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.step-hint {
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 15px;
}

.challenge-section {
  background: var(--surface-light);
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.challenge-section h4 {
  color: var(--accent);
  margin-bottom: 15px;
}

.challenge-question {
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

.challenge-options {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.option-btn {
  background: var(--bg);
  border: 2px solid var(--surface);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 0.95rem;
}

.option-btn:hover {
  border-color: var(--accent);
  background: rgba(229, 156, 69, 0.1);
}

.option-btn.selected {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.text-answer-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 2px solid var(--surface);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  margin-bottom: 15px;
}

.text-answer-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(229, 156, 69, 0.05);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 44px;
  min-width: 100px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--surface-light);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #a82e20;
  transform: translateY(-2px);
}

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-group .btn {
  flex: 1;
}

/* Completion Screen */
#screen-done {
  justify-content: center;
  align-items: center;
}

.completion-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}

.completion-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.completion-card h2 {
  margin-bottom: 10px;
  color: var(--ok);
  font-size: 2rem;
}

.completion-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.completion-stats {
  background: var(--surface-light);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 25px;
  text-align: left;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  color: var(--text-secondary);
}

.stat-line strong {
  color: var(--text);
}

/* Flash messages */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash.success {
  background: rgba(46, 158, 91, 0.2);
  color: var(--ok);
  border-left: 4px solid var(--ok);
}

.flash.error {
  background: rgba(192, 57, 43, 0.2);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

.flash.info {
  background: rgba(229, 156, 69, 0.2);
  color: var(--accent);
  border-left: 4px solid var(--accent);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(229, 156, 69, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 600px) {
  .screen {
    padding: 12px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .mode-selector {
    grid-template-columns: 1fr;
  }

  .btn-group {
    flex-direction: column;
  }

  .gps-compass {
    width: 150px;
    height: 150px;
  }

  .game-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Print styles */
@media print {
  body {
    display: none;
  }
}

/* Dark mode (default, already applied) */
@media (prefers-color-scheme: light) {
  /* Users preferring light mode still get dark theme for this app */
  /* Override system preference */
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
