* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #101624; color: #f1ecdf;
  font: 14px/1.35 ui-rounded, "Trebuchet MS", system-ui, sans-serif; -webkit-user-select: none; user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas#view.drag { cursor: grabbing; }
button { font: inherit; color: inherit; cursor: pointer; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 6px; align-items: center; padding: 8px 10px;
  background: linear-gradient(#0e1424e0, #0e142400); pointer-events: none; flex-wrap: wrap; }
#hud > * { pointer-events: auto; }
.res { display: flex; align-items: baseline; gap: 5px; background: #1b2236d9; border: 1px solid #ffffff1a; border-radius: 9px; padding: 4px 9px; }
.res i { font-style: normal; font-size: 15px; }
.res b { font-size: 16px; font-variant-numeric: tabular-nums; }
.res small { opacity: .7; font-size: 12px; font-variant-numeric: tabular-nums; }
.res small.neg { color: #ff8a7a; opacity: 1; }
.res.alert { border-color: #ff6a5a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { background: #5a1e1ed9; } }
.spacer { flex: 1; }
.speed { display: flex; background: #1b2236d9; border: 1px solid #ffffff1a; border-radius: 9px; overflow: hidden; }
.speed button { background: none; border: 0; padding: 5px 9px; opacity: .65; }
.speed button.on { background: #f1c75a; color: #1b1608; opacity: 1; font-weight: 700; }
#menu-btn { background: #1b2236d9; border: 1px solid #ffffff1a; border-radius: 9px; padding: 4px 10px; font-size: 16px; }

#cambar { position: fixed; right: 10px; top: 50%; transform: translateY(-60%); display: flex; flex-direction: column; gap: 6px; }
#cambar button { width: 38px; height: 38px; border-radius: 10px; background: #1b2236d9; border: 1px solid #ffffff22; font-size: 17px; }
#cambar button.on { background: #f1c75a; color: #1b1608; }

#toasts { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 5; }
.toast { background: #1b2236ee; border: 1px solid #ffffff22; padding: 6px 14px; border-radius: 20px; animation: tin .3s ease-out; transition: opacity .6s; white-space: nowrap; }
.toast.big { background: #f1c75a; color: #1b1608; font-weight: 700; font-size: 16px; }
.toast.unlock { border-color: #f1c75a; }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }
#warn { position: fixed; top: 58px; left: 12px; color: #ffb0a4; font-weight: 700; text-shadow: 0 1px 2px #000; pointer-events: none; }

#panel { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 8px 8px; pointer-events: none; }
#panel > * { pointer-events: auto; }
#panel nav { display: inline-flex; gap: 4px; margin: 0 4px 6px; }
#panel nav button { background: #141b2ccc; backdrop-filter: blur(6px); border: 1px solid #ffffff1a; border-radius: 8px; padding: 3px 12px; opacity: .75; }
#panel nav button.on { opacity: 1; border-color: #f1c75a; }
#panel.min .cards, #panel.min .stats { display: none; }
#panel.min #collapse { transform: rotate(180deg); }
.cards { display: flex; gap: 6px; overflow-x: auto; padding: 2px 4px 4px; scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }
.card { flex: 0 0 auto; width: 132px; background: #141b2cd0; backdrop-filter: blur(8px); border: 1px solid #ffffff1f; border-radius: 12px; padding: 6px 7px 7px;
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto 1fr auto; column-gap: 6px; text-align: left; }
.card canvas { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 8px; }
.card h3 { margin: 1px 0 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .n { font-size: 12px; opacity: .75; }
.card p { grid-column: 1 / 3; margin: 3px 0 5px; font-size: 11px; opacity: .75; line-height: 1.2; }
.card button.buy { grid-column: 1 / 3; margin-top: 6px; border: 0; border-radius: 8px; padding: 4px; background: #f1c75a; color: #1b1608; font-weight: 700; font-size: 13px; }
.card button.buy:disabled { background: #3a4260; color: #a8aec4; cursor: default; }
.card.locked { opacity: .55; }
.card.locked button.buy { background: #2a3048; font-weight: 400; font-size: 11.5px; }
.card.upg { grid-template-columns: 1fr; width: 160px; }
.card.upg h3 { grid-column: 1; }
.card.upg button.buy { grid-column: 1; }
.card .pips { display: flex; gap: 2px; margin-top: 3px; }
.card .pips span { width: 9px; height: 4px; border-radius: 2px; background: #3a4260; }
.card .pips span.on { background: #f1c75a; }
.stats { display: none; }
#panel.min #collapse { transform: rotate(180deg); }
.cards { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 6px; scrollbar-width: thin; }
.hidden { display: none !important; }
.card { flex: 0 0 auto; width: 148px; background: #1b2236; border: 1px solid #ffffff1f; border-radius: 12px; padding: 7px 8px 8px; position: relative;
  display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto 1fr auto; column-gap: 6px; text-align: left; }
.card canvas { grid-row: 1 / 3; width: 40px; height: 40px; background: #2a3350; border-radius: 8px; }
.card h3 { margin: 0; font-size: 14px; }
.card .n { font-size: 12px; opacity: .75; }
.card p { grid-column: 1 / 3; margin: 4px 0 6px; font-size: 11px; opacity: .75; line-height: 1.2; height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card button.buy { grid-column: 1 / 3; border: 0; border-radius: 8px; padding: 5px; background: #f1c75a; color: #1b1608; font-weight: 700; }
.card button.buy:disabled { background: #3a4260; color: #a8aec4; cursor: default; }
.card.locked { opacity: .5; }
.card.locked button.buy { background: #2a3048; }
.card.upg { grid-template-columns: 1fr; }
.card.upg h3 { grid-column: 1; }
.card .pips { display: flex; gap: 2px; margin-top: 3px; }
.card .pips span { width: 9px; height: 4px; border-radius: 2px; background: #3a4260; }
.card .pips span.on { background: #f1c75a; }
.stats { background: #141b2cd8; backdrop-filter: blur(8px); border-radius: 12px; margin: 0 4px; padding: 8px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 18px; font-size: 13px; max-height: 190px; overflow: auto; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px solid #ffffff12; padding: 2px 0; }
.stats b { font-variant-numeric: tabular-nums; }

.modal { position: fixed; inset: 0; background: #0a0f1ccc; display: grid; place-items: center; z-index: 10; }
.modal .box { max-width: 460px; margin: 16px; background: #1b2236; border: 1px solid #ffffff26; border-radius: 16px; padding: 22px 24px; box-shadow: 0 20px 60px #0008; }
.modal h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: .5px; color: #f1c75a; }
.modal h2 { margin: 0 0 8px; color: #f1c75a; }
.modal ul { padding-left: 18px; opacity: .9; }
.modal button { display: block; width: 100%; margin-top: 10px; border: 0; border-radius: 10px; padding: 10px; font-size: 16px; font-weight: 700; background: #f1c75a; color: #1b1608; }
.modal button.danger { background: #5a2a2a; color: #ffd0c8; font-weight: 400; font-size: 14px; }

@media (max-width: 640px) {
  .res { padding: 3px 6px; } .res b { font-size: 14px; } .res small { display: none; }
  .card { width: 118px; }
  #cambar { top: auto; bottom: 200px; transform: none; }
}
