:root {
  --ink: #1d2b3a;
  --card: #ffffff;
  --accent: #ff6b35;
  --accent-2: #ffb703;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #fff4e0; color: var(--ink); }
[hidden] { display: none !important; }

.panel {
  max-width: 640px; margin: 4vh auto; padding: 28px; background: var(--card);
  border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
h1 { margin: 0 0 6px; font-size: 2.2rem; color: var(--accent); }
h2 { margin: 22px 0 8px; font-size: 1.1rem; }
.tag { font-size: 1.1rem; margin: 0 0 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button, .row button {
  flex: 1 1 120px; padding: 12px; border: 2px solid #e3d5bd; background: #fffaf0;
  border-radius: 14px; font-size: 1rem; cursor: pointer; color: var(--ink);
}
.choices button small { display: block; font-size: .75rem; opacity: .7; margin-top: 2px; }
.choices button.on { border-color: var(--accent); background: #fff0e6; font-weight: 700; }
button.big {
  display: block; width: 100%; margin-top: 22px; padding: 16px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 1.3rem; font-weight: 700; cursor: pointer;
}
button.big:hover { filter: brightness(1.08); }
button.link { background: none; border: 0; margin-top: 12px; color: #4a5d73; text-decoration: underline; cursor: pointer; font-size: .95rem; }
.fine { font-size: .85rem; opacity: .75; line-height: 1.4; }
label { display: block; margin: 12px 0; font-weight: 600; }
select, input[type=number] { display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 1rem; border-radius: 10px; border: 2px solid #e3d5bd; }
fieldset { border: 2px solid #e3d5bd; border-radius: 12px; margin: 14px 0; }
label.radio { font-weight: 400; margin: 6px 0; }
.row { display: flex; gap: 8px; margin-top: 12px; }

#stage { position: fixed; inset: 0; background: #000; }
#canvas { width: 100%; height: 100%; display: block; }
#hud {
  position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
#menuBtn, #collectionBtn {
  background: rgba(0,0,0,.35); color: #fff; border: 0; padding: 8px 14px; border-radius: 999px;
  font-size: 1.2rem; cursor: pointer; backdrop-filter: blur(6px);
}
#banner { flex: 1; text-align: center; color: #fff; font-size: 1.1rem; text-shadow: 0 1px 6px rgba(0,0,0,.6); pointer-events: none; }
#meter {
  position: absolute; left: 5%; right: 5%; bottom: 14px; height: 14px; border-radius: 999px;
  background: rgba(255,255,255,.25); backdrop-filter: blur(4px); touch-action: none; cursor: ew-resize;
}
#meterFill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #ffd166, #ff6b35); transition: width .08s linear; }
#goalLine {
  position: absolute; top: -8px; bottom: -8px; width: 4px; background: #fff; border-radius: 2px;
  box-shadow: 0 0 6px rgba(0,0,0,.5); transform: translateX(-2px);
}
#goalLine span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); color: #fff; font-size: .7rem; text-shadow: 0 1px 3px #000; }
#toast {
  position: absolute; top: 70px; left: 50%; transform: translate(-50%, -20px); opacity: 0;
  background: rgba(255,255,255,.92); color: var(--ink); padding: 10px 20px; border-radius: 999px;
  font-size: 1.2rem; font-weight: 700; transition: all .4s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#settings, #collection { position: fixed; inset: 0; margin: auto; height: fit-content; max-height: 92vh; overflow: auto; z-index: 10; }
#collectionGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.cell { text-align: center; padding: 8px 4px; border-radius: 12px; background: #fffaf0; font-size: .75rem; }
.cell .em { font-size: 2rem; display: block; }
.cell.locked { opacity: .35; filter: grayscale(1); }
.cell.rare { outline: 2px solid var(--accent-2); }
