/* Arena Ricochet 3D — mobile-first HUD scaled from a 390px portrait reference */

@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url('../fonts/Fredoka-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url('../fonts/Fredoka-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --ui-scale: 1;
    --top-h: 70px;
    --bot-h: 112px;
    --ref-w: 390px;
    --sky: #7dd3fc;
    --ink: #fff;
    --wood: #3b2a1a;
    --gold: #f5c04a;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    position: fixed;
    inset: 0;
    background: var(--sky);
    font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
    color: var(--ink);
}

#app {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
    box-sizing: border-box;
    background:
        linear-gradient(#7dd3fc, #7dd3fc) padding-box,
        linear-gradient(#0c4a6e, #451a03) border-box;
}

#battleScreen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1;
}
#battleScreen.active { display: flex; }

/* ---------- text stroke ---------- */
.ts {
    text-shadow: 0 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.ts-lg {
    text-shadow: 0 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

.btn-3d {
    transition: transform .1s ease, box-shadow .1s ease;
    box-shadow: 0 4px 0 rgba(0,0,0,.55);
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}
.btn-3d:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.55); }

.hud-panel {
    background: linear-gradient(180deg, #3b2a1a 0%, #24180e 100%);
    border: 2px solid #f5c04a;
    box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 3px 0 rgba(0,0,0,.45);
}

.hidden { display: none !important; }

/* ---------- TOP HUD (anchored top, scaled inner) ---------- */
#topHud {
    flex: 0 0 auto;
    height: calc(var(--top-h) * var(--ui-scale));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: visible;
    z-index: 20;
    background: linear-gradient(180deg, #0c4a6e 0%, #075985 88%, #0c4a6e 100%);
    border-bottom: 3px solid #b45309;
    width: 100%;
}
#topHudInner {
    width: var(--ref-w);
    height: var(--top-h);
    transform: scale(var(--ui-scale));
    transform-origin: top center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 8px 4px;
}

.side-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1 1 96px;
    width: auto;
    min-width: 0;
    max-width: 136px;
}
.side-stat.enemy { justify-content: flex-end; text-align: right; }

