:root {
  --bg: #14161b;
  --panel: #1d2028;
  --panel-2: #262a34;
  --line: #343946;
  --text: #eef0f4;
  --muted: #9aa1ae;
  --hazard: #ffc400;
  --red: #ff4d3d;
  --green: #4cd27a;
  --silly: #ff7ad9;
  --standard: #58b4ff;
  --overkill: #ff4d3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; }

/* Header */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 4px solid var(--hazard);
  background: repeating-linear-gradient(-45deg, #1a1c22 0 18px, #16181d 18px 36px);
}
.logo { font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 30px; margin: 0; letter-spacing: 1px; }
.logo span { color: var(--hazard); }
.tag { margin: 0; color: var(--muted); flex: 1; }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  width: 40px; height: 40px; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { border-color: var(--hazard); }

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(240px, 300px);
  gap: 16px;
  padding: 16px;
  max-width: 1400px; width: 100%; margin: 0 auto;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; min-width: 0;
  max-height: calc(100vh - 140px); overflow-y: auto;
}
.panel h2 {
  font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 15px;
  margin: 2px 4px 10px; color: var(--hazard); letter-spacing: .5px;
}
.picker { display: flex; flex-direction: column; gap: 6px; }
.tier {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px;
  margin: 10px 4px 2px; color: var(--muted);
}
.tier.silly { color: var(--silly); }
.tier.standard { color: var(--standard); }
.tier.overkill { color: var(--overkill); }

.pick {
  display: grid; grid-template-columns: 36px 1fr; gap: 2px 10px; align-items: center;
  text-align: left; padding: 8px 10px;
  background: var(--panel-2); border: 2px solid transparent; border-radius: 10px;
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.pick:hover { border-color: var(--line); transform: translateX(2px); }
.pick[aria-pressed="true"] { border-color: var(--hazard); background: #2e2a1a; }
.pick .ico { grid-row: span 2; font-size: 26px; text-align: center; }
.pick .nm { font-weight: 600; font-size: 14px; }
.pick .meta { font-size: 12px; color: var(--muted); }
.pick .bar { letter-spacing: 1px; color: var(--hazard); }

/* Stage */
.stage-wrap { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.hud {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.hud-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hud-row.small { font-size: 13px; color: var(--muted); margin-top: 6px; justify-content: flex-start; }
.hud-row.small b { color: var(--text); }
.eff { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: var(--panel-2); }
.eff.good { color: #0b1a10; background: var(--green); }
.eff.meh { color: #1a1400; background: var(--hazard); }
.eff.bad { color: #fff; background: var(--red); }
.hp {
  position: relative; height: 22px; margin-top: 8px; border-radius: 6px; overflow: hidden;
  background: #0d0f13; border: 1px solid var(--line);
}
#hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #e53935, #ffc400 60%, #4cd27a);
  transition: width .15s ease-out;
}
#hp-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000;
}

.stage { position: relative; }
#stage {
  display: block; margin: 0 auto; height: auto; aspect-ratio: 600 / 720;
  width: min(100%, calc((100vh - 290px) * 600 / 720));
  border-radius: 12px; border: 1px solid var(--line); background: #2b2f38;
  touch-action: none; cursor: none; outline: none;
}
#stage:focus-visible { border-color: var(--hazard); }
.stage-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }
.tally { margin: 0; color: var(--muted); font-size: 13px; }
.tally b { color: var(--hazard); }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--hazard); }
.btn.primary { background: var(--hazard); color: #1a1400; border-color: var(--hazard); font-weight: 800; }

/* Result card */
.result {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: min(92%, 420px);
  background: rgba(20, 22, 27, .96); border: 3px solid var(--hazard); border-radius: 14px;
  padding: 20px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
.r-kicker { margin: 0; font-family: Bungee, Impact, sans-serif; color: var(--hazard); letter-spacing: 3px; font-size: 13px; }
.result h2 { font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 26px; margin: 4px 0 6px; }
.result p { margin: 6px 0; }
#r-blurb { color: var(--muted); }
.r-stats { display: flex; justify-content: center; gap: 22px; margin: 12px 0; }
.r-stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.r-stats dd { margin: 0; font-weight: 800; font-size: 18px; }
.r-coll { font-weight: 600; }
.r-behind { font-style: italic; color: var(--muted); }
.r-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* Footer + doc dialog */
.foot {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center; justify-content: center;
  padding: 14px 16px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line);
}
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; }
.link:hover { color: var(--hazard); }
dialog {
  width: min(720px, calc(100% - 32px)); max-height: 80vh;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.doc-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.doc-head h2 { margin: 0; font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 18px; }
#doc-body { padding: 4px 18px 18px; overflow-y: auto; max-height: calc(80vh - 70px); }
#doc-body pre { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--text); }

/* Content pages */
a.logo { color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 18px; margin-left: auto; }
.nav a { color: var(--text); text-decoration: none; font-weight: 600; }
.nav a:hover { color: var(--hazard); }
.article { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.article h1 { font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 32px; line-height: 1.15; margin: 8px 0 12px; }
.article h2 { font-family: Bungee, Impact, sans-serif; font-weight: 400; font-size: 20px; color: var(--hazard); margin: 32px 0 8px; }
.article h3 { font-size: 17px; margin: 22px 0 4px; }
.article p, .article li { color: #d6d9df; }
.article a { color: var(--hazard); }
.lede { font-size: 17px; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.data { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; display: block; overflow-x: auto; }
.data th, .data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th { color: var(--muted); font-weight: 600; }
.ad { margin: 24px 0; min-height: 100px; }

/* Mobile: stage first, pickers become horizontal scrollers */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .panel { max-height: none; overflow: visible; }
  .picker { flex-direction: row; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
  .tier { display: none; }
  .pick { min-width: 170px; scroll-snap-align: start; }
  .pick:hover { transform: none; }
  #stage { width: min(100%, calc(62vh * 600 / 720)); }
  .logo { font-size: 24px; }
  .tag { display: none; }
  .top { justify-content: space-between; }
}
