:root {
  --bg: #101217;
  --panel: #191c23;
  --panel-2: #22262f;
  --line: #2e333e;
  --text: #eef0f4;
  --muted: #9aa2b1;
  --accent: #ffb547;
  --accent-ink: #1a1305;
  --great: #5fd38d;
  --ok: #ffb547;
  --bad: #ff6b6b;
  --aperture: #7cc4ff;
  --shutter: #ff9ad5;
  --iso: #b3f07a;
  --radius: 14px;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

body.no-scroll { overflow: hidden; }

a { color: var(--accent); }

button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: fade 0.25s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding: 18px 0 8px; }
.logo { image-rendering: pixelated; }
.hero h1 {
  font: 26px/1.35 var(--pixel);
  margin: 14px 0 10px;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #6a3f00;
}
.tagline { color: var(--muted); margin: 0 auto; max-width: 30ch; }
.tagline b { color: var(--text); }

.levels { display: grid; gap: 12px; margin: 24px 0 18px; }

.level-card {
  position: relative;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 16px 18px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s;
}
button.level-card:hover, button.level-card:focus-visible { border-color: var(--accent); outline: none; transform: translateY(-1px); }
button.level-card:active { transform: translateY(1px); }
.level-tag { font: 9px/1.4 var(--pixel); color: var(--accent); letter-spacing: 0.5px; }
.level-name { font-weight: 800; font-size: 19px; }
.level-desc { color: var(--muted); font-size: 14px; }
.level-best { font-size: 13px; color: var(--text); opacity: 0.8; margin-top: 4px; }
.level-card.locked { opacity: 0.5; border-style: dashed; }
.level-card .lock { position: absolute; top: 14px; right: 16px; font-size: 18px; }

.howto {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 18px;
}
.howto summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.howto ul { padding-left: 18px; }
.howto li { margin: 6px 0; color: var(--muted); }
.howto li b, .howto p b { color: var(--text); }
.howto p { color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  flex: none;
}
.progress { display: grid; flex: 1; min-width: 0; }
#level-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#round-label { font: 12px/1.6 var(--pixel); }
.score-pill {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--line);
  cursor: zoom-in;
}
.frame img {
  display: block;
  width: 100%;
  height: 100%;
}
.frame img { object-fit: contain; }
.frame [hidden] { display: none; }
.zoom-hint {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  padding: 0 7px;
  font-size: 16px;
  pointer-events: none;
}
.frame.zoomed {
  position: fixed;
  inset: 0;
  z-index: 50;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  cursor: zoom-out;
}
.frame.zoomed .zoom-hint { display: none; }

.loader { position: absolute; inset: 0; display: grid; place-items: center; }
.loader span {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 6px; }
.chip { color: var(--muted); font-size: 14px; flex: 1 1 200px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 4px 0; text-decoration: underline; }

#dials { display: grid; gap: 10px; margin: 8px 0 14px; }
.dial {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 8px;
}
.dial:nth-child(1) { --c: var(--aperture); }
.dial:nth-child(2) { --c: var(--shutter); }
.dial:nth-child(3) { --c: var(--iso); }
.dial-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dial-label { display: grid; }
.dial-label span { font-weight: 700; }
.dial-label small { color: var(--muted); font-size: 12px; }
.dial-value { font: 15px/1 var(--pixel); color: var(--c); white-space: nowrap; }
.dial-ctl { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.step {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 20px;
  font-weight: 700;
  touch-action: manipulation;
}
.step:active { background: var(--line); }
.dial-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 2px 50px 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 36px;
  background: transparent;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(to right, var(--c) var(--pct, 50%), var(--panel-2) var(--pct, 50%));
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(to right, var(--c) var(--pct, 50%), var(--panel-2) var(--pct, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  margin-top: -8px;
  border-radius: 6px;
  background: var(--text);
  border: 3px solid var(--c);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 6px;
  background: var(--text);
  border: 3px solid var(--c);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.primary, .secondary {
  display: block;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 16px;
  border: 0;
}
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 #a86a10; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #a86a10; }
.secondary { background: var(--panel-2); border: 1px solid var(--line); margin-top: 10px; }

/* reveal */
#reveal-panel { margin-top: 8px; }
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
}
.res-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.25fr 0.9fr;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.res-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 0; }
.res-name { font-weight: 700; }
.res-guess { color: var(--muted); }
.res-actual { display: grid; }
.res-actual small { color: var(--muted); font-size: 11px; }
.res-pts { display: grid; gap: 4px; }
.res-pts i { display: block; height: 5px; border-radius: 5px; background: var(--panel-2); position: relative; overflow: hidden; }
.res-pts i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--great); }
.res-pts i[data-tier="ok"]::after { background: var(--ok); }
.res-pts i[data-tier="bad"]::after { background: var(--bad); }
.res-total { display: flex; justify-content: space-between; padding: 10px 0 6px; }
.res-total b { color: var(--accent); }

.tips { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.tip {
  background: var(--panel);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: #d5d9e1;
}
.tip-aperture { border-color: var(--aperture); }
.tip-shutter { border-color: var(--shutter); }
.tip-iso { border-color: var(--iso); }
.tip-exposure { border-color: var(--accent); }

.credit {
  display: grid;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.credit span { color: var(--muted); }
.credit a { font-weight: 700; margin-top: 4px; }
.credit[hidden] { display: none; }

.sum-title { font: 16px/1.5 var(--pixel); text-align: center; margin: 26px 0 8px; color: var(--accent); }
.sum-score { text-align: center; font: 40px/1.3 var(--pixel); }
.sum-score small { font-size: 14px; color: var(--muted); }
.sum-rank { text-align: center; font-weight: 800; font-size: 20px; margin: 6px 0; }
.sum-best { text-align: center; color: var(--great); font-weight: 700; margin: 0; }
.sum-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 8px; }
.sum-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.sum-item img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #000; }
.sum-txt { display: grid; min-width: 0; font-size: 13px; }
.sum-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.sum-txt span { color: var(--muted); }
.sum-pts { font: 13px var(--pixel); color: var(--accent); padding-right: 4px; }

.noscript { text-align: center; padding: 40px 16px; }

@media (min-width: 600px) {
  .hero h1 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