.portrait {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 3px solid #fcd34d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 3px 0 rgba(0,0,0,.5);
}
.portrait.player { background: linear-gradient(135deg, #38bdf8, #1d4ed8); }
.portrait.foe { background: linear-gradient(135deg, #fb923c, #92400e); border-color: #f87171; }

.trophy-pip {
    position: absolute;
    bottom: -7px;
    background: linear-gradient(180deg, #fcd34d, #f59e0b);
    color: #0f172a;
    font-size: 9px;
    font-weight: 800;
    padding: 0 5px;
    border-radius: 999px;
    border: 2px solid #000;
    line-height: 14px;
}
.trophy-pip.left { left: -6px; }
.trophy-pip.right { right: -6px; }

.stat-col { flex: 1; min-width: 0; }
.stat-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 8px;
    font-weight: 700;
    margin-bottom: 2px;
    gap: 0;
    line-height: 1.15;
}
.side-stat.enemy .stat-row { align-items: flex-end; }
.stat-row .name { color: #bae6fd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.stat-row .hp-num { font-size: 11px; font-weight: 800; }
.side-stat.enemy .name { color: #fed7aa; }

.hp-track {
    background: #1a0f08;
    border: 2px solid #000;
    border-radius: 999px;
    overflow: hidden;
    height: 11px;
}
.hp-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
    box-shadow: inset 0 3px 0 rgba(255,255,255,.35);
}
.hp-fill.ally { background: linear-gradient(90deg, #22c55e, #bef264); }
.hp-fill.foe { background: linear-gradient(270deg, #dc2626, #fb923c); margin-left: auto; }

.center-hud {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px 8px 3px;
    border-radius: 14px;
    flex: 0 0 auto;
    min-width: 92px;
}
.turn-block {
    text-align: center;
    padding-right: 0;
    border-right: none;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
}
.turn-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.turn-label.ally { color: #6ee7b7; }
.turn-label.enemy { color: #fda4af; }
.turn-label.alert { color: #fcd34d; }
.turn-num {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.05;
}

.loot-block { display: flex; flex-direction: column; align-items: center; }
.chest-row { display: flex; gap: 1px; font-size: 14px; line-height: 1; }
.chest { filter: grayscale(1) brightness(.55); transition: filter .3s, transform .3s; }
.chest.on { filter: none; transform: scale(1.12); }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1.12); } }
.chest.pop { animation: pop .5s ease; }

.loot-meter {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    width: 100%;
}
.loot-meter .tag { font-size: 8px; font-weight: 800; color: #fcd34d; }
.loot-meter .bar {
    flex: 1;
    height: 6px;
    background: rgba(0,0,0,.7);
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, .6);
    overflow: hidden;
    min-width: 48px;
}
.loot-meter .bar > div {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #fef08a);
    width: 0;
    transition: width .2s;
}
.loot-meter .count { font-size: 8px; font-weight: 700; color: #fde68a; }

.menu-wrap { position: relative; flex-shrink: 0; }
#menuBtn {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbbf24, #ea580c);
    border: 2px solid #fde68a;
    font-size: 16px;
    font-weight: 800;
}
#menuPanel {
    position: absolute;
    right: 0;
    top: 40px;
    width: 168px;
    border-radius: 16px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 40;
}
#menuPanel button {
    width: 100%;
    padding: 7px 8px;
    border-radius: 12px;
    border: 1px solid #64748b;
    background: #334155;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
}
#menuPanel #camToggleBtn {
    background: linear-gradient(180deg, #6366f1, #6d28d9);
    border-color: #a5b4fc;
}
#menuPanel #resetArenaBtn {
    background: linear-gradient(180deg, #f59e0b, #ea580c);
    border-color: #fcd34d;
}

/* ---------- ARENA ---------- */
#arenaContainer {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    background: #7dd3fc;
}
#webglCanvas, #hudCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}
#webglCanvas { z-index: 0; }
#hudCanvas { z-index: 10; pointer-events: none; }

#tutorialBanner {
    pointer-events: none;
    position: absolute;
    top: 8px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.72);
    border: 2px solid #fcd34d;
    color: #fef3c7;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    z-index: 20;
    white-space: nowrap;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
}
#legend {
    pointer-events: none;
    position: absolute;
    left: 8px;
    top: 42px;
    bottom: auto;
    z-index: 21;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    max-width: min(320px, calc(100% - 24px));
    font-size: 11px;
    font-weight: 700;
}
#legend .tip-info-btn {
    pointer-events: auto;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 2px solid #fde68a;
    background: rgba(15, 23, 42, .82);
    color: #fef3c7;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 0 #0f172a;
    padding: 0;
}
#legend .tip-text {
    display: none;
    background: rgba(0,0,0,.58);
    border-radius: 8px;
    padding: 5px 10px;
    color: #fef3c7;
    max-width: calc(100% - 40px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    align-self: center;
}
#legend .tip-text.is-callout { display: block; }
#legend .tip-text:empty { display: none; }
#legend .tip-panel {
    pointer-events: auto;
    position: absolute;
    left: 0;
    top: 38px;
    min-width: 220px;
    max-width: min(300px, calc(100vw - 24px));
    background: rgba(15, 23, 42, .94);
    border: 2px solid #fcd34d;
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 24;
    color: #fef3c7;
    box-shadow: 0 6px 0 rgba(0,0,0,.35);
}
#legend .tip-panel.hidden { display: none !important; }
#legend .tip-panel div {
    background: transparent;
    border-radius: 0;
    padding: 0;
    font-size: 11px;
    line-height: 1.35;
}

@media (max-height: 700px) {
    #legend .tip-text { max-width: min(230px, calc(100vw - 56px)); font-size: 10px; }
}
@media (max-height: 560px) {
    #tutorialBanner { font-size: 10px; padding: 3px 10px; }
    #legend { top: 36px; }
    #legend .tip-text { font-size: 10px; padding: 3px 8px; }
}

/* ---------- BOTTOM HUD (anchored bottom, scaled inner) ---------- */
#bottomHud {
    flex: 0 0 auto;
    height: calc(var(--bot-h) * var(--ui-scale));
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: visible;
    z-index: 20;
    width: 100%;
    background: linear-gradient(180deg, #b45309 0%, #78350f 30%, #451a03 100%);
    border-top: 3px solid #f59e0b;
}
#bottomHudInner {
    width: var(--ref-w);
    height: var(--bot-h);
    transform: scale(var(--ui-scale));
    transform-origin: bottom center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px 8px;
}

