:root { --ink: #2c2115; --paper: #fbf5e7; --gold: #e0a92e; --green: #4f7f35; --line: #e0d4b8; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6d9c41; color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: center; padding: 10px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.pill { background: rgba(38,30,20,.8); color: #fff6df; padding: 7px 12px; border-radius: 999px; font-size: 14px; border: 0; white-space: nowrap; }
.pill.link { text-decoration: underline; text-underline-offset: 3px; }
.pill.gold { background: var(--gold); color: #2c2115; font-weight: 700; }
#money { font-size: 16px; color: #ffd76a; }
#money.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.14); } }

#nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); overflow-x: auto; background: linear-gradient(transparent, rgba(30,24,14,.55)); scrollbar-width: none; }
.nav { user-select: none; background: var(--paper); border: 0; border-radius: 10px; padding: 9px 13px; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,.28); }
.nav:hover { background: #fff; }

#rideBar, #rideInfo { display: none; }
.riding #nav, .riding #hud { display: none; }
.riding #rideBar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; gap: 8px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); justify-content: center; touch-action: manipulation; }
.riding #rideInfo { display: block; position: fixed; top: 10px; left: 16px; right: 16px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.8); pointer-events: none; }
#rideInfo h2 { margin: 0; font-size: 20px; }
#rideInfo p { margin: 2px 0 0; font-size: 13px; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; background: #fff; color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.btn:hover:not(:disabled) { background: #fff8e6; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.gold { background: var(--gold); box-shadow: none; }
.btn.gold:hover:not(:disabled) { background: #edb83f; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.ride { flex: 1 1 0; max-width: 170px; min-width: 0; padding: 15px 6px; font-size: 15px; background: rgba(251,245,231,.95); box-shadow: 0 3px 7px rgba(0,0,0,.35); user-select: none; }
.btn.ride:active, .btn.ride.on, .btn.ride.gold { background: var(--gold); }

#panel { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(25,18,8,.5); padding: 16px; }
#panel[hidden] { display: none; }
.sheet { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 16px; padding: 16px 18px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.head h2 { margin: 0; font-size: 22px; font-family: Georgia, serif; }
#panelClose { border: 0; background: none; font-size: 19px; padding: 6px 10px; color: var(--ink); }
h3 { margin: 12px 0 4px; font-size: 17px; }
p { margin: 6px 0; line-height: 1.4; }
.sub { color: #6c5c45; font-size: 13.5px; margin: 2px 0 6px; }
.center { text-align: center; }
.card { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; background: #fffdf6; }
.card.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.card h3 { margin-top: 0; }
.mini { width: 210px; height: 151px; flex: none; background: linear-gradient(#cfe3ef 62%, #a5c477 62%); border-radius: 10px; }
#panelBody > .mini { display: block; margin: 8px auto; }
.info { flex: 1; min-width: 0; }
.bar { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 12.5px; margin: 3px 0; }
.bar i { height: 8px; border-radius: 4px; background: #e9dfc8; overflow: hidden; display: block; }
.bar b { display: block; height: 100%; background: var(--green); }
.bar b.low { background: #c4503c; }
.routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 8px; }
.route { display: flex; flex-direction: column; gap: 2px; padding: 0 0 10px; text-align: left; color: inherit; background: #fffdf6; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.route:hover { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.route canvas { display: block; width: 100%; height: auto; margin-bottom: 6px; }
.route strong, .route span { padding: 0 10px; }
.center-row { justify-content: center; }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grow { flex: 1 1 180px; min-width: 0; }
.big { font-size: 26px; }
.tag { background: #efe5cc; padding: 5px 9px; border-radius: 8px; font-size: 13px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--gold); }
.stars { font-size: 40px; color: var(--gold); text-align: center; letter-spacing: 4px; }
.payout { text-align: center; font-size: 30px; font-weight: 800; color: var(--green); margin: 8px 0 14px; }
#panelBody > .btn.gold { display: block; width: 100%; margin-top: 8px; }

#toast { position: fixed; left: 50%; bottom: 76px; transform: translate(-50%, 16px); background: rgba(38,30,20,.92); color: #fff6df; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); opacity: 0; transition: .25s; pointer-events: none; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .card { flex-direction: column; }
  .mini { width: 100%; height: auto; aspect-ratio: 320 / 230; }
}

.hofcode { margin: 6px 0; padding: 10px; text-align: center; font-size: 18px; font-weight: 700; letter-spacing: .04em; overflow-wrap: anywhere; background: #efe5cc; border-radius: 8px; }
.hofqr { display: block; width: 200px; max-width: 100%; margin: 8px auto; image-rendering: pixelated; }
.hofinput { flex: 1; min-width: 180px; padding: 8px 10px; border: 1px solid #c9b98f; border-radius: 8px; font: inherit; text-transform: uppercase; }
