:root,
[data-theme='dark'] {
  --bg: #0e1220;
  --bg2: #151b2e;
  --panel: #1a2138;
  --border: #2b3558;
  --text: #e8ecf8;
  --muted: #a3adc9;
  --accent: #7c9cff;
  --accent-text: #0b1020;
  --good: #4ade80;
  --danger: #ff7a7a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #f1f4fb;
  --bg2: #e6ebf7;
  --panel: #ffffff;
  --border: #ccd4ea;
  --text: #16203a;
  --muted: #4b5675;
  --accent: #3157d5;
  --accent-text: #ffffff;
  --good: #11763a;
  --danger: #b3261e;
  --shadow: 0 6px 18px rgba(30, 50, 100, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed;
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
}

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-text); padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

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

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.logo { margin: 0; font-size: 1.15rem; }
.stats { display: flex; gap: 20px; flex: 1; justify-content: center; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.stat-label { font-size: 0.75rem; color: var(--muted); }
.stat strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.layout {
  max-width: 1100px; margin: 0 auto; padding: 16px;
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.panel h2 small { color: var(--muted); font-weight: normal; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.wide { grid-column: 1 / -1; }

.btn {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 4px 10px; min-height: 44px; min-width: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn[aria-checked='true'] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; }

.click-panel { text-align: center; }
.click-wrap { position: relative; display: flex; justify-content: center; padding: 8px 0; }
.click-btn {
  width: min(260px, 70vw); aspect-ratio: 1; border-radius: 50%;
  border: 4px solid var(--accent); background: radial-gradient(circle at 30% 30%, var(--accent), var(--bg2));
  color: var(--text); font: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: var(--shadow); touch-action: manipulation; user-select: none;
  transition: transform 0.08s;
}
.click-btn:active, .click-btn.pop { transform: scale(0.94); }
.click-icon { font-size: 4rem; line-height: 1; color: var(--accent-text); }
.click-label { font-weight: 700; color: var(--accent-text); }
.click-value { font-size: 0.95rem; color: var(--accent-text); font-variant-numeric: tabular-nums; }
[data-theme='dark'] .click-icon, [data-theme='dark'] .click-label, [data-theme='dark'] .click-value { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.float {
  position: absolute; font-weight: 700; color: var(--good); font-size: 1.2rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-80px); }
}

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  background: var(--bg2);
}
.item.affordable { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.item.owned { opacity: 0.7; }
.item .info { min-width: 0; }
.item .name { font-weight: 600; }
.item .desc { color: var(--muted); font-size: 0.82rem; }
.item .meta { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.item .buy { min-width: 110px; font-variant-numeric: tabular-nums; }
.item.affordable .buy { background: var(--good); color: #04130a; border-color: var(--good); font-weight: 600; }

.rebirth-info { margin: 0 0 12px; color: var(--muted); }

.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ach { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg2); }
.ach.done { border-color: var(--good); }
.ach .name { font-weight: 600; }
.ach .desc, .ach .reward { color: var(--muted); font-size: 0.8rem; }
.ach progress { width: 100%; height: 8px; margin-top: 6px; accent-color: var(--accent); }

.settings-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field > span { color: var(--muted); font-size: 0.85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
select, textarea {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 44px;
}
textarea { width: 100%; resize: vertical; font-family: ui-monospace, monospace; font-size: 0.8rem; }

.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 16px; }

.toast-area { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 8px; z-index: 50; max-width: calc(100vw - 24px); }
.toast {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow); animation: toastIn 0.25s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }
.modal-box h2 { margin-top: 0; }

@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .settings-grid { grid-template-columns: 1fr; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .stats { gap: 10px; }
  .stat strong { font-size: 1.15rem; }
  .item { flex-wrap: wrap; }
  .item .buy { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
