/* ===== Sky Runner — UI ===== */
:root {
  --bg: #070a12;
  --bg-2: #0c111c;
  --panel: rgba(11, 16, 27, 0.82);
  --panel-2: rgba(20, 27, 42, 0.7);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #eef3fb;
  --muted: #8b98ad;
  --accent: #ff6a3d;
  --accent-2: #22d3ee;
  --gold: #ffc94d;
  --green: #38e07b;
  --danger: #ff4d5e;
  --grad: linear-gradient(120deg, #ff8a4c 0%, #ff5a3c 45%, #ff3d7f 100%);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --font-display: 'Orbitron', 'Impact', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%; overflow: hidden; background: var(--bg);
  color: var(--text); font-family: var(--font-body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: none; user-select: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx-scan {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0.5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#ui { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ===== screens ===== */
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 56px) max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.screen.active { display: flex; animation: screenIn 0.32s cubic-bezier(.2,.8,.3,1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#s-menu { background: linear-gradient(100deg, rgba(4,7,14,.94) 0%, rgba(5,9,18,.82) 38%, rgba(6,10,20,.15) 66%, rgba(6,10,20,0) 100%); }
#s-levels, #s-runners, #s-howto, #s-settings { background: radial-gradient(120% 90% at 50% -10%, rgba(18,26,44,.96), rgba(5,8,15,.97)); }
#s-levels, #s-runners, #s-howto, #s-settings { overflow-y: auto; }

.kicker {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .24em;
  color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 8px;
}
.kicker.center { justify-content: center; }
.kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* ===== menu ===== */
.menu-grid { margin: auto 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; width: 100%; }
.brand { max-width: 620px; }
.logo {
  font-family: var(--font-display); font-weight: 900; color: #fff;
  font-size: clamp(46px, 8vw, 104px); line-height: .92; letter-spacing: -0.02em;
  margin: 10px 0 6px; text-shadow: 0 8px 44px rgba(255, 90, 60, .35);
}
.logo span {
  display: inline-block;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 26px rgba(255,90,60,.45));
}
.tagline { color: #b9c6d9; font-size: clamp(13px, 1.5vw, 17px); margin-bottom: 26px; letter-spacing: .01em; }
.menu-actions { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-strip { display: flex; gap: 26px; margin-top: 26px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 20px; color: #fff; letter-spacing: .02em; }
.stat span { font-family: var(--font-mono); font-size: 9px; letter-spacing: .2em; color: var(--muted); }
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; padding-bottom: 10px; }
.badge-vert {
  writing-mode: vertical-rl; font-family: var(--font-display); font-size: 11px; letter-spacing: .5em;
  color: rgba(255,255,255,.35); padding: 12px 6px; border-left: 1px solid var(--line);
}
.hero-note { font-family: var(--font-mono); font-size: 10px; color: rgba(255,255,255,.32); letter-spacing: .1em; }

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: .12em;
  color: var(--text); background: transparent; cursor: pointer;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: var(--grad); color: #12070a;
  box-shadow: 0 10px 34px rgba(255, 90, 60, .34), inset 0 1px 0 rgba(255,255,255,.28);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 44px rgba(255, 90, 60, .48); }
.btn-primary:active { transform: translateY(0) scale(.985); }
.btn-ghost { border-color: var(--line-2); background: rgba(255,255,255,.035); color: #dbe5f2; }
.btn-ghost:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.28); transform: translateY(-2px); }
.btn-ghost:active { transform: translateY(0); }
.btn-xl { padding: 18px 40px; font-size: 15px; border-radius: 999px; min-width: 240px; }
.btn-xl svg { width: 18px; height: 18px; }
.btn-icon { padding: 12px; width: 44px; height: 44px; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-text {
  background: none; border: none; color: var(--muted); font-size: 10px; margin-top: 6px;
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}
.btn-text:hover { color: var(--text); }
.btn:disabled, .btn.locked { opacity: .4; cursor: not-allowed; transform: none !important; }

/* ===== screen head ===== */
.screen-head { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; flex: none; }
.screen-head h2 { font-family: var(--font-display); font-size: clamp(24px, 3.4vw, 38px); letter-spacing: -.01em; line-height: 1; margin-top: 4px; }
.screen-head .back { flex: none; }
.head-right { margin-left: auto; font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; color: var(--muted); }
.head-right span { color: var(--gold); }

/* ===== level grid ===== */
.level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(10px, 1.4vw, 18px); align-content: start; padding-bottom: 20px; }
.level-card {
  position: relative; border-radius: var(--r); overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); min-height: 132px;
  background: linear-gradient(160deg, rgba(28,38,58,.9), rgba(10,15,25,.94));
  transition: transform .18s ease, box-shadow .22s ease, border-color .2s;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 14px;
}
.level-card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--card-grad, linear-gradient(180deg, rgba(255,106,61,.22), transparent 70%));
  opacity: .9;
}
.level-card:hover { transform: translateY(-4px); border-color: rgba(255,255,255,.26); box-shadow: 0 18px 40px rgba(0,0,0,.55); }
.level-card.locked { cursor: not-allowed; }
.level-card.locked::after {
  content: ''; position: absolute; inset: 0; background: rgba(5,8,14,.62); backdrop-filter: blur(2px);
}
.level-card .num {
  position: absolute; top: 10px; left: 13px; font-family: var(--font-display);
  font-size: 30px; color: rgba(255,255,255,.18); line-height: 1; letter-spacing: -.02em;
}
.level-card .lname { font-family: var(--font-display); font-size: 12px; letter-spacing: .04em; color: #fff; z-index: 1; margin-bottom: 7px; text-transform: uppercase; }
.level-card .lmeta { display: flex; align-items: center; justify-content: space-between; z-index: 1; }
.level-card .stars { display: flex; gap: 2px; }
.level-card .stars svg { width: 12px; height: 12px; fill: rgba(255,255,255,.18); }
.level-card .stars svg.on { fill: var(--gold); filter: drop-shadow(0 0 6px rgba(255,201,77,.55)); }
.level-card .bt { font-family: var(--font-mono); font-size: 9.5px; color: rgba(255,255,255,.5); }
.level-card .lock-badge {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; z-index: 2; color: rgba(255,255,255,.7); font-family: var(--font-mono); font-size: 9px; letter-spacing: .18em;
}
.level-card .lock-badge svg { width: 20px; height: 20px; }

/* ===== runners ===== */
.runner-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.5vw, 18px); align-content: start; padding-bottom: 20px; }
.runner-card {
  position: relative; border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(26,35,54,.9), rgba(9,13,22,.95));
  padding: 16px; display: flex; gap: 14px; align-items: center; cursor: pointer;
  transition: transform .18s ease, border-color .2s, box-shadow .22s;
}
.runner-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.25); box-shadow: 0 16px 36px rgba(0,0,0,.5); }
.runner-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 14px 34px rgba(255,106,61,.25); }
.runner-card.locked { cursor: not-allowed; opacity: .62; }
.runner-thumb {
  width: 62px; height: 74px; border-radius: 12px; flex: none; position: relative; overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.12), rgba(0,0,0,.35));
  display: grid; place-items: center;
}
.runner-thumb svg { width: 42px; height: 58px; }
.runner-info { min-width: 0; }
.runner-info h4 { font-family: var(--font-display); font-size: 13px; letter-spacing: .06em; }
.runner-info .role { font-family: var(--font-mono); font-size: 9px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
.runner-info .req { display: flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 9.5px; color: var(--gold); margin-top: 8px; }
.runner-info .req svg { width: 11px; height: 11px; fill: currentColor; }
.runner-card .tick {
  position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; opacity: 0; transition: opacity .2s;
}
.runner-card.sel .tick { opacity: 1; }
.runner-card .tick svg { width: 12px; height: 12px; stroke: #12070a; stroke-width: 3.4; fill: none; }

/* ===== how to play ===== */
.howto-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.4vw, 16px); align-content: start; padding-bottom: 20px; }
.howto-card {
  border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  background: linear-gradient(160deg, rgba(24,33,50,.85), rgba(9,13,22,.9));
  display: flex; gap: 13px; align-items: flex-start;
}
.howto-card .ico {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: rgba(255,106,61,.12); border: 1px solid rgba(255,106,61,.28); color: var(--accent);
}
.howto-card .ico svg { width: 19px; height: 19px; }
.howto-card h4 { font-family: var(--font-display); font-size: 11.5px; letter-spacing: .08em; margin-bottom: 5px; }
.howto-card p { font-size: 11.5px; line-height: 1.55; color: #a9b6c9; }
.howto-card .keys { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
kbd {
  font-family: var(--font-mono); font-size: 9px; padding: 2px 6px; border-radius: 5px;
  background: rgba(255,255,255,.07); border: 1px solid var(--line-2); color: #cbd6e6;
}

/* ===== settings ===== */
.settings-list { display: flex; flex-direction: column; gap: 10px; max-width: 720px; padding-bottom: 24px; }
.setting-row {
  display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.setting-row .label { flex: 1; min-width: 0; }
.setting-row .label b { display: block; font-size: 13px; font-weight: 600; }
.setting-row .label span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.switch {
  width: 50px; height: 28px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255,255,255,.07); position: relative; cursor: pointer; flex: none; transition: background .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #8b98ad; transition: transform .22s cubic-bezier(.2,.9,.3,1.2), background .2s;
}
.switch.on { background: rgba(255,106,61,.24); border-color: rgba(255,106,61,.5); }
.switch.on::after { transform: translateX(22px); background: var(--accent); box-shadow: 0 0 14px rgba(255,106,61,.7); }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 150px; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.14); outline: none; flex: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 0 12px rgba(255,106,61,.6);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--accent); }

