:root {
    --gold: #f7c948;
    --gold-dark: #d4a017;
    --gold-glow: rgba(247, 201, 72, 0.35);
    --wood: #6b3f22;
    --ink: #2a1a10;
    --cream: #fff6e8;
    --berry: #c44536;
    --leaf: #4f8f3e;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; }

html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: linear-gradient(180deg, #6db3d8 0%, #f2d7a4 48%, #c9965a 100%);
    color: var(--ink);
    font-family: "Nunito", "Trebuchet MS", sans-serif;
    position: fixed;
    inset: 0;
}

.ico {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: -4px;
    flex-shrink: 0;
}
.ico.sm { width: 16px; height: 16px; vertical-align: -3px; }
.ico.xs { width: 13px; height: 13px; vertical-align: -2px; }
.ico.lg { width: 28px; height: 28px; }
.ico-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: inline-block;
    vertical-align: -4px;
    flex-shrink: 0;
}
.ico-img.sm { width: 16px; height: 16px; vertical-align: -3px; }

.app,
.app-container {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    padding:
        var(--safe-top)
        0
        0
        0;
    overflow: hidden;
}

.header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
    padding: 10px 12px 12px;
    background:
        linear-gradient(180deg, rgba(255,246,232,.72), rgba(255,246,232,.28));
}
.header::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 2px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent);
    box-shadow: 0 0 10px var(--gold-glow);
}
.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.logo-text {
    font-family: "Ruslan Display", serif;
    font-size: clamp(22px, 6.2vw, 32px);
    line-height: 1;
    letter-spacing: 0.02em;
    background: linear-gradient(180deg, #f7c948 0%, #d79a2a 48%, #8a3a12 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 0 rgba(255, 231, 184, 0.95)) drop-shadow(0 3px 0 rgba(90, 40, 10, 0.35));
}
.logo-sword {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,.2)) drop-shadow(0 0 8px var(--gold-glow));
}
.logo-sword-left { transform: rotate(-28deg); }
.logo-sword-right { transform: scaleX(-1) rotate(-28deg); }
.build-tag {
    margin-left: 2px;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #5a3a20;
    background: rgba(255, 246, 232, 0.85);
    border: 1px solid rgba(90, 58, 32, 0.25);
    flex-shrink: 0;
}
.balance {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, #fff8e8, #f0d9a0);
    border: 3px solid var(--wood);
    border-radius: 999px;
    padding: 5px 12px 5px 8px;
    font-weight: 900;
    color: #8a5a12;
    box-shadow: 0 3px 0 rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.65);
    flex-shrink: 0;
}
.balance-ico {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 1px 0 rgba(0,0,0,.15));
}

.main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}
.tab-panel.active {
    display: flex;
    animation: fadeUp .18s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

#panelBattle.active {
    gap: 0;
}

/* ===== BATTLE SCENE ===== */
.battle-scene {
    position: relative;
    width: 100%;
    /* Fill free space between header and info/energy/nav (Hamster-style) */
    flex: 1 1 0;
    height: 0;
    min-height: 140px;
    max-height: 60vh;
    aspect-ratio: 1 / 1;
    border-radius: 0;
    overflow: hidden;
    border: 0;
    border-top: 3px solid var(--wood);
    border-bottom: 3px solid var(--wood);
    box-shadow: none;
    background:
        linear-gradient(180deg, rgba(110,180,220,.35) 0%, rgba(255,255,255,0) 40%),
        linear-gradient(180deg, transparent 55%, rgba(42,26,16,.25) 100%),
        url("/m/fix86/a/bg-field.webp") center/cover no-repeat;
    margin: 0;
    cursor: pointer;
    transition: background-image .35s ease;
}

/* Prefer filling the column over a rigid square when flex space remains */
@supports (height: 100dvh) {
    .battle-scene {
        aspect-ratio: auto;
        max-height: none;
    }
}
.sky-layer, .clouds-layer {
    position: absolute; inset: 0; pointer-events: none; z-index: 0;
}
.clouds-layer {
    background:
        radial-gradient(ellipse at 20% 18%, rgba(255,255,255,.45) 0 18%, transparent 40%),
        radial-gradient(ellipse at 70% 12%, rgba(255,255,255,.35) 0 14%, transparent 35%);
    animation: drift 28s linear infinite;
}
@keyframes drift {
    from { transform: translateX(0); }
    to { transform: translateX(-40px); }
}

.enemy-counter {
    position: absolute;
    top: 12px; left: 12px; z-index: 5;
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,246,232,.94);
    border: 3px solid var(--wood);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 13px; font-weight: 900;
}

.hero-container {
    position: absolute;
    bottom: 8%;
    left: 44%;
    transform: translateX(-50%);
    z-index: 3;
    text-align: center;
    pointer-events: none;
    width: 78%;
}
.hero-stage {
    position: relative;
    width: min(52vw, 220px);
    height: min(52vw, 220px);
    margin: 0 auto;
    isolation: isolate;
    background: transparent;
}
.hero-art {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: transparent !important;
    mix-blend-mode: normal !important;
    filter: drop-shadow(0 8px 0 rgba(0,0,0,.2)) drop-shadow(0 12px 14px rgba(0,0,0,.35));
    transform-origin: 50% 85%;
    opacity: 1 !important;
    transition: opacity .18s ease;
}
.hero-art.is-loading {
    opacity: 0 !important;
    visibility: hidden;
}
.hero-container.is-hidden,
.hero-container.is-boot-hidden,
.enemy.is-boot-hidden {
    visibility: hidden;
    pointer-events: none;
}