.hero-deck {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.hero-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 110px;
    min-width: 108px;
    max-width: 150px;
    height: 52px;
    border-radius: 14px;
    padding: 3px 6px 3px 4px;
    border: 3px solid #fcd34d;
    box-shadow: 0 4px 0 rgba(0,0,0,.5);
    cursor: pointer;
    font-family: inherit;
    color: #fff;
    transition: transform .18s ease, box-shadow .18s ease, opacity .2s;
}
.hero-card.fire { background: linear-gradient(180deg, #ef4444, #be123c 50%, #4c0519); border-color: #fcd34d; }
.hero-card.water { background: linear-gradient(180deg, #38bdf8, #2563eb 50%, #172554); border-color: #bae6fd; }
.hero-card.nature { background: linear-gradient(180deg, #34d399, #059669 50%, #042f2e); border-color: #d9f99d; }
.hero-card.lightning { background: linear-gradient(180deg, #facc15, #ca8a04 50%, #422006); border-color: #fef08a; }
.hero-card.shadow { background: linear-gradient(180deg, #818cf8, #4c1d95 50%, #1e1b4b); border-color: #c4b5fd; }
.hero-card.arcane { background: linear-gradient(180deg, #e879f9, #a21caf 50%, #4a044e); border-color: #f5d0fe; }

.hero-card.card-active {
    transform: translateY(-5px) scale(1.04);
    box-shadow: 0 0 0 3px #4ade80, 0 0 18px rgba(74,222,128,.85), 0 5px 0 #14532d;
}
.hero-card.opacity-40 { opacity: .4; }
.hero-card.grayscale { filter: grayscale(1); }

.active-badge {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: #a3e635;
    color: #0f172a;
    font-size: 8px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    border: 2px solid #000;
    text-transform: uppercase;
    letter-spacing: .04em;
    z-index: 2;
}

.hero-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #fde68a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.elem-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f97316;
    border: 2px solid #000;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 0 rgba(0,0,0,.55);
}
.hero-card.water .elem-badge { background: #38bdf8; }
.hero-card.nature .elem-badge { background: #84cc16; }
.hero-card.lightning .elem-badge { background: #facc15; }
.hero-card.shadow .elem-badge { background: #818cf8; }
.hero-card.arcane .elem-badge { background: #e879f9; }

.hero-meta { min-width: 0; text-align: left; line-height: 1; flex: 1; }
.hero-name { font-size: 11px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { color: #facc15; letter-spacing: -1px; text-shadow: 0 1px 0 #000; font-size: 10px; margin-top: 2px; }
.hero-tag { display: none; }
.hero-hp {
    width: 100%;
    max-width: 56px;
    height: 5px;
    background: rgba(0,0,0,.6);
    border-radius: 999px;
    margin-top: 4px;
    overflow: hidden;
}
.hero-hp-fill { height: 100%; width: 100%; background: #a3e635; }

#launchBtn {
    appearance: none;
    position: relative;
    z-index: 26;
    border: 3px solid #fff3c4;
    background: radial-gradient(circle at 50% 30%, #ffe27a 0%, #f59e0b 45%, #c2410c 100%);
    box-shadow: 0 5px 0 #7c2d12, 0 0 20px rgba(251,191,36,.65);
    border-radius: 999px;
    color: #fff;
    font-family: inherit;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .06em;
    width: 210px;
    min-width: 210px;
    height: 52px;
    min-height: 52px;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    text-shadow: 0 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}
#launchBtn::before {
    content: '';
    position: absolute;
    inset: -16px -22px;
}
#launchBtn:active, #launchBtn.is-pressed {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #7c2d12, 0 0 16px rgba(251,191,36,.6);
}
#launchBtn.disabled { filter: grayscale(.85) brightness(.7); pointer-events: none; }

/* Landscape / wide: cards + launch in one row, slimmer bars */
#app.landscape #bottomHudInner {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    padding: 6px 12px;
}
#app.landscape .hero-deck { width: auto; flex: 0 0 auto; }
#app.landscape .hero-card { flex: 0 0 130px; width: 130px; min-width: 130px; }
#app.landscape #launchBtn { width: 150px; height: 44px; font-size: 20px; }
#app.landscape #legend { display: none; }

/* ---------- modal ---------- */
#gameOverModal {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 16px;
}
#gameOverModal.hidden { display: none !important; }
.modal-card {
    background: linear-gradient(180deg, #3b2a1a 0%, #24180e 100%);
    border: 2px solid #f5c04a;
    box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 8px 0 rgba(0,0,0,.45);
    border-radius: 24px;
    max-width: 380px;
    width: 100%;
    padding: 20px 18px;
    text-align: center;
}
.modal-emoji { font-size: 56px; margin-bottom: 4px; }
.modal-title { font-size: 28px; font-weight: 800; margin: 0 0 4px; }
.modal-title.win { color: #fbbf24; }
.modal-title.lose { color: #f43f5e; }
.modal-sub { color: #fef3c7; font-size: 14px; margin: 0 0 14px; }
.modal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(0,0,0,.5);
    padding: 10px;
    border-radius: 16px;
    border: 1px solid #b45309;
    margin-bottom: 16px;
}
.modal-stats .lbl { font-size: 9px; color: rgba(253, 230, 138, .8); font-weight: 700; }
.modal-stats .val { font-size: 18px; font-weight: 800; }
.modal-stats .val.g { color: #4ade80; }
.modal-stats .val.y { color: #fbbf24; }
.modal-stats .val.b { color: #38bdf8; }
#playAgainBtn {
    width: 100%;
    padding: 12px;
    border-radius: 16px;
    background: linear-gradient(180deg, #a3e635, #059669);
    font-weight: 800;
    font-size: 16px;
    font-family: inherit;
    color: #fff;
    border: 2px solid #d9f99d;
}

/* overlays used later by the campaign shell */
.screen-layer {
    position: absolute;
    inset: 0;
    z-index: 50;
}
.allow-scroll {
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}


/* ========== CAMPAIGN / MENU SHELL ========== */
.menu-screen {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 40;
    flex-direction: column;
    padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
    background:
        radial-gradient(circle at 50% 0%, rgba(255,255,255,.25), transparent 42%),
        linear-gradient(180deg, #38bdf8 0%, #7dd3fc 38%, #fbbf24 100%);
    overflow: hidden;
}
.menu-screen.active { display: flex; }

.title-hero { text-align: center; margin-top: 8%; }
.title-icon {
    width: 96px; height: 96px; border-radius: 24px;
    border: 4px solid #f5c04a;
    box-shadow: 0 8px 0 rgba(0,0,0,.25);
}
.title-name {
    margin: 14px 0 4px;
    font-size: clamp(28px, 8vw, 42px);
    color: #fff7ed;
    letter-spacing: .02em;
}
.title-tag { margin: 0; color: #1c1917; font-weight: 700; font-size: 16px; opacity: .85; }
.title-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding: 24px 8px 8px; }
.title-row { display: flex; gap: 10px; }
.title-row > * { flex: 1; }
.title-footer { display: flex; justify-content: center; padding-top: 8px; }

.menu-btn {
    appearance: none;
    border: 3px solid #fff3c4;
    background: linear-gradient(180deg, #fbbf24, #ea580c);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    font-size: 18px;
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 5px 0 #7c2d12;
    cursor: pointer;
}
.menu-btn.primary {
    background: radial-gradient(circle at 50% 30%, #ffe27a 0%, #f59e0b 45%, #c2410c 100%);
    font-size: 22px;
    padding: 14px 16px;
}
.menu-btn.ghost {
    background: linear-gradient(180deg, #64748b, #334155);
    border-color: #cbd5e1;
    box-shadow: 0 5px 0 #0f172a;
}
.menu-btn.danger {
    background: linear-gradient(180deg, #fb7185, #be123c);
    border-color: #fecdd3;
    box-shadow: 0 5px 0 #7f1d1d;
}
.menu-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #7c2d12; }
.menu-btn:disabled { filter: grayscale(.7) brightness(.75); pointer-events: none; }

.coin-chip {
    background: #1c1917;
    border: 2px solid #f5c04a;
    border-radius: 999px;
    padding: 3px 10px;
    font-weight: 800;
    font-size: 14px;
}

.screen-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.screen-head h2 { margin: 0; font-size: 22px; }
.back-btn {
    width: 40px; height: 40px; border-radius: 12px;
    border: 2px solid #fde68a;
    background: linear-gradient(180deg, #fbbf24, #ea580c);
    color: #fff; font-size: 18px; font-weight: 800;
    box-shadow: 0 3px 0 #7c2d12; cursor: pointer; font-family: inherit;
}
.screen-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.info-card {
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 4px 0 rgba(0,0,0,.35);
}
.info-card h3 { margin: 0 0 6px; font-size: 16px; }
.info-card p { margin: 0; color: #fde68a; font-size: 14px; font-weight: 600; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 16px;
    padding: 12px 14px;
    font-weight: 800;
}
.toggle {
    min-width: 72px;
    border-radius: 999px;
    border: 2px solid #14532d;
    background: #22c55e;
    color: #052e16;
    font-weight: 800;
    font-family: inherit;
    padding: 6px 10px;
    cursor: pointer;
}
.toggle.off { background: #64748b; border-color: #0f172a; color: #f8fafc; }
.setting-hint { margin: 0; color: #1c1917; font-size: 13px; font-weight: 600; }
.privacy-link { color: #7c2d12; font-weight: 800; text-align: center; margin-top: 8px; }

.hero-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    min-height: 0;
    align-content: start;
}
.collect-card {
    position: relative;
    border-radius: 16px;
    border: 3px solid #fcd34d;
    padding: 10px;
    text-align: left;
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,.4);
    min-height: 112px;
}
.collect-card.fire { background: linear-gradient(180deg, #ef4444, #4c0519); }
.collect-card.water { background: linear-gradient(180deg, #38bdf8, #172554); }
.collect-card.nature { background: linear-gradient(180deg, #34d399, #042f2e); }
.collect-card.lightning { background: linear-gradient(180deg, #facc15, #422006); color: #1c1917; }
.collect-card.shadow { background: linear-gradient(180deg, #818cf8, #1e1b4b); }
.collect-card.arcane { background: linear-gradient(180deg, #e879f9, #4a044e); }
.collect-card.locked { filter: grayscale(.85) brightness(.7); }
.collect-card.selected { box-shadow: 0 0 0 3px #4ade80, 0 4px 0 #14532d; }
.collect-card .cc-emoji { font-size: 28px; }
.collect-card .cc-name { font-size: 16px; font-weight: 800; }
.collect-card .cc-meta { font-size: 12px; font-weight: 700; opacity: .9; margin-top: 4px; }
.collect-card .lock-pip {
    position: absolute; top: 8px; right: 8px; font-size: 16px;
}

.hero-detail {
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 16px;
    padding: 12px;
    margin-top: 10px;
}
.hero-detail h3 { margin: 0 0 4px; }
.hero-detail p { margin: 0 0 8px; color: #fde68a; font-size: 13px; }

.stage-list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.stage-node {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 16px;
    padding: 10px 12px;
    color: #fff;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,.35);
}
.stage-node.locked { filter: grayscale(.8) brightness(.75); cursor: default; }
.stage-node .sn-num {
    width: 36px; height: 36px; border-radius: 50%;
    background: #f59e0b; color: #1c1917;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.stage-node.final .sn-num { background: #f43f5e; color: #fff; }
.stage-node .sn-body { flex: 1; min-width: 0; }
.stage-node .sn-name { font-weight: 800; font-size: 16px; }
.stage-node .sn-sub { font-size: 12px; color: #fde68a; }
.stage-node .sn-stars { color: #facc15; font-size: 16px; letter-spacing: 1px; }

.team-hint { margin: 0 0 8px; font-weight: 700; color: #1c1917; }
#btnStartBattle { margin-top: 10px; }

.result-card {
    margin: auto;
    width: min(400px, 100%);
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 24px;
    padding: 20px 16px;
    text-align: center;
    box-shadow: 0 8px 0 rgba(0,0,0,.4);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.star-row { font-size: 36px; color: #facc15; letter-spacing: 4px; line-height: 1; }
.unlock-row { color: #86efac; font-weight: 800; min-height: 1em; }
.chest-rewards { display: flex; flex-direction: column; gap: 8px; font-weight: 800; font-size: 18px; }
@keyframes chestpop { 0% { transform: scale(.6) rotate(-8deg); } 60% { transform: scale(1.2) rotate(6deg); } 100% { transform: scale(1); } }
.chest-bounce { animation: chestpop .55s ease; }

#pauseOverlay, #tutorialOverlay, #confirmOverlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    background: rgba(2,6,23,.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#pauseOverlay.hidden, #tutorialOverlay.hidden, #confirmOverlay.hidden { display: none !important; }
.tut-card {
    width: min(400px, 100%);
    background: linear-gradient(180deg, #3b2a1a, #24180e);
    border: 2px solid #f5c04a;
    border-radius: 20px;
    padding: 16px;
}
.tut-card p { margin: 0 0 14px; font-size: 16px; font-weight: 700; color: #fef3c7; }
.tut-actions { display: flex; gap: 10px; }
.tut-actions .menu-btn { flex: 1; font-size: 16px; padding: 10px; }

/* Camera / skill overlays */
.skill-fab {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 22;
    border: 3px solid #fff3c4;
    background: radial-gradient(circle at 50% 30%, #c4b5fd 0%, #7c3aed 50%, #4c1d95 100%);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    font-size: 13px;
    border-radius: 999px;
    padding: 10px 14px;
    box-shadow: 0 4px 0 #3b0764, 0 0 16px rgba(167,139,250,.55);
    cursor: pointer;
}
.skill-fab.ready {
    background: radial-gradient(circle at 50% 30%, #ffe27a 0%, #f59e0b 45%, #c2410c 100%);
    box-shadow: 0 4px 0 #7c2d12, 0 0 18px rgba(251,191,36,.7);
    animation: skillpulse 1s ease-in-out infinite;
}
@keyframes skillpulse { 50% { transform: scale(1.06); } }
.skill-fab.hidden { display: none !important; }

#passOverlay {
    position: absolute;
    inset: 0;
    z-index: 35;
    background: rgba(2,6,23,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#passOverlay.hidden { display: none !important; }

.online-code {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: #fde68a;
    text-align: center;
    margin-top: 8px;
}
.code-input {
    width: 100%;
    text-align: center;
    font-family: inherit;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    padding: 12px;
    border-radius: 16px;
    border: 3px solid #f5c04a;
    background: #1c1917;
    color: #fff;
}

.preview-wrap {
    height: 160px;
    border-radius: 16px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 70%, #7dd3fc, #0c4a6e);
    border: 2px solid #f5c04a;
    margin-bottom: 10px;
}
#heroPreview {
    width: 100%;
    height: 160px;
    display: block;
}

.stat-compare { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0; font-weight: 800; font-size: 13px; }
.stat-compare span { flex: 1; background: rgba(0,0,0,.35); border-radius: 10px; padding: 6px; text-align: center; }
.skill-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.skill-item {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    background: rgba(0,0,0,.35); border-radius: 12px; padding: 8px;
    text-align: left;
}
.skill-item h4 { margin: 0; font-size: 13px; }
.skill-item p { margin: 2px 0 0; font-size: 11px; color: #fde68a; font-weight: 600; }
.skill-item button { flex-shrink: 0; font-size: 11px; padding: 6px 8px; border-radius: 10px; }
.star-ascend { color: #facc15; font-size: 20px; letter-spacing: 2px; margin: 4px 0; }

.hero-detail { max-height: 46vh; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.cam-fab {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 22;
    width: 40px; height: 40px;
    border-radius: 999px;
    border: 3px solid #fff3c4;
    background: radial-gradient(circle at 50% 30%, #93c5fd, #1d4ed8 70%);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 3px 0 #1e3a8a;
    cursor: pointer;
}

#screenHeroes:not(.has-detail) {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
#screenHeroes:not(.has-detail) #heroGrid {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
    align-content: start;
    padding-bottom: 28px;
}
#screenHeroes.has-detail {
    overflow: hidden;
}
#screenHeroes.has-detail > .screen-head { display: none; }
#screenHeroes.has-detail #heroGrid { display: none !important; }
#screenHeroes #heroDetail,
.hero-detail {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}
#screenHeroes.has-detail #heroDetail {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    margin-top: 0;
}
#screenHeroes .collect-card {
    min-height: 108px;
    height: auto;
    padding: 12px 10px 14px;
    overflow: visible;
    box-sizing: border-box;
}
#screenHeroes .collect-card .cc-emoji { font-size: 26px; line-height: 1.15; }
#screenHeroes .collect-card .cc-name { font-size: 16px; line-height: 1.2; }
#screenHeroes .collect-card .cc-meta {
    font-size: 11px;
    line-height: 1.35;
    margin-top: 6px;
    white-space: nowrap;
    overflow: visible;
}
.detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: -4px 0 12px;
    position: sticky;
    top: -4px;
    z-index: 2;
    padding: 4px 0 10px;
    background: linear-gradient(180deg, #3b2a1a 78%, rgba(36,24,14,0));
}
.detail-head h2 { margin: 0; font-size: 20px; }
.preview-wrap, #heroPreview { height: 210px; }

.notify-dot {
    display: inline-block;
    width: 10px; height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #1c1917;
    margin-left: 6px;
    vertical-align: middle;
}
.notify-dot.hidden { display: none; }
.gem-chip { background: #1e1b4b; border-color: #818cf8; }
.title-footer { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.control-meter {
    margin: 0 0 4px;
    min-width: 110px;
}
.control-meta {
    display: flex; justify-content: space-between;
    font-size: 10px; font-weight: 800; letter-spacing: .04em;
}
.control-track {
    height: 7px; border-radius: 99px;
    background: rgba(0,0,0,.45);
    overflow: hidden; margin: 2px 0;
}
.control-fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, #4ade80, #facc15);
    transition: width .25s ease;
}
.control-meter.ready .control-fill { background: linear-gradient(90deg, #facc15, #f97316); }
.control-goal { font-size: 9px; font-weight: 700; opacity: .85; white-space: nowrap; }

.combo-burst {
    position: absolute;
    left: 50%; top: 28%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    font-weight: 800;
    color: #fde047;
    text-shadow: 0 3px 0 #78350f, 0 0 18px #f59e0b;
    pointer-events: none;
    z-index: 8;
    letter-spacing: .04em;
}
.combo-burst.pop { animation: comboPop .7s ease; }
@keyframes comboPop {
    0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
    25% { transform: translate(-50%, -50%) scale(1.18); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.rarity-pip { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.rarity-common { color: #e2e8f0; }
.rarity-rare { color: #38bdf8; }
.rarity-epic { color: #c084fc; }
.rarity-legendary { color: #fbbf24; }

.collect-card.wind, .hero-card.wind { background: linear-gradient(180deg, #22d3ee, #0e7490 55%, #083344); border-color: #a5f3fc; }
.collect-card.steel, .hero-card.steel { background: linear-gradient(180deg, #94a3b8, #334155 55%, #0f172a); border-color: #e2e8f0; }
.collect-card.light, .hero-card.light { background: linear-gradient(180deg, #fde68a, #d97706 55%, #78350f); border-color: #fef3c7; color: #1c1917; }
.hero-card.wind .elem-badge { background: #22d3ee; }
.hero-card.steel .elem-badge { background: #94a3b8; }
.hero-card.light .elem-badge { background: #fde047; }

.gear-grid { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 8px 0; }
.gear-slot {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px;
}
.gear-slot select { flex: 1; min-width: 0; }

.login-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 8px 0; }
.login-day {
    background: #1c1917; border: 2px solid #f5c04a; border-radius: 10px;
    padding: 6px 2px; text-align: center; font-size: 11px; font-weight: 800;
}
.login-day.current { box-shadow: 0 0 0 2px #4ade80; }
.login-day.claimed { opacity: .55; }

.quest-list { display: flex; flex-direction: column; gap: 8px; }
.quest-row {
    display: flex; justify-content: space-between; gap: 8px; align-items: center;
    background: rgba(0,0,0,.2); border-radius: 10px; padding: 8px;
}
.quest-row p { margin: 0; font-size: 13px; }

.spin-wheel { font-size: 64px; text-align: center; margin: 8px 0; }
.spin-wheel.spinning { animation: wheelSpin 1.1s ease; }
@keyframes wheelSpin { from { transform: rotate(0); } to { transform: rotate(720deg); } }

.summon-results { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.summon-card {
    border-radius: 14px; padding: 10px; text-align: center; color: #fff;
    border: 3px solid #fcd34d; min-height: 88px;
}
.summon-card.new { box-shadow: 0 0 0 3px #4ade80; }
.team-power {
    font-weight: 800; color: #1c1917; margin: 0 0 8px;
    background: #fde68a; border-radius: 999px; padding: 6px 12px; text-align: center;
}
.swatch {
    width: 12px; height: 12px; border-radius: 50%; display: inline-block;
    border: 2px solid #fff; vertical-align: middle; margin-right: 6px;
}
.hero-card .notify-dot, .collect-card .notify-dot {
    position: absolute; top: 6px; right: 6px; margin: 0;
}

@media (max-width: 400px) {
    .combo-burst { font-size: 34px; }
    .control-goal { font-size: 8px; }
}

#launchBtn.need-aim { filter: saturate(.75) brightness(.88); }
