:root {
  --bg: #0a0d14;
  --panel: #111622;
  --ink: #eef1f6;
  --mute: #8b93a5;
  --rule: rgba(255, 255, 255, 0.1);
  --loss: #ff7433;
  --gain: #4ea8ff;
  --cut: #ffd166;
  --drop: #c9cfdb;
}

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.head {
  position: absolute;
  left: 24px;
  top: 16px;
  pointer-events: none;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

h1 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.wave {
  margin-top: 6px;
  font-size: 13px;
  color: var(--mute);
}

.wave b { color: var(--loss); font-weight: 700; }

.hud {
  position: absolute;
  right: 24px;
  top: 16px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
  pointer-events: none;
  text-align: right;
}

.lab {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

.saved b {
  display: block;
  margin-top: 2px;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.saved b.neg { color: var(--loss); }

.margin { width: 150px; }

.bar {
  margin-top: 8px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gain);
  border-radius: 4px;
}

.bar i.low { background: var(--loss); }

.mt {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

.banner {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: calc(100% - 32px);
}

.banner[hidden] { display: none; }
.banner b { display: block; font-size: 34px; font-weight: 800; letter-spacing: -0.01em; }
.banner span { display: block; margin-top: 8px; font-size: 14px; color: var(--mute); }

.chips {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--panel);
  max-width: calc(100% - 32px);
  box-sizing: border-box;
}

.chips button {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 124px;
  border: 0;
  border-radius: 10px;
  padding: 7px 14px;
  font: 600 13px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--mute);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.chips button b { font-weight: 700; }
.chips button .val { margin-top: 2px; font-size: 11px; font-weight: 600; min-height: 14px; font-variant-numeric: tabular-nums; }
.chips button:hover { color: var(--ink); }
.chips button.on { color: var(--bg); }
.chips button[data-tool="cut"].on { background: var(--cut); }
.chips button[data-tool="bundle"].on { background: var(--gain); }
.chips button[data-tool="drop"].on { background: var(--drop); }
.chips button.off { opacity: 0.4; }

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(580px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px 26px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--panel);
  z-index: 5;
}

.card[hidden] { display: none; }
.card h2 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.card p { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: #c3c9d6; }
.card .k { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); }
.card .big { margin-top: 4px; font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; }
.card .big.neg { color: var(--loss); }
.card .sub2 { margin-top: 4px; font-size: 13px; color: var(--mute); }
.card .rules { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.45; }
.card .rules li { margin-top: 8px; padding-left: 20px; position: relative; color: #c3c9d6; }
.card .rules li b { color: var(--ink); }
.card .rules li::before { content: ""; position: absolute; left: 0; top: 5px; width: 10px; height: 10px; border-radius: 2px; background: var(--mute); }
.card .rules li.l::before { background: var(--loss); transform: rotate(45deg) scale(0.85); }
.card .rules li.g::before { background: var(--gain); border-radius: 50%; }
.card .rules li.c::before { background: var(--cut); }
.card .rules li.d::before { background: var(--drop); }
.card .tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.card .tools div { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 12px; line-height: 1.4; color: var(--mute); }
.card .tools div b { display: block; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.card .tools div.best { box-shadow: inset 0 0 0 1.5px var(--cut); }
.card .tools div .tag { color: var(--cut); font-weight: 700; }
.card .hurt { margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--loss); background: rgba(255, 116, 51, 0.07); border-radius: 0 10px 10px 0; font-size: 13px; line-height: 1.5; color: #c3c9d6; }
.card .hurt b { color: var(--ink); }
.card .hurt .neg { color: var(--loss); font-weight: 700; }
.card .take { margin-top: 14px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.card .take em { font-style: normal; color: var(--loss); font-weight: 700; }
.card .take strong { color: var(--gain); }
.card .math { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 11.5px; line-height: 1.55; color: var(--mute); }
.card .math b { color: #c3c9d6; font-weight: 600; }
.card .btns { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.card button { border: 0; border-radius: 10px; padding: 10px 18px; font: 700 14px system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer; color: var(--bg); background: var(--ink); }
.card button.alt { color: var(--ink); background: rgba(255, 255, 255, 0.08); }

.foot {
  position: absolute;
  right: 24px;
  bottom: 26px;
  font-size: 10px;
  color: rgba(139, 147, 165, 0.6);
  pointer-events: none;
}

.error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--mute);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

@media (max-width: 860px) {
  .foot { display: none; }
}

/* Narrow sheets: the score row sits under the title, chips stretch. */
@media (max-width: 560px) {
  .head { left: 16px; right: 16px; top: 12px; }
  h1 { font-size: 21px; }
  .wave { font-size: 12px; }
  .hud { left: 16px; right: 16px; top: 82px; justify-content: space-between; gap: 12px; text-align: left; }
  .saved b { font-size: 22px; }
  .margin { width: 140px; text-align: right; }
  .chips { gap: 4px; padding: 4px; bottom: 10px; width: calc(100% - 20px); max-width: none; }
  .chips button { min-width: 0; flex: 1; padding: 7px 4px; font-size: 12px; }
  .card { padding: 18px; }
  .card h2 { font-size: 22px; }
  .card .big { font-size: 36px; }
  .card .tools { gap: 6px; }
  .card .tools div { padding: 8px; }
  .card .tools div b { font-size: 15px; }
  .banner b { font-size: 26px; }
}
