/* ============================================
   Tai-Lack Power — control-room HUD design system
   Mobile first · breakpoints 480 / 760 / 1100 / 1440
   ============================================ */

:root {
  color-scheme: dark;
  --bg: #0a1020;
  --bg-2: #0d1528;
  --surface: #121c33;
  --surface-2: #18243f;
  --surface-3: #1f2e4f;
  --line: #263657;
  --line-strong: #34507e;
  --text: #e8eef9;
  --muted: #94a6c4;
  --faint: #6c7f9f;
  --accent: #22d3ee;
  --primary: #3b82f6;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --violet: #a78bfa;
  --mix-n: #a3e635;
  --mix-g: #34d399;
  --mix-s: #60a5fa;
  --mix-t: #f97316;
  --radius: 16px;
  --radius-sm: 10px;
  --hud-h: 64px;
  --gap: 12px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --font: 'Inter', 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(34, 211, 238, .08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(59, 130, 246, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
small { font-size: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.ic { flex: none; display: block; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---------- Shared controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  font-weight: 700; transition: background-color .18s, border-color .18s, transform .18s var(--ease);
}
.btn:hover:not(:disabled) { background: #29406b; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--primary); border-color: #60a5fa; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #2563eb; }
.btn.good { background: #059669; border-color: #34d399; color: #fff; }
.btn.good:hover:not(:disabled) { background: #047857; }
.btn.warn { background: #d97706; border-color: #fbbf24; color: #1a1200; }
.btn.warn:hover:not(:disabled) { background: #b45309; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.block { width: 100%; margin-top: 18px; min-height: 52px; font-size: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.chip small { color: var(--muted); font-weight: 500; margin-left: 2px; }
.season-spring { color: #6ee7b7; }
.season-summer { color: #fda4af; }
.season-autumn { color: #fcd34d; }
.season-winter { color: #67e8f9; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600;
  transition: background-color .18s;
}
.chip-btn:hover { background: var(--surface-3); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); transition: background-color .18s;
}
.icon-btn:hover { background: var(--surface-3); }
.lang-tag { font-size: 12px; font-weight: 700; }

.seg {
  display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.seg button {
  min-width: 44px; height: 38px; padding: 0 10px; border-radius: 9px;
  font-weight: 700; color: var(--muted); transition: background-color .18s, color .18s;
}
.seg button:hover:not(:disabled):not(.on) { color: var(--text); background: var(--surface-2); }
.seg button.on { background: var(--primary); color: #fff; box-shadow: 0 2px 10px -2px rgba(59, 130, 246, .7); }
.seg button:disabled { opacity: .35; text-decoration: line-through; }
.seg.big { width: 100%; }
.seg.big button { flex: 1; height: 48px; font-size: 18px; font-weight: 800; }

/* ---------- Menu ---------- */

.menu {
  position: relative; min-height: 100vh; max-width: 1180px; margin: 0 auto;
  padding: 72px 20px 40px; display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.menu-lang { position: absolute; top: 16px; right: 16px; }
.menu-hero { text-align: center; display: grid; justify-items: center; gap: 14px; max-width: 720px; }
.menu-hero h1 {
  font-size: clamp(36px, 7vw, 64px); font-weight: 900; letter-spacing: -.02em; line-height: 1.1;
  background: linear-gradient(120deg, #e0f2fe 10%, #22d3ee 55%, #60a5fa 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.menu-hero p { color: var(--muted); font-size: clamp(15px, 2.2vw, 18px); }
.menu-sub { font-size: 14px; letter-spacing: .14em; color: var(--faint); font-weight: 700; }

.brand-mark {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none;
  color: #052e36; background: linear-gradient(135deg, #67e8f9, #22d3ee 50%, #0ea5e9);
  box-shadow: 0 6px 20px -6px rgba(34, 211, 238, .8);
}
.brand-mark.big { width: 72px; height: 72px; border-radius: 20px; }

.diffs { width: 100%; display: grid; gap: 16px; grid-template-columns: 1fr; }
.diff {
  --tone: var(--primary);
  position: relative; display: grid; gap: 12px; text-align: left; padding: 24px;
  border-radius: 20px; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.diff:hover { transform: translateY(-3px); border-color: var(--tone); box-shadow: 0 16px 40px -16px var(--tone); }
.diff.easy { --tone: #10b981; }
.diff.normal { --tone: #3b82f6; }
.diff.real { --tone: #f43f5e; }
.diff-ico {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.diff-title { font-size: 22px; font-weight: 800; }
.diff-desc { color: var(--muted); min-height: 3em; }
.diff-money { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); }
.diff-money small { color: var(--muted); font-size: 13px; }
.diff-money b { font-size: 22px; font-weight: 800; color: var(--good); }
.meter-row { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.meter { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--tone); }
.diff-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin-top: 4px;
  border-radius: 12px; font-weight: 800; color: #fff; background: var(--tone);
}
.version { color: var(--faint); font-size: 12px; }
.menu-best { color: var(--accent); font-weight: 700; }
.continue { min-height: 52px; padding: 0 22px; font-size: 16px; }
.seed-field { display: grid; gap: 8px; width: min(520px, 100%); color: var(--muted); font-weight: 700; font-size: 13px; }
.seed-field input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit;
}
.challenges { width: 100%; display: grid; gap: 10px; grid-template-columns: 1fr; }
.challenge {
  display: grid; gap: 4px; text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: inherit;
}
.challenge.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.challenge b { font-size: 15px; }
.challenge span { color: var(--muted); font-size: 13px; }
.recap { font-weight: 800; color: var(--text); margin-bottom: 4px; }
.vs { font-size: 13px; margin: 8px 0; }
.missions, .resume, .epitaphs { list-style: none; display: grid; gap: 8px; padding: 0; margin: 0 0 16px; }
.missions li, .resume li { padding: 8px 10px; border-radius: 10px; background: var(--bg-2); }
.missions .done { color: var(--good); }
.missions .miss { color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.grade { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; background: var(--bg-2); }
.grade b { font-size: 22px; font-weight: 900; color: var(--accent); }
.grade small, .grade span { color: var(--muted); font-size: 12px; }
.season-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.season-chip { display: grid; justify-items: center; min-width: 72px; padding: 8px; border-radius: 10px; background: var(--bg-2); }
.season-chip b { font-size: 20px; }
.epitaph-wall { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.epitaphs li { padding: 10px 12px; border-radius: 12px; background: var(--bg-2); }
.epi-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; color: var(--muted); font-size: 12px; }
.epitaph-form { display: grid; gap: 10px; }
.epitaph-form input, .epitaph-form textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit;
}
.build-item.locked { opacity: .45; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.modal-card.scorecard { max-width: 640px; }
.mission-alert { opacity: .92; }

/* ---------- App shell ---------- */

.app { max-width: 1680px; margin: 0 auto; padding: 0 10px 32px; }

.hud {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand ctrl" "time time";
  gap: 8px 10px; align-items: center;
  margin: 0 -10px 12px; padding: 8px 10px;
  background: rgba(10, 16, 32, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.hud-brand { grid-area: brand; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { display: grid; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--faint); }
.hud-time { grid-area: time; display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.hud-time::-webkit-scrollbar { display: none; }
.hud-clock { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.hud-clock > span { display: grid; line-height: 1.1; }
.hud-clock small { font-size: 12px; }
.hud-clock b { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: .02em; }
.clock { width: 34px; height: 34px; flex: none; }
.hud-ctrl { grid-area: ctrl; display: flex; align-items: center; gap: 8px; }
.play {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; min-width: 44px; padding: 0 16px;
  border-radius: 12px; font-weight: 800; background: var(--surface-3); border: 1px solid var(--line-strong);
  transition: background-color .18s;
}
.play.paused { background: var(--good); border-color: #6ee7b7; color: #022c22; animation: nudge 2.4s ease-in-out infinite; }
.play:hover { filter: brightness(1.08); }
.hide-sm { display: none; }

.board { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.col-main, .col-side { display: grid; gap: var(--gap); align-content: start; min-width: 0; }

.panel {
  position: relative; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; }
.panel-head h2 .ic { color: var(--accent); }
.hint { color: var(--faint); font-size: 13px; margin: -4px 0 12px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span, .bal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .bal-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.lg-supply { background: var(--accent); }
.lg-demand { background: #fb7185; }
.lg-target { background: var(--warn); }

/* ---------- Grid balance (hero) ---------- */

.balance {
  --tone: var(--muted);
  display: grid; gap: 16px; padding: 18px; grid-template-areas: "main" "reserve" "chart";
  border-color: color-mix(in srgb, var(--tone) 45%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tone) 10%, transparent), transparent 55%),
    var(--surface);
  transition: border-color .3s;
}
.balance[data-state="good"] { --tone: var(--good); }
.balance[data-state="warn"] { --tone: var(--warn); }
.balance[data-state="bad"] { --tone: var(--bad); }
.bal-main { grid-area: main; display: grid; gap: 14px; align-content: start; min-width: 0; }
.bal-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fig { display: grid; gap: 2px; min-width: 0; }
.fig small { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.fig b { font-size: clamp(24px, 6vw, 40px); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.fig span { color: var(--faint); font-size: 12px; font-weight: 600; }
.fig.supply b { color: var(--accent); }
.fig.net b { color: var(--tone); }
.bal-meter { position: relative; height: 16px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); }
.bal-supply { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, #0e7490, var(--accent)); transition: width .4s var(--ease); }
.bal-demand, .bal-target { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; border-radius: 2px; transition: left .4s var(--ease); }
.bal-demand { background: #fb7185; box-shadow: 0 0 0 2px var(--surface); }
.bal-target { background: var(--warn); box-shadow: 0 0 0 2px var(--surface); }
.bal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.bal-stab { --tone: var(--good); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); }
.bal-stab[data-state="warn"] { --tone: var(--warn); }
.bal-stab[data-state="bad"] { --tone: var(--bad); }
.bal-stab-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.bal-stab-label .ic { color: var(--tone); }
.bal-stab b { font-size: 18px; font-weight: 800; color: var(--tone); }
.bal-stab .kpi-bar i { background: var(--tone); }
.bal-chart { grid-area: chart; display: grid; gap: 6px; min-width: 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.bal-chart-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.bal-chart-head > span:first-child { display: inline-flex; align-items: center; gap: 6px; }

.bal-reserve {
  grid-area: reserve; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px;
  background: var(--bg-2); border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--line));
}
.res-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 14px; }
.res-head .ic { color: var(--tone); }
.res-value { font-size: clamp(44px, 12vw, 64px); font-weight: 900; line-height: 1; color: var(--tone); letter-spacing: -.03em; }
.res-status { font-weight: 700; color: var(--tone); }
.res-gap { color: var(--muted); font-size: 13px; }
.balance[data-state="bad"] .res-value { animation: blink 1s steps(2, start) infinite; }
.res-target { display: grid; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); }
.res-target-label { display: grid; font-weight: 800; font-size: 15px; }
.res-target-label small { color: var(--faint); font-weight: 500; }

/* ---------- Alerts ---------- */

.alerts { display: grid; gap: 8px; }
.alert {
  --tone: var(--primary);
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 50%, transparent);
}
.alert > .ic { color: var(--tone); margin-top: 2px; }
.alert div { display: grid; gap: 2px; }
.alert b { font-weight: 800; }
.alert span { color: var(--muted); font-size: 13px; }
.alert.bad { --tone: var(--bad); }
.alert.warn { --tone: var(--warn); }
.alert.info { --tone: var(--accent); }

/* ---------- KPI tiles ---------- */

.kpis { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi {
  --tone: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.kpi[data-state="good"] { --tone: var(--good); }
.kpi[data-state="warn"] { --tone: var(--warn); }
.kpi[data-state="bad"] { --tone: var(--bad); }
.kpi-head { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-head .ic { color: var(--tone); }
.kpi-value { font-size: clamp(22px, 5vw, 30px); font-weight: 800; line-height: 1.1; color: var(--tone); letter-spacing: -.02em; overflow-wrap: anywhere; }
.kpi-value small { font-size: 13px; color: var(--faint); font-weight: 600; margin-left: 2px; }
.kpi-bar { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.kpi-bar i { display: block; height: 100%; border-radius: inherit; background: var(--tone); transition: width .4s var(--ease); }
.kpi-sub { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .mini, .kpi .mini-tag { margin-top: auto; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border-radius: 10px; font-size: 13px; font-weight: 700; background: var(--surface-3); border: 1px solid var(--line-strong);
  transition: background-color .18s;
}
.mini:hover:not(:disabled) { background: #29406b; }
.mini:disabled { opacity: .45; }
.mini.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface-2)); border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: #fde68a; }
.mini.good { background: color-mix(in srgb, var(--good) 18%, var(--surface-2)); border-color: color-mix(in srgb, var(--good) 50%, transparent); color: #a7f3d0; }
.mini-tag { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 10px; font-size: 13px; font-weight: 700; color: #c4b5fd; background: rgba(167, 139, 250, .14); }

.kpi.price .stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi.price .kpi-value { text-align: center; }
.stepper button {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-strong); transition: background-color .18s;
}
.stepper button:hover:not(:disabled) { background: #29406b; }
.stepper button:disabled { opacity: .35; }
.price-scale { position: relative; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--good) 0 16%, var(--warn) 16% 34%, var(--bad) 34%); opacity: .85; }
.price-scale i { position: absolute; top: -4px; width: 4px; height: 14px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Chart ---------- */

.chart-wrap { width: 100%; min-height: 120px; }
.chart { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart-empty { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; color: var(--muted); font-size: 14px; border: 1px dashed var(--line); border-radius: 12px; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Plants ---------- */

.plants { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.plant {
  --c: var(--accent);
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-top: 3px solid color-mix(in srgb, var(--c) 75%, #fff); transition: border-color .2s, opacity .2s;
}
.plant:hover { border-color: var(--line-strong); border-top-color: color-mix(in srgb, var(--c) 75%, #fff); }
.plant.off { opacity: .62; }
.plant.down { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.plant.low .track i { background: var(--bad); }
.plant-head { display: flex; align-items: center; gap: 10px; }
.grip { color: var(--faint); cursor: grab; margin-left: -4px; }
.tile {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px;
  color: color-mix(in srgb, var(--c) 65%, #fff); background: color-mix(in srgb, var(--c) 20%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.plant-name { display: grid; gap: 2px; min-width: 0; flex: 1; }
.plant-name b { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-name b small { color: var(--muted); font-weight: 600; }
.plant-meta { display: flex; align-items: center; gap: 8px; }
.plant-meta small { color: var(--faint); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.dots i.off { background: var(--faint); }
.dots i.fault { background: var(--bad); animation: pulse 1s ease-in-out infinite; }
.power {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%;
  color: var(--faint); background: var(--bg-2); border: 2px solid var(--line-strong); transition: all .18s;
}
.power.on { color: #022c22; background: var(--good); border-color: #6ee7b7; box-shadow: 0 0 16px -2px rgba(52, 211, 153, .6); }
.power:hover:not(:disabled) { filter: brightness(1.1); }
.power:disabled { opacity: .4; }
.plant-status { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.plant-status.warn { color: #fde68a; background: rgba(251, 191, 36, .12); }
.plant-status.bad { color: #fecaca; background: rgba(248, 113, 113, .14); }
.plant-status.violet { color: #ddd6fe; background: rgba(167, 139, 250, .14); }
.plant-out { display: flex; align-items: baseline; gap: 6px; }
.plant-out > b { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.plant-out > span { color: var(--muted); font-size: 14px; font-weight: 600; }
.track { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: inherit; background: color-mix(in srgb, var(--c) 75%, #fff); transition: width .4s var(--ease); }
.plant-flow { color: var(--muted); font-size: 13px; }
.plant-note { color: var(--faint); font-size: 12px; }
.plant-note.bad { color: var(--bad); font-weight: 700; }
.target { display: grid; gap: 6px; }
.target > span { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.target b { color: var(--text); font-size: 15px; }
.target small { margin-left: auto; color: var(--faint); }
input[type="range"] { width: 100%; height: 28px; margin: 0; accent-color: var(--c); background: transparent; cursor: pointer; }
input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.plant-ctrl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px; border-radius: 10px;
  font-size: 13px; font-weight: 800; background: var(--bg-2); border: 1px solid var(--line-strong); transition: background-color .18s;
}
.pill:hover:not(:disabled) { background: var(--surface-3); }
.pill:disabled { opacity: .4; }
.pill.prio.high { color: #fecaca; border-color: rgba(248, 113, 113, .5); }
.pill.prio.mid { color: #fde68a; border-color: rgba(251, 191, 36, .5); }
.pill.prio.low { color: #bfdbfe; border-color: rgba(96, 165, 250, .5); }
.pill.auto.on { color: #a5f3fc; border-color: rgba(34, 211, 238, .55); background: rgba(34, 211, 238, .1); }
.pill.expand { margin-left: auto; }

/* ---------- Side: build / mix / log ---------- */

.build-list { display: grid; gap: 8px; }
.build-item {
  --c: var(--accent);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left;
  padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .18s, background-color .18s, transform .18s var(--ease);
}
.build-item:hover:not(:disabled) { border-color: var(--c); background: var(--surface-3); transform: translateY(-1px); }
.build-item:disabled { opacity: .5; }
.build-body { display: grid; gap: 4px; min-width: 0; }
.build-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 800; }
.build-name small { color: var(--muted); font-weight: 600; }
.build-desc { color: var(--faint); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.build-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.build-tags em { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: var(--muted); background: var(--bg-2); }
.build-cost { display: grid; justify-items: end; gap: 2px; }
.build-cost b { font-size: 16px; font-weight: 800; color: var(--good); }
.build-cost.short b { color: var(--muted); }
.build-cost small { color: var(--bad); font-weight: 700; white-space: nowrap; }

.toast { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 10px 12px; border-radius: 10px; font-weight: 700; animation: drop .25s var(--ease); }
.toast.ok { color: #a7f3d0; background: rgba(52, 211, 153, .14); }
.toast.bad { color: #fecaca; background: rgba(248, 113, 113, .14); }

.mix-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 10px; }
.mix-label { display: grid; font-weight: 700; font-size: 13px; line-height: 1.2; }
.mix-label small { color: var(--faint); font-weight: 500; font-size: 11px; }
.mix-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--bg-2); }
.mix-bar i { display: block; height: 100%; transition: width .4s var(--ease); }
.mix-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.mix-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mix-legend i { width: 10px; height: 10px; border-radius: 3px; }

.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: grid; gap: 2px; }
.log li { padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.log li:first-child { color: var(--text); background: var(--surface-2); }
.empty { color: var(--faint); font-size: 13px; padding: 4px 0; }

/* ---------- Modals & tutorial ---------- */

.modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  padding: 0; background: rgba(2, 6, 18, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .2s ease;
}
.modal-card {
  width: 100%; max-height: 92vh; overflow-y: auto; padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .8); animation: rise .28s var(--ease);
}
.modal-card.danger { border-color: rgba(248, 113, 113, .55); }
.modal-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.modal-card h3 { font-size: 15px; font-weight: 800; margin: 18px 0 8px; }
.modal-card p { color: var(--muted); }
.modal-icon {
  --tone: var(--accent);
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 14px; border-radius: 16px;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.modal-icon.good { --tone: var(--good); }
.modal-icon.warn { --tone: var(--warn); }
.modal-icon.bad { --tone: var(--bad); }
.modal-icon[class*="season-"] { --tone: currentColor; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--faint) !important; margin-bottom: 4px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line span { color: var(--muted); }
.line b { font-size: 17px; }
.report-net { display: grid; justify-items: center; gap: 2px; margin: 14px 0 6px; padding: 16px; border-radius: 14px; background: var(--bg-2); }
.report-net small { color: var(--muted); }
.report-net b { font-size: 34px; font-weight: 900; }
.report-net.pos b { color: var(--good); }
.report-net.neg b { color: var(--bad); }
.tips { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
.tipbox { display: flex; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); color: var(--text); font-size: 14px; }
.tipbox .ic { color: var(--accent); margin-top: 2px; }
.impacts { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.impacts li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border-left: 3px solid var(--faint); }
.impacts li span { color: var(--muted); font-size: 12px; }
.impacts li b { font-size: 16px; }
.impacts li.up { border-left-color: var(--good); }
.impacts li.up b { color: var(--good); }
.impacts li.down { border-left-color: var(--bad); }
.impacts li.down b { color: var(--bad); }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions-right { display: inline-flex; gap: 8px; margin-left: auto; }
.actions.stack { display: grid; }
.actions.stack .btn { width: 100%; }
.choices { display: grid; gap: 10px; margin-top: 18px; }
.choice {
  display: grid; gap: 4px; width: 100%; padding: 14px 16px; text-align: left; color: inherit; font: inherit; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, background-color .15s, transform .15s;
}
.choice strong { font-size: 16px; }
.choice small { color: var(--muted); font-size: 12px; }
.choice .impacts { margin-top: 6px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.choice .impacts li { padding: 6px 10px; background: var(--bg-2); }
.choice .impacts li b { font-size: 14px; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-3); transform: translateY(-1px); }
.choice:disabled { opacity: .5; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .choice { transition: none; } .choice:hover:not(:disabled) { transform: none; } }

.dim { position: fixed; inset: 0; z-index: 40; background: rgba(2, 6, 18, .7); animation: fade .2s ease; }
.spot { z-index: 45 !important; box-shadow: 0 0 0 3px var(--accent), 0 0 40px 4px rgba(34, 211, 238, .35); }
.panel.spot { position: relative; }
.touring .col-side { position: static; }
.coach {
  position: fixed; z-index: 50; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--accent);
  box-shadow: 0 20px 60px -10px rgba(0, 0, 0, .8); animation: rise .28s var(--ease);
}
.coach h2 { font-size: 19px; font-weight: 800; margin: 8px 0 6px; }
.coach p { color: var(--muted); font-size: 14px; }
.coach .actions { margin-top: 14px; }
.coach-top { display: flex; align-items: center; justify-content: space-between; }
.coach-step { font-size: 12px; font-weight: 800; color: var(--accent); letter-spacing: .08em; }
.coach-dots { display: inline-flex; gap: 6px; }
.coach-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.coach-dots i.on { width: 22px; border-radius: 99px; background: var(--accent); }

.boot-fail { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.boot-fail h1 { font-size: 28px; font-weight: 900; }
.boot-fail p { color: var(--muted); }
.boot-fail button { min-height: 48px; padding: 0 24px; border-radius: 12px; font-weight: 800; color: #fff; background: var(--primary); }

.dock { display: none; }
#stats-row, #plant-grid, #build-menu, #event-log { scroll-margin-top: 104px; }

@media (pointer: coarse) {
  .grip, .drag-hint { display: none; }
}

/* ---------- Motion ---------- */

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: .55; } }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, .2); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Breakpoints ---------- */

@media (max-width: 479px) {
  .brand-text { display: none; }
  .res-target { margin-top: 10px; }
  .hud-ctrl .seg button { min-width: 40px; padding: 0 6px; }
  .play span { display: none; }
  .play { padding: 0; width: 44px; }
  .bal-figures .fig b { font-size: 24px; }
  .plant-out > b { font-size: 26px; }
}

@media (max-width: 759px) {
  .kpi.price { grid-column: 1 / -1; }
  .app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .dock {
    position: fixed; z-index: 35; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(10, 16, 32, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .dock a {
    display: grid; justify-items: center; gap: 2px; min-height: 52px; padding-top: 6px; border-radius: 12px;
    color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700;
  }
  .dock a:active { background: var(--surface-2); color: var(--text); }
  .touring .dock, .app:has(.modal) .dock { display: none; }
  .coach { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

@media (min-width: 480px) {
  .diffs { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .challenges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: inline; }
}

@media (min-width: 760px) {
  .app { padding: 0 16px 40px; }
  .hud { margin: 0 -16px 16px; padding: 10px 16px; }
  :root { --gap: 14px; }
  .panel { padding: 18px; }
  .balance { grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); grid-template-areas: "main reserve" "chart reserve"; grid-template-rows: auto 1fr; padding: 22px; }
  .res-target { padding-top: 14px; }
  .bal-figures .fig b { font-size: 40px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .col-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-side .build-panel { grid-column: 1 / -1; }
  .build-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { align-items: center; padding: 24px; }
  .modal-card { max-width: 480px; border-radius: 22px; padding: 28px; }
  .modal-card.wide { max-width: 620px; }
  .coach { left: 50%; right: auto; bottom: 24px; width: min(560px, calc(100vw - 32px)); transform: translateX(-50%); }
}

@media (min-width: 1024px) {
  .hud { grid-template-columns: auto 1fr auto; grid-template-areas: "brand time ctrl"; gap: 16px; }
  .hud-time { justify-content: center; }
}

@media (min-width: 1100px) {
  .board { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .col-side {
    grid-template-columns: minmax(0, 1fr);
    position: sticky; top: calc(var(--hud-h) + 24px);
    max-height: calc(100vh - var(--hud-h) - 40px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin;
  }
  .build-list { grid-template-columns: minmax(0, 1fr); }
  .build-desc { -webkit-line-clamp: 1; }
}

@media (min-width: 1440px) {
  .board { grid-template-columns: minmax(0, 1fr) 420px; }
  .balance { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); }
}
