:root {
  --ink: #1d1d1f;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #d9d9d4;
  --accent: #4d86e8;
  --good: #2fbf4f;
  --bad: #e0413a;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #ecebe4; font-family: 'Fredoka', system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
kbd { font-family: inherit; font-size: 10px; background: #f0f0ec; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: #666; }

#top { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; }
#top > * { pointer-events: auto; }
.logo, .bigLogo { font-weight: 700; letter-spacing: -0.5px; }
.logo { background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 8px 14px; font-size: 22px; cursor: pointer; }
.logo span, .bigLogo span { color: var(--accent); }
.stats { display: flex; gap: 2px; background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 5px 6px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 1px 10px; min-width: 62px; position: relative; }
.stat b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat small { font-size: 11px; color: #777; margin-top: -2px; }
.stat .bar { position: absolute; left: 10px; right: 10px; bottom: -2px; height: 3px; background: #e7e7e2; border-radius: 3px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.stat.neg b { color: var(--bad); }
.speed { margin-left: auto; display: flex; gap: 3px; background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 5px; }
.speed button { border: 0; background: transparent; border-radius: 9px; padding: 6px 10px; font-size: 13px; color: #444; }
.speed button.on { background: var(--ink); color: #fff; }
.speed button:hover:not(.on) { background: #efefea; }

#goal { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 12px; padding: 7px 14px; font-size: 14px; box-shadow: var(--shadow); max-width: min(620px, calc(100vw - 32px)); text-align: center; pointer-events: none; }
#goal:empty { display: none; }

#inv { position: fixed; right: 10px; top: 80px; width: 190px; background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 10px; }
#inv h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: #555; }
#invList { display: flex; flex-direction: column; gap: 4px; }
.bcard { display: flex; align-items: center; gap: 8px; border: 1.5px solid transparent; background: #f6f6f2; border-radius: 10px; padding: 6px 8px; font-size: 14px; text-align: left; color: var(--ink); }
.bcard:hover { background: #efefea; }
.bcard.on { border-color: var(--ink); background: #fff; }
.bcard i { width: 18px; height: 14px; border-radius: 3px; flex: none; box-shadow: 1px 2px 0 rgba(0,0,0,.18); }
.bcard span { flex: 1; }
.bcard b { font-weight: 600; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 7px; font-size: 12px; }
.bcard .d { display: block; font-size: 11px; color: #777; }
#invList .empty { font-size: 12px; color: #888; }

#tools { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 3px; background: var(--panel); box-shadow: var(--shadow); border-radius: 16px; padding: 6px; max-width: calc(100vw - 20px); overflow-x: auto; }
#tools button { position: relative; border: 0; background: transparent; border-radius: 11px; padding: 6px 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 62px; color: var(--ink); }
#tools button:hover { background: #efefea; }
#tools button.on { background: var(--ink); color: #fff; }
#tools button.on kbd { background: #444; color: #ddd; border-color: #555; }
#tools button span { font-size: 12px; }
#tools button kbd { position: absolute; top: 3px; right: 4px; font-size: 9px; padding: 0 3px; }
#tools svg { width: 24px; height: 24px; fill: currentColor; }
#tools svg .rd { fill: none; stroke: #9d9d9a; stroke-width: 5; stroke-linecap: round; }
#tools svg .rd.w { stroke-width: 7; }
#tools svg .rd.ww { stroke-width: 8; }
#tools svg .rd.br { stroke: #222; }
#tools svg .mk { fill: none; stroke: #e3c341; stroke-width: 1; }
#tools svg .ar { fill: none; stroke: currentColor; stroke-width: 2; }
#tools .sep { width: 1px; background: var(--line); margin: 6px 3px; flex: none; }
#tools button.toggle.on { background: #222; color: #fff; }

#info { position: fixed; left: 10px; bottom: 90px; width: 240px; background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 12px; font-size: 13px; }
#info h4 { margin: 0 0 4px; font-size: 16px; }
#info .row { display: flex; justify-content: space-between; padding: 1px 0; color: #444; }
#info .why { color: var(--bad); font-size: 12px; margin-top: 4px; }

#tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; border-radius: 7px; padding: 3px 8px; transform: translate(14px, 14px); white-space: nowrap; }
#tip.err { background: var(--bad); }

#toasts { position: fixed; top: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--panel); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 16px; font-size: 14px; animation: tin .25s ease-out; }
.toast.big { background: var(--ink); color: #fff; font-size: 16px; padding: 12px 20px; }
.toast.err { border-left: 4px solid var(--bad); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(236, 235, 228, 0.55); backdrop-filter: blur(3px); padding: 16px; z-index: 10; }
.card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 28px; width: 440px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; }
.bigLogo { font-size: 52px; text-align: center; line-height: 1; }
.sub { text-align: center; color: #555; margin: 10px 0 16px; line-height: 1.35; }
.card h4 { margin: 14px 0 6px; font-weight: 600; }
.card .row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.card .row button { flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 8px; font-size: 14px; }
.card .row button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.card .row button .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.seedRow { align-items: center; }
.seedRow label { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; color: #555; }
.seedRow input { flex: 1; font: inherit; border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.seedRow button { flex: 0 0 auto !important; }
.primary { display: block; width: 100%; border: 0; background: var(--ink); color: #fff; font-size: 16px; font-weight: 500; border-radius: 12px; padding: 12px; margin-top: 8px; }
.primary:hover { background: #333; }
.ghost { display: block; width: 100%; border: 1.5px solid var(--line); background: #fff; font-size: 15px; border-radius: 12px; padding: 10px; margin-top: 8px; }
.fine { font-size: 12px; color: #888; text-align: center; margin: 14px 0 0; }
.fine a { color: #666; }
.help { width: 560px; }
.help h2 { margin-top: 0; }
.help ul { padding-left: 18px; line-height: 1.45; }
.help li { margin-bottom: 7px; }

@media (max-width: 760px) {
  .stat { min-width: 50px; padding: 1px 5px; }
  .stat b { font-size: 14px; }
  .logo { font-size: 17px; padding: 6px 10px; }
  #top { flex-wrap: wrap; }
  .speed { margin-left: 0; }
  #inv { top: auto; bottom: 88px; right: 8px; width: 160px; max-height: 40vh; overflow: auto; }
  #goal { top: auto; bottom: 90px; left: 8px; transform: none; max-width: 50vw; font-size: 12px; }
  #tools button { min-width: 52px; }
  #tools button span { font-size: 11px; }
}

.music { display: flex; align-items: center; gap: 2px; padding-left: 4px; border-left: 1px solid var(--line); margin-left: 2px; }
.music button { display: flex; align-items: center; }
.music svg { width: 16px; height: 16px; fill: currentColor; }
.music button.off { opacity: 0.4; }
.music input { width: 70px; accent-color: var(--ink); }
@media (max-width: 760px) { .music input { display: none; } }
