* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #c9d7e6;
  touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #24324a; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
.pill { pointer-events: auto; background: rgba(255,255,255,0.86); border: 2px solid #8aa4c4; border-radius: 20px; padding: 4px 12px 4px 6px; display: flex; align-items: center; gap: 6px; font-size: 18px; box-shadow: 0 2px 8px rgba(30,50,80,0.18); }
.coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, #f2c53d 45%, #b8860b); border: 2px solid #9a6e08; display: inline-block; }
#topBtns { display: flex; gap: 6px; pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; }
.hbtn { background: rgba(255,255,255,0.86); border: 2px solid #8aa4c4; border-radius: 12px; padding: 6px 10px; font-size: 14px; font-weight: 700; color: #2a3e5c; min-height: 36px; }
#taskBar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(52px + env(safe-area-inset-top)); z-index: 4; background: rgba(28,44,70,0.78); color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 94vw; pointer-events: none; }
#taskBar span.done { color: #ffe27a; }
#toast { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 9; background: rgba(255,255,255,0.95); color: #23324a; border: 3px solid #f2c53d; border-radius: 16px; padding: 10px 18px; font-size: 20px; font-weight: 700; opacity: 0; transition: opacity .25s; pointer-events: none; text-align: center; max-width: 88vw; }
#toast.show { opacity: 1; }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 3; color: #2a3e5c; background: rgba(255,255,255,0.7); padding: 3px 10px; border-radius: 10px; font-size: 13px; pointer-events: none; white-space: nowrap; }
#hint:empty { display: none; }
#actions { position: fixed; right: calc(10px + env(safe-area-inset-right)); bottom: calc(36px + env(safe-area-inset-bottom)); z-index: 6; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#actions button { background: #2f6a3e; color: #fff; border: 3px solid #e8f4ea; border-radius: 16px; padding: 10px 16px; font-size: 17px; font-weight: 700; box-shadow: 0 3px 10px rgba(20,40,30,0.3); min-width: 150px; }
#actions button.alt { background: #3a5a8a; }
#actions button.warn { background: #8a4a2a; }
body.riding #actions { bottom: auto; top: calc(96px + env(safe-area-inset-top)); }
body.riding #actions button { padding: 7px 12px; font-size: 15px; min-width: 0; }
#rideUI { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#joy, #walkJoy { position: fixed; left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,0.28); border: 3px solid rgba(255,255,255,0.75); pointer-events: auto; touch-action: none; z-index: 6; }
#walkJoy { width: 110px; height: 110px; opacity: 0.8; }
#joyKnob, #walkKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255,255,255,0.9); border: 3px solid #6a8cb8; }
#walkKnob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
#rideBtns { position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto auto; gap: 10px; pointer-events: auto; align-items: end; }
.rbtn { width: 76px; height: 64px; border-radius: 16px; border: 3px solid #fff; background: rgba(58,90,138,0.88); color: #fff; font-size: 22px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; touch-action: none; }
.rbtn small { font-size: 10px; font-weight: 600; margin-top: 3px; }
.rbtn.big { width: 96px; height: 96px; border-radius: 50%; background: rgba(196,72,60,0.92); font-size: 19px; grid-column: 2; grid-row: 1 / span 2; }
#bFaster { grid-column: 1; grid-row: 1; } #bSlower { grid-column: 1; grid-row: 2; }
.rbtn.press { filter: brightness(1.3); transform: scale(0.96); }
#gaitLabel { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); background: rgba(28,44,70,0.8); color: #fff; padding: 5px 14px; border-radius: 12px; font-weight: 700; font-size: 16px; }
body.desktop #joy, body.desktop #rideBtns, body.desktop #walkJoy { display: none; }
body.desktop #gaitLabel { bottom: calc(40px + env(safe-area-inset-bottom)); }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20,32,52,0.55); display: flex; align-items: center; justify-content: center; padding: 10px; }
.panel { background: #f7fafd; border: 3px solid #8aa4c4; border-radius: 18px; padding: 12px 14px; width: min(560px, 96vw); max-height: 94vh; overflow-y: auto; touch-action: pan-y; box-shadow: 0 12px 40px rgba(0,0,0,0.3); }
.panel.wide { width: min(760px, 98vw); }
.panel.small { width: min(360px, 92vw); }
.panel h2 { margin: 0 0 8px; font-size: 20px; color: #2a3e5c; }
.phead { display: flex; justify-content: space-between; align-items: center; }
.close { border: 0; background: #dfe8f2; border-radius: 10px; width: 40px; height: 36px; font-size: 18px; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row.end { justify-content: flex-end; }
.row button, .tools button, .item button { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 15px; background: #dfe8f2; color: #24324a; }
button.ok { background: #2f6a3e; color: #fff; }
.crow { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#creatorCanvas { background: linear-gradient(#cfdff0, #f4f8fc); border-radius: 12px; border: 2px solid #b8cade; width: 180px; height: 196px; }
.copts { flex: 1; min-width: 230px; display: flex; flex-direction: column; gap: 6px; }
.copts label { font-weight: 700; display: flex; flex-direction: column; gap: 3px; }
.copts input, #dlgInput { font-size: 17px; padding: 7px 9px; border: 2px solid #8aa4c4; border-radius: 9px; font-family: inherit; width: 100%; }
.optRow { display: flex; align-items: center; gap: 6px; }
.optRow > span { width: 70px; font-size: 14px; font-weight: 700; }
.sw { display: flex; gap: 5px; flex-wrap: wrap; }
.sw button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #8aa4c4; padding: 0; }
.sw button.txt { width: auto; border-radius: 9px; padding: 0 8px; font-size: 12px; font-weight: 700; background: #dfe8f2; }
.sw button.on { box-shadow: 0 0 0 3px #2f6a3e; }
.sw button.locked { opacity: 0.35; }
#careCanvas { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 12px; display: block; background: #3a2c22; touch-action: none; }
#careStats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.stat { font-size: 12px; font-weight: 700; }
.bar { height: 9px; background: #dbe3ec; border-radius: 5px; overflow: hidden; margin-top: 2px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #5fae6a, #2f8a4a); }
.bar i.low { background: linear-gradient(90deg, #e07a4a, #c4483c); }
.tabs { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.tab { border: 0; border-radius: 10px; padding: 7px 12px; font-weight: 700; background: #dfe8f2; color: #24324a; font-size: 14px; }
.tab.on { background: #3a5a8a; color: #fff; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tools button.on { background: #3a5a8a; color: #fff; }
.tackRow { display: flex; align-items: center; gap: 6px; width: 100%; flex-wrap: wrap; margin-bottom: 4px; }
.tackRow > span { width: 110px; font-weight: 700; font-size: 14px; }
.tackRow button { padding: 6px 9px; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,0.3); }
#careMsg { min-height: 20px; margin-top: 6px; font-size: 14px; color: #2f6a3e; font-weight: 700; }
#shopList { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.item { background: #fff; border: 2px solid #c8d6e6; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.item canvas { width: 100%; height: auto; border-radius: 8px; background: linear-gradient(#dbe7f3, #f4f8fb); }
.item b { font-size: 15px; } .item small { color: #50607a; font-size: 12px; min-height: 28px; }
.item .price { display: flex; align-items: center; gap: 5px; font-weight: 700; }
.item .price .coin { width: 16px; height: 16px; }
.item button.buy { background: #2f6a3e; color: #fff; }
.item button:disabled { opacity: 0.45; }
.item.owned { opacity: 0.75; }
.helpList { padding-left: 18px; margin: 4px 0; line-height: 1.45; font-size: 15px; }
#dlgText { margin: 4px 0 8px; }
body:not(.desktop) #gaitLabel { left: auto; right: calc(14px + env(safe-area-inset-right)); transform: none; bottom: calc(170px + env(safe-area-inset-bottom)); }
body.riding:not(.desktop) #actions { top: auto; right: auto; left: calc(18px + env(safe-area-inset-left)); bottom: calc(176px + env(safe-area-inset-bottom)); align-items: flex-start; }
@media (max-width: 500px) { #taskBar { font-size: 12px; gap: 4px 10px; padding: 5px 10px; } }
#homeCanvas, #buildCanvas { width: 100%; height: auto; border-radius: 12px; display: block; background: #e9f0f7; }
#homeCanvas { aspect-ratio: 16 / 9; }
#buildCanvas { aspect-ratio: 640 / 290; }
.note { font-size: 13px; color: #3a4a62; margin: 6px 0; }
#homeItems { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.hitem { display: flex; align-items: center; gap: 6px; border: 2px solid #c8d6e6; background: #fff; border-radius: 12px; padding: 4px 8px 4px 4px; text-align: left; color: #24324a; }
.hitem canvas { width: 46px; height: 40px; flex: none; background: linear-gradient(#e7eef6, #f7fafd); border-radius: 8px; }
.hitem span { display: flex; flex-direction: column; line-height: 1.15; }
.hitem b { font-size: 13px; } .hitem small { font-size: 12px; color: #2f6a3e; font-weight: 700; }
.hitem:active { transform: scale(0.97); }
.buildGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.buildGrid .item button:not(.buy) { background: #3a5a8a; color: #fff; }
.styleList { display: flex; flex-direction: column; gap: 8px; }
.styleRow > span { width: 130px; }
.styleName { font-size: 12px; color: #50607a; }
@media (max-width: 500px) { .styleRow { flex-wrap: wrap; } .styleRow > span { width: 100%; } #homeItems { grid-template-columns: 1fr 1fr; } .buildGrid { grid-template-columns: 1fr 1fr; } }
@media (max-height: 520px) and (orientation: landscape) {
  #home .panel, #build .panel { display: grid; grid-template-columns: 46% 1fr; column-gap: 10px; width: 98vw; align-content: start; }
  #home .phead, #build .phead { grid-column: 1 / -1; }
  #homeCanvas, #buildCanvas { grid-column: 1; grid-row: 2 / span 3; align-self: start; position: sticky; top: 0; }
  #home .note, #homeItems, #home .row, #buildTabs, #buildList { grid-column: 2; }
  #home .note { margin-top: 0; }
  #homeItems { grid-template-columns: 1fr 1fr; }
  .buildGrid { grid-template-columns: 1fr 1fr; }
}
#bJump.cue { animation: cue 0.5s ease-in-out infinite alternate; box-shadow: 0 0 0 4px #ffe27a, 0 0 18px #ffe27a; }
@keyframes cue { from { transform: scale(1); } to { transform: scale(1.08); } }
