:root {
  --bg-start: #667eea;
  --bg-end: #764ba2;
  --card: rgba(255,255,255,0.95);
  --card-glass: rgba(255,255,255,0.15);
  --text: #2d3436;
  --text-light: rgba(255,255,255,0.9);
  --accent: #764ba2;
  --success: #00b894;
  --error: #e74c3c;
  --warning: #fdcb6e;
  --btn-primary: #764ba2;
  --btn-hover: #5a3580;
  --shadow: 0 8px 32px rgba(0,0,0,0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ========== SCREENS ========== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ========== CARDS ========== */
.card {
  background: var(--card);
  border-radius: 24px;
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}

.card-glass {
  background: var(--card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 24px;
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  color: var(--text-light);
}

/* ========== TYPOGRAPHY ========== */
.title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.2;
}

.subtitle {
  font-size: 16px;
  opacity: 0.7;
  margin-bottom: 20px;
  line-height: 1.4;
}

.emoji-big {
  font-size: 64px;
  margin-bottom: 16px;
  display: block;
}

.emoji-huge {
  font-size: 96px;
  margin-bottom: 16px;
  display: block;
}

.question-text {
  font-size: 20px;
  font-weight: 600;
  margin: 16px 0;
  line-height: 1.4;
}

.hint-text {
  font-size: 14px;
  opacity: 0.6;
  margin-bottom: 20px;
  line-height: 1.4;
}

.stop-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--btn-primary);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  width: 100%;
  max-width: 400px;
  margin-top: 16px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-success {
  background: var(--success);
}

.btn-outline {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.4);
  color: var(--text-light);
}

.btn-outline:active {
  background: rgba(255,255,255,0.1);
}

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

.btn-garage {
  background: linear-gradient(135deg, #f7971e, #ffd200);
  color: #333;
  font-size: 22px;
  padding: 24px 32px;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(247,151,30,0.4);
}

.btn-garage:active {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ========== NUMPAD ========== */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin: 16px auto 0;
}

.numpad-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 16px;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.numpad-btn:active {
  transform: scale(0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.numpad-btn.correct {
  background: var(--success);
  color: #fff;
  animation: popCorrect 0.5s ease;
}

.numpad-btn.wrong {
  background: var(--error);
  color: #fff;
  animation: shake 0.5s ease;
}

/* ========== CODE INPUT (final) ========== */
.code-display {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.code-digit {
  width: 44px;
  height: 56px;
  border-radius: 12px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  border: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}

.code-digit.active {
  border-color: var(--accent);
  background: #fff;
}

.code-digit.filled {
  background: #e8dff5;
}

.numpad-small {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 240px;
  margin: 12px auto 0;
}

.numpad-small .numpad-btn {
  font-size: 22px;
  border-radius: 12px;
}

.numpad-small .numpad-btn-wide {
  grid-column: span 3;
  aspect-ratio: auto;
  padding: 12px;
  font-size: 16px;
  background: #f0f0f0;
}

/* ========== COMPASS ========== */
.compass-container {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--card-glass);
  border: 3px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  position: relative;
}

.compass-arrow {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 90px solid #ff6b6b;
  position: absolute;
  transform-origin: center bottom;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
  top: 20px;
  left: calc(50% - 20px);
}

.compass-arrow::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 90px solid rgba(255,255,255,0.3);
  top: 90px;
  left: -20px;
}

.compass-center {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: absolute;
  z-index: 2;
}

.compass-n {
  position: absolute;
  top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  opacity: 0.5;
}

.distance-display {
  font-size: 48px;
  font-weight: 800;
  color: var(--text-light);
  margin: 8px 0;
}

.distance-unit {
  font-size: 18px;
  font-weight: 400;
  opacity: 0.7;
}

.distance-label {
  font-size: 14px;
  opacity: 0.6;
  color: var(--text-light);
}

.destination-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 4px;
}

/* ========== PROXIMITY ========== */
.proximity-ok {
  background: rgba(0,184,148,0.2) !important;
  border-color: var(--success) !important;
}

.proximity-badge {
  display: inline-block;
  background: var(--success);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 16px;
  margin: 12px 0;
  animation: pulse 1.5s infinite;
}

/* ========== ATTEMPTS ========== */
.attempts {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}

.attempt-heart {
  font-size: 22px;
  transition: opacity 0.3s;
}

.attempt-heart.lost {
  opacity: 0.2;
  filter: grayscale(1);
}

/* ========== FEEDBACK ========== */
.feedback {
  font-size: 18px;
  font-weight: 700;
  margin-top: 12px;
  min-height: 28px;
  transition: opacity 0.3s;
}

.feedback-wrong {
  color: var(--error);
}

.feedback-warn {
  color: var(--warning);
}

/* ========== SUMMARY ========== */
.summary-list {
  text-align: left;
  margin: 12px 0;
  list-style: none;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  line-height: 1.3;
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-num {
  background: var(--accent);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* ========== CONFETTI CANVAS ========== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

/* ========== ANIMATIONS ========== */
@keyframes shake {
  0%, 100% { transform: translateX(0) scale(0.9); }
  20% { transform: translateX(-8px) scale(0.9); }
  40% { transform: translateX(8px) scale(0.9); }
  60% { transform: translateX(-6px) scale(0.9); }
  80% { transform: translateX(6px) scale(0.9); }
}

@keyframes popCorrect {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

/* ========== GAME OVER ========== */
.gameover-overlay {
  background: rgba(231,76,60,0.95);
}

/* ========== GARAGE NOTE ========== */
.garage-note {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 12px;
  color: var(--text-light);
  line-height: 1.4;
}

/* ========== SCROLLABLE CARD ========== */
.card-scroll {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* ========== SAFE AREA ========== */
@supports (padding-top: env(safe-area-inset-top)) {
  .screen {
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* ========== GPS STATUS ========== */
.gps-status {
  font-size: 12px;
  opacity: 0.5;
  color: var(--text-light);
  margin-top: 8px;
}

.gps-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 4px;
  vertical-align: middle;
}

.gps-dot.inactive {
  background: var(--error);
}