/* ===== modals ===== */
.modal-layer {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(3,6,12,.72); backdrop-filter: blur(9px); padding: 20px; z-index: 20;
}
.modal-layer.active { display: flex; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(460px, 100%); border-radius: var(--r-lg); padding: 28px;
  background: linear-gradient(165deg, rgba(24,32,48,.98), rgba(8,12,20,.99));
  border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: modalIn .3s cubic-bezier(.2,.9,.3,1.05);
  text-align: center;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.96) } to { opacity: 1; transform: none } }
.modal-title { font-family: var(--font-display); font-size: 24px; margin: 8px 0 18px; letter-spacing: -.01em; }
.modal-actions { display: flex; flex-direction: column; gap: 9px; }
.modal-actions.row2 { flex-direction: row; justify-content: center; }
.modal-actions.row2 .btn { flex: 1; }
.victory .modal-title { margin-bottom: 6px; }
.star-row { display: flex; justify-content: center; gap: 10px; margin: 14px 0 20px; }
.star { width: 46px; height: 46px; fill: rgba(255,255,255,.1); transition: fill .3s, filter .3s, transform .3s; }
.star.on { fill: var(--gold); filter: drop-shadow(0 0 16px rgba(255,201,77,.7)); transform: scale(1.06); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.result-grid > div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; }
.result-grid span { display: block; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .18em; color: var(--muted); }
.result-grid b { display: block; font-family: var(--font-display); font-size: 15px; margin-top: 4px; }