/* Boot / splash */
.boot-splash {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 50% 20%, rgba(255, 220, 140, .55), transparent 50%),
        linear-gradient(180deg, #6db3d8 0%, #f2d7a4 48%, #c9965a 100%);
    transition: opacity .35s ease, visibility .35s ease;
}
.boot-splash.is-done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.boot-card {
    width: min(92vw, 340px);
    text-align: center;
    padding: 28px 22px 24px;
    border: 4px solid var(--wood);
    border-radius: 22px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    box-shadow: 0 10px 0 rgba(107, 63, 34, .22);
}
.boot-swords {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 6px;
}
.boot-swords img:last-child {
    transform: scaleX(-1);
}
.boot-logo {
    font-family: "Ruslan Display", serif;
    font-size: clamp(2.2rem, 10vw, 3rem);
    color: #7a2f14;
    letter-spacing: .04em;
    text-shadow: 0 2px 0 rgba(255, 246, 232, .8);
    animation: bootPulse 1.4s ease-in-out infinite;
}
@keyframes bootPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
.boot-sub {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 900;
    color: #5a3a20;
}
.boot-build {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 800;
    color: rgba(90, 58, 32, 0.72);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.boot-bar {
    margin-top: 18px;
    height: 14px;
    border: 3px solid var(--wood);
    border-radius: 999px;
    background: rgba(90, 58, 32, .2);
    overflow: hidden;
}
.boot-bar-fill {
    height: 100%;
    width: 8%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6fcf4d, #f7c948);
    transition: width .2s ease;
}
.app.is-booting {
    visibility: hidden;
}
.weapon-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.weapon {
    position: absolute;
    width: 72px;
    height: 72px;
    object-fit: contain;
    opacity: 0;
    visibility: hidden;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
    pointer-events: none;
}
.weapon.is-active {
    visibility: visible;
}
.weapon-sword {
    right: -6px;
    top: 24px;
    transform-origin: 15% 85%;
}
.weapon-mace {
    right: -2px;
    top: 10px;
    width: 92px;
    height: 92px;
    transform-origin: 30% 85%;
    mix-blend-mode: multiply;
}
.weapon-bow {
    display: none !important; /* bow stays on hero sprite; arrow flies separately */
}
.weapon-fist {
    /* disabled: floating fist looked like a broken black-square glitch */
    display: none !important;
}
.hero-container.attack-fist .weapon-fist {
    display: none !important;
}
.weapon-staff {
    right: -8px;
    top: 4px;
    width: 96px;
    height: 96px;
    transform-origin: 25% 90%;
    mix-blend-mode: multiply;
}
.weapon-axe {
    right: -4px;
    top: 8px;
    width: 94px;
    height: 94px;
    transform-origin: 28% 85%;
    mix-blend-mode: multiply;
}
.weapon-spear {
    right: -18px;
    top: -6px;
    width: 110px;
    height: 110px;
    transform-origin: 20% 90%;
    mix-blend-mode: multiply;
}

.fx {
    position: absolute;
    pointer-events: none;
    opacity: 0;
}
.fx-slash {
    width: 130px;
    height: 130px;
    right: -36px;
    top: 0;
    object-fit: contain;
}
.fx-arrow {
    width: 110px;
    height: 36px;
    left: 58%;
    top: 38%;
    object-fit: contain;
    transform-origin: left center;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
    mix-blend-mode: multiply;
    border-radius: 0;
    background: none;
    box-shadow: none;
}
.fx-impact {
    width: 70px;
    height: 70px;
    right: -10px;
    top: 40px;
    border-radius: 50%;
    border: 4px solid #f7c948;
    box-shadow: 0 0 0 0 rgba(196,69,54,.45);
    background: radial-gradient(circle, rgba(247,201,72,.35), transparent 70%);
}

/* --- weapon-specific attacks --- */
.hero-container.attack-sword .hero-art { animation: strikeSword .34s ease; }
.hero-container.attack-sword .fx-slash { animation: slashFlash .34s ease; }

.hero-container.attack-mace .hero-art { animation: strikeMace .42s ease; }
.hero-container.attack-mace .weapon-mace.is-active { animation: maceSwing .42s ease; }
.hero-container.attack-mace .fx-impact { animation: impactBurst .42s ease; }

.hero-container.attack-bow .hero-art { animation: strikeBow .45s ease; }
.hero-container.attack-bow .fx-arrow { animation: arrowFly .45s ease; }

.hero-container.attack-fist .hero-art { animation: strikeFist .38s ease; }
.hero-container.attack-fist .weapon-fist { animation: fistFly .38s ease; }

.hero-container.attack-staff .hero-art { animation: strikeStaff .42s ease; }
.hero-container.attack-staff .weapon-staff.is-active { animation: staffSwing .42s ease; }
.hero-container.attack-staff .fx-impact { animation: impactBurst .42s ease; }

.hero-container.attack-axe .hero-art { animation: strikeAxe .40s ease; }
.hero-container.attack-axe .weapon-axe.is-active { animation: axeSwing .40s ease; }
.hero-container.attack-axe .fx-impact { animation: impactBurst .40s ease; }

.hero-container.attack-spear .hero-art { animation: strikeSpear .38s ease; }
.hero-container.attack-spear .weapon-spear.is-active { animation: spearThrust .38s ease; }
.hero-container.attack-spear .fx-impact { animation: impactBurst .38s ease; }

@keyframes strikeSword {
    0% { transform: rotate(0); }
    30% { transform: rotate(-22deg) translate(-8px,-6px); }
    55% { transform: rotate(26deg) translate(16px,10px); }
    100% { transform: none; }
}
@keyframes strikeMace {
    0% { transform: rotate(0) scale(1); }
    25% { transform: rotate(28deg) translate(8px,-12px) scale(1.04); }
    55% { transform: rotate(-26deg) translate(14px,8px) scale(1.08); }
    100% { transform: none; }
}
@keyframes maceSwing {
    0% { opacity: 0; transform: rotate(-50deg) translate(0,-8px) scale(.75); }
    22% { opacity: 1; transform: rotate(-95deg) translate(-6px,-18px) scale(1); }
    55% { opacity: 1; transform: rotate(35deg) translate(28px,8px) scale(1.12); }
    100% { opacity: 0; transform: rotate(55deg) translate(40px,18px) scale(1); }
}
@keyframes strikeBow {
    0% { transform: none; }
    30% { transform: translateX(-10px) scaleX(.97); }
    55% { transform: translateX(-4px); }
    100% { transform: none; }
}
@keyframes arrowFly {
    0% { opacity: 0; transform: translate(0, 0) rotate(-6deg) scale(.7); }
    12% { opacity: 1; transform: translate(8px, -4px) rotate(-8deg) scale(1); }
    100% { opacity: 0; transform: translate(130px, -78px) rotate(-14deg) scale(1); }
}
@keyframes strikeFist {
    0% { transform: none; }
    30% { transform: translateX(-14px) scale(.94); }
    55% { transform: translateX(22px) scale(1.06); }
    100% { transform: none; }
}
@keyframes fistFly {
    /* same idea as arrowFly: from hero toward enemy */
    0% { opacity: 0; transform: translate(0, 8px) scale(.55) rotate(-18deg); }
    18% { opacity: 1; transform: translate(10px, 0) scale(.9) rotate(-6deg); }
    70% { opacity: 1; transform: translate(78px, -36px) scale(1.15) rotate(8deg); }
    100% { opacity: 0; transform: translate(110px, -48px) scale(1.25) rotate(14deg); }
}
@keyframes strikeStaff {
    0% { transform: rotate(0); }
    28% { transform: rotate(24deg) translate(6px, -10px); }
    58% { transform: rotate(-30deg) translate(12px, 8px); }
    100% { transform: none; }
}
@keyframes staffSwing {
    0% { opacity: 0; transform: rotate(-40deg) translate(0, -6px) scale(.8); }
    20% { opacity: 1; transform: rotate(-70deg) translate(-4px, -14px) scale(1); }
    55% { opacity: 1; transform: rotate(40deg) translate(26px, 10px) scale(1.1); }
    100% { opacity: 0; transform: rotate(55deg) translate(38px, 16px) scale(1); }
}
@keyframes strikeAxe {
    0% { transform: rotate(0) scale(1); }
    30% { transform: rotate(-28deg) translate(-6px, -10px) scale(1.03); }
    58% { transform: rotate(32deg) translate(16px, 10px) scale(1.07); }
    100% { transform: none; }
}
@keyframes axeSwing {
    0% { opacity: 0; transform: rotate(-60deg) translate(0, -10px) scale(.75); }
    22% { opacity: 1; transform: rotate(-100deg) translate(-8px, -16px) scale(1); }
    55% { opacity: 1; transform: rotate(45deg) translate(30px, 12px) scale(1.14); }
    100% { opacity: 0; transform: rotate(65deg) translate(42px, 20px) scale(1); }
}
@keyframes strikeSpear {
    0% { transform: none; }
    30% { transform: translateX(-12px) rotate(-6deg); }
    58% { transform: translateX(18px) rotate(4deg) scale(1.04); }
    100% { transform: none; }
}
@keyframes spearThrust {
    0% { opacity: 0; transform: translate(-18px, 8px) rotate(-20deg) scale(.85); }
    18% { opacity: 1; transform: translate(-6px, 2px) rotate(-12deg) scale(1); }
    55% { opacity: 1; transform: translate(42px, -10px) rotate(8deg) scale(1.08); }
    100% { opacity: 0; transform: translate(58px, -14px) rotate(12deg) scale(1); }
}
@keyframes slashFlash {
    0% { opacity: 0; transform: scale(.4) rotate(-25deg); }
    40% { opacity: 1; transform: scale(1.1) rotate(8deg); }
    100% { opacity: 0; transform: scale(1.35) rotate(20deg); }
}
@keyframes impactBurst {
    0% { opacity: 0; transform: scale(.2); box-shadow: 0 0 0 0 rgba(196,69,54,.55); }
    40% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 12px rgba(196,69,54,.2); }
    100% { opacity: 0; transform: scale(1.45); box-shadow: 0 0 0 22px rgba(196,69,54,0); }
}

