/* Stick Runner - styles.css */

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

:root {
  --bg-0: #0f0f1e;
  --bg-1: #1a1a2e;
  --panel: rgba(20, 22, 40, 0.85);
  --panel-2: rgba(30, 35, 60, 0.9);
  --border: #2c3252;
  --text: #ffffff;
  --muted: #aab0c8;
  --accent: #ffd700;
  --accent-2: #4cc9f0;
  --danger: #ff4757;
  --good: #2ecc71;
  --btn: #0f3460;
  --btn-h: #16213e;
}

html, body {
  height: 100%;
  width: 100%;
  background: linear-gradient(to bottom, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Generic screen */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.visible {
  display: flex;
}

.screen h1 {
  font-size: 2.6rem;
  letter-spacing: 3px;
  margin: 8px 0 4px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.screen h2 {
  font-size: 1.4rem;
  letter-spacing: 2px;
  margin: 12px 0 8px;
  color: var(--accent-2);
}

.screen p, .screen li {
  color: var(--muted);
  line-height: 1.5;
}

/* Top bar (menu) */
.top-bar {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.top-bar .stats {
  display: flex;
  gap: 14px;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.top-bar .stats .pill {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.icon-row {
  display: flex;
  gap: 6px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.icon-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:focus-visible,
.button:focus-visible,
.small-btn:focus-visible,
.roster .slot:focus-visible,
.biome-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.button {
  background: var(--btn);
  color: var(--text);
  border: 2px solid var(--btn-h);
  padding: 14px 36px;
  border-radius: 25px;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 2px;
  transition: transform 0.15s, background 0.15s;
}

.button:active { transform: scale(0.96); background: var(--btn-h); }
.button.primary { background: linear-gradient(135deg, #1e63a8, #0f3460); }
.button.ghost  { background: transparent; border-color: var(--border); }
.button.danger { background: #6e1f2e; border-color: #8a2b3a; }

.small-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
}

/* Biome strip */
.biome-strip {
  width: 100%;
  max-width: 720px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 4px;
  scrollbar-width: thin;
}

.biome-card {
  flex: 0 0 150px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.biome-card.selected {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.biome-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.biome-card .preview {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}

.biome-card .name {
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 1rem;
}

.biome-card .req {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Character roster */
.roster {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.roster .slot {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px 4px 6px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.roster .slot.selected {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.roster .slot.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.roster .slot canvas {
  width: 56px;
  height: 70px;
  display: block;
  margin: 0 auto 2px;
}

.roster .slot .label {
  font-size: 0.78rem;
  letter-spacing: 1px;
  color: var(--text);
}

.roster .slot .req {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Play CTA */
.cta-row {
  display: flex;
  gap: 12px;
  margin: 16px 0 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Game HUD */
#gameScreen {
  background: #000;
  padding: 0;
  justify-content: flex-start;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 12px;
  left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 10;
}

#scoreText {
  font-size: 1.8rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#speedText {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 4px;
}

#coinHud {
  font-size: 0.95rem;
  color: var(--accent);
  margin-top: 2px;
}

#boostIndicator {
  position: absolute;
  top: 90px; left: 0; right: 0;
  text-align: center;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

#boostIndicator.active { opacity: 1; }

#instructions {
  position: absolute;
  bottom: 12px; left: 0; right: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 1px;
  pointer-events: none;
  line-height: 1.4;
}

/* Touch-style jump button (control style = button) */
#jumpBtn {
  display: none;
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.25);
  border: 3px solid var(--accent);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: bold;
  z-index: 20;
}

body.control-button #jumpBtn { display: flex; align-items: center; justify-content: center; }

/* Game over */
#gameOverScreen .gameOverTitle {
  font-size: 2.2rem;
  color: var(--danger);
  letter-spacing: 2px;
  margin-bottom: 12px;
}

#gameOverScreen .finalScore {
  font-size: 1.4rem;
  margin-bottom: 6px;
  font-weight: 600;
}

#newBestBadge {
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 3px;
  margin: 10px 0 8px;
  text-shadow: 0 0 12px rgba(255,215,0,0.6);
}

/* Forms (settings) */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
}

.form-row label { color: var(--text); font-size: 1rem; text-align: left; }
.form-row input[type="range"] { width: 160px; }
.form-row select, .form-row input[type="text"] {
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

/* Lists (leaderboard, achievements) */
.list {
  width: 100%;
  max-width: 540px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.list .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.list .row:last-child { border-bottom: none; }

.tabs {
  display: flex;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
}

.tab.active { background: var(--btn); border-color: var(--accent); }

.achievement {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.achievement:last-child { border-bottom: none; }
.achievement.locked { opacity: 0.55; }
.achievement .name { font-weight: 600; }
.achievement .desc { font-size: 0.82rem; color: var(--muted); }

/* Shop grid */
.shop-grid {
  width: 100%;
  max-width: 540px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.shop-item {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  position: relative;
}

.shop-item canvas { width: 60px; height: 50px; display: block; margin: 0 auto 4px; }
.shop-item.owned { border-color: var(--good); }
.shop-item.selected { border-color: var(--accent); }

/* Toasts */
#toastLayer {
  position: fixed;
  top: 16px;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 9999;
}

.toast {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease-out;
  max-width: 90vw;
}

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

/* Reduced motion: kill all transitions */
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation: none !important;
  transition: none !important;
}

/* Small screens */
@media (max-width: 480px) {
  .screen h1 { font-size: 2rem; }
  .roster { grid-template-columns: repeat(4, 1fr); }
  .roster .slot canvas { width: 48px; height: 60px; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); }
  .biome-card { flex: 0 0 130px; }
}

/* ===== LIGHT THEME ===== */
:root[data-theme="light"] {
  --bg-0: #f6f6fb;
  --bg-1: #e9ebf5;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-2: rgba(255, 255, 255, 0.98);
  --border: rgba(15, 18, 40, 0.14);
  --text: #15192e;
  --muted: #5b6280;
  --btn: #15192e;
  --btn-h: #2a3050;
}
:root[data-theme="light"] html,
:root[data-theme="light"] body {
  background: linear-gradient(to bottom, #f6f6fb 0%, #e9ebf5 50%, #f6f6fb 100%);
  color: #15192e;
}
:root[data-theme="light"] .pill { background: rgba(15,18,40,0.06); color: #15192e; }
:root[data-theme="light"] .button.ghost { color: #15192e; border-color: rgba(15,18,40,0.3); }
:root[data-theme="light"] .icon-btn { background: rgba(15,18,40,0.06); color: #15192e; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-0: #f6f6fb;
    --bg-1: #e9ebf5;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-2: rgba(255, 255, 255, 0.98);
    --border: rgba(15, 18, 40, 0.14);
    --text: #15192e;
    --muted: #5b6280;
    --btn: #15192e;
    --btn-h: #2a3050;
  }
  :root:not([data-theme="dark"]) html,
  :root:not([data-theme="dark"]) body {
    background: linear-gradient(to bottom, #f6f6fb 0%, #e9ebf5 50%, #f6f6fb 100%);
    color: #15192e;
  }
}
