/* ============ TIME TO FLY — UI stylesheet ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #04060d;
  --ink: #e8edf7;
  --dim: #8b96ad;
  --faint: #5c6a84;
  --cyan: #46e0ff;
  --cyan-soft: #8fd8ff;
  --gold: #ffc44d;
  --red: #ff5d6c;
  --panel: rgba(10, 15, 27, 0.78);
  --line: rgba(120, 160, 220, 0.18);
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --disp: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--disp);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#scene { position: fixed; inset: 0; display: block; touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(1, 3, 8, 0.62) 100%);
}
#grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0.5;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
}

.hidden { display: none !important; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  transition: opacity 0.7s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.loader-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(70, 224, 255, 0.15);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-family: var(--mono); font-size: 11px; letter-spacing: 0.5em; color: var(--dim); text-align: center; line-height: 2; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 5, 10, 0.42);
}

/* ---------- title ---------- */
.title-inner { text-align: center; padding: 24px; }
.kicker { font-family: var(--mono); font-size: 11px; letter-spacing: 0.55em; color: var(--cyan); margin-bottom: 26px; }
.game-title {
  font-size: clamp(56px, 11vw, 128px); font-weight: 700; line-height: 0.95;
  letter-spacing: 0.06em; color: #f2f6ff;
  text-shadow: 0 0 44px rgba(70, 224, 255, 0.22);
}
.game-title .gold { color: var(--gold); text-shadow: 0 0 44px rgba(255, 196, 77, 0.3); }
.tagline { margin: 26px 0 38px; color: var(--dim); letter-spacing: 0.14em; font-size: 14px; font-weight: 300; }
.title-actions { display: flex; gap: 16px; justify-content: center; }
.title-foot { margin-top: 52px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.4em; color: var(--faint); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
  padding: 15px 34px; background: transparent; color: var(--ink);
  border: 1px solid rgba(140, 170, 220, 0.35); cursor: pointer;
  transition: all 0.18s ease;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: inset 0 0 22px rgba(70,224,255,0.08), 0 0 22px rgba(70,224,255,0.1); }
.btn.primary { border-color: rgba(255, 196, 77, 0.6); color: var(--gold); }
.btn.primary:hover { border-color: var(--gold); box-shadow: inset 0 0 22px rgba(255,196,77,0.1), 0 0 26px rgba(255,196,77,0.16); color: #ffd98a; }

.icon-btn {
  width: 38px; height: 38px; background: var(--panel); color: #cfd9ec;
  border: 1px solid var(--line); cursor: pointer; font-size: 15px; line-height: 1;
  transition: all 0.15s ease; font-family: var(--disp);
}
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* ---------- panels (select / howto) ---------- */
.panel-wrap {
  width: min(92vw, 880px); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 22px 26px;
}
.panel-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.panel-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.45em; color: var(--ink); }
.panel-spacer { flex: 1; }

#levelGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; overflow-y: auto; padding: 2px 4px 6px 2px;
}
#levelGrid::-webkit-scrollbar { width: 6px; }
#levelGrid::-webkit-scrollbar-thumb { background: rgba(120,160,220,0.25); }