.hero-name {
    display: inline-block;
    margin-top: 2px;
    font-family: "Ruslan Display", serif;
    font-size: 18px;
    color: #6b2c12;
    background: rgba(255,246,232,.94);
    border: 3px solid var(--wood);
    border-radius: 12px;
    padding: 2px 10px;
}
.hero-title {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 800;
    color: #5a3a20;
}

.enemy {
    position: absolute;
    /* Right of hero, standing on the ground plane */
    top: 62%;
    right: 8%;
    z-index: 2;
    text-align: center;
    width: 120px;
    pointer-events: none;
    transform: translateY(-50%);
    transform-origin: 50% 70%;
}
.enemy.is-idle,
.enemy[data-state="idle"] {
    animation: enemyIdle 2.2s ease-in-out infinite;
}
.enemy.is-appear,
.enemy[data-state="appear"] {
    animation: enemyAppear .55s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}
.enemy.is-hit,
.enemy[data-state="hit"] {
    animation: enemyHit .28s ease;
}
.enemy.is-hit .enemy-art,
.enemy[data-state="hit"] .enemy-art {
    animation: enemyFlash .28s ease, enemyShakeArt .28s ease;
}
.enemy.is-death,
.enemy[data-state="death"] {
    animation: enemyDeath .7s ease forwards;
}
.enemy.is-death .coin-bit,
.enemy[data-state="death"] .coin-bit {
    animation: coinScatter .7s ease forwards;
}
.enemy.is-death .coin-bit:nth-child(1) { --dx: -36px; --dy: -28px; animation-delay: 0s; }
.enemy.is-death .coin-bit:nth-child(2) { --dx: 10px; --dy: -42px; animation-delay: .04s; }
.enemy.is-death .coin-bit:nth-child(3) { --dx: 38px; --dy: -22px; animation-delay: .08s; }
.enemy.is-death .coin-bit:nth-child(4) { --dx: -22px; --dy: 8px; animation-delay: .05s; }
.enemy.is-death .coin-bit:nth-child(5) { --dx: 28px; --dy: 12px; animation-delay: .1s; }
.enemy.is-death .coin-bit:nth-child(6) { --dx: 0px; --dy: -18px; animation-delay: .02s; }

.enemy.is-appear .enemy-appear-ring,
.enemy[data-state="appear"] .enemy-appear-ring {
    animation: appearRing .55s ease-out forwards;
}

