:root {
  --panel: rgba(22, 28, 44, .74);
  --panel-solid: #1a2134;
  --edge: rgba(255, 255, 255, .1);
  --text: #f4f1ea;
  --muted: #aab3c5;
  --accent: #ffcf5a;
  --good: #7be495;
  --bad: #ff7a6b;
  --radius: 16px;
  --font: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a1030; color: var(--text); font-family: var(--font); }
body { -webkit-user-select: none; user-select: none; touch-action: none; }
#app canvas { display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font: 500 11px/1 var(--font); padding: 3px 5px; border-radius: 5px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .14);
}

.panel, .pill, #info, #toolbar, .toast, .card {
  background: var(--panel);
  border: 1px solid var(--edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}

/* ---------------------------------------------------------------- HUD */
#hud {
  position: fixed; top: 12px; left: 12px; right: 12px;
  display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; pointer-events: none;
}
#hud > * { pointer-events: auto; }
.brand {
  align-self: center; font-weight: 600; font-size: 22px; letter-spacing: .3px; padding: 0 6px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}
.pill {
  position: relative; border-radius: var(--radius); padding: 7px 14px 8px; min-width: 120px;
  display: grid; grid-template-columns: auto; align-content: center;
}
.pill .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.pill .value { font-size: 22px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pill .detail { font-size: 12px; color: var(--muted); }
.money .value { color: var(--good); }
.money.broke .value { color: var(--bad); }
#income.neg { color: var(--bad); }
.money .tip {
  position: absolute; top: calc(100% + 6px); left: 0; white-space: nowrap; font-size: 12px;
  background: var(--panel-solid); padding: 6px 10px; border-radius: 10px; border: 1px solid var(--edge);
  opacity: 0; transform: translateY(-4px); transition: .15s; pointer-events: none;
}
.money:hover .tip { opacity: 1; transform: none; }
.money.flash-pos { animation: flashPos .7s; }
.money.flash-neg { animation: flashNeg .7s; }
@keyframes flashPos { 30% { box-shadow: 0 0 0 3px rgba(123, 228, 149, .55), 0 8px 28px rgba(0, 0, 0, .25); } }
@keyframes flashNeg { 30% { box-shadow: 0 0 0 3px rgba(255, 122, 107, .55), 0 8px 28px rgba(0, 0, 0, .25); } }
.payout {
  position: absolute; right: 12px; top: 6px; font-weight: 600; font-size: 14px;
  opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .6s;
}
.payout.show { opacity: 1; transform: translateY(-2px); }
.payout.pos { color: var(--good); }
.payout.neg { color: var(--bad); }

.clock { min-width: 150px; }
#sun { color: var(--accent); }
.speeds { display: flex; gap: 3px; margin-top: 4px; }
.speeds button {
  border: 0; background: rgba(255, 255, 255, .08); border-radius: 7px; padding: 3px 7px;
  font-size: 10px; letter-spacing: -1px; min-width: 30px;
}
.speeds button:hover { background: rgba(255, 255, 255, .16); }
.speeds button.active { background: var(--accent); color: #2a2110; }

.actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--edge); font-weight: 600; font-size: 18px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.icon-btn:hover { background: rgba(40, 50, 75, .9); }
#mute .cross { display: none; }
#mute.off .cross { display: inline; }
#mute.off .wave { display: none; }
#mute.off { color: var(--muted); }

/* ---------------------------------------------------------------- info panel */
#info {
  position: fixed; top: 92px; right: 12px; width: 270px; border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; pointer-events: none;
}
#info h3 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
#info h3 small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
#info p { margin: 4px 0; color: #dfe3ec; }
#info p.sub { color: var(--muted); font-size: 13px; }
#info p.warn { color: var(--bad); }
#info ul { list-style: none; padding: 0; margin: 8px 0; }
#info li { display: flex; gap: 8px; margin: 3px 0; font-size: 13px; }
#info li .mark { flex: none; width: 16px; font-weight: 700; }
#info li.ok .mark { color: var(--good); }
#info li.no { color: #f0d0cc; }
#info li.no .mark { color: var(--bad); }
#info em { color: var(--muted); font-style: normal; }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 8px; }
.bar div { height: 100%; background: linear-gradient(90deg, #7be495, #c9f27a); transition: width .3s; }

/* ---------------------------------------------------------------- toolbar */
#dock {
  position: fixed; left: 0; right: 0; bottom: 14px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none; padding: 0 12px;
}
#hint {
  font-size: 13px; color: #e8ecf4; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); text-align: center; max-width: 560px;
}
#toolbar {
  pointer-events: auto; display: flex; gap: 6px; padding: 8px; border-radius: 22px;
  max-width: 100%; overflow-x: auto;
}
.tool {
  position: relative; width: 82px; padding: 8px 4px 6px; border-radius: 15px; border: 1px solid transparent;
  background: rgba(255, 255, 255, .05); display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .12s, transform .12s;
  flex: none;
}
.tool:hover { background: rgba(255, 255, 255, .12); transform: translateY(-2px); }
.tool.active { background: var(--accent); color: #2a2110; border-color: rgba(255, 255, 255, .5); }
.tool .tname { font-size: 13px; font-weight: 500; }
.tool .tcost { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tool.active .tcost { color: #5b4a1e; }
.tool kbd { position: absolute; top: 5px; right: 6px; font-size: 9px; padding: 2px 4px; opacity: .7; }
.tool.active kbd { background: rgba(0, 0, 0, .1); border-color: rgba(0, 0, 0, .15); }

/* ---------------------------------------------------------------- feedback */
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; left: 0; top: 0; font-weight: 600; font-size: 15px; white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .5);
}
.floater.pos { color: #9dffb4; }
.floater.neg { color: #ffb0a6; font-size: 13px; }
.floater.pop { color: #bfe1ff; font-size: 13px; }

#toasts {
  position: fixed; top: 92px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  padding: 8px 16px; border-radius: 999px; font-size: 14px; animation: toastIn .25s ease-out;
  transition: opacity .4s, transform .4s;
}
.toast.good { border-color: rgba(123, 228, 149, .5); color: #c9ffd6; }
.toast.bad { border-color: rgba(255, 122, 107, .5); color: #ffd4cd; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

#paused-badge {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 28px; font-weight: 600;
  letter-spacing: 3px; text-transform: uppercase; padding: 10px 26px; border-radius: 999px;
  background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.paused #paused-badge { opacity: 1; }

/* ---------------------------------------------------------------- help */
.modal {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 12, 28, .45);
}
.modal[hidden] { display: none; }
.card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  border-radius: 24px; padding: 26px 28px; background: rgba(22, 28, 44, .9);
}
.card h1 { margin: 0; font-size: 34px; font-weight: 600; }
.card .lead { margin: 2px 0 14px; color: var(--muted); }
.steps { margin: 0 0 16px; padding-left: 20px; line-height: 1.45; }
.steps li { margin: 6px 0; }
.steps b { color: var(--accent); font-weight: 600; }
.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13px; color: #dfe3ec;
  padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .05); margin-bottom: 18px;
}
.primary {
  width: 100%; border: 0; border-radius: 14px; padding: 12px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: #2a2110;
}
.primary:hover { filter: brightness(1.07); }

@media (max-width: 720px) {
  .brand { display: none; }
  .pill { min-width: 0; padding: 6px 10px; }
  .pill .value { font-size: 18px; }
  .pill .detail { display: none; }
  #info { top: auto; bottom: 150px; right: 12px; left: 12px; width: auto; }
  .tool { width: 66px; }
  .tool kbd { display: none; }
  .controls { grid-template-columns: 1fr; }
}
