/* ============================================================
   VARIABLES & RESET
   ============================================================ */
:root {
  --forest: #2d6a4f;
  --forest-light: #52b788;
  --ocean: #1565c0;
  --ocean-light: #42a5f5;
  --desert: #bf360c;
  --desert-light: #ff7043;
  --arctic: #01579b;
  --arctic-light: #4fc3f7;

  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: rgba(255,255,255,0.08);
  --text: #e6edf3;
  --text-muted: #8b949e;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

button { cursor: pointer; border: none; outline: none; font-family: inherit; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: linear-gradient(135deg, #2ea043, #3fb950);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 2px 8px rgba(46,160,67,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(46,160,67,0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.btn-large { padding: 14px 32px; font-size: 1.1rem; border-radius: 10px; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover { background: #2d333b; border-color: rgba(255,255,255,0.2); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.small { padding: 6px 10px; font-size: 0.8rem; }

/* ============================================================
   HEADER
   ============================================================ */
#header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 1.8rem; }
.header-brand h1 { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.brand-sub { font-size: 0.72rem; color: var(--text-muted); display: block; }

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

#header-progress { display: flex; align-items: center; gap: 8px; }
#progress-label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.progress-track {
  width: 100px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ea043, #3fb950);
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ============================================================
   PHASES
   ============================================================ */
.phase { display: none; max-width: 960px; margin: 0 auto; padding: 32px 20px 60px; }
.phase.active { display: block; }

.phase-header { text-align: center; margin-bottom: 28px; }
.phase-header h2 { font-size: 1.6rem; margin-bottom: 6px; }
.phase-header p { color: var(--text-muted); font-size: 0.95rem; }

.phase-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   INTRO PHASE
   ============================================================ */
.intro-wrap { text-align: center; max-width: 640px; margin: 0 auto; }
.intro-hero-icon { font-size: 5rem; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.intro-wrap h2 { font-size: 2rem; font-weight: 700; margin-bottom: 10px; }
.intro-sub { color: var(--text-muted); font-size: 1rem; margin-bottom: 32px; max-width: 480px; margin-left: auto; margin-right: auto; }

.intro-phases {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.intro-phase-card {
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.forest-bg  { background: linear-gradient(135deg, #1b4332, #2d6a4f); }
.ocean-bg   { background: linear-gradient(135deg, #0a1929, #1565c0); }
.desert-bg  { background: linear-gradient(135deg, #4a1a00, #bf360c); }
.arctic-bg  { background: linear-gradient(135deg, #0a1929, #01579b); }

.phase-num {
  position: absolute;
  top: 8px; left: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
}
.phase-icon { font-size: 1.8rem; }
.intro-phase-card strong { font-size: 0.95rem; }
.intro-phase-card span { font-size: 0.75rem; color: rgba(255,255,255,0.7); text-align: center; }

.intro-note { color: var(--text-muted); font-size: 0.85rem; margin-top: 12px; }

.wordpress-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  padding: 6px 14px;
  border-radius: 99px;
  background: rgba(33, 115, 185, 0.15);
  border: 1px solid rgba(33, 115, 185, 0.3);
  color: #42a5f5;
  font-size: 0.78rem;
}

/* ============================================================
   TRAINING PHASE
   ============================================================ */
.category-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.cat-tab {
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--text-muted);
  transition: all 0.2s;
}
.cat-tab:hover { background: var(--surface); color: var(--text); }
.cat-tab.active { color: #fff; border-color: currentColor; }
.cat-tab.forest-tab  { --tab-color: var(--forest-light); }
.cat-tab.ocean-tab   { --tab-color: var(--ocean-light); }
.cat-tab.desert-tab  { --tab-color: var(--desert-light); }
.cat-tab.arctic-tab  { --tab-color: var(--arctic-light); }
.cat-tab.active { color: var(--tab-color); border-color: var(--tab-color); background: rgba(255,255,255,0.05); }

.training-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.training-tip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}
.training-tip strong { color: var(--text); }

/* ============================================================
   ANIMAL CARD
   ============================================================ */
.animal-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.animal-card:not(.placed-card) { cursor: grab; }
.animal-card:not(.placed-card):hover { transform: translateY(-4px); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.animal-card:not(.placed-card):active { cursor: grabbing; }

.card-photo {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  position: relative;
}
.card-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.4));
}

.card-body { padding: 10px 10px 12px; }
.card-name { font-size: 0.82rem; font-weight: 600; margin-bottom: 7px; line-height: 1.3; }
.card-attrs { display: flex; flex-wrap: wrap; gap: 4px; }
.attr-pill {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Card states */
.animal-card.dragging { opacity: 0.4; transform: scale(0.95); }
.animal-card.selected {
  outline: 3px solid #3fb950;
  outline-offset: 2px;
  transform: translateY(-4px);
}
.animal-card.correct-flash { animation: correctPulse 0.5s ease forwards; }
.animal-card.wrong-flash { animation: wrongShake 0.5s ease forwards; }

@keyframes correctPulse {
  0% { box-shadow: 0 0 0 0 rgba(46,160,67,0.8); }
  100% { box-shadow: 0 0 0 20px rgba(46,160,67,0); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Card ghost (drag clone) */
.card-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  opacity: 0.9;
  transform: rotate(5deg) scale(1.05);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  width: 160px;
}

/* ============================================================
   PRACTICE / TEST ARENA
   ============================================================ */
#practice-arena, #test-arena {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.cards-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: 100px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.cards-pool-label {
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
}

.drop-zones-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.drop-zone {
  border-radius: var(--radius);
  border: 2px dashed rgba(255,255,255,0.15);
  min-height: 160px;
  padding: 12px;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  position: relative;
}
.drop-zone-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  pointer-events: none;
}
.drop-zone-icon { font-size: 1.2rem; }
.drop-zone-label { font-size: 0.9rem; font-weight: 600; }
.drop-zone-count { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

.drop-zone-cards { display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }

/* zone active states */
.drop-zone.hover-valid {
  border-style: solid;
  background: rgba(46,160,67,0.08);
  transform: scale(1.01);
}
.drop-zone.hover-invalid {
  border-color: rgba(248,81,73,0.5);
  background: rgba(248,81,73,0.05);
}

/* zone category colors */
.drop-zone[data-cat="forest"] { border-color: rgba(82,183,136,0.3); }
.drop-zone[data-cat="ocean"]  { border-color: rgba(66,165,245,0.3); }
.drop-zone[data-cat="desert"] { border-color: rgba(255,112,67,0.3); }
.drop-zone[data-cat="arctic"] { border-color: rgba(79,195,247,0.3); }

.drop-zone[data-cat="forest"] .drop-zone-label { color: var(--forest-light); }
.drop-zone[data-cat="ocean"]  .drop-zone-label { color: var(--ocean-light); }
.drop-zone[data-cat="desert"] .drop-zone-label { color: var(--desert-light); }
.drop-zone[data-cat="arctic"] .drop-zone-label { color: var(--arctic-light); }

/* placed cards in zones are smaller */
.drop-zone .animal-card {
  width: 90px;
  cursor: default;
}
.drop-zone .animal-card .card-photo { height: 60px; font-size: 2rem; }
.drop-zone .animal-card .card-name { font-size: 0.7rem; }
.drop-zone .animal-card .card-attrs { display: none; }
.drop-zone .animal-card.wrong-card { outline: 2px solid #f85149; }
.drop-zone .animal-card.right-card { outline: 2px solid #3fb950; }

/* ============================================================
   PRACTICE SUMMARY
   ============================================================ */
.summary-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
  text-align: center;
}
.summary-score { font-size: 3rem; font-weight: 800; margin: 8px 0; }
.summary-sub { color: var(--text-muted); margin-bottom: 20px; }
.summary-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ============================================================
   TEST PHASE
   ============================================================ */
.test-phase-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  text-align: left;
}
.test-phase-header h2 { font-size: 1.5rem; }
.test-phase-header p { color: var(--text-muted); font-size: 0.9rem; }

.test-hud {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.hud-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  min-width: 64px;
}
.hud-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 2px; }
.hud-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#timer-display.urgent { color: #f85149; animation: timerPulse 1s ease-in-out infinite; }

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   RESULTS PHASE
   ============================================================ */
.results-wrap { max-width: 520px; margin: 0 auto; text-align: center; }
#results-badge { font-size: 4rem; margin-bottom: 12px; }
#results-title { font-size: 1.8rem; margin-bottom: 20px; }

#results-score-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  font-size: 2.2rem;
  font-weight: 800;
  border: 6px solid var(--surface-2);
}
#results-score-ring.score-great { border-color: #3fb950; color: #3fb950; }
#results-score-ring.score-good  { border-color: #d29922; color: #d29922; }
#results-score-ring.score-poor  { border-color: #f85149; color: #f85149; }
.ring-label { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }

#results-breakdown { margin-bottom: 24px; }
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.breakdown-cat { font-weight: 600; flex: 1; text-align: left; }
.breakdown-bar-wrap { flex: 2; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.breakdown-bar { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.breakdown-frac { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; min-width: 36px; text-align: right; }

.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#results-best { margin-top: 16px; font-size: 0.82rem; color: var(--text-muted); }

/* ============================================================
   TAP SELECT INDICATOR
   ============================================================ */
#tap-indicator {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: #2ea043;
  color: #fff;
  border-radius: 99px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(46,160,67,0.5);
  animation: slideUp 0.3s ease;
}
#tap-indicator button {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  font-size: 0.85rem;
  line-height: 1;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ============================================================
   TOUR OVERLAY
   ============================================================ */
#tour-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
}
#tour-overlay.active { display: block; }

#tour-spotlight {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.75);
  transition: all 0.35s ease;
  pointer-events: none;
}

#tour-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  padding: 16px 18px;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  pointer-events: all;
  z-index: 8001;
  transition: all 0.35s ease;
}
#tour-tooltip::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  background: var(--surface);
  border-left: 1px solid rgba(255,255,255,0.15);
  border-bottom: 1px solid rgba(255,255,255,0.15);
  transform: rotate(-45deg);
  top: -7px;
  left: 24px;
}
.tour-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
#tour-counter { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
#tour-skip { background: none; color: var(--text-muted); font-size: 0.8rem; padding: 2px 6px; border-radius: 4px; }
#tour-skip:hover { background: var(--surface-2); color: var(--text); }
#tour-message { font-size: 0.88rem; line-height: 1.5; margin-bottom: 12px; color: var(--text); }
.tour-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .phase { padding: 20px 14px 60px; }

  .header-brand h1 { font-size: 0.95rem; }
  .brand-sub { display: none; }
  .progress-track { width: 60px; }

  .intro-wrap h2 { font-size: 1.5rem; }
  .intro-phases { grid-template-columns: 1fr; gap: 8px; }
  .intro-phase-card { flex-direction: row; padding: 12px 14px; text-align: left; gap: 12px; }
  .phase-icon { font-size: 1.4rem; flex-shrink: 0; }
  .intro-phase-card span { display: none; }

  .phase-header h2 { font-size: 1.25rem; }

  .training-cards-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  .drop-zones-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .drop-zone { min-height: 130px; padding: 8px; }
  .drop-zone-label { font-size: 0.8rem; }

  .test-phase-header { flex-direction: column; }
  .test-hud { align-self: flex-end; }

  #tour-tooltip { width: 240px; }

  .category-tabs { gap: 6px; }
  .cat-tab { padding: 6px 12px; font-size: 0.8rem; }
}

@media (max-width: 400px) {
  .drop-zones-grid { grid-template-columns: 1fr; }
}