@keyframes enemyIdle {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(calc(-50% - 10px)); }
}
@keyframes enemyAppear {
    0% { opacity: 0; transform: translateY(calc(-50% - 28px)) scale(.35) rotate(-8deg); }
    65% { opacity: 1; transform: translateY(calc(-50% + 4px)) scale(1.08) rotate(3deg); }
    100% { opacity: 1; transform: translateY(-50%) scale(1) rotate(0); }
}
@keyframes enemyHit {
    0% { transform: translateY(-50%) translate(0, 0) rotate(0); }
    12% { transform: translateY(-50%) translate(-12px, 3px) rotate(-14deg); }
    28% { transform: translateY(-50%) translate(14px, -4px) rotate(12deg); }
    44% { transform: translateY(-50%) translate(-10px, 2px) rotate(-10deg); }
    60% { transform: translateY(-50%) translate(9px, -2px) rotate(8deg); }
    76% { transform: translateY(-50%) translate(-5px, 1px) rotate(-4deg); }
    100% { transform: translateY(-50%) translate(0, 0) rotate(0); }
}
@keyframes enemyShakeArt {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    20% { transform: translate(-3px, 1px) rotate(-6deg); }
    40% { transform: translate(4px, -1px) rotate(6deg); }
    60% { transform: translate(-3px, 0) rotate(-4deg); }
    80% { transform: translate(2px, 0) rotate(3deg); }
}
@keyframes enemyFlash {
    0%, 100% { filter: drop-shadow(0 6px 6px rgba(0,0,0,.3)) brightness(1); }
    35% { filter: drop-shadow(0 0 10px rgba(220,40,30,.9)) brightness(1.35) sepia(.4) saturate(2.4) hue-rotate(-20deg); }
}
@keyframes enemyDeath {
    0% { opacity: 1; transform: translateY(-50%) rotate(0) scale(1); }
    35% { opacity: 1; transform: translateY(calc(-50% + 8px)) rotate(18deg) scale(1.05); }
    100% { opacity: 0; transform: translateY(calc(-50% + 64px)) rotate(55deg) scale(.55); }
}
@keyframes coinScatter {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.7); }
}
@keyframes appearRing {
    0% { opacity: .9; transform: translate(-50%, -50%) scale(.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

.enemy-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
.enemy-coins {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 0;
    height: 0;
}
.coin-bit {
    position: absolute;
    left: 0;
    top: 0;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff2b0, #f7c948 45%, #b8860b 100%);
    border: 2px solid #6b3f22;
    opacity: 0;
    box-shadow: inset 0 0 0 2px rgba(138,90,18,.35);
}
.enemy-appear-ring {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 90px;
    height: 90px;
    margin: 0;
    border: 3px solid rgba(247,201,72,.85);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 16px rgba(247,201,72,.45);
}

.enemy-art {
    width: 96px;
    height: 96px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    background: transparent !important;
    mix-blend-mode: normal;
    filter: drop-shadow(0 6px 6px rgba(0,0,0,.3));
}
.enemy-name {
    display: inline-block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .02em;
    color: #3a220e;
    background: linear-gradient(180deg, #fff6e4, #f0d7a0);
    border: 2px solid var(--wood);
    border-radius: 8px;
    padding: 2px 10px;
    text-shadow: none;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 2px 0 rgba(107,63,34,.25);
}
.enemy-hp-wrap {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.enemy-hp-bar {
    width: 92px;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(40, 20, 10, 0.45);
    border: 2px solid var(--wood);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}
.enemy-hp-fill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    transition: width .18s ease, background .18s ease;
}
.enemy-hp-fill.hp-high {
    background: linear-gradient(90deg, #2f8f3a, #6fcf4d);
}
.enemy-hp-fill.hp-mid {
    background: linear-gradient(90deg, #c9a012, #f7c948);
}
.enemy-hp-fill.hp-low {
    background: linear-gradient(90deg, #8b1e1e, #e05a45);
}
.enemy-hp-text {
    font-size: 11px;
    font-weight: 800;
    color: #fff8ea;
    text-shadow: 0 1px 2px rgba(0,0,0,.55);
}

.tap-effect {
    position: absolute; z-index: 12; pointer-events: none;
    animation: tapFly .55s ease-out forwards;
}
.tap-effect span {
    font-family: "Ruslan Display", serif;
    font-size: 30px; color: #fff;
    text-shadow: 0 2px 0 #6b2c12, 0 0 8px rgba(247,201,72,.8);
}
@keyframes tapFly {
    0% { transform: translateY(0) scale(.7); opacity: 1; }
    100% { transform: translateY(-80px) scale(1.2); opacity: 0; }
}
.tap-area { position: absolute; inset: 0; z-index: 10; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; }

.info-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 8px 10px 6px;
    flex-shrink: 0;
}
.info-item {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    background: rgba(255,246,232,.92);
    border: 3px solid var(--wood);
    border-radius: 12px;
    padding: 6px 4px;
    font-size: 12px; font-weight: 900;
    box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.info-item .gold { color: #8a5a12; }

.energy-wrap {
    margin: 0 10px 8px;
    flex-shrink: 0;
    cursor: pointer;
}
.energy-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; font-weight: 800; color: #4a2f18; margin-bottom: 4px;
    gap: 8px;
}
.energy-label span { display: inline-flex; align-items: center; gap: 4px; }
.energy-label-right { gap: 8px !important; }
.energy-track {
    height: 14px; background: #5a3a20;
    border: 3px solid var(--wood); border-radius: 999px; overflow: hidden;
}
.energy-fill {
    height: 100%;
    background: linear-gradient(90deg, #6fcf4d, var(--gold));
    transition: width .2s ease;
}
.energy-shop-btn {
    position: static;
    border: 2px solid var(--wood);
    border-radius: 999px;
    background: linear-gradient(180deg, #ffe07a, #e0a83a);
    color: #3a220e;
    font-family: "Nunito", sans-serif;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 10px;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.energy-shop-btn:active { transform: translateY(1px); }

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(30, 16, 6, .55);
    backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none !important; }
.modal-card {
    width: min(360px, 100%);
    background: linear-gradient(180deg, #fff6e4, #f0d7a0);
    border: 4px solid var(--wood);
    border-radius: 18px;
    padding: 18px 16px 14px;
    box-shadow: 0 10px 0 rgba(0,0,0,.18);
}
.modal-title {
    margin: 0 0 6px;
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 22px;
    color: #5a3014;
    text-align: center;
}
.modal-text {
    margin: 0 0 14px;
    font-size: 13px;
    font-weight: 700;
    color: #5a3a20;
    text-align: center;
    line-height: 1.35;
}
.shop-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.shop-opt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: linear-gradient(180deg, #fffaf0, #edd4a2);
    padding: 12px 14px;
    cursor: pointer;
    font-family: "Nunito", sans-serif;
    box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.shop-opt:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.shop-opt-full {
    background: linear-gradient(180deg, #ffe07a, #f0c14a 45%, #d79a2a);
}
.shop-opt-main {
    font-size: 14px;
    font-weight: 900;
    color: #3a220e;
}
.shop-opt-cost {
    font-size: 12px;
    font-weight: 800;
    color: #8a5a12;
}
.modal-close {
    width: 100%;
    border: 3px solid var(--wood);
    border-radius: 12px;
    background: rgba(255,246,232,.9);
    color: #5a3a20;
    font-family: "Nunito", sans-serif;
    font-size: 13px;
    font-weight: 900;
    padding: 10px;
    cursor: pointer;
}

.nav-grid {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    max-width: none;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    z-index: 50;
    margin: 0;
    padding: 10px 8px max(10px, var(--safe-bottom));
    border-radius: 0;
    background:
        linear-gradient(180deg, #fff4dc 0%, #f0d7a0 55%, #e4c07e 100%);
    border: 0;
    border-top: 4px solid var(--wood);
    box-shadow: 0 -6px 16px rgba(40,20,5,.14);
    flex-shrink: 0;
}
.nav-btn {
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
    font-family: "Nunito", sans-serif;
    font-size: 10px;
    font-weight: 900;
    padding: 8px 2px 7px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    box-shadow: 0 3px 0 rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.55);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.nav-btn .nav-icon {
    width: 26px;
    height: 26px;
    display: block;
    pointer-events: none;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,.18));
}
.nav-btn .nav-label {
    font-size: 10px;
    letter-spacing: 0.03em;
    line-height: 1;
}
.nav-btn.active {
    background: linear-gradient(180deg, #ffe07a, #f0c14a 45%, #d79a2a);
    color: #3a220e;
    border-color: #5a3014;
    box-shadow:
        0 3px 0 rgba(90, 40, 10, .28),
        0 0 18px rgba(247, 201, 72, .45),
        inset 0 1px 0 rgba(255,255,255,.55);
    transform: translateY(-1px);
}
.nav-btn.active .nav-icon {
    filter: drop-shadow(0 2px 0 rgba(0,0,0,.2)) drop-shadow(0 0 8px rgba(247,201,72,.55));
}
.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0,0,0,.14);
}

.card {
    background: rgba(255,246,232,.95);
    border: 4px solid var(--wood);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 6px 0 rgba(0,0,0,.14);
    margin: 0 10px 8px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.card-title {
    font-family: "Ruslan Display", serif;
    font-size: 26px; color: #7a2f14; margin-bottom: 10px;
    flex-shrink: 0;
}

.scroll-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.hero-item, .land-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; margin-bottom: 8px;
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: #f7ebd3;
    overflow: hidden;
    position: relative;
}
.hero-item::before {
    content: "";
    position: absolute; inset: 0;
    opacity: .35;
    background-size: cover;
    background-position: center;
    pointer-events: none;
}
.hero-item[data-theme="field"]::before {
    background-image: linear-gradient(90deg, rgba(247,201,72,.35), transparent 55%), url("assets/bg-field.webp");
}
.hero-item[data-theme="forest"]::before {
    background-image: linear-gradient(90deg, rgba(79,143,62,.35), transparent 55%), url("assets/bg-forest.webp");
}
.hero-item[data-theme="river"]::before {
    background-image: linear-gradient(90deg, rgba(110,180,220,.4), transparent 55%), url("assets/bg-city.webp");
}
.hero-item[data-theme="mountains"]::before {
    background-image: linear-gradient(90deg, rgba(120,120,140,.4), transparent 55%), url("assets/bg-mountain.webp");
}
.hero-item .thumb, .land-item .thumb {
    width: 64px; height: 64px;
    object-fit: contain;
    border-radius: 12px;
    border: 3px solid var(--wood);
    background: transparent;
    flex-shrink: 0;
    position: relative; z-index: 1;
    mix-blend-mode: multiply;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,.25));
}
.hero-item .meta, .land-item .meta { flex: 1; min-width: 0; position: relative; z-index: 1; }
.hero-item .name, .land-item .name { font-weight: 900; font-size: 13px; color: #3a220e; }
.hero-item .bonus, .land-item .bonus { display: block; font-size: 11px; color: var(--leaf); font-weight: 800; margin-top: 2px; }

.buy-btn {
    border: 3px solid var(--wood); border-radius: 12px;
    background: linear-gradient(180deg, #f0c14a, #d79a2a);
    color: #3a220e; font-size: 11px; font-weight: 900;
    padding: 8px 10px; cursor: pointer; white-space: nowrap;
    position: relative; z-index: 1;
    display: inline-flex; align-items: center; gap: 4px;
}
.buy-btn:disabled { opacity: .45; cursor: not-allowed; }

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}
.profile-action-btn {
    width: 100%;
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffe07a, #f0c14a 45%, #d79a2a);
    color: #3a220e;
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    padding: 12px 14px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(107, 63, 34, .28);
}
.profile-action-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(107, 63, 34, .28);
}
.profile-action-btn.admin {
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
}
.rating-list {
    margin-top: 12px;
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: rgba(255, 246, 232, .96);
    overflow: hidden;
}
.rating-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 2px dashed rgba(107, 63, 34, .22);
    font-size: 12px;
    font-weight: 800;
    color: #5a3a20;
}
.rating-row:last-child { border-bottom: 0; }
.rating-row .place { margin-right: 6px; }
.rating-row .val { color: #7a2f14; white-space: nowrap; }
.rating-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.rating-header {
    flex-shrink: 0;
    margin-bottom: 8px;
}
.rating-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    border: 3px solid var(--wood);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(107, 63, 34, .22);
}
.rating-back-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(107, 63, 34, .22);
}
#ratingListFull {
    flex: 1;
    min-height: 0;
}
#ratingListFull .rating-row {
    font-size: 14px;
    padding: 12px 14px;
}
.rating-row.me {
    background: linear-gradient(90deg, rgba(247, 201, 72, .35), transparent);
    font-weight: 900;
}
.quests-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#questsList {
    flex: 1;
    min-height: 0;
}
.quest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,246,232,.96);
    border: 3px solid var(--wood);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.quest-item.is-ready {
    border-color: #c9a227;
    background: linear-gradient(180deg, #fff4c8, #f7ebd3);
}
.quest-item.is-claimed {
    opacity: .72;
}
.quest-ico {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,.18));
}
.quest-body { flex: 1; min-width: 0; }
.quest-title {
    font-size: 14px;
    font-weight: 900;
    color: #3a220e;
    line-height: 1.2;
}
.quest-desc {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 700;
    color: #6b4a28;
}
.quest-progress-meta {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 900;
    color: #2f6b2a;
}
.quest-track {
    margin-top: 4px;
    height: 10px;
    border: 2px solid var(--wood);
    border-radius: 999px;
    background: rgba(90, 58, 32, .18);
    overflow: hidden;
}
.quest-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6fcf4d, #f7c948);
}
.quest-actions {
    flex-shrink: 0;
}
.quest-actions .buy-btn {
    min-width: 92px;
}
.quest-bonus {
    margin: 4px 0 10px;
    padding: 10px 12px;
    border: 3px dashed rgba(107, 63, 34, .45);
    border-radius: 14px;
    background: rgba(255, 246, 232, .85);
    color: #5a3a20;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}
.quest-bonus.is-done {
    border-style: solid;
    color: #2f6b2a;
}
.quest-bonus-btn {
    display: block;
    width: 100%;
    margin: 4px 0 10px;
    border: 3px solid var(--wood);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffe07a, #f0c14a 45%, #d79a2a);
    color: #3a220e;
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    padding: 12px 14px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(107, 63, 34, .28);
}
.quest-bonus-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(107, 63, 34, .28);
}
.shop-hero-badge {
    margin: 0 0 10px;
    padding: 8px 12px;
    border: 3px solid var(--wood);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #4a2f18;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.profile-avatar {
    width: 120px; height: 120px;
    object-fit: contain; display: block; margin: 0 auto 8px;
    mix-blend-mode: multiply;
    filter: drop-shadow(0 8px 8px rgba(0,0,0,.3));
}
.profile-name {
    font-family: "Ruslan Display", serif;
    font-size: 26px; color: #7a2f14; text-align: center;
}
.profile-stat {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0;
    border-bottom: 2px dashed rgba(107,63,34,.25);
    font-size: 13px; font-weight: 800; color: #5a3a20;
}
.profile-stat .val { color: #7a2f14; display: inline-flex; align-items: center; gap: 4px; }

/* iPhone SE / short phones — keep everything on one screen, no empty gap */
@media (max-height: 700px), (max-width: 380px) {
    .header { padding: 6px 10px 10px; }
    .logo-text { font-size: clamp(18px, 5.5vw, 24px); }
    .logo-sword { width: 20px; height: 20px; }
    .balance { padding: 3px 10px 3px 6px; font-size: 13px; border-width: 2px; }
    .battle-scene {
        /* Fill leftover column space so nothing looks like a white margin */
        max-height: none;
        aspect-ratio: auto;
        min-height: 160px;
        border-top-width: 2px;
        border-bottom-width: 2px;
    }
    .hero-stage, .hero-art { width: min(42vw, 150px); height: min(42vw, 150px); }
    .enemy { width: 104px; top: 58%; right: 5%; }
    .enemy-art { width: 86px; height: 86px; }
    .enemy-hp-bar { width: 78px; height: 8px; }
    .hero-container { bottom: 6%; left: 43%; }
    .hero-name { font-size: 14px; padding: 1px 8px; border-width: 2px; }
    .hero-title { font-size: 10px; margin-top: 2px; }
    .info-panel { gap: 4px; margin: 6px 8px 4px; }
    .info-item { padding: 4px 2px; font-size: 11px; border-width: 2px; border-radius: 10px; box-shadow: 0 2px 0 rgba(0,0,0,.12); }
    .energy-wrap { margin: 0 8px 6px; }
    .energy-label { font-size: 11px; margin-bottom: 2px; }
    .energy-track { height: 11px; border-width: 2px; }
    .nav-grid { gap: 4px; padding: 6px 8px max(6px, var(--safe-bottom)); }
    .nav-btn { padding: 6px 0; border-width: 2px; border-radius: 10px; }
    .nav-btn .nav-icon { width: 20px; height: 20px; }
    .nav-btn .nav-label { font-size: 9px; }
    .card { margin: 0 8px 6px; padding: 10px; border-width: 3px; border-radius: 14px; }
    .card-title { font-size: 22px; margin-bottom: 8px; }
    .hero-item, .land-item { padding: 6px; margin-bottom: 6px; gap: 8px; }
    .hero-item .thumb, .land-item .thumb { width: 52px; height: 52px; }
}

/* Very short screens (SE landscape / tiny height) */
@media (max-height: 580px) {
    .battle-scene { min-height: 120px; max-height: none; aspect-ratio: auto; }
    .hero-stage, .hero-art { width: min(36vw, 120px); height: min(36vw, 120px); }
    .hero-container { bottom: 4%; left: 43%; }
    .enemy { top: 56%; right: 3%; }
    .enemy-art { width: 74px; height: 74px; }
    .enemy-hp-bar { width: 70px; }
    .info-panel { margin-top: 4px; }
    .header { padding-top: 4px; padding-bottom: 2px; }
}

/* Large phones — proportional heroes, scene still fills column */
@media (min-width: 430px) and (min-height: 800px) {
    .header { padding: 10px 16px 14px; }
    .logo-text { font-size: 32px; }
    .logo-sword { width: 30px; height: 30px; }
    .hero-stage, .hero-art { width: min(48vw, 260px); height: min(48vw, 260px); }
    .hero-container { bottom: 10%; left: 44%; }
    .enemy { width: 130px; top: 60%; right: 9%; }
    .enemy-art { width: 110px; height: 110px; }
    .enemy-hp-bar { width: 110px; height: 12px; }
    .info-panel { gap: 8px; margin: 10px 14px 8px; }
    .info-item { padding: 8px 6px; font-size: 14px; }
    .energy-wrap { margin: 0 14px 10px; }
    .energy-track { height: 16px; }
    .nav-grid { padding: 10px 14px max(10px, var(--safe-bottom)); gap: 8px; }
    .nav-btn { padding: 10px 0; }
    .nav-btn .nav-icon { width: 28px; height: 28px; }
    .nav-btn .nav-label { font-size: 11px; }
    .card { margin: 0 14px 10px; padding: 16px; }
}

/* ===== SHOP ===== */
.nav-icon-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 0 rgba(0,0,0,.18));
}
.shop-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.shop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.shop-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.shop-title-ico {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.shop-balance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,246,232,.95);
    border: 3px solid var(--wood);
    border-radius: 999px;
    padding: 4px 12px;
    font-weight: 900;
    font-size: 13px;
    color: #8a5a12;
}
.shop-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.shop-tab {
    flex: 1 1 calc(33.33% - 6px);
    min-width: 88px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 2px;
    border: 3px solid var(--wood);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
    font-family: "Nunito", sans-serif;
    font-size: 10px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(0,0,0,.12);
}
.shop-tab img { width: 16px; height: 16px; object-fit: contain; }
.shop-section-title {
    margin: 12px 0 8px;
    font-family: "Ruslan Display", serif;
    font-size: 18px;
    color: #7a2f14;
    text-align: center;
}
.shop-item.is-equipped,
.land-item.is-selected {
    border-color: #d79a2a;
    box-shadow: 0 0 0 2px rgba(247, 201, 72, .45);
    background: linear-gradient(180deg, #fff8e8, #ffe7b0);
}
.buy-btn.is-active {
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
    opacity: 1;
}
.shop-locked-note {
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 3px dashed var(--wood);
    border-radius: 12px;
    background: rgba(255,246,232,.85);
    color: #5a3a20;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}
.buy-btn.equip {
    background: linear-gradient(180deg, #6fcf4d, #4f8f3e);
    color: #fff8ea;
}
.buy-btn.equipped {
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
}
.shop-tab.active {
    background: linear-gradient(180deg, #ffe07a, #f0c14a 45%, #d79a2a);
    color: #3a220e;
    box-shadow: 0 3px 0 rgba(90,40,10,.22);
}
.shop-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}
.shop-content[hidden] { display: none !important; }
.shop-hint {
    flex-shrink: 0;
    margin: 8px 0 0;
    font-size: 12px;
    font-weight: 700;
    color: #6b4a28;
    text-align: center;
}
.shop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,246,232,.96);
    border: 3px solid var(--wood);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.shop-item .thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    image-rendering: auto;
}
.shop-item .info { flex: 1; min-width: 0; }
.shop-item .name {
    display: block;
    font-size: 14px;
    font-weight: 900;
    color: #3a220e;
    line-height: 1.2;
}
.shop-item .desc {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b4a28;
    margin-top: 2px;
}
.shop-item .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 800;
}
.shop-item .level { color: #2f6b2a; }
.shop-item .effect { color: #8a5a12; }
.shop-item .stock { color: #5a3a20; }
.shop-item .cost {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.shop-item .price {
    font-size: 12px;
    font-weight: 900;
    color: #8a5a12;
    white-space: nowrap;
}
.shop-item .buy-btn {
    min-width: 88px;
}
.shop-energy-bar {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: rgba(255,246,232,.95);
    border: 3px solid var(--wood);
    border-radius: 14px;
}
.shop-energy-bar .label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 900;
    color: #4a2f18;
    margin-bottom: 6px;
}
.shop-locked {
    opacity: .72;
}
.shop-locked .buy-btn { opacity: .55; }



/* ===== SLOBODA — full-bleed scenic bg + building cards ===== */
#panelSloboda.active {
    gap: 0;
}
.sloboda-scene {
    position: relative;
    width: 100%;
    flex: 1 1 0;
    height: 0;
    min-height: 180px;
    overflow: hidden;
    border-top: 3px solid var(--wood);
    border-bottom: 3px solid var(--wood);
    background: #6a9a4a;
}
.sloboda-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}
.sloboda-veil {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(20, 28, 12, .18) 0%, rgba(20, 28, 12, .08) 28%, rgba(20, 28, 12, .22) 100%),
        radial-gradient(ellipse at 50% 0%, rgba(255, 248, 220, .12), transparent 55%);
}
.sloboda-scroll {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 10px max(14px, env(safe-area-inset-bottom, 0px));
}
.sloboda-hud {
    position: relative;
    align-self: center;
    flex: 0 0 auto;
    z-index: 3;
    text-align: center;
    pointer-events: none;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(255, 246, 232, .92);
    border: 3px solid var(--wood);
    box-shadow: 0 4px 14px rgba(20, 12, 4, .22);
    max-width: min(94vw, 380px);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.sloboda-title {
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 17px;
    color: #5a3a20;
    line-height: 1.1;
}
.sloboda-hint {
    font-size: 10px;
    font-weight: 800;
    color: #8a5a2a;
    line-height: 1.25;
}
.sloboda-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0;
    z-index: 2;
}
.sloboda-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 10px 8px 8px;
    border: 3px solid rgba(90, 52, 24, .88);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 248, 230, .88), rgba(232, 201, 138, .82));
    box-shadow: 0 4px 12px rgba(20, 12, 4, .28), 0 1px 0 rgba(255, 255, 255, .35) inset;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease;
    text-align: center;
    color: inherit;
    font: inherit;
}
.sloboda-card:active {
    transform: scale(.97);
}
.sloboda-card.is-empty {
    background: linear-gradient(180deg, rgba(255, 250, 236, .72), rgba(220, 200, 150, .62));
    border-style: dashed;
}
.sloboda-card-art-wrap {
    position: relative;
    width: 100%;
    height: 72px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sloboda-card-art {
    max-width: 100%;
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center bottom;
    display: block;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 3px 2px rgba(40,20,5,.22));
}
.sloboda-card.is-empty .sloboda-card-art {
    opacity: .38;
    filter: grayscale(.35) drop-shadow(0 2px 1px rgba(40,20,5,.15));
}
.sloboda-card-badge {
    position: absolute;
    top: -2px;
    right: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #c44536;
    border: 2px solid #6b3f22;
    color: #fff8e8;
    font-size: 11px;
    font-weight: 900;
    line-height: 16px;
    text-align: center;
}
.sloboda-card-name {
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 13px;
    color: #5a3a20;
    line-height: 1.1;
}
.sloboda-card-meta {
    font-size: 10px;
    font-weight: 800;
    color: #7a4a22;
    line-height: 1.25;
    min-height: 2.5em;
}
.sloboda-card-cta {
    margin-top: 2px;
    width: 100%;
    border: 2px solid var(--wood);
    border-radius: 10px;
    background: linear-gradient(180deg, #ffe08a, #e0a93a);
    color: #5a3a20;
    font-size: 11px;
    font-weight: 900;
    padding: 6px 4px;
    pointer-events: none;
}
.sloboda-card.is-built .sloboda-card-cta {
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
}
.sloboda-card.is-max .sloboda-card-cta {
    background: linear-gradient(180deg, #e8dcc4, #d4c4a0);
    opacity: .85;
}

.sloboda-scene.is-inside .sloboda-scroll,
.sloboda-scene.is-inside .sloboda-veil,
.sloboda-scene.is-inside .sloboda-bg {
    visibility: hidden;
    pointer-events: none;
}
.sloboda-interior {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: block;
    background: transparent;
}
.sloboda-interior.is-hidden {
    display: none;
}
.sloboda-interior-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
}
.sloboda-interior-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    z-index: 2;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
    /* soft veil only — keep interior art fully visible */
    background:
        linear-gradient(180deg, rgba(18, 12, 8, .28) 0%, rgba(18, 12, 8, .08) 18%, rgba(18, 12, 8, .12) 70%, rgba(18, 12, 8, .42) 100%);
    border-top: 0;
    pointer-events: auto;
    backdrop-filter: none;
}
.sloboda-interior-name {
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 18px;
    color: #fff8e8;
    text-shadow: 0 1px 0 #3a2412, 0 0 8px rgba(0,0,0,.55);
    text-align: center;
    align-self: center;
    padding: 6px 14px 2px;
    border-radius: 12px;
    background: rgba(255, 246, 232, .22);
    border: 2px solid rgba(255, 246, 232, .35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    max-width: min(92vw, 360px);
}
.sloboda-interior-meta {
    font-size: 12px;
    font-weight: 800;
    color: #ffe8c0;
    margin: 4px auto 6px;
    white-space: pre-line;
    line-height: 1.35;
    text-align: center;
    text-shadow: 0 1px 0 #3a2412, 0 0 6px rgba(0,0,0,.5);
    max-width: min(92vw, 360px);
    padding: 4px 10px;
    border-radius: 10px;
    background: rgba(20, 12, 6, .28);
}
.sloboda-interior-actions {
    display: flex;
    gap: 8px;
}
.sloboda-btn {
    flex: 1;
    border: 3px solid var(--wood);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff6e4, #edd4a2);
    color: #5a3a20;
    font-family: "Nunito", sans-serif;
    font-size: 13px;
    font-weight: 900;
    padding: 10px 8px;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0,0,0,.14);
}
.sloboda-btn.primary {
    background: linear-gradient(180deg, #ffe08a, #e0a93a);
}
.sloboda-btn:disabled {
    opacity: .55;
    cursor: default;
}
@media (max-width: 360px) {
    .sloboda-card-art-wrap { height: 64px; }
    .sloboda-card-art { max-height: 64px; }
    .nav-btn .nav-label { font-size: 9px; }
}


/* Sloboda building feature panels (forge / watch / chapel) */
.sloboda-interior-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}
.sloboda-feature {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    flex: 1 1 auto;
}
.sloboda-feature.is-hidden { display: none; }
.sloboda-feature-title {
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 14px;
    color: #fff8e8;
    text-align: center;
    text-shadow: 0 1px 0 #3a2412, 0 0 6px rgba(0,0,0,.45);
    align-self: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 246, 232, .28);
    border: 2px solid rgba(255, 246, 232, .4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.sloboda-feature-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 2px 6px;
}
.sloboda-feature-body .shop-item,
.sloboda-feature-body .artifact-row {
    background: rgba(255, 248, 230, .55);
    border: 2px solid rgba(90, 52, 24, .65);
    border-radius: 12px;
    box-shadow: 0 2px 0 rgba(0,0,0,.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.sloboda-feature-body .shop-hero-badge,
.sloboda-feature-body .artifact-slot-row,
.sloboda-feature-body .shop-locked-note,
.sloboda-feature-body .artifact-empty {
    background: rgba(255, 246, 232, .5);
    border: 2px solid rgba(90, 52, 24, .5);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
    color: #5a3a20;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.sloboda-feature-lead {
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    color: #fff4e0;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 1px 0 #3a2412, 0 0 5px rgba(0,0,0,.45);
}
.sloboda-interior-actions .sloboda-btn {
    background: linear-gradient(180deg, rgba(255,246,228,.88), rgba(237,212,162,.82));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}


/* ===== BARN / SLOBODa craft UI ===== */
.sloboda-feature-lead {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 800;
    color: #fff4e0;
    text-align: center;
    text-shadow: 0 1px 0 #3a2412, 0 0 5px rgba(0,0,0,.45);
    line-height: 1.3;
}
.barn-cap {
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    color: #ffe8c0;
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
    margin: 4px 0;
}
.barn-action-card {
    background: rgba(255, 248, 230, .52);
    border: 2px solid rgba(90, 52, 24, .55);
    border-radius: 12px;
    padding: 10px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.barn-action-title {
    font-family: "Ruslan Display", "Nunito", sans-serif;
    font-size: 14px;
    color: #5a3a20;
}
.barn-action-meta {
    font-size: 11px;
    font-weight: 800;
    color: #6a4020;
}
.barn-stacks { display: flex; flex-direction: column; gap: 8px; }
.barn-empty {
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff0d8;
    text-shadow: 0 1px 2px rgba(0,0,0,.45);
    padding: 12px 8px;
}
.barn-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 248, 230, .55);
    border: 2px solid rgba(90, 52, 24, .6);
    border-radius: 12px;
    padding: 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.barn-row.is-soon { border-color: #c44536; }
.barn-ico { font-size: 22px; width: 28px; text-align: center; }
.barn-info { flex: 1; min-width: 0; }
.barn-name { font-size: 13px; font-weight: 900; color: #5a3a20; }
.barn-meta { font-size: 10px; font-weight: 800; color: #7a4a22; }
.barn-tag {
    font-size: 10px;
    font-weight: 900;
    color: #7a4a22;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,.35);
}
