:root {
  --font-display: 'Clash Display', 'Segoe UI', sans-serif;
  --font-body: 'Satoshi', 'Segoe UI', sans-serif;
  --bg: #14110f;
  --surface: #1c1815;
  --surface-2: #25201c;
  --surface-3: #2f2924;
  --border: rgba(255, 228, 196, 0.09);
  --border-strong: rgba(255, 228, 196, 0.18);
  --text: #efe6dc;
  --muted: #a6978a;
  --faint: #6f6359;
  --accent: #f2a541;
  --accent-ink: #1d1206;
  --good: #7fcf8a;
  --danger: #ef6a5a;
  --shard: #c69bff;
  --t1: #8b8f97;
  --t2: #d9804a;
  --t3: #b9c3cc;
  --t4: #f5c542;
  --t5: #6fe3f0;
  --t6: #b06cff;
  --r: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(242, 165, 65, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .stat-value, .session-time { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

.app { max-width: 1280px; margin: 0 auto; padding: 16px; min-height: 100%; display: flex; flex-direction: column; gap: 16px; }

/* Top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .01em; }
.brand-ver { font-size: 12px; color: var(--accent); border: 1px solid var(--border-strong); padding: 1px 6px; border-radius: 99px; }
.stats { display: flex; gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 14px; display: flex; flex-direction: column; min-width: 96px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-weight: 700; font-size: 17px; }
.stat-value.money { color: var(--accent); }
.stat-value.shard { color: var(--shard); }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; flex: 1; min-height: 0; }
.layout > * { min-width: 0; }
.mine, .side { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.mine { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.mine-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.loc-name { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.1; margin-top: 4px; }
.session { text-align: right; display: flex; flex-direction: column; }
.session-time { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--accent); }
.session.urgent .session-time { color: var(--danger); }

/* Rock */
.rock { position: relative; width: 100%; aspect-ratio: 5 / 4; max-height: 300px; border-radius: 12px; background:
  radial-gradient(closest-side at 50% 60%, rgba(242,165,65,.10), transparent), var(--surface-2);
  border: 1px solid var(--border); overflow: hidden; touch-action: manipulation; user-select: none; }
.rock-svg { position: absolute; inset: 8% 10% 4%; width: 80%; height: 88%; transition: transform 120ms var(--ease); }
.rock:active .rock-svg, .rock.hit .rock-svg { transform: scale(0.97) rotate(-0.6deg); }
.pick-svg { position: absolute; width: 26%; right: 8%; top: 6%; transform-origin: 50% 90%; transform: rotate(28deg); transition: transform 90ms ease-in; filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
.rock.swing .pick-svg { transform: rotate(-38deg); }
.rock.broken-state .pick-svg { opacity: .35; }
.fx { position: absolute; inset: 0; pointer-events: none; }
.float { position: absolute; font-weight: 700; font-size: 14px; white-space: nowrap; animation: floatUp 1s var(--ease) forwards; text-shadow: 0 2px 4px rgba(0,0,0,.7); }
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -48px); } }
.spark { position: absolute; width: 6px; height: 6px; border-radius: 2px; animation: spark 600ms ease-out forwards; }
@keyframes spark { to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(120deg); } }
.rock-hint { font-size: 13px; color: var(--faint); text-align: center; margin-top: -8px; }

/* Durability */
.dura { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.dura-row, .dura-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dura-row span:first-child { font-weight: 700; }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--good); border-radius: 99px; transition: width 200ms linear, background 300ms; }
.broken { color: var(--danger); font-size: 13px; font-weight: 500; }

/* Log */
.log-wrap { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.log { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; max-height: 140px; overflow: hidden; }
.log li { display: flex; justify-content: space-between; color: var(--muted); }
.log li b { font-weight: 700; }

/* Tabs */
.tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; transition: background 180ms var(--ease), color 180ms; position: relative; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: var(--accent-ink); background: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--surface-3); color: var(--text); font-size: 11px; line-height: 18px; text-align: center; }
.tabs button.active .badge { background: rgba(0,0,0,.2); color: var(--accent-ink); }
.panel { padding: 16px; overflow-y: auto; flex: 1; }
.panel-intro { color: var(--muted); font-size: 14px; margin-bottom: 14px; max-width: 64ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; }

