/* v4 — readability, frame-safe padding, mobile-only touch controls, new HUD pieces. */

/* ---------- Touch controls appear ONLY in mobile (touch) mode ---------- */
body:not(.is-touch) #hud .touch-controls { display: none !important; }
body.is-touch #hud .touch-controls { display: block !important; }
body.is-touch #hud .keyboard-hint { display: none !important; }
body:not(.is-touch) #hud { --hud-bottom: max(40px, calc(env(safe-area-inset-bottom) + 12px)) !important; }
body.is-touch #hud { --hud-bottom: max(176px, calc(env(safe-area-inset-bottom) + 176px)); }
@media (max-height: 550px) and (orientation: landscape) { body.is-touch #hud { --hud-bottom: max(5px, env(safe-area-inset-bottom)); } }
@media (max-width: 760px) { body:not(.is-touch) #hud .keyboard-hint { display: none; } }
body:not(.is-touch) #hud .player-card { left: var(--hud-left) !important; }
body:not(.is-touch) #hud .skill-card { right: var(--hud-right) !important; }
body:not(.is-touch) #hud .shot-charge { bottom: calc(var(--hud-bottom) + 128px) !important; }

/* ---------- HUD text: nothing below 10px, nothing touching the painted frame ---------- */
#hud .match-label { font-size: 11px !important; bottom: 15px; width: 34%; letter-spacing: .4px; }
#hud .player-card { padding: 18px 34px 20px 38px; }
#hud .player-card small, #hud .stamina-heading, #hud .stamina-heading b { font-size: 11px !important; letter-spacing: .6px; }
#hud .player-card strong { font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
#hud .dodge-status { font-size: 12px !important; }
#hud .skill-card { padding: 22px 30px 22px 30px; }
#hud .skill-card small { font-size: 12px !important; line-height: 1.2; }
#hud .skill-card strong { font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
#hud .keyboard-hint { font-size: 12px; gap: 14px; }
#hud .keyboard-hint kbd { font-size: 13px; padding: 5px 8px; }
#hud .touch-actions small { font-size: 11px !important; }
#hud .shot-charge > span { font-size: 13px; }
#hud .shot-charge > div { position: relative; height: 8px !important; overflow: visible; }
#hud .shot-charge i { position: relative; z-index: 1; }
#hud .perfect-zone { position: absolute; top: -3px; bottom: -3px; background: #ffd84a; box-shadow: 0 0 10px #ffd84a, inset 0 0 0 1px #fff6; border-radius: 3px; opacity: .85; z-index: 2; mix-blend-mode: screen; }

#hud .frenzy-banner { width: auto !important; min-width: 360px; height: auto !important; padding: 18px 48px 16px !important; font-size: 23px !important; white-space: nowrap; }
#hud .frenzy-banner small { font-size: 12px !important; letter-spacing: 1px; margin-top: 6px; }
#hud .frenzy-banner[data-kind="candy"] { color: #ffd38a; }
#hud .frenzy-banner[data-kind="hands"] { color: #b9ffb0; }
#hud .frenzy-banner[data-kind="moonball"] { color: #bfe4ff; }
#hud .frenzy-banner { animation: bannerIn .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes bannerIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#hud .goal-banner small { font-family: var(--display) !important; font-size: 18px !important; font-weight: 800; letter-spacing: 3px !important; margin-top: 10px !important; color: #fff0cf; }
#hud .goal-banner em { display: block; font-style: normal; font-size: 64px; color: #fff1d1; letter-spacing: 2px; text-shadow: 0 4px 0 #3a1720, 0 0 40px #ff8a3266; animation: vsIn .6s cubic-bezier(.2,1.5,.4,1); }
#hud .goal-banner em span { color: #ff9d3d; font-size: 40px; margin: 0 14px; }
@keyframes vsIn { from { letter-spacing: 30px; opacity: 0; } to { letter-spacing: 2px; opacity: 1; } }
#hud .goal-banner:not(.kickoff-count):not(.hidden) { animation: goalPop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes goalPop { from { transform: translateX(-50%) scale(2.2); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#toast { max-width: min(90vw, 560px) !important; padding: 24px 48px !important; font-size: 18px !important; text-align: center; white-space: normal; }

/* ---------- Side HUD: coins, combo, missions ---------- */
.soul-coin { display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -.12em; margin-right: .25em; background: radial-gradient(circle at 35% 30%, #fff6c4, #ffc23d 38%, #c86d12 70%, #6b3207); box-shadow: 0 0 6px #ffb3388a, inset 0 0 0 2px #7a3d0b55; }
#hud .side-hud { position: absolute; left: var(--hud-left); top: calc(var(--hud-top) + 8px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#hud .coin-hud, #hud .combo-hud { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: linear-gradient(90deg, #170d22e6, #170d2299); border-left: 3px solid #ffb43c; font-family: var(--display); color: #fff1d1; text-shadow: var(--hud-shadow); width: max-content; }
#hud .coin-hud b { font-size: 22px; } #hud .coin-hud small { font-size: 11px; letter-spacing: 1px; color: #e8c98e; }
#hud .combo-hud { border-left-color: #ff5d77; flex-wrap: wrap; animation: comboPulse .35s; }
#hud .combo-hud b { font-size: 30px; color: #ffcf6a; line-height: 1; } #hud .combo-hud span { font-size: 13px; letter-spacing: 2px; }
#hud .combo-hud i { flex-basis: 100%; height: 4px; background: #3c2340; border-radius: 3px; overflow: hidden; } #hud .combo-hud em { display: block; height: 100%; background: linear-gradient(90deg, #ff5d77, #ffcf6a); }
@keyframes comboPulse { 50% { transform: scale(1.12); } }
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mission-list li { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 14px; color: #efe1c4; }

.mission-list li.done { color: #b8ffb0; } .mission-list li.done span { text-decoration: line-through; text-decoration-color: #b8ffb099; }
.mission-list li b { margin-left: auto; color: #ffcf6a; font-size: 13px; padding-left: 10px; white-space: nowrap; }
#hud .mission-hud { padding: 9px 14px; background: #120a1bb3; border-left: 3px solid #8a6bd8; max-width: 270px; }
#hud .mission-hud li { font-size: 13px; text-shadow: var(--hud-shadow); }
@media (max-width: 760px), (max-height: 520px) { #hud .mission-hud { display: none; } #hud .coin-hud { padding: 6px 12px; } #hud .coin-hud b { font-size: 18px; } }
@media (max-width: 700px) and (orientation: portrait) { #hud .side-hud { top: calc(var(--hud-top) + 92px); } }

#popups { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.style-pop { position: absolute; transform: translate(-50%, -50%); text-align: center; font-family: var(--display); animation: popUp 1.5s cubic-bezier(.2,1.3,.4,1) forwards; white-space: nowrap; }
.style-pop b { display: block; font-size: 30px; color: #fff3d6; letter-spacing: 1px; text-shadow: 0 3px 0 #451a28, 0 0 18px #ff8a3288; }
.style-pop span { font-size: 17px; color: #ffcf6a; text-shadow: 0 2px 2px #000; }
.style-pop.hot b { color: #ffcf6a; font-size: 36px; } .style-pop.warn b { color: #ffb0a0; }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.4); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 70% { opacity: 1; transform: translate(-50%, -110%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -150%) scale(.95); } }

/* ---------- Menu: upgrades button + coin badge ---------- */
.menu-coins { position: absolute; left: 22px; top: 18px; display: flex; align-items: center; gap: 6px; padding: 9px 18px; background: #160c20d9; border: 2px solid #c79a4d; border-radius: 30px; font-family: var(--display); color: #fff1cf; box-shadow: 0 3px 10px #0008; }
.menu-coins b { font-size: 28px; line-height: 1; } .menu-coins small { font-size: 13px; letter-spacing: 1px; color: #e9c88a; }
.menu-quick { left: 260px; top: 342px; width: 380px; }
.menu-upgrades { left: 218px; top: 412px; width: 228px; height: 62px; }
.menu-upgrades .game-button-label { font-size: 44px; }
.menu-upgrades.can-buy::after { content: '!'; position: absolute; right: -6px; top: -8px; width: 26px; height: 26px; border-radius: 50%; background: #ff4d5e; color: #fff; font: 800 18px/26px var(--display); text-align: center; box-shadow: 0 0 10px #ff4d5e; animation: comboPulse 1s infinite; }
.menu-more-games { left: 454px; top: 412px; width: 228px; }
.menu-options, .has-cup .menu-options { left: 218px; top: 482px; width: 148px; height: 52px; }
.menu-controls, .has-cup .menu-controls { left: 376px; top: 482px; width: 148px; height: 52px; }
.menu-credits, .has-cup .menu-credits { left: 534px; top: 482px; width: 148px; height: 52px; }
.menu-options .game-button-label { font-size: 36px; }
.menu-controls .game-button-label, .has-cup .menu-controls .game-button-label { font-size: 28px; }
.menu-credits .game-button-label { font-size: 36px; }
.has-cup .menu-quick { left: 218px; width: 290px; }
.has-cup .menu-quick .game-button-label { font-size: 56px; }
.has-cup .menu-new-cup { left: 516px; top: 342px; width: 166px; height: 62px; }
@media (max-width: 699px) and (orientation: portrait) {
 .menu-coins { left: 26px; top: 14px; }
 .menu-quick { left: 80px; top: 488px; width: 440px; }
 .menu-upgrades { left: 70px; top: 576px; width: 224px; height: 76px; }
 .menu-more-games { left: 306px; top: 576px; width: 224px; height: 76px; }
 .menu-options, .has-cup .menu-options { left: 40px; top: 666px; width: 166px; height: 68px; }
 .menu-controls, .has-cup .menu-controls { left: 218px; top: 666px; width: 164px; height: 68px; }
 .menu-credits, .has-cup .menu-credits { left: 394px; top: 666px; width: 166px; height: 68px; }
 .menu-options .game-button-label, .menu-credits .game-button-label { font-size: 40px; }
 .menu-controls .game-button-label, .has-cup .menu-controls .game-button-label { font-size: 30px; }
 .has-cup .menu-quick { left: 40px; width: 330px; }
 .has-cup .menu-new-cup { left: 382px; top: 488px; width: 178px; height: 74px; }
}

/* ---------- Page screens: readable sizes, text kept inside the bone frames ---------- */
.page-screen .eyebrow { font-size: 12px !important; letter-spacing: 1.4px; }
.page-screen .page-heading p { font-size: 13px !important; }
.page-screen .step-label, .setup-confirm > span { font-size: 12px !important; letter-spacing: .8px; }
.page-screen .field-label { font-size: 12px; }
.team-option { padding: 26px 24px 22px !important; }
.team-option .team-number { top: 24px !important; right: 26px !important; font-size: 16px; }
.team-option h2 { font-size: 22px !important; }
.team-skill { font-size: 12px !important; }
.team-option p { font-size: 12px !important; line-height: 1.3 !important; }
.team-traits span { font-size: 10px; }
.team-select-label { font-size: 11px !important; }
.arena-option { padding: 14px 22px !important; font-size: 13px !important; line-height: 1.2; text-align: left; }
.arena-option small { display: block; font-size: 10px !important; letter-spacing: 1px; margin-bottom: 3px; color: #e2c486; }
.setup-confirm .button, .cup-callout .button, .page-footer .button { padding-left: 34px !important; padding-right: 34px !important; }
.option-row label { font-size: 14px !important; } .option-row small { font-size: 12px !important; }
.ads-option > p, .option-note { font-size: 12px !important; }
.control-row h2 { font-size: 18px !important; } .control-row p { font-size: 12px !important; } .control-row kbd { font-size: 12px !important; }
.tips-panel { padding: 26px 28px !important; } .tips-panel p { font-size: 12px !important; }
.cup-round { padding: 26px 26px !important; } .cup-round small, .round-state { font-size: 11px !important; } .cup-opponent strong { font-size: 13px !important; }
.credit-grid p, .credit-grid a { font-size: 13px; }
.topbar .text-button { font-size: 13px !important; } .brand small { font-size: 8px !important; }

/* Pause & result: keep labels clear of the ornate left/right borders */
.pause-panel { padding: 46px 52px !important; }
.pause-panel .button, .modal-panel .button { padding-left: 40px !important; padding-right: 40px !important; justify-content: space-between; }
.pause-panel h1 { font-size: 62px !important; }
.pause-links .text-button { font-size: 15px !important; }
.pause-panel .mission-list { margin: -6px 0 18px; padding: 10px 14px; background: #0006; border-radius: 6px; }
.result-panel { padding: 34px 56px !important; }
.result-score small, .result-stats span { font-size: 12px !important; }
.result-actions .button { padding-left: 30px !important; padding-right: 30px !important; }
.reward-block { display: grid; grid-template-columns: auto 1fr 1.3fr; gap: 6px 22px; align-items: center; padding: 10px 0 4px; border-top: 1px solid #dabf7944; }
.reward-total small { display: block; font-family: var(--display); font-size: 12px; letter-spacing: 1px; color: #e9c88a; }
.reward-total b { font-family: var(--display); font-size: 36px; color: #ffd36a; line-height: 1.05; }
.reward-total span { display: block; font-size: 11px; color: #cfc4b8; letter-spacing: .5px; }
.reward-lines { display: flex; flex-wrap: wrap; gap: 4px 14px; font-family: var(--display); font-size: 14px; color: #e6dccd; }
.reward-lines b { color: #ffd36a; }
.result-panel .result-stats { padding: 8px 0 !important; }
.result-panel .result-score { padding: 8px 0 !important; margin-top: 8px !important; }
.result-panel .result-heading h1 { font-size: 46px !important; }
@media (max-width: 700px) {
 .reward-block { grid-template-columns: 1fr; } .result-panel { padding: 26px 30px !important; }
 .page-screen .eyebrow { font-size: 11px !important; } .team-option p { font-size: 11px !important; }
 .player-card small, .skill-card small { font-size: 10px !important; }
}

/* ---------- Upgrades screen ---------- */
.upgrades-screen .page-heading { justify-content: space-between; }
.wallet { display: flex; align-items: center; gap: 8px; padding: 12px 22px; background: #160c20d9; border: 2px solid #c79a4d; border-radius: 40px; font-family: var(--display); color: #fff1cf; flex: 0 0 auto; }
.wallet b { font-size: 34px; line-height: 1; } .wallet small { font-size: 12px; letter-spacing: 1px; color: #e9c88a; }
.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.upgrade-card { position: relative; isolation: isolate; padding: 24px 26px 22px; display: grid; grid-template-columns: 46px 1fr; grid-template-rows: auto auto auto auto; column-gap: 12px; align-items: center; }
.upgrade-card::before { content: ''; position: absolute; inset: -2px; z-index: -1; border: 29px solid transparent; border-image: url('../assets/ui/hud-modal.webp') 20% fill stretch; pointer-events: none; }
.upgrade-card.maxed::before { filter: brightness(1.25) drop-shadow(0 0 5px #ffd36a); }
.upgrade-icon { grid-row: 1 / 3; font-size: 32px; width: 46px; height: 46px; display: grid; place-items: center; background: url('../assets/ui/hud-rune.webp') center / contain no-repeat; }
.upgrade-card h2 { font-family: var(--display); font-size: 21px; line-height: 1; color: #fff1d1; }
.upgrade-card p { grid-column: 1 / -1; font-size: 12px; line-height: 1.3; color: #d6cbbe; margin: 8px 0; min-height: 31px; }
.upgrade-pips { grid-column: 1 / -1; display: flex; gap: 5px; margin-bottom: 10px; }
.upgrade-pips i { flex: 1; height: 8px; border-radius: 4px; background: #3a2a40; box-shadow: inset 0 1px 2px #0008; }
.upgrade-pips i.on { background: linear-gradient(90deg, #ffb43c, #ffe28a); box-shadow: 0 0 6px #ffb43c99; }
.upgrade-card .button { grid-column: 1 / -1; min-height: 46px !important; height: 46px; font-size: 22px !important; justify-content: center; padding: 8px 20px !important; }
.upgrade-card .button[disabled] { filter: grayscale(.6) brightness(.8); cursor: default; }
@media (max-width: 700px) { .upgrade-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .upgrade-card { padding: 20px 18px; } .wallet { margin-top: 12px; width: max-content; } }
@media (min-aspect-ratio: 1/1) { .upgrades-screen .page-heading h1 { font-size: 46px; } }
.mission-list li > i:first-child { display: grid; place-items: center; width: 18px; height: 18px; border: 2px solid #c9a96b; border-radius: 4px; font-style: normal; font-size: 13px; color: #9dff9a; flex: 0 0 auto; background: none; box-shadow: none; }
.mission-list li i.soul-coin { width: 1em; height: 1em; border: 0; border-radius: 50%; }
.upgrades-screen .page-heading { margin-bottom: 10px !important; }
.upgrades-screen .page-heading h1 { font-size: 40px !important; }
.upgrade-grid { gap: 8px 14px; }
.upgrade-card { padding: 20px 24px 18px; }
.upgrade-card p { margin: 5px 0 6px; min-height: 0; }
.upgrade-pips { margin-bottom: 8px; }
.upgrade-card .button { min-height: 42px !important; height: 42px; }
#hud .frenzy-banner { background-image: url('../assets/ui/hud-player.webp') !important; padding: 20px 56px 18px !important; }
@media (min-aspect-ratio: 1/1) { .modal-panel, .result-panel { transform: scale(var(--modal-scale, var(--page-scale, 1))) !important; } }
.pause-panel .button { white-space: nowrap; font-size: 30px !important; }
.pause-panel .eyebrow, .result-panel .eyebrow { font-size: 14px !important; }
.pause-panel p, .result-heading p { font-size: 15px !important; }
.result-stats span, .result-score small { font-size: 14px !important; } .result-score strong { font-size: 16px !important; }
.reward-lines { font-size: 16px; } .modal-screen .mission-list li { font-size: 16px; } .modal-screen .mission-list li b { font-size: 15px; }
@media (max-height: 550px) and (orientation: landscape) {
 .pause-panel h1 { display: none; } .pause-panel .eyebrow { font-size: 22px !important; margin-bottom: 6px; }
 .result-heading p, .result-stats { display: none !important; }
 #toast { top: calc(var(--hud-top) + 160px) !important; bottom: auto !important; font-size: 16px !important; padding: 16px 40px !important; }
 #hud .frenzy-banner { min-width: 300px; font-size: 19px !important; padding: 14px 44px 12px !important; top: calc(var(--hud-top) + 72px) !important; }
 #hud .frenzy-banner small { font-size: 11px !important; }
}
@media (max-width: 700px) {
 #hud .player-card strong, #hud .skill-card strong { font-size: 15px !important; white-space: normal; line-height: 1.02; overflow: visible; }
 #hud .skill-card small { font-size: 11px !important; }
}
body[data-screen="pause"] #toast, body[data-screen="result"] #toast { display: none; }

/* ---------- Announcements stay out of the play area ---------- */
body[data-screen="game"] #toast { top: auto !important; bottom: 54px !important; background: #130b1dd9 !important; border: 1px solid #c79a4d99 !important; border-radius: 22px !important; min-height: 0 !important; min-width: 0 !important; width: max-content; max-width: min(80vw, 470px) !important; padding: 8px 22px !important; font-size: 15px !important; line-height: 1.25; filter: none !important; }
body.is-touch[data-screen="game"] #toast { bottom: 290px !important; font-size: 14px !important; }
#hud .frenzy-banner { min-width: 0 !important; padding: 12px 40px 11px !important; font-size: 19px !important; transition: transform .35s, opacity .35s, padding .35s; }
#hud .frenzy-banner small { font-size: 11px !important; margin-top: 4px; }
#hud .frenzy-banner.compact { padding: 8px 30px 7px !important; font-size: 15px !important; opacity: .88; }
#hud .frenzy-banner.compact small { display: none; }
.style-pop b { font-size: 22px !important; } .style-pop.hot b { font-size: 26px !important; } .style-pop span { font-size: 14px; }
@media (max-height: 550px) and (orientation: landscape) {
 #hud .frenzy-banner { left: auto !important; right: calc(var(--hud-right) + 58px); transform: none !important; top: calc(var(--hud-top) + 6px) !important; animation: none; padding: 7px 24px 6px !important; font-size: 14px !important; }
 #hud .frenzy-banner small { display: none; }
 body.is-touch[data-screen="game"] #toast, body[data-screen="game"] #toast { top: 88px !important; bottom: auto !important; font-size: 13px !important; padding: 6px 16px !important; }
}
@media (max-width: 700px) and (orientation: portrait) { #hud .frenzy-banner { top: calc(var(--hud-top) + 92px) !important; left: auto !important; right: var(--hud-right); transform: none !important; animation: none; font-size: 14px !important; padding: 7px 22px !important; } #hud .frenzy-banner small { display: none; } }
.options-screen { overflow: hidden !important; }
@media (max-width: 700px) and (orientation: portrait) {
 .options-screen .topbar { height: 62px; }
 .options-screen .page-heading { margin-bottom: 10px !important; } .options-screen .page-heading h1 { font-size: 36px !important; }
 .options-screen .options-grid { gap: 10px !important; } .options-screen .option-row { min-height: 50px !important; padding: 5px 0 !important; }
 .options-screen .page-footer { margin-top: 10px !important; padding-top: 10px !important; }
}
@media (max-width: 700px) and (orientation: portrait) {
 .controls-content .page-heading { margin-bottom: 10px !important; } .controls-content .page-heading h1 { font-size: 34px !important; }
 .controls-content .controls-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0 14px !important; }
 .controls-content .control-row { padding: 9px 0 !important; } .controls-content .control-row kbd { margin-bottom: 5px !important; }
 .controls-content .control-row h2 { font-size: 16px !important; } .controls-content .control-row p { font-size: 11px !important; line-height: 1.3; }
 .controls-content .tips-panel { padding: 18px 20px !important; margin-top: 8px !important; } .controls-content .tips-panel h2, .controls-content .mobile-note { display: none; }
 .controls-content .tips-panel p { font-size: 11px !important; margin-top: 6px !important; }
 .controls-content .page-footer { margin-top: 10px !important; padding-top: 10px !important; }
}
.control-row kbd { white-space: nowrap; }
@media (min-aspect-ratio: 1/1) { .page-screen .control-row { min-height: 0 !important; padding: 8px 0 !important; } .page-screen .tips-panel h2 { font-size: 27px !important; } }
.controls-content { padding-top: 14px; }
@media (max-width: 700px) and (orientation: portrait) { .page-screen { overflow: hidden !important; } #screens { overflow: hidden !important; } }
body:not([data-screen="game"]):not([data-screen="upgrades"]) #toast { display: none !important; }
@media (min-aspect-ratio: 1/1) { .controls-content { padding-top: 56px; } .controls-content .tips-panel p { font-size: 13px !important; margin-top: 12px !important; } }
@media (min-aspect-ratio: 1/1) { .page-screen .page-content.controls-content { padding-top: 64px !important; } }
