:root {
  --bg: #0c0d10; --panel: #15171c; --line: #262a33; --text: #eceef2; --muted: #8a919e;
  --accent: #ffcf5a; --accent-ink: #1b1403; --good: #5ee0a0; --bad: #ff7a6b;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% -10%, #1b1e26 0%, var(--bg) 60%);
  color: var(--text); font: 15px/1.5 var(--font);
  display: grid; grid-template-rows: auto 1fr auto auto; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.ball { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #b9bdc8 22%, #4a4f5c 60%, #15171c 100%); box-shadow: 0 4px 14px #0008; }
.hud { display: flex; gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; min-width: 76px; }
.stat .k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 17px; }

.stage { position: relative; margin: 0 22px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #000; min-height: 320px; }
#gl { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
@media (orientation: portrait) and (max-width: 760px) { .stage { min-height: 120vw; } }
#gl.dragging { cursor: grabbing; }
.view-labels { position: absolute; inset: 0; pointer-events: none; display: grid; grid-template-columns: 1fr 1fr; z-index: 1; }
.view-labels::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #ffffff22; }
.lbl { align-self: start; justify-self: start; margin: 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; background: #000a; padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(6px); }
.lbl.yours { color: var(--accent); }
.lbl em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.toast { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: #000c; padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 2; }

.panel { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 18px; align-items: end; padding: 16px 22px; }
.ctrl label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.ctrl output { color: var(--text); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input.kelvin { appearance: none; height: 6px; border-radius: 6px; background: linear-gradient(90deg, #ff8a2a, #ffd6a8 30%, #fff 50%, #cfe0ff 75%, #9bbcff); outline: none; }
input.kelvin::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid #0c0d10; box-shadow: 0 0 0 1px #fff8; cursor: pointer; }
input.kelvin::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #0c0d10; }
.actions { display: flex; gap: 8px; }
button { font: 700 14px var(--font); border-radius: 10px; padding: 11px 18px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button:hover { filter: brightness(1.08); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; width: min(440px, 92vw); box-shadow: 0 30px 80px #000c; }
dialog::backdrop { background: #000a; backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -0.01em; }
dialog p { color: #c9ced8; margin: 0 0 12px; }
.how { padding-left: 18px; margin: 0 0 14px; color: #c9ced8; }
.how li { margin: 4px 0; }
.big { font-size: 56px; font-weight: 800; color: var(--accent) !important; margin: 0 0 8px !important; font-variant-numeric: tabular-nums; line-height: 1; }
.breakdown { list-style: none; padding: 0; margin: 0 0 12px; }
.breakdown li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.breakdown .bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.breakdown .bar i { display: block; height: 100%; background: var(--good); }
.breakdown small { color: var(--muted); }
.tip { font-size: 13px; color: var(--muted) !important; }
dialog form { margin-top: 8px; }
dialog form button { width: 100%; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 14px; }

@media (max-width: 760px) {
  .panel { grid-template-columns: 1fr 1fr; }
  .actions { grid-column: 1 / -1; }
  .actions button { flex: 1; }
  .stage { margin: 0 12px; }
  .top, .panel { padding-inline: 12px; }
}
@media (orientation: portrait) and (max-width: 760px) {
  .view-labels { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .view-labels::after { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px; }
}
