:root {
  --bg: #0b0f0c;
  --panel: #121915;
  --line: #1f2a23;
  --text: #d7e6dc;
  --muted: #7d9184;
  --accent: #3dff8a;
  --accent-dim: #1d6b3f;
  --warn: #ffb547;
  --danger: #ff5a5a;
  --cloud: #7cc8ff;
  --font: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at top, #13201a 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.4 var(--font);
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
  user-select: none; -webkit-user-select: none;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }

.hud { text-align: center; padding: calc(10px + env(safe-area-inset-top)) 12px 4px; }
.hud-title { font-size: 11px; letter-spacing: .3em; color: var(--muted); }
.hud-title span { color: var(--accent); }
.hud-cycles { font-size: 34px; font-weight: 700; color: var(--accent); text-shadow: 0 0 18px rgba(61,255,138,.35); font-variant-numeric: tabular-nums; }
.hud-cycles small { font-size: 13px; color: var(--muted); font-weight: 400; text-shadow: none; }
.hud-rate { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--cloud); color: var(--cloud); font-size: 12px; }

.core-wrap { display: flex; flex-direction: column; align-items: center; padding: 6px 0 10px; position: relative; }
.core {
  width: 150px; height: 150px; border: 0; background: none; padding: 0;
  touch-action: manipulation; transition: transform .06s;
  filter: drop-shadow(0 0 16px rgba(61,255,138,.25));
}
.core:active, .core.hit { transform: scale(.93); }
.core svg { width: 100%; height: 100%; }
.core .pins path { stroke: #8aa595; stroke-width: 3; stroke-linecap: round; }
.core .die { fill: #18241d; stroke: var(--accent); stroke-width: 2; }
.core .die-inner { fill: #0e1611; stroke: var(--accent-dim); stroke-width: 1.5; }
.core .trace { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.tap-hint { font-size: 12px; color: var(--muted); }
.floater {
  position: fixed; pointer-events: none; color: var(--accent); font-weight: 700;
  animation: float .9s ease-out forwards; text-shadow: 0 0 8px rgba(61,255,138,.6);
}
@keyframes float { to { transform: translateY(-70px); opacity: 0; } }

main { flex: 1; padding: 0 10px; }
.panel { display: none; }
.panel.active { display: block; }

.buy-mode { display: flex; gap: 6px; margin-bottom: 8px; }
.buy-mode button { flex: 1; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.buy-mode button.on { border-color: var(--accent); color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 4px 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.item.locked { opacity: .45; }
.item .ico { font-size: 26px; text-align: center; grid-row: span 2; }
.item .name { font-weight: 700; }
.item .name .n { color: var(--accent); margin-left: 6px; }
.item .sub { font-size: 12px; color: var(--muted); grid-column: 2; }
.item .buy {
  grid-row: span 2; grid-column: 3; min-width: 92px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--accent-dim); background: #0f1d15; color: var(--accent); text-align: center;
  font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.item .buy small { display: block; font-size: 10px; color: var(--muted); }
.item .buy:disabled { border-color: var(--line); color: var(--muted); background: transparent; cursor: default; }
.bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.card h2 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.cloud h2 { color: var(--cloud); }
.cloud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 12px 0; }
.cloud-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; }
.cloud-stats small { display: block; color: var(--muted); font-size: 11px; }
.cloud-stats b { color: var(--cloud); font-size: 18px; }
.btn {
  display: block; width: 100%; padding: 10px; margin: 6px 0; border-radius: 10px;
  border: 1px solid var(--line); background: #0f1512;
}
.btn.big { padding: 14px; font-size: 17px; border-color: var(--cloud); color: var(--cloud); }
.btn.primary { border-color: var(--accent); color: var(--accent); }
.btn.danger { border-color: #5a2323; color: var(--danger); }
.btn:disabled { opacity: .4; cursor: default; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; max-width: 560px; margin: 0 auto;
  background: rgba(11,15,12,.95); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(6px);
}
.tabs button { flex: 1; background: none; border: 0; padding: 8px 0 10px; color: var(--muted); font-size: 18px; position: relative; }
.tabs button span { display: block; font-size: 11px; }
.tabs button.on { color: var(--accent); }
.tabs i { position: absolute; top: 6px; left: 58%; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.modal[hidden] { display: none; }
.modal .card { max-width: 360px; width: 100%; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

.toasts { position: fixed; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 20; }
.toast { background: #10261a; border: 1px solid var(--accent); color: var(--accent); padding: 6px 12px; border-radius: 20px; font-size: 13px; animation: toast 2.6s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
