:root {
  --ink: #f4f4f4;
  --ink-dim: #a6a6a6;
  --ink-faint: #6d6d6d;
  --rail: #1e1e1e;
  --rail-2: #2b2b2b;
  --line: rgba(244, 244, 244, 0.08);
  --accent: #da3a00;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #141414;
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  overflow: hidden;
}

/* ── the scene ─────────────────────────────────────────────────────── */
#scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #2468b4;
  outline: none;
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#scene canvas {
  position: absolute;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#fire { pointer-events: none; }

/* ── the line of help ──────────────────────────────────────────────── */
.hint-wrap {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
.hint-wrap.bottom { bottom: 16px; }
.hint-wrap.top { top: 16px; }

.hint-wrap p {
  margin: 0;
  padding: 6px 10px;
  border-radius: 3px;
  background: rgba(11, 26, 51, 0.55);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

/* ── touch buttons (shown on phones / tablets) ─────────────────────── */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }

#touch-ui button {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  height: 56px;
  width: 4.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(11, 26, 51, 0.6);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  touch-action: none;
  cursor: pointer;
}
#touch-ui button:active { background: rgba(11, 26, 51, 0.9); }
#touch-ui button.on { border-color: rgba(255, 255, 255, 0.7); }
#view-btn { left: max(14px, env(safe-area-inset-left)); }
#boost { right: max(14px, env(safe-area-inset-right)); }

/* ── the top bar ───────────────────────────────────────────────────── */
#top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  pointer-events: none;
  z-index: 5;
}
#top .brand { display: flex; align-items: baseline; gap: 8px; pointer-events: auto; }
#top .name { font-size: 15px; font-weight: 500; letter-spacing: 0.01em; }
#top .sub { font-size: 12px; color: var(--ink-dim); }

#credit {
  position: fixed;
  top: 56px;
  left: 14px;
  z-index: 5;
  font-size: 10px;
  line-height: 1.25;
  color: rgba(166, 166, 166, 0.7);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
#credit a {
  color: rgba(244, 244, 244, 0.6);
  text-decoration: none;
  pointer-events: auto;
  border-bottom: 1px solid rgba(244, 244, 244, 0.18);
}
#credit a:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.5); }
#panel-toggle, #fs {
  pointer-events: auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(30, 30, 30, 0.82);
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
#fs { margin-left: 6px; }
#panel-toggle:hover, #fs:hover { border-color: rgba(244, 244, 244, 0.2); }

/* ── boot cover ────────────────────────────────────────────────────── */
#boot {
  position: fixed;
  inset: 0;
  background: #141414;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#boot.gone { opacity: 0; }

/* ── the control panel ─────────────────────────────────────────────── */
#panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 88vw;
  background: var(--rail);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  z-index: 6;
}
body.panel-open #panel { transform: translateX(0); }

#panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-dim);
}
#panel-close {
  border: 0;
  background: none;
  color: var(--ink-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
#panel-close:hover { color: var(--ink); }

#panel-body {
  padding: 4px 14px 24px;
  overflow-y: auto;
  flex: 1;
}

#panel-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
}
#reset {
  width: 100%;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #191919;
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
}
#reset:hover { border-color: rgba(244, 244, 244, 0.2); }
#panel-foot .keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}
#panel-foot .keys b { color: var(--ink-dim); font-weight: 500; }
#panel-foot .share { margin: 8px 0 0; font-size: 10.5px; color: var(--ink-faint); }

#panel-body h3 {
  margin: 18px 0 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
#panel-body h3:first-child { margin-top: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  min-height: 32px;
}
.row .label {
  flex: 1;
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.3;
}

.row input[type="range"] {
  flex: 0 0 108px;
  accent-color: var(--accent);
  height: 18px;
}
.row .val {
  flex: 0 0 34px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.row input[type="checkbox"] {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #2b2b2b;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8a8a8a;
  transition: transform 0.15s ease, background 0.15s ease;
}
.row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.row input[type="checkbox"]:checked::after { transform: translateX(14px); background: #fff; }

.row input[type="number"] {
  width: 70px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #191919;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.row input[type="color"] {
  width: 42px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #191919;
  cursor: pointer;
}

.seg { display: flex; gap: 4px; }
.seg button {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #191919;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.seg button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 640px) {
  #top .sub { display: none; }
  .hint-wrap p { font-size: 9.5px; letter-spacing: 0.1em; }

  /* the panel becomes a bottom sheet */
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: 68vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }
  body.panel-open #panel { transform: translateY(0); }
  #credit { top: 54px; left: 12px; }
}
