/* Downhill Shred — UI shell styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: var(--sky-top);
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--sky-top);
}

#game { display: block; background: var(--sky-top); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(15, 24, 48, 0.55), rgba(15, 24, 48, 0.88));
  z-index: 30;
  padding: 16px;
}
.screen.active { display: flex; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  max-width: min(92vw, 660px);
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  touch-action: pan-y;              /* panels may overflow on phones — allow scroll */
  -webkit-overflow-scrolling: touch;
}

h1.logo {
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 52px);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 3px 0 #7b3f16, 0 8px 22px rgba(255, 140, 66, 0.35);
}
.subtitle { color: var(--ink-dim); font-size: 14px; margin-top: 2px; }

.menu-btn {
  display: block; width: 100%;
  margin-top: 10px; padding: 12px 18px;
  font-size: 17px; font-weight: 700;
  font-family: var(--font);
  color: var(--ink);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.menu-btn.primary { background: var(--accent); color: #23120a; border-color: transparent; }
.menu-btn:active { transform: scale(0.97); }

.coin-badge { color: var(--coin); font-weight: 700; }

/* ---------- character select ---------- */
.char-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.char-card {
  width: 98px; padding: 8px 5px;
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer; position: relative;
}
.char-card.selected { border-color: var(--accent); background: rgba(255, 140, 66, 0.16); }
.char-card.locked { opacity: 0.55; }
.char-card canvas { width: 56px; height: 56px; }
.char-name { font-weight: 800; font-size: 13px; }
.char-desc { font-size: 10px; color: var(--ink-dim); min-height: 30px; margin-top: 3px; }
.char-cost { font-size: 12px; color: var(--coin); font-weight: 700; margin-top: 4px; }
.stat-bars { margin-top: 6px; display: grid; gap: 3px; }
.stat-row { display: flex; align-items: center; gap: 4px; font-size: 9px; color: var(--ink-dim); }
.stat-track { flex: 1; height: 4px; background: rgba(255,255,255,0.12); border-radius: 2px; }
.stat-fill { height: 100%; border-radius: 2px; background: var(--accent-soft); }

/* ---------- settings / board ---------- */
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; gap: 18px; font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.toggle {
  min-width: 64px; padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.toggle.on { background: var(--accent); color: #23120a; border-color: transparent; }

table.board { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.board td, table.board th {
  padding: 6px 8px; font-size: 14px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
table.board th { color: var(--ink-dim); font-size: 12px; }
table.board tr.latest td { color: var(--accent); font-weight: 800; }
.record-line { color: var(--ink-dim); font-size: 13px; margin-top: 8px; }

/* ---------- game over ---------- */
.score-breakdown { display: grid; gap: 5px; margin: 12px 0; text-align: left; }
.score-breakdown div { display: flex; justify-content: space-between; font-size: 15px; }
.score-breakdown .total { font-size: 22px; font-weight: 900; color: var(--accent); border-top: 1px solid rgba(255,255,255,0.15); padding-top: 6px; }
.new-record { color: var(--good); font-weight: 900; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

/* ---------- in-game touch controls ---------- */
#controls { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; }
#controls.active { display: block; }

.ctl {
  position: absolute;
  pointer-events: auto;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  touch-action: none;
}
.ctl:active, .ctl.pressed { background: var(--btn-active); color: #23120a; border-color: transparent; }
.ctl small { font-size: 10px; font-weight: 600; opacity: 0.75; }

#btn-jump  { right: max(3vw, 16px); bottom: max(6vh, 20px); width: 108px; height: 108px; font-size: 18px; }
#btn-flip  { right: calc(max(3vw, 16px) + 124px); bottom: max(5vh, 16px); width: 74px; height: 74px; font-size: 13px; }
#btn-trick { right: calc(max(3vw, 16px) + 42px); bottom: calc(max(6vh, 20px) + 122px); width: 74px; height: 74px; font-size: 13px; }
#btn-crouch { left: max(3vw, 16px); bottom: max(6vh, 20px); width: 96px; height: 96px; font-size: 14px; }

#btn-pause {
  position: absolute; top: 10px; right: 12px;
  width: 44px; height: 44px; border-radius: 10px;
  font-size: 18px; pointer-events: auto;
}

/* tutorial overlay */
#tutorial {
  position: fixed; left: 50%; top: 12%;
  transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 18px; z-index: 25;
  font-size: 14px; text-align: center; line-height: 1.55;
  display: none; max-width: 88vw;
}
#tutorial.active { display: block; }
