:root {
  --bg: #091322;
  --surface: #102038;
  --panel: #182e4e;
  --line: #2a4770;
  --text: #f0f6fc;
  --muted: #94a3b8;
  --teal: #10b981;
  --gold: #f59e0b;
  --target: #fbbf24;
  --blue: #38bdf8;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: 0.75rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.brand p {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.controls-bar select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  outline: none;
}

.btn-header {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--teal);
  border-color: var(--teal);
}

main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* HUD & Target Billboard */
.hud-bar {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 0.8rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.hud-val {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.timer-val {
  color: var(--blue);
}

.target-box {
  text-align: center;
  background: radial-gradient(circle, #294a73, #152740);
  border: 3px solid var(--target);
  border-radius: 16px;
  padding: 0.4rem 2rem;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.25);
}

.target-sub {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--target);
}

.target-num {
  font-family: var(--display);
  font-size: 2.8rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.6);
}

.hud-streak {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: #f97316;
}

/* Workbench Arena */
.workbench-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Number Pool */
.numbers-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  min-height: 70px;
}

.num-card {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  min-width: 68px;
  height: 68px;
  padding: 0 0.8rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #1e3a5f, #152943);
  border: 2px solid #38bdf8;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.num-card:hover {
  transform: translateY(-4px) scale(1.06);
  border-color: var(--target);
  box-shadow: 0 8px 20px rgba(251, 191, 36, 0.3);
}

.num-card.selected {
  background: linear-gradient(180deg, #d97706, #b45309);
  border-color: #fde047;
  transform: scale(0.95);
}

.num-card.used {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  border-color: #475569;
}

/* Calculation Stage */
.calc-stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.equation-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.calc-slot {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  min-width: 64px;
  height: 64px;
  padding: 0 0.6rem;
  border-radius: 14px;
  background: #091322;
  border: 2px dashed #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s;
}

.calc-slot.filled {
  border: 2px solid var(--teal);
  background: #064e3b;
  color: #a7f3d0;
}

.op-slot {
  min-width: 52px;
  height: 52px;
  font-size: 1.8rem;
  color: var(--target);
  border-radius: 50%;
}

.calc-equals {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--muted);
}

.result-slot {
  border: 2px solid var(--blue);
  background: #0c4a6e;
  color: #bae6fd;
}

/* Operators Row */
.operators-row {
  display: flex;
  gap: 0.6rem;
}

.op-btn {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.op-btn:hover, .op-btn.active {
  background: var(--target);
  color: #091322;
  border-color: var(--target);
  transform: scale(1.08);
}

/* Actions & History */
.workbench-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.btn-secondary {
  font-family: var(--body);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--line);
}

.history-box {
  background: #0b172a;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
}

.history-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.hist-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
  font-family: monospace;
}

.empty-hist {
  color: #64748b;
  font-style: italic;
  font-size: 0.85rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 19, 34, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border: 2px solid var(--target);
  border-radius: 22px;
  padding: 2.2rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
}

.modal-card p {
  color: var(--muted);
  margin: 0.6rem 0 1rem;
}

.modal-equation {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--teal);
  background: var(--panel);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.4rem;
}

.modal-btn {
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
