:root {
  --bg: #0a0b0d;
  --surface: #131418;
  --surface-2: #18191e;
  --line: #1c1e22;
  --line-2: #26282c;
  --text: #edeeef;
  --muted: #9c9fa6;
  --faint: #8e9199;
  --pink: #e23a6e;
  --violet: #9b2fe0;
  --accent: #e24fbe;
  --grad: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
  --on: #3ddc97;
  --off: #ff5c7a;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.glow {
  position: fixed; inset: -20vh -10vw auto auto; width: 70vw; height: 70vh; pointer-events: none; z-index: 0;
  background: radial-gradient(closest-side, rgba(193, 58, 166, .16), transparent 70%);
}
.wrap { position: relative; z-index: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 480px; }

/* header */
.bar { position: relative; z-index: 2; border-bottom: 1px solid var(--line); background: rgba(10, 11, 13, .72); backdrop-filter: blur(10px); }
.bar .wrap { display: flex; align-items: center; gap: 14px; height: 68px; }
.logo img { height: 26px; display: block; }
.tag { font-size: 13px; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line-2); }

main.wrap { flex: 1; padding-top: 48px; padding-bottom: 48px; }
.foot { color: var(--faint); font-size: 13px; padding-bottom: 24px; }

/* type */
h1 { font: 600 34px/1.15 var(--display); letter-spacing: -.01em; margin: 0 0 8px; }
h2 { font: 600 20px/1.2 var(--display); margin: 0; }
h3 { font: 600 18px/1.25 var(--display); margin: 14px 0 4px; word-break: break-word; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 Inter, sans-serif;
  height: 44px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; color: #fff;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s; text-decoration: none !important; }
.btn.primary { background: var(--grad); box-shadow: 0 6px 22px -10px rgba(155, 47, 224, .5); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 28px -10px rgba(155, 47, 224, .7); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover { border-color: #3a3d43; }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.btn.wide { width: 100%; }

/* panels & forms */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; margin-top: 24px; }
form.panel, form.card { display: grid; gap: 16px; }
.panel h1 { font-size: 28px; }
.panel .btn { margin-top: 4px; }
label { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
input { font: 15px Inter, sans-serif; height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #4b4e55; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(193, 58, 166, .18); }
input.code { font: 600 26px var(--display); letter-spacing: .5em; text-align: center; }
.back { font-size: 14px; color: var(--muted); justify-self: center; }

/* dashboard */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0 8px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; display: grid; }
.stats b { font: 600 28px var(--display); }
.stats span { font-size: 13px; color: var(--muted); }
.stats div:first-child b { color: var(--on); }

.brigade { margin-top: 36px; }
.brigade-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.count { font-size: 13px; color: var(--muted); }
.count b { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

.machine { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex;
  flex-direction: column; transition: border-color .15s, transform .15s; }
.machine.on:hover { border-color: rgba(193, 58, 166, .34); transform: translateY(-2px); }
.machine form { margin-top: auto; padding-top: 18px; }
.machine .btn { width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); }
.pill i { width: 8px; height: 8px; border-radius: 50%; }
.on .pill { color: var(--on); }
.on .pill i { background: var(--on); box-shadow: 0 0 0 4px rgba(61, 220, 151, .15); animation: pulse 2s infinite; }
.off .pill { color: var(--off); }
.off .pill i { background: var(--off); }
.cut .pill { color: var(--muted); }
.cut .pill i { background: var(--faint); }
.machine.cut h3 { color: var(--muted); }
.btn.danger:hover { border-color: var(--off); color: var(--off); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0); } }

/* waiting screen */
.wait h1 { display: flex; align-items: center; gap: 12px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
.wait.ok .spinner { animation: none; border-color: var(--on); }
.wait.slow .spinner { animation: none; border-color: var(--off); }
@keyframes spin { to { transform: rotate(360deg); } }
.game { margin-top: 20px; }
.game canvas { width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; touch-action: manipulation; display: block; }
.game-help { margin-top: 8px; }
.w-actions { margin-top: 20px; }

@media (max-width: 600px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  main.wrap { padding-top: 28px; }
  h1 { font-size: 28px; }
  .panel, .card { padding: 24px; }
  .stats b { font-size: 22px; }
  .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
