/* Wheelie Bad Day — menus, HUD and touch buttons. The 3D game draws on the <canvas>. */
:root {
  --ink: #1d1442; --sun: #ffd23f; --tomato: #ff5a36; --grass: #3ddc84; --sky: #3ec7ff; --card: #fff; --pink: #ff6fb5;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1442; overscroll-behavior: none; }
body { font-family: Fredoka, system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
h1, h2, .logo, .btn, .tb { font-family: 'Lilita One', Fredoka, sans-serif; font-weight: 400; }

/* ---------- buttons ---------- */
.btn { font-size: 1.25rem; color: #fff; background: #6c63ff; border: 4px solid var(--ink); border-radius: 16px; padding: 8px 22px 10px;
  box-shadow: 0 5px 0 var(--ink); cursor: pointer; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; margin: 6px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.go { background: var(--grass); font-size: 1.7rem; padding: 8px 34px 12px; }
.btn.small { font-size: 1rem; padding: 5px 14px 7px; border-width: 3px; }
.btn.danger { background: var(--tomato); }
.btn[disabled] { background: #b9b3d6; cursor: default; }
.pill { background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: 1rem; white-space: nowrap; box-shadow: 0 3px 0 var(--ink); }
.pill.cash { background: var(--sun); }
.pill.big { font-size: 1.4rem; padding: 4px 18px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); touch-action: pan-y; }
.screen.dim { background: rgba(29, 20, 66, .55); }
.panel { background: #fff; border: 5px solid var(--ink); border-radius: 26px; box-shadow: 0 9px 0 var(--ink); padding: 16px 22px 18px; text-align: center;
  max-width: min(560px, 94vw); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; align-items: center; }
.panel h2 { font-size: 2.4rem; margin: 0 0 4px; color: var(--tomato); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.panel p { margin: 4px 0; font-size: 1.05rem; }
.panel table { margin: 8px auto; border-collapse: collapse; font-size: 1.1rem; }
.panel td { padding: 2px 10px; text-align: left; } .panel td:last-child { text-align: right; font-weight: 700; }
.panel tr.total td { border-top: 3px solid var(--ink); font-size: 1.35rem; }
.panel .tip { background: #eef9ff; border: 2.5px dashed var(--ink); border-radius: 12px; padding: 6px 12px; font-size: .95rem; margin-top: 6px; }
.panel .row { display: flex; flex-wrap: wrap; justify-content: center; }
.new { color: #fff; background: var(--pink); border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; font-size: .8rem; margin-left: 6px; }
.spinner { font-size: 3rem; animation: wheelie 1s ease-in-out infinite; }
@keyframes wheelie { 0%, 100% { transform: rotate(0) translateY(0); } 50% { transform: rotate(-25deg) translateY(-10px); } }

/* ---------- title ---------- */
#title { background: linear-gradient(170deg, rgba(62, 199, 255, .55), rgba(123, 92, 255, .6)); }
.title-card { text-align: center; display: flex; flex-direction: column; align-items: center; max-height: 100%; }
.logo { display: flex; flex-direction: column; line-height: .88; font-size: clamp(3rem, 15vmin, 7rem); color: #fff; -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); transform: rotate(-4deg); margin-bottom: 14px; }
.logo .bad { color: var(--tomato); font-size: 1.25em; }
.tag { background: var(--sun); border: 4px solid var(--ink); border-radius: 999px; padding: 6px 20px; font-weight: 700; font-size: clamp(.95rem, 3.5vmin, 1.25rem); box-shadow: 0 5px 0 var(--ink); margin: 6px 0 14px; }
.howto { margin-top: 12px; background: rgba(255, 255, 255, .92); border: 3px solid var(--ink); border-radius: 16px; padding: 8px 16px; font-size: .95rem; line-height: 1.5; max-width: 560px; }
.howto kbd, .info kbd { background: var(--ink); color: #fff; border-radius: 6px; padding: 0 6px; font-family: inherit; font-size: .85em; }
.back { margin-top: 10px; color: #fff; font-weight: 700; text-decoration: none; text-shadow: 0 2px 0 var(--ink); }

/* ---------- garage ---------- */
#garage { background: linear-gradient(170deg, #ffe9a8, #ffc978 60%, #ff9f6b); justify-content: flex-start; align-items: stretch; gap: 8px; }
.g-head { display: flex; justify-content: space-between; align-items: center; }
.g-head h1 { margin: 0; font-size: clamp(1.5rem, 6vmin, 2.4rem); color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.tabs { display: flex; gap: 6px; }
.tabs button { font: 700 1.05rem Fredoka, sans-serif; flex: 1; background: #fff6; border: 3px solid var(--ink); border-bottom: none; border-radius: 14px 14px 0 0; padding: 6px 4px; cursor: pointer; color: var(--ink); }
.tabs button.on { background: #fff; }
.tabs button[data-tab=more] { flex: 0 0 52px; }
.g-body { flex: 1; min-height: 0; background: #fff; border: 4px solid var(--ink); border-radius: 0 0 18px 18px; margin-top: -8px; overflow: hidden; display: flex; }
.tab { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.g-foot { display: flex; justify-content: center; }
.info { padding: 8px 14px; border-top: 3px solid var(--ink); background: #f6f3ff; font-size: 1rem; min-height: 62px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#tab-more .info { border: none; display: block; line-height: 1.7; }
.info b { font-size: 1.1rem; }
.tree-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; padding: 10px; }
#tree { position: relative; margin: 0 auto; }
#tree svg { position: absolute; inset: 0; pointer-events: none; }
.node { position: absolute; width: 92px; height: 78px; border: 3px solid var(--ink); border-radius: 14px; background: #d9d6e6; cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font: 700 .72rem/1.1 Fredoka, sans-serif; color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.node .ic { font-size: 1.45rem; line-height: 1.1; }
.node .cost { font-size: .78rem; }
.node.locked { opacity: .5; filter: grayscale(1); }
.node.can { background: var(--sun); animation: pop 1.2s ease-in-out infinite; }
.node.open { background: #fff; }
.node.owned { background: var(--grass); }
.node.sel { outline: 4px solid var(--tomato); outline-offset: 2px; }
@keyframes pop { 50% { transform: scale(1.06); } }
.tree-label { position: absolute; font: 400 1.1rem 'Lilita One', sans-serif; color: var(--ink); opacity: .55; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 12px; }
.card { border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; background: #fff; box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; gap: 4px; }
.card.sel { background: #e9fff1; outline: 4px solid var(--grass); }
.card.locked { opacity: .55; }
.card h3 { margin: 0; font: 400 1.25rem 'Lilita One', sans-serif; }
.card p { margin: 0; font-size: .92rem; }
.card .swatch { width: 100%; height: 10px; border-radius: 6px; border: 2px solid var(--ink); }
.stat { display: grid; grid-template-columns: 74px 1fr; align-items: center; font-size: .78rem; font-weight: 700; }
.stat i { display: block; height: 8px; border-radius: 4px; background: #e6e3f2; overflow: hidden; }
.stat i b { display: block; height: 100%; background: #6c63ff; }
.card .btn { align-self: flex-start; margin: 4px 0 0; }

/* haze that closes in from the edges when the kid is out of puff */
#tired { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(225, 230, 235, 0) 18%, rgba(225, 230, 235, .55) 55%, rgba(235, 238, 242, .97) 100%); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top { position: absolute; top: calc(8px + var(--sat)); left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); display: flex; gap: 6px; align-items: center; }
.progress { flex: 1; height: 24px; background: rgba(255, 255, 255, .8); border: 3px solid var(--ink); border-radius: 999px; position: relative; overflow: hidden; min-width: 60px; }
#hProg { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--grass), #9cf06a); }
#hBest { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--tomato); left: 0; }
#hDist { position: absolute; inset: 0; text-align: center; font-weight: 700; font-size: .85rem; line-height: 18px; }
.btn-pause { pointer-events: auto; cursor: pointer; font-size: 1rem; }
.hud-meters { position: absolute; left: calc(10px + var(--sal)); top: calc(46px + var(--sat)); display: flex; flex-direction: column; gap: 4px; width: 150px; }
.speed { color: #fff; font-family: 'Lilita One', sans-serif; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); line-height: 1; }
.speed b { font-size: 2.6rem; font-weight: 400; } .speed small { font-size: 1rem; margin-left: 4px; }
.meter label { font-size: .68rem; font-weight: 700; color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 3px var(--ink); letter-spacing: .06em; }
.bar { height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: rgba(255, 255, 255, .75); overflow: hidden; }
.bar > div { height: 100%; width: 100%; background: var(--sky); transition: background .2s; }
#hWobble { width: 0; background: var(--tomato); }
.low { animation: flash .35s linear infinite; } @keyframes flash { 50% { opacity: .35; } }
#toasts { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toast { background: var(--sun); border: 3px solid var(--ink); border-radius: 999px; padding: 2px 14px; font-weight: 700; box-shadow: 0 3px 0 var(--ink); animation: toast 1.6s ease-out forwards; white-space: nowrap; }
.toast.bad { background: #fff; } .toast.good { background: var(--grass); }
@keyframes toast { 0% { transform: scale(.4); opacity: 0; } 12% { transform: scale(1.1); opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
#big { position: absolute; inset: 12% 0 auto 0; display: flex; align-items: center; justify-content: center; text-align: center; font-family: 'Lilita One', sans-serif; font-size: clamp(2.6rem, 13vmin, 6rem);
  color: var(--tomato); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); transform: rotate(-5deg); pointer-events: none; }
#big small { display: block; font: 700 1.2rem Fredoka, sans-serif; color: #fff; -webkit-text-stroke: 0; text-shadow: 0 2px 0 var(--ink), 0 0 6px var(--ink); }
#dbg { position: absolute; left: 8px; bottom: 8px; margin: 0; color: #0f0; background: #000a; font-size: 11px; padding: 4px; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
#stick { pointer-events: auto; position: absolute; left: calc(18px + var(--sal)); bottom: calc(22px + var(--sab)); width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255, 255, 255, .22); border: 3px solid rgba(255, 255, 255, .7); touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px; border-radius: 50%; background: rgba(255, 255, 255, .85); border: 3px solid var(--ink); }
.tbtns { position: absolute; right: calc(14px + var(--sar)); bottom: calc(18px + var(--sab)); width: 250px; height: 230px; }
.tb { pointer-events: auto; position: absolute; width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(255, 255, 255, .8); color: var(--ink);
  font-size: .95rem; touch-action: none; padding: 0; }
.tb.down { transform: scale(.92); filter: brightness(.8); }
.tb.big { width: 108px; height: 108px; right: 0; bottom: 0; background: rgba(61, 220, 132, .9); font-size: 1.25rem; }
#bBoost { right: 116px; bottom: 4px; background: rgba(255, 210, 63, .9); }
#bJump { right: 84px; bottom: 92px; background: rgba(62, 199, 255, .9); }
#bBrake { right: 0; bottom: 118px; }
#bOff { right: 176px; bottom: 170px; background: rgba(255, 255, 255, .85); }
#bTrick { right: 172px; bottom: 96px; background: rgba(255, 111, 181, .9); }
.tb.small { width: 66px; height: 66px; font-size: .8rem; }

/* ---------- ending ---------- */
#ending { position: fixed; inset: 0; z-index: 30; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.bars { position: absolute; left: 0; right: 0; height: 11vh; background: #000; }
.bars.top { top: 0; } .bars.bottom { bottom: 0; display: flex; align-items: center; justify-content: center; }
#caption { color: #fff; font-size: clamp(1rem, 4.5vmin, 1.6rem); font-weight: 700; text-align: center; padding: 0 12px; }
#note { background: #fffbe6; border: 3px solid #cbbf8a; box-shadow: 0 10px 30px #0008; padding: 22px 30px; transform: rotate(-3deg); font: 600 clamp(1.1rem, 4.6vmin, 1.7rem)/1.3 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive;
  max-width: 86vw; animation: noteIn .5s cubic-bezier(.3, 1.5, .5, 1); }
#note p { margin: 6px 0; } #note .sig { text-align: right; } #note .ps { font-size: .75em; margin-top: 14px; }
@keyframes noteIn { from { transform: scale(.2) rotate(20deg); opacity: 0; } }
#credits { pointer-events: auto; }
#btnSkip { pointer-events: auto; position: absolute; right: calc(12px + var(--sar)); top: calc(12px + var(--sat)); }

@media (max-height: 480px) {
  .logo { font-size: 3rem; flex-direction: row; gap: .25em; margin-bottom: 4px; }
  .howto { display: none; }
  #stick { width: 120px; height: 120px; }
  .tbtns { transform: scale(.82); transform-origin: bottom right; }
  .panel h2 { font-size: 1.8rem; }
  .hud-meters { width: 120px; } .speed b { font-size: 1.9rem; }
}
@media (max-width: 560px) { #hArea, #hWeather { display: none; } .pill { font-size: .85rem; padding: 1px 8px; } }