.level-card {
  text-align: left; background: rgba(16, 23, 40, 0.65);
  border: 1px solid var(--line); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 7px;
  cursor: pointer; transition: all 0.18s ease;
  color: inherit; font-family: inherit;
}
.level-card:hover:not(.locked) { transform: translateY(-3px); border-color: rgba(70, 224, 255, 0.65); box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.level-card.locked { opacity: 0.32; cursor: not-allowed; }
.lc-num { font-family: var(--mono); font-size: 10px; letter-spacing: 0.35em; color: var(--cyan); }
.lc-name { font-size: 17px; font-weight: 600; letter-spacing: 0.08em; }
.lc-meta { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: 0.12em; }
.lc-stars { font-size: 14px; letter-spacing: 0.25em; color: var(--gold); }
.lc-stars .off { color: rgba(255, 196, 77, 0.16); }

/* ---------- how to ---------- */
.howto-panel { width: min(92vw, 640px); }
.how-rows { overflow-y: auto; padding-right: 4px; }
.how-row { display: flex; gap: 20px; margin: 15px 0; align-items: baseline; }
.how-key { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--cyan); min-width: 118px; text-align: right; flex-shrink: 0; }
.how-desc { color: #c6d0e2; font-size: 13.5px; line-height: 1.65; font-weight: 300; }
.how-desc b { color: var(--ink); font-weight: 600; }
.how-actions { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px; }
.hud-level { font-family: var(--mono); font-size: 10px; letter-spacing: 0.4em; color: var(--cyan); }
.hud-name { font-size: 20px; font-weight: 600; letter-spacing: 0.14em; margin-top: 5px; }
.hud-stats { display: flex; gap: 30px; }
.stat { text-align: center; }
.stat .label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.3em; color: var(--dim); display: block; margin-bottom: 5px; }
.stat .value { font-family: var(--mono); font-size: 20px; color: var(--ink); }
.stat .value.low { color: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.hud-right { display: flex; gap: 10px; pointer-events: auto; }

.hud-bottom { display: flex; flex-direction: column; align-items: center; gap: 13px; padding-bottom: 26px; }
.ring-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.4em; color: var(--cyan-soft); }
.ring-label .lock { color: var(--gold); }
.rotate-controls { display: flex; gap: 14px; pointer-events: auto; align-items: center; }
.rotate-btn {
  width: 62px; height: 62px; border-radius: 50%;
  border: 1px solid rgba(70, 224, 255, 0.4); background: rgba(10, 16, 28, 0.78);
  color: var(--cyan); font-size: 23px; cursor: pointer; transition: all 0.15s ease;
}
.rotate-btn:hover { box-shadow: 0 0 26px rgba(70,224,255,0.22); border-color: var(--cyan); }
.rotate-btn:active { transform: scale(0.93); }
.slow-btn {
  height: 62px; padding: 0 24px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.28em;
  border: 1px solid rgba(255, 196, 77, 0.45); color: var(--gold);
  background: rgba(10, 16, 28, 0.78); cursor: pointer; transition: all 0.15s ease; line-height: 1.7;
}
.slow-btn:hover { box-shadow: 0 0 26px rgba(255,196,77,0.18); }
.slow-btn.active { background: rgba(255, 196, 77, 0.16); box-shadow: 0 0 30px rgba(255,196,77,0.3); }
.hint { font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; color: var(--faint); }

/* ---------- overlays ---------- */
#slowmoBadge {
  position: fixed; top: 86px; left: 50%; transform: translateX(-50%); z-index: 9;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.55em; color: var(--gold);
  animation: badgePulse 1.1s ease-in-out infinite; pointer-events: none;
}
@keyframes badgePulse { 50% { opacity: 0.4; } }

#toast {
  position: fixed; bottom: 128px; left: 50%; transform: translateX(-50%); z-index: 20;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.28em; color: var(--ink);
  background: rgba(10, 16, 28, 0.88); border: 1px solid var(--line);
  padding: 11px 24px; opacity: 0; transition: opacity 0.25s ease; pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

#levelIntro { position: fixed; top: 32%; width: 100%; text-align: center; pointer-events: none; z-index: 9; opacity: 0; }
#levelIntro.show { animation: intro 1.9s ease forwards; }
.li-num { font-family: var(--mono); font-size: 11px; letter-spacing: 0.6em; color: var(--cyan); margin-bottom: 12px; }
.li-name { font-size: clamp(28px, 4.5vw, 46px); font-weight: 600; letter-spacing: 0.22em; color: #f2f6ff; text-shadow: 0 0 34px rgba(70,224,255,0.25); }
@keyframes intro {
  0% { opacity: 0; transform: translateY(16px); }
  16% { opacity: 1; transform: translateY(0); }
  74% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* ---------- win ---------- */
.win-panel {
  background: rgba(9, 13, 24, 0.86); border: 1px solid rgba(255, 196, 77, 0.32);
  padding: 46px 64px; text-align: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.win-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 0.55em; color: var(--cyan); margin-bottom: 14px; }
.win-level { font-size: clamp(24px, 3.4vw, 38px); font-weight: 600; letter-spacing: 0.18em; margin-bottom: 20px; }
.win-stars { font-size: 42px; letter-spacing: 0.32em; color: rgba(255, 196, 77, 0.14); margin-bottom: 18px; }
.win-stars span { display: inline-block; }
.win-stars .on { color: var(--gold); text-shadow: 0 0 26px rgba(255, 196, 77, 0.65); animation: starPop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes starPop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-stats { font-family: var(--mono); font-size: 11px; letter-spacing: 0.24em; color: var(--dim); margin-bottom: 30px; }
.win-actions { display: flex; gap: 14px; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .hud-stats { gap: 16px; }
  .stat .value { font-size: 16px; }
  .hud-name { font-size: 15px; }
  .hint { display: none; }
  .hud-top { padding: 14px 14px; }
  .win-panel { padding: 34px 26px; }
  .how-key { min-width: 88px; font-size: 9px; }
  .title-actions { flex-direction: column; align-items: center; }
}
