* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe6ff; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; color: #fff; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.tx { font-weight: 900; color: #fff; text-shadow: -2px -2px 0 #3a2a14, 2px -2px 0 #3a2a14, -2px 2px 0 #3a2a14, 2px 2px 0 #3a2a14, 0 3px 0 #3a2a14; }
.panel { border: 16px solid transparent; border-image: url(../assets/ui-panel.webp) 18% fill / 16px stretch; color: #3a2a14; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hudPanel { position: absolute; left: max(8px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); width: min(230px, 58%); padding: 0; }
#hudPanel .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; line-height: 1.1; }
#hudDay { font-size: 15px; }
#hudClock { font-size: 14px; }
.tx.big { font-size: 24px; }
#hudScore { font-size: 22px; color: #ffe27a; }
.bar { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.bar img, .ico-energy { width: 18px; height: 18px; flex: none; }
.ico-energy { display: inline-block; background: linear-gradient(135deg, #7cc8f0, #2f7fc0); clip-path: polygon(55% 0, 10% 58%, 45% 58%, 35% 100%, 90% 40%, 55% 40%); }
.track { flex: 1; height: 10px; background: rgba(58,42,20,0.25); border-radius: 3px; overflow: hidden; border: 2px solid #3a2a14; }
.fill { height: 100%; width: 50%; transition: width .2s; }
.fill.sat { background: linear-gradient(#ff8a7a, #e8483f); }
.fill.en { background: linear-gradient(#a6e1ff, #3d95d6); }
.fill.low { animation: blink .5s infinite alternate; }
@keyframes blink { to { opacity: .35; } }
#hudPanel .gold { justify-content: flex-start; margin-top: 3px; }
#hudPanel .gold img { width: 20px; height: 20px; }
#hudGold { font-size: 16px; }
.chip { margin-top: 4px; font-size: 14px; background: rgba(92,174,74,0.85); border-radius: 8px; padding: 2px 8px; display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.roundBtn { position: absolute; right: max(10px, env(safe-area-inset-right)); width: 50px; height: 50px; border-radius: 50%; border: 3px solid #3a2a14; background: rgba(255, 246, 223, 0.92); pointer-events: auto; padding: 5px; cursor: pointer; box-shadow: 0 3px 0 #3a2a14; transition: transform .1s; }
.roundBtn img { width: 100%; height: 100%; object-fit: contain; }
.roundBtn:active { transform: scale(.88); }
.roundBtn.on { background: #ffd84a; }
#btnBrain { top: calc(max(8px, env(safe-area-inset-top)) + 58px); }
#btnBag { top: calc(max(8px, env(safe-area-inset-top)) + 116px); }
#mission { position: absolute; left: max(8px, env(safe-area-inset-left)); right: 70px; max-width: 460px; padding: 0 0 8px; transition: transform .3s cubic-bezier(.3,1.6,.6,1); }
#mission.pop { animation: pop .45s cubic-bezier(.3,1.6,.6,1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mTitle { font-size: 14px; color: #ffe27a; }
.mText { font-size: 14px; font-weight: 700; line-height: 1.3; margin-top: 2px; }
.mBar { height: 8px; margin-top: 4px; background: rgba(58,42,20,0.2); border-radius: 4px; overflow: hidden; }
#missionFill { height: 100%; width: 0; background: linear-gradient(90deg, #5cae4a, #ffd84a); transition: width .3s; }
#brainPanel { position: absolute; left: max(8px, env(safe-area-inset-left)); right: 70px; max-width: 520px; height: 36%; padding: 0; animation: pop .3s cubic-bezier(.3,1.6,.6,1); }
#modalBox.panel, #brainPanel.panel { border: 4px solid #3a2a14; border-image: none; border-radius: 14px; background: linear-gradient(#fffaf0, #f6ead0); box-shadow: inset 0 0 0 4px #7cc35a, inset 0 0 0 6px #4c8a36, 0 4px 0 #3a2a14; padding: 12px; }
#brainCanvas { width: 100%; height: 100%; display: block; }
#toasts { position: absolute; left: 0; right: 0; top: 44%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { font-size: 18px; padding: 4px 14px; border-radius: 12px; background: rgba(58,42,20,0.55); animation: toast 2.2s forwards; white-space: nowrap; }
@keyframes toast { 0% { transform: scale(.4) translateY(10px); opacity: 0; } 12% { transform: scale(1.12); opacity: 1; } 20% { transform: scale(1); } 80% { opacity: 1; transform: translateY(-14px); } 100% { opacity: 0; transform: translateY(-30px); } }

/* subtitles */
#subtitle { position: absolute; left: 8px; right: 8px; max-width: 520px; bottom: 36%; display: flex; align-items: center; gap: 8px; padding: 0; pointer-events: none; animation: pop .25s ease-out; }
#profCanvas { width: 58px; height: 58px; flex: none; }
#subText { font-size: 15px; font-weight: 800; line-height: 1.35; color: #3a2a14; }

/* title */
#title { position: absolute; inset: 0; cursor: pointer; }
#titleBg { position: absolute; inset: 0; background: #bfe6ff url(../assets/cover-bg.webp) center / cover no-repeat; animation: kb 18s ease-in-out infinite alternate; }
@keyframes kb { from { transform: scale(1.02); } to { transform: scale(1.09) translateY(-1%); } }
#titleLogo { position: absolute; left: 50%; top: 6%; width: 82%; max-height: 30%; object-fit: contain; transform: translateX(-50%); animation: logoIn .7s cubic-bezier(.3,1.6,.6,1) both, floaty 3s 0.7s ease-in-out infinite alternate; filter: drop-shadow(0 6px 0 rgba(58,42,20,.35)); }
@keyframes logoIn { from { transform: translateX(-50%) translateY(-60px) scale(.5); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes floaty { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-8px); } }
#titlePrompt { position: absolute; left: 20px; right: 20px; bottom: 9%; text-align: center; font-size: 18px; padding: 0; white-space: normal; line-height: 1.25; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .65; transform: scale(.96); } to { opacity: 1; transform: scale(1.04); } }
.cornerBtn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(58,42,20,.6); background: rgba(255,246,223,.55); padding: 9px; cursor: pointer; }
.cornerBtn svg { width: 100%; height: 100%; }

/* intro */
#introLayer { position: absolute; inset: 0; background: #000 url(../assets/cover-bg.webp) center / cover no-repeat; z-index: 20; }
#introVideo { width: 100%; height: 100%; object-fit: cover; }
#btnSkip { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); }

/* buttons */
.btn { min-width: 120px; min-height: 48px; padding: 6px 18px; border: 14px solid transparent; border-image: url(../assets/ui-button.webp) 28% fill / 14px stretch; background: none; font: inherit; font-weight: 900; font-size: 17px; color: #fff; cursor: pointer; text-shadow: -2px -2px 0 #6a3a08, 2px -2px 0 #6a3a08, -2px 2px 0 #6a3a08, 2px 2px 0 #6a3a08; transition: transform .1s, filter .1s; pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover, .btn.focus { filter: brightness(1.12) drop-shadow(0 0 6px #fff6a0); transform: scale(1.04); }
.btn:active { transform: scale(.92); }
.btn.dim { filter: grayscale(.8) brightness(.85); }
.btn img { width: 24px; height: 24px; }

/* modal */
#modal { position: absolute; inset: 0; background: rgba(20, 30, 20, 0.5); display: flex; align-items: center; justify-content: center; z-index: 15; }
#modalBox { width: min(92%, 380px); max-height: 86%; overflow: auto; padding: 12px 12px 16px; text-align: center; animation: pop .3s cubic-bezier(.3,1.6,.6,1); }
#modalTitle { margin: 4px 0 8px; }
#modalBody { font-size: 15px; font-weight: 700; line-height: 1.45; color: #3a2a14; text-align: left; }
#modalBody p { margin: 6px 0; }
#modalBtns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.itemRow { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 6px 0; background: rgba(255,255,255,.45); border-radius: 10px; }
.itemRow img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.itemRow .info { flex: 1; min-width: 0; }
.itemRow .name { font-weight: 900; font-size: 15px; }
.itemRow .desc { font-size: 12px; opacity: .8; }
.itemRow .btn { min-width: 84px; font-size: 14px; min-height: 44px; padding: 2px 8px; }
.secTitle { font-weight: 900; font-size: 16px; margin: 10px 0 2px; color: #5a7a20; }
.goldLine { display: flex; align-items: center; gap: 6px; justify-content: center; font-weight: 900; font-size: 18px; }
.goldLine img { width: 26px; height: 26px; }

#fade { position: absolute; inset: 0; background: #fff6df; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 30; }
#fade.on { opacity: 1; }
