:root {
  --bg: #07090c;
  --panel: rgba(12, 16, 22, 0.88);
  --ink: #e8eef4;
  --muted: #8b97a4;
  --line: #243040;
  --accent: #3d7ea6;
  --gold: #c4a35a;
  --hot: #b5523a;
  --ok: #6aa84f;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 "IBM Plex Sans", "Segoe UI", sans-serif;
  overflow: hidden;
}

#c { display: block; width: 100%; height: 100%; }

#hud {
  position: absolute;
  inset: max(12px, env(safe-area-inset-top)) auto auto max(12px, env(safe-area-inset-left));
  width: 340px;
  max-height: calc(100% - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px 16px;
  backdrop-filter: blur(10px);
  z-index: 5;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hud-bar h1 { margin: 0; }
#btn-hud {
  flex-shrink: 0;
  min-height: 36px;
}

#hud.collapsed {
  width: min(340px, calc(100vw - 24px));
  max-height: none;
  overflow: hidden;
  padding: 10px 12px;
}
#hud.collapsed .hud-body { display: none; }

h1 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.sub {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 12px;
}

.row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}
button {
  background: #151b24;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
}
button:hover { border-color: var(--accent); }
button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

label.opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  color: var(--ink);
  cursor: pointer;
}

.stats {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stats b { color: var(--ink); font-weight: 600; text-align: right; }

.swatches { display: flex; gap: 10px; margin: 8px 0 4px; font-size: 11px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: -1px; }

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11.5px;
}

#hint {
  position: absolute;
  right: 16px;
  bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.media { margin-top: 14px; }
a.dl {
  display: inline-flex;
  align-items: center;
  background: #151b24;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  text-decoration: none;
}
a.dl:hover { border-color: var(--gold); color: #fff; }
a.dl.block { margin: 12px 16px 16px; width: calc(100% - 32px); justify-content: center; }

#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
}
#modal[hidden] { display: none; }
.sheet {
  width: min(960px, 100%);
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.sheet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}
#fly { display: block; width: 100%; background: #000; max-height: 70vh; }

@media (max-width: 720px) {
  #hud {
    inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) auto max(8px, env(safe-area-inset-left));
    width: auto;
    max-width: none;
  }
  #hud:not(.collapsed) {
    max-height: min(70vh, calc(100% - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  #hint {
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    text-align: center;
    font-size: 11px;
  }
  button, a.dl {
    min-height: 40px;
    padding: 8px 12px;
  }
  #modal { padding: 8px; align-items: flex-end; }
  .sheet { width: 100%; border-radius: 12px 12px 8px 8px; }
  #fly { max-height: 50vh; }
}