/* ===== touch controls ===== */
#controls { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
#controls.hidden { display: none; }
.pad { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; }
.pad-left { left: max(18px, env(safe-area-inset-left)); }
.pad-right { right: max(18px, env(safe-area-inset-right)); align-items: center; }
.tbtn {
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 78px; height: 78px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18);
  background: rgba(10,15,25,.42); backdrop-filter: blur(8px); color: rgba(255,255,255,.9);
  font-family: var(--font-display); font-size: 9px; letter-spacing: .1em; cursor: pointer;
  transition: transform .1s ease, background .12s ease, border-color .12s;
  touch-action: none; -webkit-user-select: none;
}
.tbtn svg { width: 26px; height: 26px; opacity: .92; }
.tbtn:active, .tbtn.down { transform: scale(.93); background: rgba(255,106,61,.28); border-color: rgba(255,106,61,.6); }
.tbtn-jump { width: 92px; height: 92px; background: rgba(255,106,61,.16); border-color: rgba(255,106,61,.34); }
.tbtn-jump svg { width: 32px; height: 32px; }
.tbtn-slide { width: 70px; height: 70px; }

/* ===== responsive ===== */
@media (max-width: 860px) {
  .logo { font-size: clamp(38px, 9vw, 64px); }
  .menu-grid { gap: 16px; }
  .level-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .runner-grid, .howto-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .level-card { min-height: 112px; padding: 11px; }
  .level-card .num { font-size: 24px; }
}
@media (max-height: 460px) {
  .menu-actions { gap: 8px; }
  .btn-xl { padding: 13px 30px; font-size: 13px; min-width: 200px; }
  .btn { padding: 9px 16px; font-size: 11px; }
  .tagline { margin-bottom: 16px; font-size: 12px; }
  .stat-strip { margin-top: 16px; gap: 18px; }
  .stat b { font-size: 16px; }
  .level-card { min-height: 96px; }
  .screen-head { margin-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