/* Cards */
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.card.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card.locked { opacity: .62; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 1.15; }
.card-sub { font-size: 13px; color: var(--muted); }
.chip { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.open { background: rgba(127, 207, 138, .15); color: var(--good); }
.chip.closed { background: rgba(239, 106, 90, .12); color: var(--danger); }
.chip.here { background: var(--accent); color: var(--accent-ink); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.meta div { display: flex; flex-direction: column; }
.meta span:first-child { color: var(--faint); font-size: 12px; }
.meta span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.ore-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ore-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px 3px 6px; border-radius: 99px; background: var(--surface-3); }
.dot { width: 10px; height: 10px; border-radius: 3px; transform: rotate(45deg); flex: none; }
.window-line { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.window-line strong { color: var(--text); }

.btn { padding: 9px 14px; border-radius: 8px; font-weight: 700; background: var(--accent); color: var(--accent-ink); transition: transform 120ms var(--ease), filter 160ms, opacity 160ms; text-align: center; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { background: var(--surface-3); color: var(--faint); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn.ghost:disabled { color: var(--faint); }
.btn.danger { background: var(--danger); color: #1d0906; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Ores table */
.ore-list { display: flex; flex-direction: column; gap: 8px; }
.ore-item { display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ore-gem { width: 22px; height: 22px; border-radius: 5px; transform: rotate(45deg); box-shadow: inset -3px -3px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.25); }
.ore-gem.unknown { background: var(--surface-3) !important; box-shadow: none; }
.ore-name { font-weight: 700; }
.ore-count { font-variant-numeric: tabular-nums; text-align: right; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* Upgrades */
.lvl-bar { display: flex; gap: 2px; }
.lvl-bar i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.lvl-bar i.on { background: var(--accent); }

/* Achievements */
.ach-summary { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 8px; }
.ach { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; }
.ach .ach-icon { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-3); flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--faint); }
.ach.done { border-color: rgba(242,165,65,.35); }
.ach.done .ach-icon { background: var(--accent); color: var(--accent-ink); }
.ach-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.ach.locked .ach-name { color: var(--muted); }
.ach-desc { font-size: 12px; color: var(--muted); }

/* Prestige */
.prestige-hero { background: linear-gradient(135deg, rgba(198,155,255,.14), rgba(198,155,255,.02)); border: 1px solid rgba(198,155,255,.25); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.prestige-hero h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.big-shard { font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--shard); line-height: 1; }
.btn.shard { background: var(--shard); color: #170a26; }
.section-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 4px 0 10px; }

/* Save */
textarea { width: 100%; min-height: 110px; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px; font-family: ui-monospace, 'SF Mono', monospace; font-size: 12px; resize: vertical; word-break: break-all; }
.save-box { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.notice { background: rgba(242,165,65,.08); border: 1px solid rgba(242,165,65,.25); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.stats-table { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; }
.stats-table span:nth-child(odd) { color: var(--muted); }
.stats-table span:nth-child(even) { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toastIn 300ms var(--ease); }
.toast b { display: block; font-size: 13px; color: var(--accent); }
.toast.shard { border-left-color: var(--shard); }
.toast.shard b { color: var(--shard); }
.toast.bad { border-left-color: var(--danger); }
.toast.bad b { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 300ms; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(8,6,5,.72); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; padding: 20px; max-width: 440px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.modal-card h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.modal-card p { color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Responsive */
@media (max-width: 860px) {
  .app { padding: 10px; gap: 10px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .mine { padding: 14px; gap: 12px; }
  .rock { max-height: 220px; }
  .loc-name { font-size: 22px; }
  .log { max-height: 84px; }
  .side { overflow: visible; }
  .tabs { position: sticky; top: 0; background: var(--surface); z-index: 5; border-radius: 14px 14px 0 0; }
  .panel { overflow: visible; }
  .topbar { gap: 8px; }
  .stats { width: 100%; }
  .stat { flex: 1; min-width: 0; padding: 6px 10px; }
  .stat-value { font-size: 15px; }
}
@media (min-width: 861px) {
  .app { height: 100vh; }
  .layout { overflow: hidden; }
  .mine { overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media (max-width: 860px) {
  .toasts { top: 10px; bottom: auto; right: 10px; left: 10px; max-width: none; }
  .toast { padding: 8px 12px; font-size: 13px; }
  .toast:nth-last-child(n+3) { display: none; }
}
.tier-list { display: flex; flex-direction: column; gap: 10px; }
.tier { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tier summary { list-style: none; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px; padding: 12px; cursor: pointer; }
.tier summary::-webkit-details-marker { display: none; }
.tier-title { display: flex; flex-direction: column; }
.tier[open] summary { border-bottom: 1px solid var(--border); }
.tier .ore-list { padding: 10px; }
.tier .ore-item { background: var(--surface); }
.rar { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-left: 4px; }
@media (max-width: 860px) {
  .tier .ore-list { padding: 6px; gap: 6px; }
  .tier .ore-item { padding: 8px 10px; gap: 10px; }
}
