:root {
  --bg: #ffffff;
  --bg-2: #f6f6f6;
  --card: #ffffff;
  --card-hover: #fafafa;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.18);
  --heading: #000000;
  --text: #333333;
  --muted: #6e6e73;
  --accent: #000000;
  --indigo: #444444;
  --amber: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
strong { color: var(--heading); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.accent { color: var(--heading); }
.indigo { color: var(--indigo); }

#fxCanvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 60;
}

/* TOPBAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .75rem; }
.back-link { font-size: .82rem; color: var(--muted); transition: color .18s; }
.back-link:hover { color: var(--heading); }
.sep { color: var(--border-strong); }
.logo-wrap { display: flex; align-items: center; gap: .5rem; color: var(--heading); }
.logo-gem {
  width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #ffffff; background: #000000;
}
.tag {
  font-size: .66rem; color: #444444; background: var(--bg-2);
  padding: .14rem .45rem; border-radius: 4px; border: 1px solid var(--border);
}
.icon-btn {
  background: #ffffff; border: 1px solid #cccccc; color: #111111;
  padding: .4rem .75rem; border-radius: 6px; font-size: .74rem; cursor: pointer;
  transition: all .18s;
}
.icon-btn:hover { border-color: #000000; background: #fafafa; }

/* MAIN ARENA */
.arena {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 1.75rem clamp(1rem, 4vw, 2rem) 2.5rem;
  flex: 1; display: flex; flex-direction: column; gap: 1.15rem;
}

/* MODE TABS */
.mode-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  background: var(--bg-2); padding: .35rem; border-radius: 8px; border: 1px solid var(--border);
}
.mode-tab {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: .68rem .75rem; text-align: left; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; gap: .15rem; transition: all .18s;
}
.mode-tab:hover { color: var(--heading); }
.mode-tab.active {
  background: #ffffff; color: var(--heading);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.mode-title { font-weight: 600; font-size: .88rem; }
.mode-tab.active .mode-title { color: #000000; }
.mode-sub { font-size: .68rem; color: var(--muted); }

/* HUD */
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: .65rem; }
.hud-box {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .7rem .9rem; display: flex; flex-direction: column; gap: .15rem;
}
.hud-label { font-size: .66rem; color: var(--muted); letter-spacing: .06em; }
.hud-val { font-size: 1.2rem; font-weight: 700; color: var(--heading); }

/* STAGE CONTAINERS */
.stage { display: none; flex-direction: column; gap: 1.1rem; position: relative; }
.stage.active { display: flex; }

/* TARGET FORGE — PlatSupply #191919 Matte Showcase Block */
.forge-header { display: flex; justify-content: center; }
.target-card {
  width: 100%; text-align: center; padding: 1.5rem 1rem;
  background: #191919; color: #ffffff;
  border-radius: var(--radius);
  transition: transform .22s;
}
.target-card.solved-flash { transform: scale(1.015); background: #000000; }
.target-eyebrow { font-size: .68rem; color: #999999; letter-spacing: .1em; }
.target-number {
  font-size: clamp(3rem, 9vw, 4.2rem); font-weight: 700; line-height: 1.05;
  margin-top: .25rem; letter-spacing: -.035em; color: #ffffff;
}
.daily-dots { display: flex; justify-content: center; gap: .45rem; margin-top: .75rem; }
.daily-dot { width: 26px; height: 6px; border-radius: 99px; background: #333333; }
.daily-dot.current { background: #888888; }
.daily-dot.done-pure { background: #ffffff; }
.daily-dot.done-assisted { background: #b45309; }

.status-banner { text-align: center; font-size: .78rem; color: var(--muted); min-height: 1.3em; }
.status-banner.warn { color: var(--amber); }
.status-banner.good { color: var(--ok); font-weight: 500; }

/* NUMBER TILES */
.tiles-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.num-tile {
  position: relative; height: 104px; border-radius: 8px;
  border: 1px solid #d4d4d4; background: #ffffff; color: var(--heading);
  font-family: "JetBrains Mono", monospace; font-size: clamp(1.6rem, 4.5vw, 2.15rem);
  font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: all .15s ease; user-select: none;
}
.num-tile:hover:not(.consumed) { border-color: #000000; transform: translateY(-2px); }
.num-tile.selected {
  background: #000000; color: #ffffff; border-color: #000000;
  transform: translateY(-3px);
}
.num-tile.selected .tile-key,
.num-tile.selected .tile-expr { color: #b5b5b5; }
.num-tile.hint-glow { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.2); }
.num-tile.consumed { opacity: 0.2; pointer-events: none; transform: scale(0.95); border-style: dashed; }
.num-tile .tile-key { position: absolute; top: 8px; left: 10px; font-size: .64rem; color: var(--muted); font-weight: 500; }
.num-tile .tile-expr {
  font-size: .66rem; color: var(--muted); font-weight: 500; margin-top: .25rem;
  max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* OPERATORS */
.ops-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.op-btn {
  height: 56px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-2); color: var(--heading); font-size: 1.45rem; font-weight: 600;
  cursor: pointer; transition: all .14s;
}
.op-btn:hover { border-color: #000000; background: #ededed; }
.op-btn.active { background: #000000; color: #ffffff; border-color: #000000; }
.op-btn.hint-glow { border-color: var(--amber); }

/* UTILITY CONTROLS */
.forge-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: .55rem; margin-top: .15rem; }
.ctrl-btn {
  background: #ffffff; border: 1px solid #d4d4d4; color: #444444;
  padding: .5rem .9rem; border-radius: 6px; font-size: .76rem; cursor: pointer;
  transition: all .14s;
}
.ctrl-btn:hover:not(:disabled) { color: #000000; border-color: #000000; background: #fafafa; }
.ctrl-btn:disabled { opacity: .4; cursor: not-allowed; }
kbd {
  font-family: "JetBrains Mono", monospace; font-size: .66rem;
  padding: .08rem .3rem; border-radius: 3px; background: var(--bg-2); color: var(--heading);
  border: 1px solid var(--border);
}

/* SUMMARY OVERLAY */
.summary-overlay {
  background: #ffffff; border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 2rem 1.5rem; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}
.summary-card { display: flex; flex-direction: column; align-items: center; gap: .85rem; }
.summary-badge {
  font-size: .68rem; color: #444444; background: var(--bg-2);
  border: 1px solid var(--border); padding: .22rem .6rem; border-radius: 4px; font-weight: 600;
}
.summary-sub { color: var(--muted); font-size: .86rem; }
.share-preview {
  background: #191919; color: #f5f5f5; border-radius: 6px;
  padding: .9rem 1.15rem; font-size: .78rem; text-align: left;
  width: 100%; max-width: 390px; white-space: pre-wrap;
}
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem; margin-top: .35rem; }

.btn-primary {
  background: #000000; color: #ffffff; border: 1px solid #000000; border-radius: 6px;
  padding: .75rem 1.35rem; font-weight: 600; font-size: .88rem; cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #333333; border-color: #333333; }
.btn-ghost {
  background: #ffffff; color: #111111; border: 1px solid #cccccc;
  border-radius: 6px; padding: .75rem 1.25rem; font-weight: 500; font-size: .88rem; cursor: pointer;
}
.btn-ghost:hover { border-color: #000000; background: #fafafa; }

/* QUANT BLITZ 60 */
.timer-track {
  width: 100%; height: 6px; background: var(--bg-2); border-radius: 99px;
  overflow: hidden;
}
.timer-fill { height: 100%; width: 100%; background: #000000; transition: width .1s linear; }
.blitz-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem 1.5rem; text-align: center;
}
.blitz-start, .blitz-result {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  max-width: 460px; margin: 0 auto;
}
.blitz-start h2, .blitz-result h2 { color: var(--heading); letter-spacing: -.03em; }
.blitz-start p { color: var(--text); font-size: .94rem; line-height: 1.6; }

.blitz-play { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.blitz-meta {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  font-size: .86rem; color: var(--heading); font-weight: 600;
}
.diff-pill {
  font-size: .68rem; color: #444444; background: #ffffff;
  border: 1px solid var(--border); padding: .18rem .55rem; border-radius: 4px;
}
.equation-display {
  font-size: clamp(2.4rem, 7vw, 3.5rem); font-weight: 700; letter-spacing: -.03em;
  color: var(--heading); padding: .5rem 0;
}
.answer-box-wrap { display: flex; align-items: center; gap: .55rem; width: 100%; max-width: 310px; }
.blitz-input {
  flex: 1; width: 100%; text-align: center; font-size: 1.8rem; font-weight: 700;
  padding: .6rem; border-radius: 8px; border: 1.5px solid #000000;
  background: #ffffff; color: var(--heading); outline: none;
}
.skip-mini {
  background: #ffffff; border: 1px solid #cccccc; color: var(--muted);
  padding: .82rem .75rem; border-radius: 6px; font-size: .74rem; cursor: pointer;
}
.skip-mini:hover { border-color: #000000; color: #000000; }

.numpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem;
  width: 100%; max-width: 310px; margin-top: .2rem;
}
.numpad button {
  height: 48px; border-radius: 6px; border: 1px solid #d4d4d4;
  background: #ffffff; color: var(--heading);
  font-family: "JetBrains Mono", monospace; font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.numpad button:active, .numpad button:hover {
  background: #000000; color: #ffffff; border-color: #000000;
}

.result-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; width: 100%; margin: .45rem 0;
}
.result-grid div {
  background: #ffffff; border: 1px solid var(--border); border-radius: 6px;
  padding: .8rem; display: flex; flex-direction: column; gap: .18rem;
}
.result-grid span { font-size: .68rem; color: var(--muted); text-transform: uppercase; }
.result-grid strong { font-size: 1.2rem; color: var(--heading); }

.tips {
  margin-top: auto; padding-top: .85rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  font-size: .72rem; color: var(--muted);
}
.tips a { color: var(--heading); text-decoration: underline; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .mode-tabs { grid-template-columns: 1fr; }
  .mode-tab { flex-direction: row; justify-content: space-between; align-items: center; padding: .6rem .85rem; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .tiles-grid { grid-template-columns: repeat(2, 1fr); }
  .num-tile { height: 88px; }
  .tips span:first-child { display: none; }
}
