:root {
    --sky-top: #6ecff5;
    --sky-mid: #4eb8e8;
    --sky-deep: #2a8fc4;
    --grass-light: #6ecf5a;
    --grass-dark: #4a9e3a;
    --panel-bg: #f4ecd8;
    --panel-inner: #fff8ea;
    --panel-border: #2d2418;
    --panel-edge: #8b7355;
    --text-dark: #2a2218;
    --text-muted: #6b5d48;
    --btn-play: #5dff9d;
    --btn-play-shadow: #1a8a4a;
    --btn-blue: #7eb8ff;
    --btn-blue-shadow: #2a5a9e;
    --btn-gold: #ffd966;
    --btn-gold-shadow: #b8860b;
    --btn-red: #ff7b7b;
    --btn-red-shadow: #9e2a2a;
    --pixel-shadow: #1a140e;
    --success: #2ecc71;
    --danger: #e74c3c;
    --ui-scale: 1;
}

#loading-screen,
#error-screen,
#welcome-screen,
#pin-screen,
#skin-screen,
#menu-screen,
#profile-screen,
#quests-screen,
#revenue-share-screen,
#leaderboard-screen,
#bag-screen,
#trainer-stats-screen {
    --ui-scale: 2.3;
    --hub-panel-max: 720px;
}

/* Wide rectangular panels — pin, main menu, and all inner hub screens */
#pin-screen,
#skin-screen,
#menu-screen,
#profile-screen,
#quests-screen,
#revenue-share-screen,
#leaderboard-screen,
#bag-screen,
#trainer-stats-screen {
    align-items: stretch;
    padding: 14px 10px;
}

@font-face {
    font-family: "silkscreen";
    src: url("/fonts/silkscreen.ttf") format("truetype");
    font-display: optional;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    color: var(--text-dark);
    font-family: silkscreen, "Courier New", monospace;
    image-rendering: pixelated;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

::selection {
    background: transparent;
    color: inherit;
}

.hidden {
    display: none !important;
}

/* Branded boot layer (mirrors inline critical styles; fades out in app.js) */
.tg-boot-splash {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px),
        radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px),
        linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-deep) 100%);
    background-size: 48px 48px, 64px 64px, auto;
    transition: opacity 320ms steps(5, end), visibility 320ms steps(5, end);
}

.tg-boot-splash.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tg-boot-logo {
    width: min(230px, 78vw);
    height: auto;
    image-rendering: pixelated;
    filter: drop-shadow(4px 4px 0 rgba(26, 20, 14, 0.35));
    animation: tg-boot-bob 1.1s steps(2, end) infinite;
}

.tg-boot-progress {
    font-family: silkscreen, "Courier New", monospace;
    font-size: calc(9px * var(--ui-scale, 1));
    letter-spacing: 0.08em;
    color: #fff8ea;
    text-shadow: 2px 2px 0 var(--pixel-shadow);
    min-height: 1.3em;
    text-align: center;
}

@keyframes tg-boot-bob {
    0%, 100% { transform: translateY(-3px); }
    50% { transform: translateY(3px); }
}

/* ── Fun pixel sky + grass (all menu screens) ── */
#loading-screen,
#error-screen,
#welcome-screen,
#pin-screen,
#skin-screen,
#menu-screen,
#profile-screen,
#bag-screen,
#quests-screen,
#revenue-share-screen,
#leaderboard-screen {
    background-color: transparent;
    background-image: none;
}

/* ── Global animated retro pixel backdrop ── */
.retro-pixel-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    image-rendering: pixelated;
}

.retro-pixel-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.95) 1px, transparent 1px),
        radial-gradient(circle, rgba(255, 255, 255, 0.55) 1px, transparent 1px),
        linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 48%, var(--sky-deep) 72%);
    background-size: 42px 42px, 68px 68px, auto;
    background-position: 0 0, 18px 12px, 0 0;
    animation: retro-star-twinkle 4s steps(4) infinite;
}

.retro-pixel-clouds {
    position: absolute;
    inset: -10% -20%;
    opacity: 0.72;
    background:
        radial-gradient(ellipse 110px 42px at 12% 24%, rgba(255, 255, 255, 0.72) 0%, transparent 72%),
        radial-gradient(ellipse 90px 34px at 38% 18%, rgba(255, 255, 255, 0.58) 0%, transparent 72%),
        radial-gradient(ellipse 120px 46px at 68% 26%, rgba(255, 255, 255, 0.62) 0%, transparent 72%),
        radial-gradient(ellipse 80px 30px at 88% 20%, rgba(255, 255, 255, 0.5) 0%, transparent 72%);
    animation: retro-cloud-drift 38s linear infinite;
}

.retro-pixel-hills {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    height: 120px;
    background:
        linear-gradient(135deg, transparent 42%, var(--grass-dark) 42%, var(--grass-dark) 58%, transparent 58%),
        linear-gradient(-135deg, transparent 42%, var(--grass-light) 42%, var(--grass-light) 58%, transparent 58%),
        repeating-linear-gradient(
            90deg,
            var(--grass-dark) 0 10px,
            var(--grass-light) 10px 20px
        );
    background-size: 80px 56px, 80px 56px, 20px 100%;
    background-position: 0 100%, 40px 100%, 0 100%;
    background-repeat: repeat-x, repeat-x, repeat;
    opacity: 0.88;
}

.retro-pixel-grass-strip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 24px;
    background:
        repeating-linear-gradient(
            90deg,
            var(--grass-dark) 0 6px,
            var(--grass-light) 6px 12px
        );
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.15);
}

@keyframes retro-star-twinkle {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.18); }
}

@keyframes retro-cloud-drift {
    from { transform: translateX(0); }
    to { transform: translateX(8%); }
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

#game-screen {
    z-index: 2;
    background: transparent;
}

body.dialogue-active #game-screen:has(#sign-modal:not(.hidden))::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 12;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.04) 0,
            rgba(0, 0, 0, 0.04) 2px,
            transparent 2px,
            transparent 4px
        ),
        rgba(8, 12, 28, 0.12);
    animation: retro-dialogue-dim 0.35s steps(4) forwards;
}

body.encounter-flash #game-screen::after {
    content: "!";
    position: absolute;
    top: 18%;
    left: 50%;
    z-index: 13;
    transform: translateX(-50%);
    font-family: silkscreen, monospace;
    font-size: 42px;
    color: #ffe566;
    text-shadow:
        0 0 8px #ff6a6a,
        3px 3px 0 #2d2418,
        -2px -2px 0 #fff;
    animation: retro-encounter-pop 0.52s steps(6) forwards;
    pointer-events: none;
}

@keyframes retro-dialogue-dim {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes retro-encounter-pop {
    0% { opacity: 0; transform: translateX(-50%) scale(0.3); }
    25% { opacity: 1; transform: translateX(-50%) scale(1.25); }
    55% { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) scale(0.85) translateY(-12px); }
}

body.dialogue-active .sign-modal-box {
    box-shadow:
        inset 0 0 0 2px #8b7355,
        0 0 0 2px #ffd966,
        4px 4px 0 rgba(0, 0, 0, 0.72);
    animation: retro-dialogue-box 0.28s steps(3);
}

@keyframes retro-dialogue-box {
    from { transform: translateY(8px); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
}

/* decorative grass tufts at bottom */
.screen::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            90deg,
            var(--grass-dark) 0px, var(--grass-dark) 6px,
            var(--grass-light) 6px, var(--grass-light) 12px
        );
    opacity: 0.5;
}

.panel {
    width: min(100%, 380px);
    position: relative;
    z-index: 1;
    background: var(--panel-inner);
    border: 4px solid var(--panel-border);
    outline: 3px solid var(--panel-edge);
    outline-offset: -7px;
    padding: 22px 20px 20px;
    box-shadow:
        6px 6px 0 var(--pixel-shadow),
        inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.panel.panel-hub {
    width: 100%;
    max-width: min(calc(100vw - 20px), var(--hub-panel-max, 720px));
    margin-inline: auto;
    align-self: stretch;
}

.panel-pixel-title {
    font-family: silkscreen, monospace;
    font-size: calc(14px * var(--ui-scale));
    letter-spacing: 0.04em;
    text-align: center;
    margin-bottom: 6px;
    color: var(--sky-deep);
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.menu-title-logo {
    display: block;
    width: min(230px, 90vw);
    height: auto;
    margin: 0 auto 8px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.menu-tagline {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    font-weight: normal;
    letter-spacing: 0.02em;
    line-height: 1.65;
    color: var(--text-dark);
    margin-bottom: 16px;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.45);
}

/* Onboarding + menu — blue sky + clouds only (no star dots, no grass) */
body.sky-plain-bg .retro-pixel-stars {
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 48%, var(--sky-deep) 72%);
    background-size: auto;
    animation: none;
}

body.sky-plain-bg .retro-pixel-hills,
body.sky-plain-bg .retro-pixel-grass-strip,
body.sky-plain-bg .retro-pixel-clouds {
    display: none;
}

body.sky-plain-bg #welcome-screen,
body.sky-plain-bg #pin-screen,
body.sky-plain-bg #skin-screen,
body.sky-plain-bg #menu-screen {
    background: transparent;
}

body.sky-plain-bg #welcome-screen::after,
body.sky-plain-bg #pin-screen::after,
body.sky-plain-bg #skin-screen::after,
body.sky-plain-bg #menu-screen::after {
    display: none;
}

body.sky-plain-bg #welcome-screen .welcome-stars {
    display: none;
}

#menu-screen {
    --menu-btn-scale: 1.3;
}

#menu-screen .panel {
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 18px 24px 16px;
}

#menu-screen .menu-title-logo {
    width: min(280px, 72vw);
    margin-bottom: 10px;
}

#menu-screen .player-badge.menu-player-badge {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 10px;
}

#menu-screen .menu-tagline {
    margin-bottom: 6px;
    line-height: 1.4;
    font-size: calc(6px * var(--ui-scale));
}

#menu-screen .menu-live {
    margin-bottom: 6px;
    padding: 4px 6px;
    gap: 5px;
    font-size: calc(7px * var(--ui-scale));
}

#menu-screen .menu-live-dot {
    width: 6px;
    height: 6px;
}

#menu-screen .player-badge {
    gap: 8px;
    padding: 3px 6px;
    margin-bottom: 6px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--pixel-shadow);
    align-items: center;
}

#menu-screen .menu-player-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

#menu-screen .menu-player-badges-side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
}

#menu-screen .menu-player-badges-side .player-badges {
    width: 100%;
    min-height: 0;
}

#menu-screen .menu-avatar-wrap {
    /* Layout slot — fixed space in the player row (does not grow the panel) */
    --menu-avatar-slot: 72px;
    /* Sprite scale — bigger character; overflows slot, bottom-aligned */
    --menu-avatar-scale: 92px;
    width: var(--menu-avatar-slot);
    height: var(--menu-avatar-slot);
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

#menu-screen .menu-avatar-face {
    flex-shrink: 0;
}

#menu-screen .player-name {
    font-size: calc(9px * var(--ui-scale));
    margin-bottom: 0;
    text-align: center;
}

#menu-screen .player-meta {
    font-size: calc(7px * var(--ui-scale));
    text-align: center;
    margin-top: 0;
}

#menu-screen .player-badges-label,
#menu-screen .player-badges-item {
    font-size: calc(7px * var(--ui-scale));
}

#menu-screen .player-badges-row {
    margin-top: 4px;
    gap: 4px;
}

#menu-screen .status {
    margin-top: 6px;
    min-height: 0.9rem;
}

.title {
    font-family: silkscreen, monospace;
    font-size: calc(13px * var(--ui-scale));
    text-align: center;
    margin-bottom: 8px;
    color: var(--sky-deep);
    text-shadow: 1px 1px 0 #fff;
}

.subtitle {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.7;
}

/* ── Welcome / how-to-play ── */
#welcome-screen {
    overflow: hidden;
    background: transparent;
    padding: max(28px, env(safe-area-inset-top, 0px)) 14px max(28px, env(safe-area-inset-bottom, 0px));
    justify-content: center;
    box-sizing: border-box;
}

#pin-screen,
#skin-screen,
#menu-screen {
    overflow: hidden;
}

.welcome-scene {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

#welcome-screen .panel,
#pin-screen .panel,
#skin-screen .panel,
#menu-screen .panel {
    position: relative;
    z-index: 1;
}

.welcome-cloud {
    position: absolute;
    width: 72px;
    height: 28px;
    background: rgba(255, 255, 255, 0.82);
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 4px 4px 0 rgba(42, 34, 24, 0.08);
    animation: welcome-cloud-drift 18s linear infinite;
}

.welcome-cloud::before,
.welcome-cloud::after {
    content: "";
    position: absolute;
    background: inherit;
    border: inherit;
}

.welcome-cloud::before {
    width: 34px;
    height: 34px;
    top: -16px;
    left: 10px;
}

.welcome-cloud::after {
    width: 28px;
    height: 28px;
    top: -12px;
    right: 8px;
}

.welcome-cloud-a { top: 12%; left: -80px; animation-duration: 22s; }
.welcome-cloud-b { top: 28%; left: -120px; animation-duration: 28s; animation-delay: -6s; opacity: 0.85; transform: scale(0.85); }
.welcome-cloud-c { top: 8%; left: -60px; animation-duration: 19s; animation-delay: -12s; transform: scale(0.7); opacity: 0.7; }

.welcome-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 68%, #ffe566 0 2px, transparent 2px),
        radial-gradient(circle at 28% 78%, rgba(255, 255, 255, 0.9) 0 1px, transparent 1px),
        radial-gradient(circle at 44% 72%, #7ee8c8 0 2px, transparent 2px),
        radial-gradient(circle at 62% 82%, rgba(255, 255, 255, 0.85) 0 1px, transparent 1px),
        radial-gradient(circle at 78% 70%, #ffb347 0 2px, transparent 2px),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1px);
    animation: welcome-stars-twinkle 2.4s steps(2, end) infinite;
}

.panel-welcome {
    width: min(100%, 520px);
    max-width: min(calc(100vw - 28px), 520px);
    max-height: calc(100dvh - 56px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: auto;
    padding: 20px 18px 18px;
    text-align: center;
    animation: welcome-panel-in 680ms steps(8, end) both;
}

.welcome-badge {
    display: inline-block;
    margin: 0 auto 10px;
    padding: 4px 10px;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    letter-spacing: 0.14em;
    color: #2d2418;
    background: linear-gradient(180deg, #ffe566 0%, #e6b800 100%);
    border: 2px solid #2d2418;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.35);
    text-align: center;
}

.welcome-logo {
    display: block;
    width: min(200px, 72vw);
    height: auto;
    margin: 0 auto 10px;
    image-rendering: pixelated;
    filter: drop-shadow(3px 3px 0 rgba(26, 20, 14, 0.28));
}

.welcome-headline {
    margin: 0 0 6px;
    font-family: silkscreen, monospace;
    font-size: calc(11px * var(--ui-scale));
    text-align: center;
    color: var(--sky-deep);
    text-shadow: 1px 1px 0 #fff;
    line-height: 1.45;
}

.welcome-lead {
    margin: 0 0 14px;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    font-weight: normal;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.65;
    letter-spacing: 0.02em;
}

.welcome-scroll {
    margin-bottom: 16px;
    padding: 12px 10px 10px;
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 5px 5px,
        linear-gradient(180deg, #fff8ea 0%, #f4ecd8 100%);
    border: 3px solid var(--panel-border);
    box-shadow: inset 0 0 0 2px var(--panel-edge), 3px 3px 0 var(--pixel-shadow);
}

.welcome-scroll-title {
    margin: 0 0 10px;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    letter-spacing: 0.1em;
    text-align: center;
    color: #3d3010;
}

.welcome-tips {
    list-style: none;
    display: grid;
    gap: 8px;
}

.welcome-tip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.55);
    border: 2px solid rgba(45, 36, 24, 0.12);
    text-align: left;
    animation: welcome-tip-in 520ms steps(5, end) both;
    animation-delay: calc(120ms + var(--tip-i, 0) * 90ms);
}

.welcome-tip-text {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    line-height: 1.55;
    color: var(--text-dark);
    letter-spacing: 0.02em;
}

.welcome-tip-text strong {
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    color: var(--sky-deep);
}

.welcome-tip-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 2px solid #2d2418;
    background: #dff4ff;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.25);
    position: relative;
}

.welcome-tip-icon-move {
    background:
        linear-gradient(#2d2418, #2d2418) 50% 62% / 10px 10px no-repeat,
        linear-gradient(#5dff9d, #5dff9d) 50% 62% / 8px 8px no-repeat,
        #dff4ff;
}

.welcome-tip-icon-talk {
    background:
        linear-gradient(#2d2418, #2d2418) 50% 38% / 14px 8px no-repeat,
        linear-gradient(#fff8ea, #fff8ea) 50% 38% / 12px 6px no-repeat,
        linear-gradient(#2d2418, #2d2418) 50% 68% / 4px 6px no-repeat,
        #ffd966;
}

.welcome-tip-icon-loot {
    background:
        linear-gradient(#2d2418, #2d2418) 50% 42% / 16px 12px no-repeat,
        linear-gradient(#c99400, #c99400) 50% 42% / 14px 10px no-repeat,
        linear-gradient(#2d2418, #2d2418) 50% 30% / 8px 4px no-repeat,
        #fff8ea;
}

.welcome-tip-icon-quest {
    background:
        linear-gradient(#2d2418, #2d2418) 50% 50% / 14px 14px no-repeat,
        linear-gradient(#ffe566, #ffe566) 50% 50% / 12px 12px no-repeat,
        linear-gradient(#2d2418, #2d2418) 50% 22% / 4px 8px no-repeat,
        #7eb8ff;
}

.welcome-setup-btn {
    width: 100%;
    font-size: calc(10px * var(--ui-scale));
    letter-spacing: 0.06em;
    animation: welcome-btn-glow 1.8s steps(2, end) infinite;
}

.welcome-footnote {
    margin: 10px 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    text-align: center;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

@keyframes welcome-cloud-drift {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 160px)); }
}

@keyframes welcome-stars-twinkle {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

@keyframes welcome-panel-in {
    0% { transform: translateY(18px) scale(0.94); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes welcome-tip-in {
    0% { transform: translateX(-8px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes welcome-btn-glow {
    0%, 100% { box-shadow: 4px 4px 0 var(--btn-play-shadow), 0 0 0 rgba(93, 255, 157, 0); }
    50% { box-shadow: 4px 4px 0 var(--btn-play-shadow), 0 0 12px rgba(93, 255, 157, 0.55); }
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--panel-bg);
    border: 3px solid var(--panel-border);
    box-shadow: 3px 3px 0 var(--pixel-shadow);
    margin-bottom: 16px;
}

.menu-avatar-wrap {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid var(--panel-border);
    background: #dff4ff;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.menu-avatar-face {
    image-rendering: pixelated;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    color: var(--text-dark);
    margin-bottom: 4px;
}

.player-meta {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
}

.player-badges-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.player-badges-label {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    text-transform: lowercase;
}

.player-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.player-badges-empty {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    opacity: 0.7;
}

.player-badges-item {
    display: inline-flex;
    align-items: center;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    line-height: 1.2;
    padding: 3px 7px;
    color: #3d3010;
    background: linear-gradient(180deg, #ffe566 0%, #e6b800 100%);
    border: 2px solid #3d3010;
    box-shadow: 2px 2px 0 var(--pixel-shadow);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.menu-live {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 10px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    box-shadow: 2px 2px 0 var(--pixel-shadow);
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
}

.menu-live-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    box-shadow: 0 0 0 2px var(--panel-border);
    animation: pulse-live 1.4s steps(2) infinite;
}

.menu-live-count {
    color: #1a7a42;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.menu-grid {
    display: grid;
    gap: 10px;
}

/* Main menu — chunky pixel buttons */
.menu-grid-pixel {
    gap: 12px;
}

#menu-screen .menu-grid-pixel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

#menu-screen .menu-grid-pixel .btn {
    width: 100%;
    min-height: calc(42px * var(--menu-btn-scale, 1.3));
    padding: calc(10px * var(--menu-btn-scale, 1.3)) calc(14px * var(--menu-btn-scale, 1.3));
    font-size: calc(10px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 3px solid var(--panel-border);
    border-radius: 0;
    letter-spacing: 0.04em;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    background-blend-mode: soft-light;
    background-image:
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.07) 0 2px,
            transparent 2px 4px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.04) 0 2px,
            transparent 2px 4px
        );
    transition:
        transform 0.05s steps(2, end),
        box-shadow 0.05s steps(2, end),
        filter 0.05s steps(2, end);
}

#menu-screen .menu-grid-pixel .btn:active,
#menu-screen .menu-grid-pixel .btn.pressed {
    /* No transform — shifting the hit box cancels click/touchend in Telegram WebView */
    filter: brightness(0.88) saturate(1.05);
    box-shadow:
        inset 0 0 0 2px var(--panel-border),
        inset 3px 3px 0 rgba(0, 0, 0, 0.28) !important;
}

#menu-screen .menu-grid-pixel .btn-play {
    background-color: var(--btn-play);
    box-shadow:
        3px 3px 0 var(--btn-play-shadow),
        inset 2px 2px 0 rgba(255, 255, 255, 0.55),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

#menu-screen .menu-grid-pixel .btn-quests {
    background-color: #c9a0ff;
    box-shadow:
        3px 3px 0 #6b3fa8,
        inset 2px 2px 0 rgba(255, 255, 255, 0.45),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

#menu-screen .menu-grid-pixel .btn-leaderboard {
    background: linear-gradient(180deg, #ffd76a 0%, #e8a317 45%, #b8730e 100%);
    border-color: #5c3a08;
    color: #2a1808;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        0 4px 0 #5c3a08;
    font-size: calc(10px * var(--ui-scale));
}

.btn-leaderboard {
    letter-spacing: 0.04em;
}

/* ── Leaderboard ── */
#leaderboard-screen {
    justify-content: flex-start;
    align-items: stretch;
    overflow: hidden;
    padding: 12px 12px max(16px, env(safe-area-inset-bottom));
}

#leaderboard-screen .panel-leaderboard {
    position: relative;
    max-height: calc(100dvh - 24px);
    height: calc(100dvh - 24px);
    margin: 0 auto;
    padding: 14px 12px 12px;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(165deg, rgba(18, 12, 42, 0.94) 0%, rgba(32, 18, 58, 0.92) 40%, rgba(12, 28, 52, 0.94) 100%);
    border: 3px solid #ffd76a;
    box-shadow:
        0 0 0 2px #2a1808,
        0 12px 32px rgba(0, 0, 0, 0.45),
        inset 0 0 40px rgba(255, 215, 100, 0.06);
    color: #fff8ea;
    overflow: hidden;
}

.lb-scroll-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding-right: 2px;
    margin-bottom: 8px;
}

.lb-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 215, 100, 0.2);
    position: relative;
    z-index: 1;
}

.lb-scanlines {
    pointer-events: none;
    position: absolute;
    inset: 0;
    opacity: 0.07;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.9) 2px,
        rgba(0, 0, 0, 0.9) 4px
    );
}

.lb-header {
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(255, 215, 100, 0.35);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.lb-title {
    font-size: 16px;
    letter-spacing: 0.1em;
    color: #ffe9a8;
    text-shadow: 2px 2px 0 #2a1808;
    margin-bottom: 8px;
}

.lb-subtitle {
    font-size: 9px;
    line-height: 1.55;
    color: rgba(255, 248, 234, 0.78);
    max-width: 340px;
    margin: 0 auto;
}

.lb-pulse-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 14px 0 10px;
    position: relative;
    z-index: 1;
}

.lb-pulse-card {
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 215, 100, 0.25);
    border-radius: 4px;
    padding: 8px 6px;
    text-align: center;
    min-width: 0;
}

.lb-pulse-val {
    display: block;
    font-size: 14px;
    color: #ffe566;
    text-shadow: 1px 1px 0 #2a1808;
}

.lb-pulse-label {
    display: block;
    font-size: 8px;
    letter-spacing: 0.08em;
    color: rgba(255, 248, 234, 0.65);
    margin-top: 2px;
}

.lb-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.lb-tab {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    font-family: inherit;
    font-size: 8px;
    padding: 8px 6px;
    border: 2px solid rgba(255, 215, 100, 0.35);
    background: rgba(0, 0, 0, 0.35);
    color: #fff8ea;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.lb-tab.active {
    background: linear-gradient(180deg, #ffd76a, #c8860a);
    color: #2a1808;
    border-color: #5c3a08;
    box-shadow: 0 2px 0 #5c3a08;
}

.lb-category-head {
    text-align: center;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.lb-cat-title {
    font-size: 12px;
    color: #ffe9a8;
    letter-spacing: 0.04em;
}

.lb-cat-tagline {
    font-size: 9px;
    color: rgba(255, 248, 234, 0.72);
    margin-top: 4px;
    line-height: 1.45;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.lb-podium {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: end;
    gap: 6px;
    min-height: 120px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.lb-podium.lb-podium--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
}

.lb-podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
    width: 100%;
}

.lb-podium-avatar {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    background: transparent;
    border: none;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.lb-podium-slot.rank-1 .lb-podium-avatar {
    width: 44px;
    height: 44px;
}

.lb-podium-bar {
    width: 100%;
    min-width: 0;
    border: 2px solid rgba(0, 0, 0, 0.35);
    border-radius: 3px 3px 0 0;
    padding: 6px 4px 8px;
    min-height: 48px;
}

.lb-podium-slot.rank-1 .lb-podium-bar {
    min-height: 72px;
    background: linear-gradient(180deg, #ffe566, #c8860a);
    color: #2a1808;
}

.lb-podium-slot.rank-2 .lb-podium-bar {
    background: linear-gradient(180deg, #e8eef5, #8a9bb0);
    color: #1a2030;
}

.lb-podium-slot.rank-3 .lb-podium-bar {
    background: linear-gradient(180deg, #ffb088, #b85c28);
    color: #2a1208;
}

.lb-podium-slot.rank-1 { order: 2; }
.lb-podium-slot.rank-2 { order: 1; }
.lb-podium-slot.rank-3 { order: 3; }

.lb-podium-rank {
    font-size: 10px;
    font-weight: bold;
}

.lb-podium-name {
    font-size: 8px;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-podium-val {
    font-size: 8px;
    margin-top: 4px;
    opacity: 0.9;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-rank-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    position: relative;
    z-index: 1;
}

.lb-rank-row {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) minmax(0, 80px);
    gap: 8px;
    align-items: center;
    padding: 8px 6px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-rank-row.is-you {
    border-color: #7dffb3;
    background: rgba(20, 60, 40, 0.45);
    box-shadow: 0 0 10px rgba(125, 255, 179, 0.15);
}

.lb-rank-num {
    font-size: 11px;
    color: #ffb347;
    text-align: center;
}

.lb-rank-name {
    font-size: 10px;
    color: #fff8ea;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-rank-val {
    font-size: 8px;
    color: #ffe566;
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-you-card {
    margin-bottom: 12px;
    padding: 10px;
    border: 2px dashed #7dffb3;
    background: rgba(10, 40, 28, 0.5);
    text-align: center;
    position: relative;
    z-index: 1;
}

.lb-you-card.hidden { display: none; }

.lb-you-label {
    font-size: 8px;
    letter-spacing: 0.14em;
    color: #7dffb3;
}

.lb-you-rank {
    font-size: 14px;
    color: #ffe566;
    margin: 4px 0;
}

.lb-you-stats {
    font-size: 9px;
    color: rgba(255, 248, 234, 0.75);
    line-height: 1.5;
    word-break: break-word;
}

.lb-empty {
    text-align: center;
    font-size: 10px;
    color: rgba(255, 248, 234, 0.65);
    padding: 16px 12px;
    line-height: 1.5;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.lb-challenge-btn {
    width: 100%;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

.lb-back-btn {
    width: 100%;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

#menu-screen .menu-grid-pixel .btn-revenue {
    background-color: #7ee8c8;
    box-shadow:
        3px 3px 0 #2a8868,
        inset 2px 2px 0 rgba(255, 255, 255, 0.45),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

#menu-screen .menu-grid-pixel .btn-bag {
    background-color: var(--btn-gold);
    box-shadow:
        3px 3px 0 var(--btn-gold-shadow),
        inset 2px 2px 0 rgba(255, 255, 255, 0.5),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

#menu-screen .menu-grid-pixel .btn-settings,
#menu-screen .menu-grid-pixel .btn-profile {
    background-color: var(--btn-blue);
    box-shadow:
        3px 3px 0 var(--btn-blue-shadow),
        inset 2px 2px 0 rgba(255, 255, 255, 0.45),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

#menu-screen .menu-grid-pixel .btn-exit {
    background-color: var(--btn-red);
    box-shadow:
        3px 3px 0 var(--btn-red-shadow),
        inset 2px 2px 0 rgba(255, 255, 255, 0.4),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22);
}

/* ── Pixel game buttons ── */
button {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

button::selection,
.btn::selection,
.icon-btn::selection,
.btn-leave::selection,
.pad-btn::selection {
    background: transparent;
    color: inherit;
}

.game-bag-btn::selection,
.game-poketab-btn::selection,
.game-drawer-tab::selection {
    background: transparent;
    color: inherit;
}

.btn,
.icon-btn,
.btn-leave,
.pad-btn {
    transition: transform 0.08s cubic-bezier(0.34, 1.2, 0.64, 1), box-shadow 0.08s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.btn {
    appearance: none;
    border: 3px solid var(--panel-border);
    border-radius: 0;
    padding: 13px 16px;
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    letter-spacing: 0.04em;
    cursor: pointer;
    text-transform: uppercase;
    image-rendering: pixelated;
    position: relative;
    user-select: none;
    touch-action: manipulation;
}

.btn:active,
.btn.pressed {
    transform: translate(4px, 4px) scale(0.97);
    box-shadow: none !important;
}

.btn-play {
    background: var(--btn-play);
    color: #0a3018;
    box-shadow: 4px 4px 0 var(--btn-play-shadow);
}

.btn-play::before {
    content: "▶ ";
}

.btn-settings,
.btn-profile {
    background: var(--btn-blue);
    color: #0a2040;
    box-shadow: 4px 4px 0 var(--btn-blue-shadow);
}

.btn-bag {
    background: var(--btn-gold);
    color: #4a3000;
    box-shadow: 4px 4px 0 var(--btn-gold-shadow);
}

.btn-quests {
    background: #c9a0ff;
    color: #2a1048;
    box-shadow: 4px 4px 0 #6b3fa8;
}

.btn-revenue {
    background: #7ee8c8;
    color: #0a3028;
    box-shadow: 4px 4px 0 #2a8868;
}

.btn-exit {
    background: var(--btn-red);
    color: #3a0808;
    box-shadow: 4px 4px 0 var(--btn-red-shadow);
}

/* legacy aliases */
.btn-primary {
    background: var(--btn-play);
    color: #0a3018;
    box-shadow: 4px 4px 0 var(--btn-play-shadow);
}

.btn-secondary {
    background: var(--btn-blue);
    color: #0a2040;
    box-shadow: 4px 4px 0 var(--btn-blue-shadow);
}

.btn-danger {
    background: var(--btn-red);
    color: #3a0808;
    box-shadow: 4px 4px 0 var(--btn-red-shadow);
}

.skin-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: 16px 0;
}

.skin-section {
    margin-bottom: 16px;
}

.skin-section-picker {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 14px;
    border-top: 2px dashed rgba(45, 36, 24, 0.18);
}

.skin-section-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.skin-setup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skin-setup-actions .btn-secondary {
    margin-top: 0;
}

.skin-section-label {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--ui-scale));
    color: var(--sky-deep);
    letter-spacing: 0.06em;
    text-align: center;
}

.skin-section {
    margin-bottom: 16px;
}

.skin-picker-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.skin-hero-stage {
    width: min(100%, 180px);
    height: 180px;
    flex: 1 1 auto;
    max-width: 180px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    border: 3px solid var(--panel-border);
    background:
        radial-gradient(circle at 50% 88%, rgba(255, 255, 255, 0.55) 0%, transparent 58%),
        linear-gradient(180deg, #dff4ff 0%, #a8daf5 100%);
    box-shadow: inset 0 0 0 2px var(--panel-inner), 3px 3px 0 var(--pixel-shadow);
}

.panel-skin .skin-picker-row .icon-btn {
    flex-shrink: 0;
}

.panel-skin .skin-counter {
    display: block;
    text-align: center;
}

.skin-hero-stage-sm {
    width: 160px;
    height: 160px;
    max-width: 100%;
}

.profile-equipped-label {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
}

.skin-sprite-preview {
    image-rendering: pixelated;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.skin-sprite-preview-hero {
    max-width: 100%;
    max-height: 100%;
    transform: translateZ(0);
    will-change: background-position;
}

.skin-sprite-preview-profile {
    width: 96px;
    height: 96px;
    max-width: 100%;
    max-height: 100%;
}

.panel-profile {
    max-height: min(92vh, 820px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 22px 26px 24px;
}

.profile-preview-block {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 8px 0 16px;
}

.profile-preview-frame {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 14px 18px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 16px;
    text-align: left;
}

.profile-preview-frame .skin-hero-stage-sm {
    justify-self: center;
}

.profile-preview-frame .profile-equipped-label {
    margin: 0;
    text-align: left;
}

.profile-section {
    margin-bottom: 14px;
    padding-top: 12px;
    border-top: 2px dashed rgba(45, 36, 24, 0.16);
}

.profile-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.profile-section-title {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--ui-scale));
    color: var(--sky-deep);
    letter-spacing: 0.05em;
}

.profile-owned-count {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    white-space: nowrap;
}

.profile-section-note {
    margin: 0 0 8px;
    font-size: calc(8px * var(--ui-scale));
    line-height: 1.45;
    color: var(--text-muted);
}

.profile-kins-deposit .profile-chips-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    text-align: center;
}

.profile-kins-deposit .profile-chips-form.hidden {
    display: none;
}

.profile-chips-amount-input {
    width: min(100%, 160px);
    padding: 8px 10px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    color: var(--text-dark);
    background: #fff;
    text-align: center;
    box-sizing: border-box;
}

.profile-chips-submit {
    width: min(100%, 160px);
    min-height: 38px;
}

.profile-chips-btn.is-active {
    outline: 2px solid #ffd838;
    outline-offset: 2px;
}

.profile-chips-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.profile-chips-btn {
    flex: 1;
    min-height: 40px;
    padding: 8px 10px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--ui-scale));
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
}

.profile-chips-btn--buy {
    background: #1a6b3a;
    box-shadow: 3px 3px 0 #0e4024;
    color: #eafff0;
}

.profile-chips-btn--sell {
    background: #7a2828;
    box-shadow: 3px 3px 0 #451616;
    color: #ffecec;
}

.profile-chips-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.22);
}

.profile-chips-btn--buy:active {
    box-shadow: 1px 1px 0 #0e4024;
}

.profile-chips-btn--sell:active {
    box-shadow: 1px 1px 0 #451616;
}

.profile-skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
}

.profile-skin-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-height: 104px;
    padding: 8px 6px 6px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel-inner);
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.12);
    transition: border-color 0.12s, transform 0.12s;
    overflow: hidden;
    isolation: isolate;
}

@keyframes profile-skin-shine {
    0% { background-position: 220% center; }
    100% { background-position: -220% center; }
}

.profile-skin-item--tier-green {
    background: linear-gradient(155deg, #dff9e6 0%, #a8ddb4 52%, #6fbf82 100%);
    border-color: #3d8f52;
    box-shadow: 2px 2px 0 rgba(34, 94, 48, 0.22);
}

.profile-skin-item--tier-silver {
    background: linear-gradient(155deg, #f8fafc 0%, #d5dde6 48%, #aeb9c6 100%);
    border-color: #8a97a6;
    box-shadow: 2px 2px 0 rgba(74, 88, 102, 0.2);
}

.profile-skin-item--tier-bronze {
    background: linear-gradient(155deg, #f3d7b8 0%, #cd9a6b 50%, #a66b3a 100%);
    border-color: #8b5a2b;
    box-shadow: 2px 2px 0 rgba(107, 62, 28, 0.24);
}

.profile-skin-item--tier-gold {
    background: linear-gradient(155deg, #fff6c8 0%, #f0d050 42%, #d4a017 100%);
    border-color: #b8860b;
    box-shadow: 2px 2px 0 rgba(140, 98, 10, 0.28);
}

.profile-skin-item[class*="--tier-"]::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(
        105deg,
        transparent 38%,
        rgba(255, 255, 255, 0.12) 44%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.12) 56%,
        transparent 62%
    );
    background-size: 220% 100%;
    animation: profile-skin-shine 3.4s ease-in-out infinite;
}

.profile-skin-item--tier-silver::before {
    background: linear-gradient(
        105deg,
        transparent 38%,
        rgba(255, 255, 255, 0.2) 44%,
        rgba(255, 255, 255, 0.72) 50%,
        rgba(255, 255, 255, 0.2) 56%,
        transparent 62%
    );
    background-size: 220% 100%;
}

.profile-skin-item--tier-bronze::before {
    background: linear-gradient(
        105deg,
        transparent 36%,
        rgba(255, 230, 200, 0.18) 43%,
        rgba(255, 248, 220, 0.62) 50%,
        rgba(255, 230, 200, 0.18) 57%,
        transparent 64%
    );
    background-size: 220% 100%;
    animation-duration: 2.8s;
}

.profile-skin-item--tier-gold::before {
    background: linear-gradient(
        105deg,
        transparent 34%,
        rgba(255, 255, 255, 0.25) 41%,
        rgba(255, 252, 210, 0.88) 50%,
        rgba(255, 255, 255, 0.25) 59%,
        transparent 66%
    );
    background-size: 220% 100%;
    animation-duration: 2s;
}

.profile-skin-thumb,
.profile-skin-id,
.profile-skin-cost {
    position: relative;
    z-index: 1;
}

.profile-skin-item:hover {
    border-color: var(--sky-deep);
}

.profile-skin-item.selected {
    border-color: var(--accent, #2a8fc4);
    box-shadow: 0 0 0 1px var(--accent, #2a8fc4), 2px 2px 0 rgba(45, 36, 24, 0.12);
}

.profile-skin-item.is-equipped::after {
    content: "ON";
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    line-height: 1;
    padding: 3px 4px;
    border-radius: 4px;
    background: #166534;
    color: #fff;
}

.profile-skin-thumb {
    image-rendering: pixelated;
    background-repeat: no-repeat;
    flex-shrink: 0;
    max-width: 100%;
}

.profile-skin-id {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: #2d2418;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.profile-skin-cost {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: #1a140e;
    line-height: 1.2;
    text-align: center;
    font-weight: bold;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.profile-skin-item--tier-green .profile-skin-cost { color: #14532d; }
.profile-skin-item--tier-silver .profile-skin-cost { color: #334155; }
.profile-skin-item--tier-bronze .profile-skin-cost { color: #6b3e1c; }
.profile-skin-item--tier-gold .profile-skin-cost { color: #7a5a00; }

.profile-skin-cost.is-expensive {
    color: #b91c1c;
}

.profile-shop-empty {
    margin: 0;
    font-size: calc(11px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0;
}

.profile-selected-cost {
    margin: 4px 0 10px;
    justify-content: center;
}

.profile-actions {
    margin-top: 0;
}

.profile-xp-block {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.22);
    text-align: center;
}

.profile-level {
    margin: 0 0 4px;
    font-family: var(--font-pixel, monospace);
    font-size: 0.95rem;
    color: #ffe08a;
}

.profile-xp {
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: #d8e6ff;
}

.profile-xpbar {
    margin: 0 auto 6px;
    max-width: 240px;
}

.profile-xp-hint {
    margin: 0;
    font-size: 0.72rem;
    color: #ffe08a;
    line-height: 1.45;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.poketab-row-meta {
    margin-top: 2px;
    font-size: 0.68rem;
    color: #9eb0c8;
    letter-spacing: 0.02em;
}

.join-toast-levelup {
    border-color: #ffe08a;
    color: #fff6d0;
    background: rgba(40, 28, 8, 0.92);
    text-align: center;
    line-height: 1.35;
}

.join-toast-levelup strong {
    color: #ffd76a;
    letter-spacing: 0.06em;
}

.skin-hero-name {
    text-align: center;
    margin: 0;
}

.skin-name-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: min(100%, 320px);
}

.skin-name-label {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
}

.skin-name-input {
    width: 100%;
    box-sizing: border-box;
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    color: var(--text-dark);
    text-align: center;
    padding: 10px 12px;
    border: 3px solid var(--panel-border);
    background: var(--panel-inner);
    box-shadow: inset 2px 2px 0 rgba(45, 36, 24, 0.08);
    outline: none;
}

.skin-name-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.skin-name-hint {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

.skin-preview img {
    width: 88px;
    height: 88px;
    image-rendering: pixelated;
    border: 3px solid var(--panel-border);
    background: #fff;
    animation: bob 1.2s steps(2) infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.skin-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 0;
    border: 3px solid var(--panel-border);
    background: var(--btn-gold);
    color: transparent;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--btn-gold-shadow);
    user-select: none;
    touch-action: manipulation;
    position: relative;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.icon-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.icon-btn-prev::before {
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 10px solid var(--text-dark);
}

.icon-btn-next::before {
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 10px solid var(--text-dark);
}

.icon-btn:active,
.icon-btn.pressed {
    transform: translate(3px, 3px) scale(0.94);
    box-shadow: none;
}

.skin-counter {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
}

/* Pixel Chip + inline balance */
.poke-chips {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    image-rendering: pixelated;
    background:
        linear-gradient(#f5d04a 0 0) 3px 1px / 4px 2px no-repeat,
        linear-gradient(#f5d04a 0 0) 2px 2px / 6px 6px no-repeat,
        linear-gradient(#c9a227 0 0) 3px 3px / 4px 4px no-repeat,
        #8b6914;
    border: 1px solid #5c4510;
    border-radius: 50%;
    box-shadow: 1px 1px 0 #3a2d08;
}

.poke-chips--sm {
    width: 8px;
    height: 8px;
}

.balance-line {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--ui-scale));
    color: var(--text-dark);
    line-height: 1;
}

.balance-line--skin {
    margin: 0 0 6px;
}

.balance-line--menu {
    margin: 0 0 2px;
}

.balance-line--profile {
    margin: 0 auto 10px;
    display: flex;
}

.skin-price-tag {
    margin: 6px 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    color: var(--text-dark);
    text-align: center;
    min-height: 1.1em;
    font-weight: normal;
}

.skin-price-tag.is-owned {
    color: #166534;
}

.skin-price-tag.is-expensive {
    color: #991b1b;
}

.panel-pin {
    padding: 20px 24px;
}

.pin-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 14px 0 16px;
}

.pin-slot {
    width: 14px;
    height: 14px;
    border: 3px solid var(--panel-border);
    background: var(--panel-inner);
    box-shadow: inset 2px 2px 0 rgba(45, 36, 24, 0.1);
}

.pin-slot.is-filled {
    background: var(--text-dark);
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.15);
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: min(100%, 340px);
    margin: 0 auto;
}

.pin-key {
    appearance: none;
    min-height: 44px;
    border: 3px solid var(--panel-border);
    background: var(--btn-gold);
    color: var(--text-dark);
    font-family: silkscreen, monospace;
    font-size: calc(12px * var(--ui-scale));
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--btn-gold-shadow);
    touch-action: manipulation;
    user-select: none;
}

.pin-key:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.pin-key-muted {
    visibility: hidden;
    pointer-events: none;
}

.pin-key-back {
    font-size: calc(10px * var(--ui-scale));
}

.skin-purchase-hint {
    margin: 10px 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
    line-height: 1.45;
}

#save-skin-btn.is-unaffordable {
    opacity: 0.55;
    filter: grayscale(0.35);
}

.status {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    text-align: center;
    color: var(--text-muted);
    margin-top: 14px;
    min-height: 1.2rem;
}

.status.error {
    color: var(--danger);
}

.bag-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    padding: 8px 4px 12px;
    justify-items: center;
    overflow: visible;
}

.bag-slot {
    width: 100%;
    max-width: 72px;
    aspect-ratio: 5 / 7;
    border-radius: 4px;
    border: 2px dashed var(--panel-edge);
    background: var(--panel-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    color: var(--text-muted);
    overflow: hidden;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.25);
}

.bag-slot-filled {
    border: 2px solid var(--panel-border);
    border-style: solid;
    background: #2a2218;
    padding: 2px;
}

.bag-slot.bag-slot-vault,
.bag-slot.bag-slot-vault.bag-slot-filled {
    overflow: visible;
    z-index: 0;
}

.bag-slot.bag-slot-vault.vault-slot--graded-high {
    z-index: 1;
}

/* ── Quest board (wood pixel theme) ── */
#quests-screen .panel-quests-wood {
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    padding: 18px 16px 16px;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(90, 58, 28, 0.08) 0px,
            rgba(90, 58, 28, 0.08) 2px,
            transparent 2px,
            transparent 6px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(60, 38, 18, 0.06) 0px,
            rgba(60, 38, 18, 0.06) 1px,
            transparent 1px,
            transparent 5px
        ),
        linear-gradient(180deg, #e8c896 0%, #c9955c 45%, #a87240 100%);
    border: 4px solid #3d2814;
    outline: 3px solid #6b4423;
    outline-offset: -7px;
    box-shadow:
        6px 6px 0 var(--pixel-shadow),
        inset 0 0 0 2px rgba(255, 236, 200, 0.55),
        inset 0 -6px 12px rgba(61, 40, 20, 0.25);
}

.quests-wood-nail {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #4a4a4a;
    border: 2px solid #2a2a2a;
    box-shadow:
        inset 1px 1px 0 #888,
        1px 1px 0 rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 2;
}

.quests-wood-nail--tl { top: 10px; left: 10px; }
.quests-wood-nail--tr { top: 10px; right: 10px; }
.quests-wood-nail--bl { bottom: 10px; left: 10px; }
.quests-wood-nail--br { bottom: 10px; right: 10px; }

.quests-board-title {
    font-family: silkscreen, monospace;
    font-size: calc(14px * var(--ui-scale));
    letter-spacing: 0.08em;
    text-align: center;
    color: #2a1808;
    text-shadow: 1px 1px 0 rgba(255, 236, 200, 0.9);
    margin-bottom: 6px;
}

.quests-weekly-banner {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    line-height: 1.65;
    text-align: center;
    color: #4a3018;
    background: rgba(255, 248, 230, 0.65);
    border: 2px solid #5c3d22;
    padding: 8px 10px;
    margin-bottom: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.quests-timeline {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.quest-node {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 0 10px;
    margin-bottom: 14px;
}

.quest-node--last {
    margin-bottom: 4px;
}

.quest-node-rail {
    position: relative;
    display: flex;
    justify-content: center;
}

.quest-node-rail::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: -14px;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(
        180deg,
        #5c3d22 0px,
        #5c3d22 4px,
        #8b5a2b 4px,
        #8b5a2b 8px
    );
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.2);
}

.quest-node--last .quest-node-rail::before {
    bottom: 50%;
}

.quest-node-dot {
    position: relative;
    z-index: 1;
    width: 14px;
    height: 14px;
    margin-top: 14px;
    flex-shrink: 0;
    background: #6b4423;
    border: 3px solid #3d2814;
    box-shadow:
        inset 0 0 0 1px #a0724a,
        2px 2px 0 rgba(0, 0, 0, 0.35);
}

.quest-node-dot--live {
    background: #5dff9d;
    border-color: #1a8a4a;
    box-shadow:
        inset 0 0 0 1px #b8ffd4,
        0 0 0 2px rgba(93, 255, 157, 0.35),
        2px 2px 0 rgba(0, 0, 0, 0.35);
    animation: quest-pulse 2s ease-in-out infinite;
}

@keyframes quest-pulse {
    0%, 100% { box-shadow: inset 0 0 0 1px #b8ffd4, 0 0 0 2px rgba(93, 255, 157, 0.35), 2px 2px 0 rgba(0, 0, 0, 0.35); }
    50% { box-shadow: inset 0 0 0 1px #b8ffd4, 0 0 0 4px rgba(93, 255, 157, 0.2), 2px 2px 0 rgba(0, 0, 0, 0.35); }
}

.quest-wood-card {
    position: relative;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(139, 90, 43, 0.05) 0px,
            rgba(139, 90, 43, 0.05) 3px,
            transparent 3px,
            transparent 8px
        ),
        linear-gradient(180deg, #fff8ea 0%, #f4ecd8 100%);
    border: 3px solid #3d2814;
    padding: 10px 10px 8px;
    box-shadow:
        3px 3px 0 rgba(26, 20, 14, 0.55),
        inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.quest-wood-card--locked {
    background: linear-gradient(180deg, #d8cfc0 0%, #c4b8a8 100%);
    filter: saturate(0.45);
    opacity: 0.82;
}

.quest-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.quest-badge {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    letter-spacing: 0.06em;
    padding: 3px 6px;
    border: 2px solid;
}

.quest-badge--live {
    color: #0d4a28;
    background: #5dff9d;
    border-color: #1a8a4a;
    box-shadow: 2px 2px 0 rgba(26, 138, 74, 0.35);
}

.quest-badge--locked {
    color: #5a5048;
    background: #b8b0a4;
    border-color: #6b6358;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.quest-week-tag {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    color: #6b5d48;
}

.quest-title {
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--ui-scale));
    color: #2a1808;
    line-height: 1.45;
    margin-bottom: 5px;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6);
}

.quest-blurb {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    line-height: 1.65;
    color: #5a4030;
    margin-bottom: 8px;
}

.quest-blurb--locked {
    color: #7a7068;
}

.quest-sub-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    border-top: 2px dashed #c4a574;
    padding-top: 6px;
}

.quest-sub {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: start;
    padding: 5px 0;
    border-bottom: 1px solid rgba(139, 90, 43, 0.2);
}

.quest-sub:last-child {
    border-bottom: none;
}

.quest-sub-id {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: #8b5a2b;
    min-width: 1.6em;
    text-align: left;
    line-height: 1.4;
}

.quest-sub--current .quest-sub-id {
    color: #0d4a28;
}

.quest-sub--done .quest-sub-id {
    color: #1a5a8a;
}

.quest-sub--done .quest-sub-name {
    color: #5a6a78;
    text-decoration: line-through;
    text-decoration-color: rgba(90, 106, 120, 0.45);
}

.quest-sub--done .quest-sub-hint {
    color: #9aa8b4;
}

.quest-node-dot--done {
    background: #7eb8ff;
    border-color: #2a5a9e;
    box-shadow: 0 0 0 2px rgba(126, 184, 255, 0.35);
}

.quest-badge--complete {
    color: #1a4a6e;
    background: linear-gradient(180deg, #b8dcff 0%, #8ec4f8 100%);
    border-color: #2a6a9e;
}

.quest-node--complete .quest-wood-card {
    border-color: #5a8ab8;
}

.quest-sub-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.quest-sub-name {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: #2a2218;
    line-height: 1.4;
}

.quest-sub--current .quest-sub-name {
    color: #0d4a28;
}

.quest-sub-hint {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    color: #8b7355;
    line-height: 1.5;
}

.quest-prize-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 6px 8px;
    background: linear-gradient(90deg, #ffd966 0%, #ffe799 100%);
    border: 2px solid #b8860b;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.quest-prize-label {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    color: #6b4a08;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.quest-prize-value {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--ui-scale));
    color: #3d2814;
    line-height: 1.4;
}

.quest-locked-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: repeating-linear-gradient(
        45deg,
        rgba(90, 80, 72, 0.12) 0px,
        rgba(90, 80, 72, 0.12) 4px,
        rgba(90, 80, 72, 0.06) 4px,
        rgba(90, 80, 72, 0.06) 8px
    );
    border: 2px dashed rgba(90, 80, 72, 0.35);
    margin: 6px;
    pointer-events: none;
}

.quest-lock-icon {
    font-family: silkscreen, monospace;
    font-size: calc(18px * var(--ui-scale));
    color: #6b6358;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.4);
}

.quest-locked-overlay span:last-child {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--ui-scale));
    color: #6b6358;
    letter-spacing: 0.04em;
}

.quests-back-btn {
    flex-shrink: 0;
}

#quests-screen .screen-nav .quests-back-btn {
    padding: 4px 8px;
    font-size: calc(7px * var(--ui-scale));
    letter-spacing: 0.02em;
    min-height: 0;
    line-height: 1.3;
}

#quests-screen .screen-nav {
    margin: -6px 0 8px;
    padding-bottom: 6px;
}

.screen-nav .quests-back-btn,
.screen-nav .lb-back-btn {
    width: auto;
}

.screen-nav:not(:has(.btn-screen-back:not(.hidden))) {
    display: none;
}

#quests-screen .subtitle {
    margin-bottom: 0;
}

.bag-card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 2px;
}

.back-row {
    margin-top: 14px;
}

/* Top back nav on inner menu screens */
.screen-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: -4px 0 12px;
    padding-bottom: 10px;
    border-bottom: 2px dashed rgba(45, 36, 24, 0.16);
}

.screen-nav .btn-screen-back {
    margin: 0;
    padding: 8px 14px;
    font-size: calc(9px * var(--ui-scale));
    letter-spacing: 0.04em;
}

#leaderboard-screen .screen-nav {
    border-bottom-color: rgba(255, 215, 100, 0.28);
    margin-bottom: 8px;
    padding-bottom: 8px;
}

#leaderboard-screen .screen-nav .btn-screen-back {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 215, 100, 0.45);
    color: #ffe9a8;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.panel-with-nav > .panel-pixel-title:first-of-type,
.panel-with-nav > .subtitle:first-of-type {
    margin-top: 0;
}

.skin-picker-frame {
    width: 100%;
    padding: 14px 12px;
    border: 3px solid var(--panel-border);
    background: var(--panel-bg);
    box-shadow:
        inset 0 0 0 2px var(--panel-inner),
        3px 3px 0 var(--pixel-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.profile-skin-grid-wrap {
    border: 3px solid var(--panel-border);
    padding: 12px;
    background: var(--panel-bg);
    box-shadow:
        inset 0 0 0 2px var(--panel-inner),
        3px 3px 0 rgba(45, 36, 24, 0.14);
}

#profile-screen .profile-actions {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#profile-screen .profile-actions .btn {
    width: 100%;
    min-height: calc(42px * 1.3);
    padding: 12px 14px;
}

@media (max-width: 420px) {
    #pin-screen,
    #skin-screen,
    #menu-screen,
    #profile-screen,
    #quests-screen,
    #revenue-share-screen,
    #leaderboard-screen,
    #bag-screen,
    #trainer-stats-screen {
        padding: 10px 8px;
    }

    .panel-profile {
        padding: 18px 16px 20px;
    }
}

.spinner {
    width: 32px;
    height: 32px;
    border-radius: 0;
    border: none;
    background:
        linear-gradient(#efefef 0 0) 0 0 / 8px 8px,
        linear-gradient(#c8c8c8 0 0) 8px 0 / 8px 8px,
        linear-gradient(#c8c8c8 0 0) 0 8px / 8px 8px,
        linear-gradient(#efefef 0 0) 8px 8px / 8px 8px,
        linear-gradient(#a8a8a8 0 0) 16px 0 / 8px 8px,
        linear-gradient(#a8a8a8 0 0) 0 16px / 8px 8px,
        linear-gradient(#efefef 0 0) 16px 16px / 8px 8px;
    background-repeat: no-repeat;
    animation: pixel-spin 0.8s steps(8) infinite;
    margin: 0 auto 16px;
    image-rendering: pixelated;
}

@keyframes pixel-spin {
    to { transform: rotate(360deg); }
}

.kins-wallet-pending {
    position: fixed;
    inset: 0;
    z-index: 10250;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(8, 10, 14, 0.42);
    pointer-events: auto;
    image-rendering: pixelated;
}

.kins-wallet-pending.hidden {
    display: none !important;
}

.kins-wallet-pending-card {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 3px solid var(--panel-border);
    background: rgba(255, 248, 234, 0.97);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kins-wallet-pending-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 4px solid #d8d8d8;
    border-top-color: #1a6b3a;
    border-right-color: #2d8a4f;
    animation: kins-wallet-pending-spin 0.72s steps(8) infinite;
    image-rendering: pixelated;
}

@keyframes kins-wallet-pending-spin {
    to { transform: rotate(360deg); }
}

.kins-wallet-pending-label {
    margin: 0;
    max-width: min(90vw, 280px);
    padding: 0 12px;
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 1.45;
    letter-spacing: 0.04em;
    text-align: center;
    color: #eafff0;
    text-shadow: 2px 2px 0 #123a24;
}

body.kins-wallet-pending [data-kins-buy] {
    pointer-events: none;
    opacity: 0.55;
    cursor: wait;
}

.sign-modal {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 226px;
    z-index: 14;
    pointer-events: none;
    image-rendering: pixelated;
}

.sign-modal.hidden {
    display: none;
}

.sign-modal-box {
    position: relative;
    pointer-events: auto;
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 4px 4px,
        #fff8ea;
    border: 3px solid #2d2418;
    box-shadow:
        inset 0 0 0 2px #8b7355,
        4px 4px 0 rgba(0, 0, 0, 0.72);
    border-radius: 0;
    padding: 14px 16px 12px;
    max-width: 420px;
    margin: 0 auto;
}

.sign-modal-box.has-next {
    padding-bottom: 42px;
}

.sign-modal-x.hidden,
.sign-modal-next.hidden,
.sign-modal-skip.hidden {
    display: none;
}

.sign-modal-skip,
.sign-modal-next {
    position: absolute;
    bottom: 10px;
    min-width: 56px;
    height: 28px;
    padding: 0 10px;
    border: 2px solid #2d2418;
    color: #2d2418;
    font-family: silkscreen, "Courier New", monospace;
    font-size: 9px;
    line-height: 24px;
    text-align: center;
    text-transform: lowercase;
    cursor: pointer;
    box-shadow: 2px 2px 0 #1a140e;
    image-rendering: pixelated;
    -webkit-tap-highlight-color: transparent;
}

.sign-modal-next {
    right: 10px;
    background: #ffd966;
}

.sign-modal-skip {
    right: 74px;
    background: #d4c4a8;
}

.sign-modal-skip:active,
.sign-modal-next:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #1a140e;
}

.sign-modal-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #2d2418;
    background: #ffd966;
    color: #2d2418;
    font-family: silkscreen, "Courier New", monospace;
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 #1a140e;
    image-rendering: pixelated;
    -webkit-tap-highlight-color: transparent;
}

.sign-modal-x:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #1a140e;
}

.sign-modal-title {
    font-family: silkscreen, "Courier New", monospace;
    font-size: 15px;
    font-weight: bold;
    line-height: 1.45;
    color: #2a2218;
    margin-bottom: 10px;
    padding-right: 34px;
    letter-spacing: 0.04em;
    text-shadow:
        1px 0 0 #2a2218,
        0 1px 0 #2a2218,
        1px 1px 0 rgba(255, 255, 255, 0.45);
}

.sign-modal-title.no-close-padding {
    padding-right: 0;
}

.sign-modal-body {
    font-family: silkscreen, "Courier New", monospace;
    font-size: 9px;
    line-height: 1.65;
    color: #4a3c28;
    white-space: pre-wrap;
    letter-spacing: 0.02em;
}

.sign-modal-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 2px dashed rgba(139, 115, 85, 0.45);
}

.sign-modal-options.hidden {
    display: none;
}

.sign-modal-box.has-options {
    padding-bottom: 14px;
}

.sign-modal-option {
    appearance: none;
    width: 100%;
    border: 2px solid #2d2418;
    background: #7eb8ff;
    color: #0a2040;
    font-family: silkscreen, "Courier New", monospace;
    font-size: 9px;
    line-height: 1.4;
    padding: 8px 10px;
    text-align: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 #2a5a9e;
    image-rendering: pixelated;
    -webkit-tap-highlight-color: transparent;
}

.sign-modal-option-exit {
    background: #f4ecd8;
    color: #4a3c28;
    box-shadow: 2px 2px 0 #8b7355;
}

.sign-modal-option:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #2a5a9e;
}

.sign-modal-option-exit:active {
    box-shadow: 1px 1px 0 #8b7355;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Game screen (unchanged dark) ── */
#game-screen {
    padding: 0;
    justify-content: stretch;
    position: relative;
    background: #87ceeb;
    touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#game-screen,
#game-screen * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

#game-screen *::selection {
    background: transparent;
    color: inherit;
}

#game-screen::after {
    display: none;
}

.game-hud-stack {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    max-width: min(92vw, 240px);
    pointer-events: none;
}

.game-hud {
    position: static;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.18);
    font-family: silkscreen, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    image-rendering: pixelated;
}

.game-hud-deposit {
    pointer-events: auto;
    position: relative;
}

.game-hud-wallet {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.18);
    font-family: silkscreen, "Courier New", monospace;
    image-rendering: pixelated;
}

.game-hud-wallet-balance-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
}

.game-hud-wallet-label {
    font-size: 8px;
    letter-spacing: 0.08em;
    color: #7a6555;
}

.game-hud-wallet-value {
    font-size: 12px;
    color: #1a140e;
    line-height: 1.2;
    margin-left: auto;
}

.game-hud-wallet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.game-hud-wallet-btn {
    font-size: 8px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 7px 6px;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.game-hud-wallet-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.game-hud-wallet-btn:active:not(:disabled) {
    transform: translate(1px, 1px);
}

.game-hud-wallet-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.game-hud-wallet-btn--deposit {
    background: #1a6b3a;
    box-shadow: 2px 2px 0 #0e4024;
    color: #eafff0;
}

.game-hud-wallet-btn--withdraw {
    background: #7a2828;
    box-shadow: 2px 2px 0 #451616;
    color: #ffecec;
}

.game-hud-chips-actions {
    display: flex;
    gap: 6px;
}

.game-hud-chips-btn {
    flex: 1;
    padding: 7px 8px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    font-family: silkscreen, monospace;
    font-size: 9px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
}

.game-hud-chips-btn--buy {
    background: #1a6b3a;
    box-shadow: 2px 2px 0 #0e4024;
    color: #eafff0;
}

.game-hud-chips-btn--sell {
    background: #7a2828;
    box-shadow: 2px 2px 0 #451616;
    color: #ffecec;
}

.game-hud-wallet-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    padding: 4px 2px;
}

.game-hud-wallet-link-label {
    font-family: silkscreen, monospace;
    font-size: 8px;
    color: #5a4a3a;
    letter-spacing: 0.04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-hud-chips-btn--connect {
    flex: 0 0 auto;
    background: #2a4a6b;
    box-shadow: 2px 2px 0 #16304a;
    color: #e8f4ff;
    padding: 5px 8px;
    font-size: 8px;
}

.profile-wallet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
}

.profile-wallet-label {
    font-family: silkscreen, monospace;
    font-size: 10px;
    color: #5a4a3a;
}

.profile-chips-btn--connect {
    background: #2a4a6b;
    box-shadow: 2px 2px 0 #16304a;
    color: #e8f4ff;
}

.game-hud-chips-btn:active {
    transform: translate(1px, 1px);
}

.game-hud-chips-btn--buy:active {
    box-shadow: 1px 1px 0 #0e4024;
}

.game-hud-chips-btn--sell:active {
    box-shadow: 1px 1px 0 #451616;
}

.game-hud-chips-btn.is-active {
    outline: 2px solid #ffd838;
    outline-offset: 1px;
}

.game-hud-chips-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    text-align: center;
}

.game-hud-chips-form.hidden {
    display: none;
}

.game-hud-chips-amount-input {
    width: min(100%, 132px);
    padding: 6px 8px;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    font-family: silkscreen, monospace;
    font-size: 11px;
    color: var(--text-dark);
    background: #fff;
    text-align: center;
    box-sizing: border-box;
}

.game-hud-chips-submit {
    width: min(100%, 132px);
    padding: 8px 10px;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.game-hud-chips-submit--buy {
    background: #1a6b3a;
    box-shadow: 2px 2px 0 #0e4024;
    color: #eafff0;
}

.game-hud-chips-submit--sell {
    background: #7a2828;
    box-shadow: 2px 2px 0 #451616;
    color: #ffecec;
}

.game-hud-chips-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.game-hud-chips-submit:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.game-hud-chips-close {
    width: min(100%, 132px);
    margin-top: 0;
    padding: 7px 10px;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    font-family: silkscreen, monospace;
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
}

.game-hud-chips-close:active {
    transform: translate(1px, 1px);
}

.game-hud-chips-toast {
    padding: 8px 10px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.16);
}

.game-hud-chips-toast-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-hud-chips-toast-chips {
    flex-shrink: 0;
}

.game-hud-chips-toast.hidden {
    display: none;
}

.game-hud-chips-toast-text {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-family: silkscreen, monospace;
    font-size: 8px;
    line-height: 1.45;
    letter-spacing: 0.03em;
    color: var(--text-dark);
}

.game-hud-chips-toast.is-error .game-hud-chips-toast-text {
    color: #8b2020;
}

.game-hud-chips-toast.is-success .game-hud-chips-toast-text {
    color: #1a5c34;
}

.game-hud-deposit-status {
    margin: 6px 0 0;
    min-height: 1.2em;
    font-size: 8px;
    line-height: 1.35;
    color: var(--text-muted);
}

.game-hud-deposit.hidden {
    display: none;
}

.hud-line--level .hud-v {
    color: #8b5a14;
}

.hud-line--xp .hud-v {
    color: #2d6a2d;
}

.hud-line {
    text-transform: uppercase;
    white-space: nowrap;
}

.hud-v {
    color: #1a140e;
}

.hud-balance-wrap {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    vertical-align: middle;
}

.hud-chips {
    vertical-align: middle;
}

.skin-economy-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 0 0 6px;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--ui-scale));
    color: var(--text-dark);
}

.skin-economy-row--cost {
    margin-top: 4px;
}

.skin-economy-label {
    color: var(--text-muted);
    font-size: calc(8px * var(--ui-scale));
}

.skin-economy-value {
    color: var(--text-dark);
}

.skin-price-value.is-owned {
    color: #166534;
}

.skin-price-value.is-expensive {
    color: #991b1b;
}

.btn-leave {
    padding: 8px 14px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    background: var(--btn-red);
    color: #3a0808;
    border: 3px solid var(--panel-border);
    border-radius: 0;
    box-shadow: 3px 3px 0 var(--btn-red-shadow);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.game-top-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}

.menu-audio-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin: 2px 0 10px;
}

.audio-mute-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border: 2px solid var(--panel-border);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.18);
    font-family: silkscreen, "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text-dark);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.audio-mute-btn--game {
    width: 100%;
}

.audio-mute-btn:active,
.audio-mute-btn.pressed {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.audio-mute-btn.is-muted {
    background: #f3ece2;
    color: var(--text-muted);
}

.audio-mute-glyph {
    font-size: 14px;
    line-height: 1;
}

.audio-mute-btn.is-muted .audio-mute-glyph {
    opacity: 0.45;
    text-decoration: line-through;
}

.audio-mute-text {
    text-transform: uppercase;
}

.game-quests-btn {
    padding: 8px 14px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    border: 3px solid var(--panel-border);
    border-radius: 0;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.game-quests-btn:active,
.game-quests-btn.pressed {
    transform: translate(3px, 3px) scale(0.96);
    box-shadow: none;
}

.btn-leave:active,
.btn-leave.pressed {
    transform: translate(3px, 3px) scale(0.96);
    box-shadow: none;
}

/* ── In-game bag (side drawer) ── */
.game-bag-btn {
    position: absolute;
    right: 12px;
    bottom: 108px;
    left: auto;
    top: auto;
    z-index: 12;
    width: 72px;
    height: 72px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    display: grid;
    place-items: center;
    animation: bag-idle-bob 2.4s steps(2, end) infinite;
}

.game-bag-btn-frame {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #3d3010;
    outline: 2px solid #ffe566;
    outline-offset: -5px;
    background:
        repeating-conic-gradient(#fff8dc 0% 25%, #f4e4a8 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #ffe566 0%, #e6b800 100%);
    box-shadow:
        3px 3px 0 rgba(0, 0, 0, 0.45),
        inset 2px 2px 0 rgba(255, 255, 255, 0.55);
    image-rendering: pixelated;
    pointer-events: none;
}

.game-bag-btn-img {
    position: relative;
    z-index: 1;
    display: block;
    width: 34px;
    height: 34px;
    margin: 0;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 2px 0 rgba(45, 36, 24, 0.35));
    pointer-events: none;
}

.game-bag-btn:active,
.game-bag-btn.pressed,
.game-bag-btn[aria-expanded="true"] {
    animation: none;
    transform: translateY(2px);
}

.game-bag-btn[aria-expanded="true"] .game-bag-btn-frame {
    outline-color: #7ee8c8;
    background:
        repeating-conic-gradient(#e8fff4 0% 25%, #c8f0dc 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #7ee8c8 0%, #3cb890 100%);
}

@keyframes bag-idle-bob {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(1px); }
}

/* ── In-game Pokédex (right edge, stacked above the bag) ── */
.game-pokedex-btn {
    position: absolute;
    right: 12px;
    bottom: 192px;
    left: auto;
    top: auto;
    z-index: 12;
    width: 72px;
    height: 72px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    display: grid;
    place-items: center;
    animation: pokedex-idle-bob 2.5s steps(2, end) infinite;
}

.game-pokedex-btn[hidden] {
    display: none !important;
}

.game-pokedex-btn-frame {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #5c1414;
    outline: 2px solid #ff8f8f;
    outline-offset: -5px;
    background:
        repeating-conic-gradient(#ffecec 0% 25%, #f8c8c8 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #ff6a6a 0%, #d43030 100%);
    box-shadow:
        3px 3px 0 rgba(0, 0, 0, 0.45),
        inset 2px 2px 0 rgba(255, 255, 255, 0.55);
    image-rendering: pixelated;
    pointer-events: none;
}

.game-pokedex-btn-img {
    position: relative;
    z-index: 1;
    display: block;
    width: 38px;
    height: 38px;
    margin: 0;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 2px 0 rgba(92, 20, 20, 0.4));
    pointer-events: none;
}

.game-pokedex-btn:active,
.game-pokedex-btn.pressed,
.game-pokedex-btn[aria-expanded="true"] {
    animation: none;
    transform: translateY(2px);
}

.game-pokedex-btn[aria-expanded="true"] .game-pokedex-btn-frame {
    outline-color: #7ee8c8;
    background:
        repeating-conic-gradient(#e8fff4 0% 25%, #c8f0dc 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #7ee8c8 0%, #3cb890 100%);
}

@keyframes pokedex-idle-bob {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(1px); }
}

/* ── In-game PokéTab (top, mirrors bag) ── */
.game-poketab-btn {
    position: absolute;
    right: 12px;
    bottom: 276px;
    left: auto;
    top: auto;
    z-index: 12;
    width: 72px;
    height: 72px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    display: grid;
    place-items: center;
    animation: poketab-idle-bob 2.6s steps(2, end) infinite;
}

.game-poketab-btn[hidden] {
    display: none !important;
}

.game-poketab-btn-frame {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #1a3d5c;
    outline: 2px solid #7ec8ff;
    outline-offset: -5px;
    background:
        repeating-conic-gradient(#eaf6ff 0% 25%, #c8e4f8 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #7ec8ff 0%, #3d8fd4 100%);
    box-shadow:
        3px 3px 0 rgba(0, 0, 0, 0.45),
        inset 2px 2px 0 rgba(255, 255, 255, 0.55);
    image-rendering: pixelated;
    pointer-events: none;
}

.game-poketab-btn-img {
    position: relative;
    z-index: 1;
    display: block;
    width: 34px;
    height: 34px;
    margin: 0;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 2px 0 rgba(26, 61, 92, 0.35));
    pointer-events: none;
}

.game-poketab-btn:active,
.game-poketab-btn.pressed,
.game-poketab-btn[aria-expanded="true"] {
    animation: none;
    transform: translateY(2px);
}

.game-poketab-btn[aria-expanded="true"] .game-poketab-btn-frame {
    outline-color: #7ee8c8;
    background:
        repeating-conic-gradient(#e8fff4 0% 25%, #c8f0dc 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #7ee8c8 0%, #3cb890 100%);
}

@keyframes poketab-idle-bob {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(1px); }
}

.game-poketab-btn[aria-expanded="true"] .game-poketab-btn-frame {
    box-shadow:
        0 0 0 3px #f8f8f0,
        0 0 0 5px #2a2218,
        inset 0 3px 0 rgba(255, 255, 255, 0.45),
        inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.poketab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 2;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    border: 2px solid #2a2218;
    background: #e83838;
    color: #fff;
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 14px;
    text-align: center;
    box-shadow: 0 2px 0 rgba(26, 20, 14, 0.35);
    pointer-events: none;
}

.poketab-badge.hidden {
    display: none;
}

.poketab-crt-line.poketab-crt-alert {
    color: #ffb4c8;
    animation: poketab-alert-blink 1s steps(2) infinite;
}

@keyframes poketab-alert-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ── PokéTab handheld link device ── */
body.poketab-open {
    overflow: hidden;
}

.poketab-screen {
    position: fixed;
    inset: 0;
    z-index: 45000;
    display: grid;
    place-items: center;
    padding: 10px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.poketab-screen.hidden {
    display: none;
}

.poketab-backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background:
        repeating-conic-gradient(#0e1a28 0% 25%, #0a1420 0% 50%) 50% / 6px 6px,
        radial-gradient(ellipse at 50% 35%, #1a3a58 0%, #060c14 72%);
}

.poketab-room {
    position: relative;
    z-index: 1;
    --pt-scale: 0.78;
    --pt-ui-font-mul: 1.45;
    --pt-left-rail: calc(184px * var(--pt-scale));
    --pt-right-rail: calc(260px * var(--pt-scale));
    --pt-btn-w: calc(148px * var(--pt-scale));
    --pt-btn-h: calc(54px * var(--pt-scale));
    --pt-btn-gap: calc(10px * var(--pt-scale));
    --pt-btn-font: calc(8px * var(--pt-ui-font-mul));
    --pt-led-size: calc(10px * var(--pt-scale));
    --pt-monitor-height: min(calc(90vh * var(--pt-scale)), calc(760px * var(--pt-scale)));
    --pt-monitor-min-height: calc(640px * var(--pt-scale));
    --pt-monitor-max-height: calc(920px * var(--pt-scale));
    --card-scale: 0.91;
    --battle-sprite-scale: 2;
    --battle-hp-scale: 1.5;
    --battle-font-scale: 2;
    --battle-hp-width: calc(118px * var(--pt-scale, 0.78));
    width: min(calc(960px * var(--pt-scale)), 98vw);
    animation: poketab-rise 0.4s cubic-bezier(0.34, 1.25, 0.64, 1);
}

@keyframes poketab-rise {
    from { transform: translateY(20px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.poketab-console {
    display: grid;
    grid-template-columns: var(--pt-left-rail) minmax(0, 1fr) var(--pt-right-rail);
    gap: 0;
    align-items: stretch;
    min-height: calc(720px * var(--pt-scale));
    position: relative;
    overflow: hidden;
    background:
        repeating-conic-gradient(#3a5a6a 0% 25%, #2e4a58 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #4a6a7a 0%, #2a4a58 100%);
    border: 4px solid #142838;
    box-shadow:
        inset 0 0 0 2px #6a8a9a,
        0 0 0 2px #1a3040,
        8px 8px 0 rgba(0, 0, 0, 0.6);
}

.poketab-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px 8px;
    background:
        repeating-linear-gradient(
            180deg,
            #243848 0,
            #243848 6px,
            #1e3040 6px,
            #1e3040 12px
        );
    border: 2px solid #142838;
}

.poketab-rail-left {
    border-right: 3px solid #0e2030;
    box-shadow: inset -3px 0 0 rgba(255, 255, 255, 0.06);
    align-items: center;
    justify-content: center;
    gap: calc(12px * var(--pt-scale));
    padding: calc(14px * var(--pt-scale)) calc(10px * var(--pt-scale));
    min-width: 0;
}

.poketab-left-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--pt-btn-gap);
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: calc(6px * var(--pt-scale)) 0;
}

.poketab-left-btn {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(6px * var(--pt-scale));
    width: var(--pt-btn-w);
    height: var(--pt-btn-h);
    min-height: var(--pt-btn-h);
    max-height: var(--pt-btn-h);
    flex-shrink: 0;
    padding: calc(8px * var(--pt-scale)) calc(6px * var(--pt-scale));
}

.poketab-rail-right {
    border-left: 3px solid #0e2030;
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.06);
    align-items: stretch;
    position: relative;
    overflow: hidden;
    gap: 8px;
    padding: 10px 8px 10px;
    z-index: 1;
    min-width: 0;
}

.poketab-grip {
    width: 22px;
    height: 72px;
    background:
        repeating-linear-gradient(
            180deg,
            #1a3040 0,
            #1a3040 4px,
            #142838 4px,
            #142838 8px
        );
    border: 2px solid #0e2030;
    border-radius: 4px;
    box-shadow:
        inset 2px 0 0 rgba(255, 255, 255, 0.08),
        inset -2px 0 0 rgba(0, 0, 0, 0.25);
}

.poketab-rail-vents {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    padding: 0 6px;
}

.poketab-rail-vents span {
    display: block;
    height: 4px;
    background: #0e2030;
    border: 1px solid #1a3040;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.4);
}

.poketab-rail-bolt {
    width: 12px;
    height: 12px;
    background: #4a6a7a;
    border: 2px solid #142838;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
}

.poketab-rail-bolt-b {
    margin-top: auto;
}

.poketab-knob {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background:
        repeating-conic-gradient(#5a7a8a 0% 25%, #4a6a7a 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #6a8a9a 0%, #3a5a6a 100%);
    border: 3px solid #142838;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.2),
        2px 2px 0 rgba(0, 0, 0, 0.4);
}

.poketab-speaker {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 6px;
    background: #142838;
    border: 2px solid #0e2030;
}

.poketab-speaker span {
    width: 8px;
    height: 8px;
    background: #0a1828;
    border: 1px solid #1a3040;
    border-radius: 50%;
}

.poketab-sim-slot {
    width: 28px;
    height: 14px;
    margin-top: auto;
    background: #0a1828;
    border: 2px solid #142838;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.poketab-main {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    min-height: 0;
    padding: calc(12px * var(--pt-scale)) calc(10px * var(--pt-scale)) calc(10px * var(--pt-scale));
}

.poketab-main-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: calc(8px * var(--pt-scale));
}

.poketab-top-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: #1a3040;
    border: 2px solid #142838;
}

.poketab-brand {
    margin-left: auto;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.08em;
    color: #7ee8ff;
    text-shadow: 0 0 6px rgba(126, 232, 255, 0.45);
}

.poketab-led {
    width: 10px;
    height: 10px;
    border: 2px solid #142838;
    background: #1a3040;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.12);
}

.poketab-console[data-led-state="power"] .poketab-led-power,
.poketab-console[data-led-state="boot"] .poketab-led-power,
.poketab-console[data-led-state="ready"] .poketab-led-ok,
.poketab-console[data-led-state="ok"] .poketab-led-ok {
    background: #4ae8c8;
    box-shadow: 0 0 8px #4ae8c8;
    animation: poketab-led-blink 0.8s steps(2) infinite;
}

.poketab-console[data-led-state="boot"] .poketab-led-busy,
.poketab-console[data-led-state="busy"] .poketab-led-busy {
    background: #7ec8ff;
    box-shadow: 0 0 8px #7ec8ff;
    animation: poketab-led-blink 0.25s steps(2) infinite;
}

.poketab-console[data-led-state="error"] .poketab-led-error {
    background: #ff7a9a;
    box-shadow: 0 0 10px #ff7a9a;
    animation: poketab-led-blink 0.35s steps(2) infinite;
}

.poketab-console[data-led-state="busy"] .poketab-led-power {
    background: #4ae8c8;
    box-shadow: 0 0 6px #4ae8c8;
}

@keyframes poketab-led-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.poketab-monitor-wrap {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

.poketab-monitor-bezel {
    padding: 10px 12px;
    background: linear-gradient(180deg, #5a7a8a 0%, #3a5a6a 100%);
    border: 3px solid #142838;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14);
}

.poketab-monitor-glass {
    position: relative;
    height: var(--pt-monitor-height);
    min-height: var(--pt-monitor-min-height);
    max-height: var(--pt-monitor-max-height);
    overflow: hidden;
    background: linear-gradient(180deg, #2a6a9a 0%, #1e5080 55%, #1a4878 100%);
    border: 4px solid #0e2848;
    box-shadow:
        inset 0 0 32px rgba(120, 200, 255, 0.28),
        inset 0 0 0 2px #3a88b8;
}

.poketab-monitor-inner--battle {
    padding: 4px 6px;
    overflow: hidden;
}

.poketab-scanlines {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 2px,
        rgba(0, 30, 60, 0.12) 2px,
        rgba(0, 30, 60, 0.12) 4px
    );
    animation: poketab-scan-drift 8s linear infinite;
}

.poketab-monitor-glow {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 38%, rgba(180, 230, 255, 0.18) 0%, transparent 68%);
    animation: poketab-glow-pulse 2.5s ease-in-out infinite;
}

@keyframes poketab-scan-drift {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

@keyframes poketab-glow-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.poketab-monitor-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    overflow: hidden;
    padding: 12px 14px;
    font-family: silkscreen, monospace;
    color: #c8f0ff;
    text-shadow: 0 0 4px rgba(160, 220, 255, 0.35);
}

.poketab-monitor-label {
    margin: 8px 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.14em;
    text-align: center;
    color: #8ab0c0;
}

.poketab-view {
    display: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    flex-direction: column;
    gap: 8px;
}

.poketab-view.active {
    display: flex;
    animation: poketab-view-in 0.1s steps(2);
}

@keyframes poketab-view-in {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.poketab-crt-title {
    margin: 0 0 8px;
    font-size: calc(10px * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.08em;
    color: #e8f8ff;
    text-shadow: 0 0 8px rgba(200, 240, 255, 0.5);
}

.poketab-crt-line {
    margin: 0 0 6px;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45));
    line-height: 1.5;
    color: #a8e8ff;
}

.poketab-crt-line.poketab-crt-hint {
    margin-top: 10px;
    color: rgba(168, 232, 255, 0.55);
    animation: poketab-hint-blink 1.4s steps(2) infinite;
}

@keyframes poketab-hint-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.poketab-crt-cursor {
    margin: 4px 0 0;
    font-size: calc(10px * var(--pt-ui-font-mul, 1.45));
    color: #7ec8ff;
    animation: poketab-cursor-blink 0.9s steps(2) infinite;
}

@keyframes poketab-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.poketab-tab-row {
    display: flex;
    flex-direction: column;
    gap: var(--pt-btn-gap);
    width: 100%;
}

.poketab-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(6px * var(--pt-scale));
    width: var(--pt-btn-w);
    height: var(--pt-btn-h);
    min-height: var(--pt-btn-h);
    max-height: var(--pt-btn-h);
    padding: calc(8px * var(--pt-scale)) calc(6px * var(--pt-scale));
    font-family: silkscreen, monospace;
    font-size: var(--pt-btn-font);
    letter-spacing: 0.04em;
    color: #d8f0ff;
    cursor: pointer;
    background:
        repeating-conic-gradient(#4a6a7a 0% 25%, #3a5a6a 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #5a7a8a 0%, #3a5a6a 100%);
    border: 2px solid #142838;
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.22),
        1px 1px 0 rgba(0, 0, 0, 0.45);
}

.poketab-tab:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45);
}

.poketab-tab.active {
    background:
        repeating-conic-gradient(#5a8aa8 0% 25%, #4a7a98 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #6a9ab8 0%, #4a7a98 100%);
    border-color: #7ec8ff;
    color: #fff;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.18),
        0 0 10px rgba(126, 200, 255, 0.35),
        2px 2px 0 rgba(0, 0, 0, 0.4);
}

.poketab-tab.active .poketab-tab-led {
    background: #4ae8c8;
    box-shadow: 0 0 6px #4ae8c8;
}

.poketab-tab.poketab-tab-alert .poketab-tab-led {
    background: #ff7a9a;
    box-shadow: 0 0 8px #ff7a9a;
    animation: poketab-led-blink 0.4s steps(2) infinite;
}

.poketab-tab-led {
    width: var(--pt-led-size);
    height: var(--pt-led-size);
    border: 1px solid #142838;
    background: #2a4a58;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.35);
}

.poketab-tab-label {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: calc(3px * var(--pt-scale));
    width: 100%;
    line-height: 1.15;
    text-align: center;
    letter-spacing: 0.03em;
}

.poketab-tab-badge {
    display: inline-block;
    min-width: calc(12px * var(--pt-scale));
    padding: 0 calc(3px * var(--pt-scale));
    font-size: calc(7px * var(--pt-ui-font-mul));
    line-height: calc(11px * var(--pt-scale));
    background: #e83838;
    color: #fff;
    border: 1px solid #881818;
    flex-shrink: 0;
}

.poketab-tab-badge.hidden {
    display: none;
}

.poketab-exit {
    width: 100%;
    box-sizing: border-box;
    padding: calc(10px * var(--pt-scale));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--pt-ui-font-mul));
    letter-spacing: 0.1em;
    color: #ffc8d8;
    cursor: pointer;
    background: #3a2848;
    border: 2px solid #142838;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.poketab-exit:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

/* ── PokéTab Battle ── */
.poketab-battle-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(6px * var(--pt-scale));
    width: var(--pt-btn-w);
    height: var(--pt-btn-h);
    min-height: var(--pt-btn-h);
    max-height: var(--pt-btn-h);
    box-sizing: border-box;
    padding: calc(8px * var(--pt-scale)) calc(6px * var(--pt-scale));
    font-family: silkscreen, monospace;
    font-size: var(--pt-btn-font);
    letter-spacing: 0.14em;
    color: #2a1800;
    cursor: pointer;
    overflow: hidden;
    background:
        repeating-conic-gradient(#ffd838 0% 25%, #f8c020 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #ffe850 0%, #e8a818 55%, #c88808 100%);
    border: 3px solid #142838;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        0 0 0 2px #886008,
        3px 3px 0 rgba(0, 0, 0, 0.55);
    animation: poketab-battle-glow 2.4s ease-in-out infinite;
}

.poketab-battle-btn-alert {
    animation: poketab-battle-alert 0.5s steps(2) infinite;
}

@keyframes poketab-battle-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.08); }
}

@keyframes poketab-battle-alert {
    0%, 100% { box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 0 0 2px #886008, 0 0 12px #ff4040, 3px 3px 0 rgba(0,0,0,0.55); }
    50% { box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 0 0 2px #886008, 0 0 20px #ff6060, 3px 3px 0 rgba(0,0,0,0.55); }
}

.poketab-battle-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.poketab-battle-btn-shine {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: poketab-battle-shine 3.2s ease-in-out infinite;
    pointer-events: none;
}

.poketab-battle-btn .poketab-tab-label,
.poketab-battle-btn .poketab-tab-led {
    position: relative;
    z-index: 1;
}

.poketab-battle-btn .poketab-tab-led {
    background: #a86808;
    border-color: #142838;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.poketab-battle-btn-alert .poketab-tab-led {
    background: #ff4050;
    box-shadow: 0 0 8px #ff4050;
    animation: poketab-led-blink 0.4s steps(2) infinite;
}

@keyframes poketab-battle-shine {
    from { transform: translateX(-120%); }
    to { transform: translateX(120%); }
}

/* ── Right-rail battle feed (red pixel LCD) ── */
.poketab-duel-module {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.poketab-duel-plastic {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    padding: calc(6px * var(--pt-scale, 1.3)) calc(5px * var(--pt-scale, 1.3)) calc(5px * var(--pt-scale, 1.3));
    background:
        repeating-conic-gradient(#4a5868 0% 25%, #3a4858 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #5a6878 0%, #3a4858 100%);
    border: 3px solid #142838;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.12),
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        2px 2px 0 rgba(0, 0, 0, 0.45);
}

.poketab-duel-module-alert .poketab-duel-plastic {
    border-color: #881828;
    box-shadow:
        inset 0 2px 0 rgba(255, 160, 160, 0.18),
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 0 14px rgba(255, 48, 64, 0.55),
        2px 2px 0 rgba(0, 0, 0, 0.45);
    animation: poketab-duel-plastic-pulse 0.9s steps(2) infinite;
}

@keyframes poketab-duel-plastic-pulse {
    0%, 100% { border-color: #881828; }
    50% { border-color: #ff4050; }
}

.poketab-duel-bezel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: calc(7px * var(--pt-scale, 1.3)) calc(6px * var(--pt-scale, 1.3));
    background: linear-gradient(180deg, #6a4048 0%, #4a2830 100%);
    border: 2px solid #281018;
    box-shadow: inset 0 1px 0 rgba(255, 200, 200, 0.15);
}

.poketab-duel-glass {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(180px * var(--pt-scale, 1.3));
    overflow: hidden;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.14) 0,
            rgba(0, 0, 0, 0.14) 1px,
            transparent 1px,
            transparent 3px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(0, 0, 0, 0.1) 0,
            rgba(0, 0, 0, 0.1) 1px,
            transparent 1px,
            transparent 3px
        ),
        radial-gradient(ellipse at 50% 28%, #5a1828 0%, #280810 45%, #120408 100%);
    border: 3px solid #180810;
    box-shadow:
        inset 0 0 28px rgba(255, 40, 60, 0.22),
        inset 0 0 0 1px rgba(255, 120, 130, 0.12);
}

.poketab-duel-module-alert .poketab-duel-glass {
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.16) 0,
            rgba(0, 0, 0, 0.16) 1px,
            transparent 1px,
            transparent 3px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(0, 0, 0, 0.12) 0,
            rgba(0, 0, 0, 0.12) 1px,
            transparent 1px,
            transparent 3px
        ),
        radial-gradient(ellipse at 50% 28%, #8a2038 0%, #401018 42%, #180408 100%);
    box-shadow:
        inset 0 0 36px rgba(255, 48, 64, 0.35),
        inset 0 0 0 1px rgba(255, 140, 150, 0.2);
    animation: poketab-duel-screen-pulse 1.1s steps(2) infinite;
}

@keyframes poketab-duel-screen-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.12); }
}

.poketab-duel-scanlines {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.22) 2px,
        rgba(0, 0, 0, 0.22) 4px
    );
    animation: poketab-scan-drift 8s linear infinite;
}

.poketab-duel-pixelgrid {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.35;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 80, 90, 0.08) 0,
            rgba(255, 80, 90, 0.08) 1px,
            transparent 1px,
            transparent 4px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 80, 90, 0.06) 0,
            rgba(255, 80, 90, 0.06) 1px,
            transparent 1px,
            transparent 4px
        );
}

.poketab-duel-glow {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 35%, rgba(255, 100, 110, 0.2) 0%, transparent 70%);
}

.poketab-duel-inner {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: calc(8px * var(--pt-scale, 1.3)) calc(7px * var(--pt-scale, 1.3)) calc(7px * var(--pt-scale, 1.3));
}

.poketab-duel-head {
    flex-shrink: 0;
    margin: 0 0 calc(8px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.1em;
    color: #ff9098;
    text-align: center;
    text-shadow: 0 0 8px rgba(255, 64, 80, 0.8);
}

.poketab-duel-module-alert .poketab-duel-head {
    color: #ffc0c8;
    animation: poketab-alert-blink 0.8s steps(2) infinite;
}

.poketab-duel-feed {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--pt-scale, 1.3));
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    position: relative;
    z-index: 3;
}

.poketab-duel-empty {
    margin: auto 0;
    padding: calc(14px * var(--pt-scale, 1.3)) calc(6px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.12em;
    color: rgba(255, 120, 130, 0.45);
    text-align: center;
}

.poketab-duel-label {
    flex-shrink: 0;
    margin: calc(6px * var(--pt-scale, 1.3)) 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.08em;
    color: #8898a8;
    text-align: center;
}

.poketab-duel-card {
    padding: calc(8px * var(--pt-scale, 1.3)) calc(6px * var(--pt-scale, 1.3));
    background: rgba(8, 0, 4, 0.55);
    border: 2px solid rgba(255, 80, 90, 0.35);
    box-shadow: inset 0 0 8px rgba(255, 40, 60, 0.12);
}

.poketab-duel-card-danger {
    border-color: rgba(255, 64, 80, 0.75);
    background: rgba(40, 8, 16, 0.72);
}

.poketab-duel-card-warn {
    border-color: rgba(255, 200, 80, 0.65);
    background: rgba(40, 24, 8, 0.65);
}

.poketab-duel-card-live {
    border-color: rgba(80, 255, 160, 0.55);
    background: rgba(8, 32, 20, 0.65);
}

.poketab-duel-title {
    margin: 0 0 calc(4px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    color: #ffb0b8;
    text-align: center;
}

.poketab-duel-body {
    margin: 0 0 calc(4px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    line-height: 1.35;
    color: #ffe8ea;
    text-align: center;
    word-break: break-word;
}

.poketab-duel-wager {
    margin: 0 0 calc(8px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    color: #ffd850;
    text-align: center;
}

.poketab-duel-actions {
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--pt-scale, 1.3));
}

.poketab-duel-btn {
    width: 100%;
    min-height: calc(36px * var(--pt-scale, 1.3));
    padding: calc(8px * var(--pt-scale, 1.3)) calc(6px * var(--pt-scale, 1.3));
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.06em;
    cursor: pointer;
    border: 2px solid #180810;
    touch-action: manipulation;
    image-rendering: pixelated;
    pointer-events: auto;
    position: relative;
    z-index: 5;
}

.poketab-duel-btn.accept {
    color: #2a0800;
    background:
        repeating-conic-gradient(#ffd838 0% 25%, #f0b818 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #ffe850 0%, #d89810 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.poketab-duel-btn.decline {
    color: #ffc0c8;
    background: linear-gradient(180deg, #503040 0%, #301820 100%);
}

.poketab-duel-card > .poketab-duel-btn {
    margin-top: 2px;
}

.poketab-rail-right .poketab-rail-bolt-b {
    flex-shrink: 0;
    margin-top: 8px;
    align-self: center;
}

.poketab-battle-balance {
    color: #ffd850 !important;
    margin-bottom: 8px !important;
}

.poketab-battle-wager-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.poketab-battle-wager-label {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45));
    color: #7ec8ff;
}

.poketab-battle-wager-input {
    width: 80px;
    padding: 6px 8px;
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--pt-ui-font-mul, 1.45));
    color: #ffd850;
    background: #0a1828;
    border: 2px solid #7ec8ff;
}

.poketab-battle-wager-hint {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.45));
    color: #7ec8ff;
}

.poketab-battle-sub {
    margin-bottom: 4px !important;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45)) !important;
}

.poketab-battle-eligible {
    margin-bottom: 8px !important;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45)) !important;
    color: #ffe08a;
}

.poketab-battle-opp-meta {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.45));
    color: #7ec8ff;
    opacity: 0.85;
}

.poketab-battle-challenge-btn {
    background: #ffd838 !important;
    color: #2a1800 !important;
    border-color: #886008 !important;
}

.poketab-battle-challenge-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.poketab-battle-challenge-btn.is-sent:disabled {
    opacity: 1;
    background: #8a9860 !important;
    color: #1a2010 !important;
    border-color: #4a5828 !important;
}

.poketab-duel-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.poketab-battle-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(14px * var(--pt-scale, 1.3));
    margin: calc(14px * var(--pt-scale, 1.3)) 0;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    align-content: start;
}

.poketab-battle-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(6px * var(--pt-scale, 1.3));
    padding: calc(8px * var(--pt-scale, 1.3));
    cursor: pointer;
    background: #0a1828;
    border: 3px solid #3a5870;
    image-rendering: pixelated;
    min-width: 0;
}

.poketab-battle-card.selected {
    border-color: #ffd838;
    box-shadow: 0 0 8px rgba(255, 216, 56, 0.5);
}

.poketab-battle-card img {
    width: 100%;
    height: auto;
    min-height: calc(384px * var(--pt-scale, 0.78) * var(--card-scale, 0.7));
    max-height: calc(420px * var(--pt-scale, 0.78) * var(--card-scale, 0.7));
    aspect-ratio: 3 / 4;
    object-fit: contain;
    object-position: center;
    image-rendering: pixelated;
}

.poketab-battle-card-fallback {
    width: 100%;
    min-height: calc(384px * var(--pt-scale, 0.78) * var(--card-scale, 0.7));
    aspect-ratio: 3 / 4;
}

.poketab-battle-card-name {
    font-family: silkscreen, monospace;
    font-size: calc(13px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    color: #fff;
    text-align: center;
    line-height: 1.25;
    word-break: break-word;
}

.poketab-battle-card-type {
    font-family: silkscreen, monospace;
    font-size: calc(11px * var(--pt-scale, 0.78) * var(--pt-ui-font-mul, 1.45));
    color: #7ec8ff;
}

.poketab-battle-confirm-btn {
    width: 100%;
    padding: 14px;
    font-family: silkscreen, monospace;
    font-size: calc(14px * var(--pt-ui-font-mul, 1.45));
    color: #2a1800;
    cursor: pointer;
    background: #ffd838;
    border: 2px solid #142838;
}

.poketab-battle-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: #688050;
    image-rendering: pixelated;
    overflow: hidden;
}

.poketab-battle-overlay.hidden {
    display: none;
}

.poketab-gb-arena,
.poketab-gb-scene {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.poketab-gb-scene {
    padding: 3px;
    background:
        linear-gradient(180deg, #78a860 0%, #588848 40%, #487038 100%);
    border: 3px solid #283818;
    box-sizing: border-box;
    overflow: hidden;
    --battle-sprite-scale: 2.3;
    --battle-hp-scale: 1.5;
    --battle-font-scale: 1.5;
    --battle-menu-scale: 1.05;
    --battle-hp-box-scale: 1;
    --battle-player-sprite-mul: 3.2;
    --battle-opp-sprite-mul: 3.2;
    --battle-hp-stack-player: calc(118px * var(--pt-scale, 0.78) * var(--battle-hp-scale, 1.5) * var(--battle-hp-box-scale, 0.6));
    --battle-hp-stack-opp: calc(92px * var(--pt-scale, 0.78) * var(--battle-hp-scale, 1.5) * var(--battle-hp-box-scale, 0.6));
    --battle-field-inset: 6px;
}

.poketab-gb-hud {
    flex-shrink: 0;
    margin-bottom: 2px;
}

.poketab-gb-field {
    position: relative;
    flex: 1 1 0;
    min-height: 240px;
    max-height: none;
    margin-bottom: 2px;
    padding: 0 var(--battle-field-inset, 6px);
    box-sizing: border-box;
    overflow: hidden;
}

.poketab-gb-field-gap {
    display: none;
}

.poketab-gb-timer {
    height: 4px;
    background: #283818;
    margin-bottom: 3px;
    border: 1px solid #142810;
}

.poketab-gb-timer div {
    height: 100%;
    background: linear-gradient(90deg, #ff4040, #ffd838);
    transition: width 0.3s linear;
}

.poketab-gb-wager {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--battle-font-scale, 2) * var(--ui-scale, 1));
    color: #ffd838;
    text-shadow: 1px 1px 0 #283818;
}

.poketab-gb-opp-panel,
.poketab-gb-me-panel {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    pointer-events: none;
}

.poketab-gb-me-panel {
    left: 0;
    bottom: 0;
    right: auto;
    align-items: flex-start;
    width: var(--battle-hp-stack-player);
    max-width: var(--battle-hp-stack-player);
}

.poketab-gb-opp-panel {
    right: 0;
    top: 0;
    left: auto;
    align-items: flex-end;
    width: var(--battle-hp-stack-opp);
    max-width: var(--battle-hp-stack-opp);
}

.poketab-gb-mon-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(3px * var(--battle-hp-scale, 1.5) * var(--battle-hp-box-scale, 0.6));
    width: 100%;
    max-width: 100%;
}

.poketab-gb-mon-stack--opp {
    align-items: flex-end;
    width: 100%;
}

.poketab-gb-me-panel .poketab-gb-mon-stack {
    width: 100%;
}

.poketab-gb-me-panel .poketab-gb-sprite {
    width: calc(96px * var(--pt-scale, 0.78) * var(--battle-player-sprite-mul, 2.75));
    height: calc(96px * var(--pt-scale, 0.78) * var(--battle-player-sprite-mul, 2.75));
    align-self: flex-start;
    margin-left: 0;
    max-width: none;
}

.poketab-gb-opp-panel .poketab-gb-sprite {
    width: calc(72px * var(--pt-scale, 0.78) * var(--battle-opp-sprite-mul, 2.75));
    height: calc(72px * var(--pt-scale, 0.78) * var(--battle-opp-sprite-mul, 2.75));
    align-self: flex-end;
    margin-right: 0;
    max-width: none;
}

.poketab-gb-me-panel .poketab-gb-sprite-img {
    object-position: left bottom;
}

.poketab-gb-opp-panel .poketab-gb-sprite-img {
    object-position: right bottom;
}

.poketab-gb-sprite {
    flex-shrink: 0;
    image-rendering: pixelated;
}

.poketab-gb-sprite.flip {
    transform: scaleX(-1);
}

.poketab-gb-sprite-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.poketab-gb-sprite-pixel {
    width: 100%;
    height: 100%;
    border: 2px solid #283818;
}

.poketab-gb-hpblock {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: calc(2px * var(--battle-hp-scale, 1.5) * var(--battle-hp-box-scale, 0.6)) calc(4px * var(--battle-hp-scale, 1.5) * var(--battle-hp-box-scale, 0.6));
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.poketab-gb-hpname {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--battle-font-scale, 2) * var(--battle-hp-box-scale, 0.6));
    color: #f8f8f0;
    text-shadow: 1px 1px 0 #283818, -1px 0 0 #283818, 0 -1px 0 #283818, 1px 0 0 #283818;
    grid-column: 1 / -1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    word-break: keep-all;
    hyphens: none;
    line-height: 1;
    letter-spacing: -0.04em;
}

.poketab-gb-mon-stack--opp .poketab-gb-hpname {
    text-align: right;
}

.poketab-gb-hpbar {
    height: calc(9px * var(--battle-hp-scale, 1.5));
    background: #283818;
    border: 1px solid #142810;
    border-radius: 999px;
    overflow: hidden;
    grid-column: 1 / -1;
}

.poketab-gb-hpfill {
    height: 100%;
    min-width: 0;
    border-radius: 999px;
    transition: width 0.35s steps(8), background 0.35s ease;
}

.poketab-gb-hpfill--hp-high {
    background: linear-gradient(90deg, #98d850, #58b830);
}

.poketab-gb-hpfill--hp-mid {
    background: linear-gradient(90deg, #ffe850, #f0a820);
}

.poketab-gb-hpfill--hp-low {
    background: linear-gradient(90deg, #ff6868, #d83030);
}

.poketab-gb-hpnums {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--battle-font-scale, 2) * var(--battle-hp-box-scale, 0.6));
    color: #f8f8f0;
    text-shadow: 1px 1px 0 #283818, -1px 0 0 #283818, 0 -1px 0 #283818, 1px 0 0 #283818;
    grid-column: 1 / -1;
    justify-self: end;
    line-height: 1;
}

.poketab-gb-textbox {
    flex-shrink: 0;
    margin-top: 0;
    margin-bottom: 3px;
    padding: calc(4px * var(--battle-font-scale, 2) / 2) calc(5px * var(--battle-font-scale, 2) / 2);
    min-height: calc(26px * var(--battle-font-scale, 2) / 2);
    max-height: calc(40px * var(--battle-font-scale, 2) / 2);
    overflow: hidden;
    background: #f8f8f0;
    border: 2px solid #283818;
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--battle-font-scale, 2) * var(--ui-scale, 1));
    color: #283818;
    line-height: 1.3;
}

.poketab-gb-textbox p {
    margin: 0 0 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poketab-gb-menu {
    flex-shrink: 0;
    margin-top: 0;
    padding: calc(6px * var(--battle-menu-scale, 1.05));
    background: #f8f8f0;
    border: 2px solid #283818;
    position: relative;
    z-index: 5;
    max-height: 38%;
}

.poketab-gb-menu-result {
    padding: calc(6px * var(--battle-menu-scale, 1.05));
}

.poketab-gb-menu-select {
    background: #fff8d0;
    border-color: #886008;
}

.poketab-gb-menu-title {
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--battle-font-scale, 1.5) * var(--battle-menu-scale, 1.05) * var(--ui-scale, 1));
    color: #283818;
    margin: 0 0 4px;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

.poketab-gb-moves {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(5px * var(--battle-menu-scale, 1.05));
}

.poketab-gb-picks {
    grid-template-columns: 1fr;
    max-height: calc(130px * var(--battle-menu-scale, 1.05));
    overflow-y: auto;
}

.poketab-gb-move {
    padding: calc(6px * var(--battle-menu-scale, 1.05)) calc(6px * var(--battle-menu-scale, 1.05));
    min-height: calc(40px * var(--battle-font-scale, 1.5) / 1.5 * var(--battle-menu-scale, 1.05));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--battle-font-scale, 1.5) * var(--battle-menu-scale, 1.05) * var(--ui-scale, 1));
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    color: #283818;
    background: #e8e8d8;
    border: 2px solid #687858;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
}

.poketab-gb-move-name {
    display: block;
    width: 100%;
}

.poketab-gb-move-stats {
    display: block;
    font-size: calc(8px * var(--battle-font-scale, 1.5) * var(--battle-menu-scale, 1.05) * var(--ui-scale, 1));
    color: #487038;
}

.poketab-gb-pick {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--battle-menu-scale, 1.05));
    font-size: calc(10px * var(--battle-font-scale, 1.5) * var(--battle-menu-scale, 1.05) * var(--ui-scale, 1));
    background: #ffe850;
    border-color: #886008;
    min-height: calc(46px * var(--battle-font-scale, 1.5) / 1.5 * var(--battle-menu-scale, 1.05));
}

.poketab-gb-pick-img {
    width: calc(48px * var(--pt-scale, 0.78) * var(--battle-sprite-scale, 2));
    height: calc(48px * var(--pt-scale, 0.78) * var(--battle-sprite-scale, 2));
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.poketab-gb-move.bag-item span,
.poketab-gb-move.bag-back {
    color: inherit;
}

.poketab-gb-move.defence {
    background: #d8e8f8;
}

.poketab-gb-move.bag {
    background: #ffe8c8;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.poketab-gb-move.flee {
    background: #ffd0d0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.poketab-gb-menu-bag {
    background: #fff0d8;
    border-color: #886008;
}

.poketab-gb-bag-items {
    grid-template-columns: 1fr;
}

.poketab-gb-move.bag-item {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    background: #ffe8c8;
    border-color: #886008;
}

.poketab-gb-move.bag-back {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: #e8e8d8;
}

.poketab-gb-bag-img {
    width: calc(48px * var(--pt-scale, 0.78) * var(--battle-sprite-scale, 2));
    height: calc(48px * var(--pt-scale, 0.78) * var(--battle-sprite-scale, 2));
}

.poketab-gb-move:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.poketab-gb-wait {
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--battle-font-scale, 1.5) * var(--battle-menu-scale, 1.05));
    color: #687858;
    margin: 0;
    animation: poketab-cursor-blink 0.8s steps(2) infinite;
}

.poketab-gb-result {
    font-family: silkscreen, monospace;
    font-size: calc(10px * var(--battle-font-scale, 2));
    color: #283818;
    text-align: center;
    margin: 0 0 4px;
}

.poketab-gb-result-sub {
    font-family: silkscreen, monospace;
    font-size: calc(5px * var(--battle-font-scale, 2));
    color: #487038;
    text-align: center;
    margin: 0 0 8px;
}

.poketab-gb-btn {
    width: 100%;
    padding: 8px;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--battle-font-scale, 2));
    cursor: pointer;
    background: #ffd838;
    border: 2px solid #283818;
}

.poketab-battle-lobby {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.poketab-battle-team {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

.poketab-battle-lobby.hidden,
.poketab-battle-team.hidden {
    display: none !important;
}

.poketab-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.poketab-row,
.poketab-conv-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 2px solid rgba(20, 60, 100, 0.85);
    background: rgba(10, 40, 72, 0.45);
    color: inherit;
    text-align: left;
}

.poketab-conv-row {
    cursor: pointer;
}

.poketab-conv-row:hover,
.poketab-row:hover {
    background: rgba(20, 70, 110, 0.55);
    border-color: rgba(126, 200, 255, 0.45);
}

.poketab-avatar {
    flex-shrink: 0;
    border: 2px solid rgba(126, 200, 255, 0.55);
    background-color: #0e2848;
    image-rendering: pixelated;
}

.poketab-row-main,
.poketab-conv-main {
    flex: 1;
    min-width: 0;
}

.poketab-row-name {
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #e8f8ff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.poketab-row-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.poketab-online-dot {
    width: 8px;
    height: 8px;
    background: #4ae8c8;
    flex-shrink: 0;
    box-shadow: 0 0 6px #4ae8c8;
    animation: poketab-online-pulse 1.2s steps(2) infinite;
}

@keyframes poketab-online-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.poketab-pill {
    font-family: silkscreen, monospace;
    font-size: 7px;
    padding: 4px 7px;
    border: 2px solid rgba(126, 200, 255, 0.4);
    background: rgba(10, 40, 72, 0.65);
    color: #a8e8ff;
}

.poketab-pill-friend {
    border-color: rgba(74, 232, 168, 0.5);
    color: #9cf0d4;
}

.poketab-action-btn {
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.04em;
    padding: 6px 9px;
    color: #0e2848;
    cursor: pointer;
    background:
        repeating-conic-gradient(#7ec8ff 0% 25%, #6ab8ef 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #9ad8ff 0%, #5aa8df 100%);
    border: 2px solid #142838;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}

.poketab-action-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
}

.poketab-action-decline {
    color: #ffd8e0;
    background: #6a2848;
    border-color: #142838;
}

.poketab-action-send {
    color: #0e2848;
    background: #4ae8c8;
}

.poketab-empty {
    margin: 0;
    padding: 22px 10px;
    text-align: center;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45));
    line-height: 1.5;
    color: rgba(168, 232, 255, 0.6);
}

.poketab-conv-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.poketab-conv-time {
    font-family: silkscreen, monospace;
    font-size: 7px;
    color: rgba(168, 232, 255, 0.5);
}

.poketab-conv-preview {
    margin-top: 4px;
    font-family: silkscreen, monospace;
    font-size: 8px;
    color: rgba(200, 240, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poketab-unread {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #e83838;
    color: #fff;
    font-family: silkscreen, monospace;
    font-size: 7px;
    line-height: 18px;
    text-align: center;
    border: 1px solid #881818;
}

.poketab-chat-peer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(126, 200, 255, 0.3);
}

.poketab-chat-thread {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 6px 2px;
}

.poketab-bubble {
    max-width: 82%;
    padding: 8px 10px;
    border: 2px solid rgba(20, 60, 100, 0.85);
    font-family: silkscreen, monospace;
    font-size: 8px;
    line-height: 1.45;
}

.poketab-bubble p {
    margin: 0 0 4px;
    word-break: break-word;
}

.poketab-bubble time {
    font-size: 7px;
    opacity: 0.65;
}

.poketab-bubble.mine {
    align-self: flex-end;
    background: rgba(30, 90, 140, 0.75);
    color: #e8f8ff;
    border-color: rgba(126, 200, 255, 0.5);
}

.poketab-bubble.theirs {
    align-self: flex-start;
    background: rgba(10, 50, 90, 0.6);
    color: #c8f0ff;
}

.poketab-chat-compose {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
    padding-top: 8px;
    border-top: 2px solid rgba(126, 200, 255, 0.28);
}

.poketab-chat-compose input {
    min-width: 0;
    padding: 9px 11px;
    border: 2px solid rgba(126, 200, 255, 0.4);
    background: rgba(8, 36, 64, 0.75);
    color: #c8f0ff;
    font-family: silkscreen, monospace;
    font-size: 8px;
}

.poketab-chat-compose input::placeholder {
    color: rgba(168, 232, 255, 0.4);
}

.poketab-chat-compose input:focus {
    outline: none;
    border-color: #7ec8ff;
    box-shadow: 0 0 8px rgba(126, 200, 255, 0.3);
}

.join-toast-error {
    border-left-color: #e83838;
    color: #ffb4b4;
}

.game-drawer {
    position: absolute;
    inset: 0;
    z-index: 16;
    pointer-events: none;
}

.game-drawer:not(.hidden) {
    pointer-events: auto;
}

.game-drawer.hidden {
    display: none;
}

.game-drawer-scrim {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(5, 5, 12, 0.52);
    cursor: pointer;
    opacity: 0;
    animation: drawer-scrim-in 0.2s steps(4, end) forwards;
}

.game-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(100%, 736px);
    display: flex;
    transform: translateX(100%);
    animation: drawer-slide-in 0.28s steps(6, end) forwards;
    image-rendering: pixelated;
    filter: drop-shadow(-6px 0 0 rgba(0, 0, 0, 0.35));
}

@keyframes drawer-scrim-in {
    to { opacity: 1; }
}

@keyframes drawer-slide-in {
    to { transform: translateX(0); }
}

.game-drawer-tabs {
    flex-shrink: 0;
    width: 64px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 0 14px 8px;
    background: linear-gradient(180deg, #2a2218 0%, #1a140e 100%);
    border-right: 3px solid #0d0a08;
    box-shadow: inset -3px 0 0 rgba(255, 255, 255, 0.06);
}

.game-drawer-tab {
    appearance: none;
    border: none;
    width: 56px;
    padding: 10px 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    touch-action: manipulation;
    background:
        repeating-conic-gradient(#3d3428 0% 25%, #342c22 0% 50%) 50% / 3px 3px,
        #2e261c;
    border-left: 3px solid #1a140e;
    border-top: 3px solid #4a4034;
    border-bottom: 3px solid #12100c;
    border-right: 3px solid #12100c;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    color: #9aa3b5;
    transition: transform 0.06s steps(2, end), filter 0.06s steps(2, end);
}

.game-drawer-tab-icon-wrap {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.28);
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.game-drawer-tab-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    opacity: 0.72;
}

.game-drawer-tab-label {
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-align: center;
}

.game-drawer-tab.active {
    transform: translateX(4px);
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #ffe566 0%, #d4a017 100%);
    border-left-color: #ffe566;
    color: #2a1808;
    box-shadow:
        -2px 0 0 #ffe566,
        3px 3px 0 rgba(0, 0, 0, 0.45);
}

.game-drawer-tab.active .game-drawer-tab-icon {
    opacity: 1;
    filter: drop-shadow(1px 1px 0 rgba(255, 255, 255, 0.45));
}

.game-drawer-tab.active .game-drawer-tab-icon-wrap {
    background: rgba(255, 255, 255, 0.35);
    border-color: #3d3010;
}

.game-drawer-tab:active {
    transform: translateX(2px) scale(0.96);
}

.game-drawer-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 4px 4px,
        #fff8ea;
    border-left: 3px solid #8b7355;
}

.game-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 12px 10px;
    border-bottom: 3px solid #2d2418;
    background: linear-gradient(180deg, rgba(255, 230, 102, 0.35) 0%, transparent 100%);
}

.game-drawer-title {
    font-family: silkscreen, monospace;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: #2a1808;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
    margin: 0;
}

.game-drawer-close {
    appearance: none;
    width: 28px;
    height: 28px;
    border: 2px solid #2d2418;
    background: #f4ecd8;
    color: #2d2418;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.game-drawer-close:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.game-drawer-panes {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.game-drawer-pane {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 12px 14px 14px;
    overflow: hidden;
}

.game-drawer-pane.active {
    display: flex;
}

.game-drawer-hero {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.45);
    border: 2px solid #8b7355;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.game-drawer-hero--compact {
    padding: 6px 10px;
    margin-bottom: 8px;
}

.game-drawer-hero--compact .game-drawer-hero-icon {
    width: 36px;
    height: 36px;
}

.game-drawer-hero--compact .game-drawer-hero-text {
    font-size: 7px;
    line-height: 1.5;
}

.game-drawer-hero-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.game-drawer-hero-text {
    font-family: silkscreen, monospace;
    font-size: 8px;
    line-height: 1.65;
    color: #4a3018;
    margin: 0;
}

.game-drawer-grid-scroll {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0 -2px;
    padding: 10px 8px 12px;
    scrollbar-width: thin;
    scrollbar-color: #8b7355 rgba(255, 255, 255, 0.35);
}

.game-drawer-grid-scroll::-webkit-scrollbar {
    width: 6px;
}

.game-drawer-grid-scroll::-webkit-scrollbar-thumb {
    background: #8b7355;
    border: 1px solid #2d2418;
}

.game-drawer-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
    align-content: start;
    padding: 4px 2px 8px;
}

.game-drawer-slot {
    aspect-ratio: 5 / 7;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    border: 2px dashed #b8a888;
    background: rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: silkscreen, monospace;
    font-size: 7px;
    color: #9a8b72;
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.4);
}

.game-drawer-slot-filled {
    border: 2px solid #2d2418;
    border-style: solid;
    background: #2a2218;
    padding: 2px;
}

.game-drawer-slot.game-drawer-slot-vault,
.game-drawer-slot.game-drawer-slot-vault.game-drawer-slot-filled {
    overflow: visible;
}

.bag-slot-vault,
.game-drawer-slot-vault {
    position: relative;
    cursor: pointer;
    padding: 0;
    border: none;
    background: transparent;
    font: inherit;
    text-align: inherit;
    overflow: visible;
    z-index: 0;
}

.bag-slot-vault.bag-slot-filled,
.game-drawer-slot-vault.game-drawer-slot-filled {
    padding: 0;
    background: transparent;
    border: none;
    overflow: visible;
    display: block;
}

.bag-slot-vault.bag-slot-filled .vault-slot-visual,
.game-drawer-slot-vault.game-drawer-slot-filled .vault-slot-visual {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
}

.vault-slot-visual {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.vault-slot-frame {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: 2px solid #0a0a0a;
    background: #1a1510;
    box-shadow: inset 0 0 0 1px rgba(255, 220, 140, 0.15);
    overflow: hidden;
    image-rendering: pixelated;
}

.vault-slot-frame[data-grade="1"] {
    box-shadow: inset 0 0 0 1px rgba(255, 220, 140, 0.22);
}

.vault-slot-frame[data-grade="2"] {
    border-color: #3a4858;
    box-shadow:
        inset 0 0 0 1px #e8f0f8,
        2px 2px 0 #0a0a0a,
        0 0 0 2px #98a8b8;
}

.vault-slot-frame[data-grade="3"] {
    border-color: #5a4010;
    box-shadow:
        inset 0 0 0 1px #fff4b0,
        2px 2px 0 #0a0a0a,
        0 0 0 2px #d8a820;
}

.vault-slot-frame[data-grade="4"] {
    border-color: #4a3080;
    box-shadow:
        inset 0 0 0 1px #f0e8ff,
        2px 2px 0 #0a0a0a,
        0 0 0 2px #a878e0;
}

.vault-slot-frame[data-grade="5"] {
    border-color: #6a1848;
    box-shadow:
        inset 0 0 0 1px #ffe8f8,
        3px 3px 0 #0a0a0a,
        0 0 0 2px #ff68b0,
        0 0 0 4px #ffd050;
}

/* Card shine sweep — G2+ only */
.vault-slot-frame[data-grade]:not([data-grade="1"])::after,
.vault-card-popup-frame[data-grade]:not([data-grade="1"])::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background-repeat: no-repeat;
    background-size: 220% 100%;
    mix-blend-mode: screen;
    image-rendering: pixelated;
    animation: vault-card-shine-sweep 2.6s steps(14) infinite;
}

.vault-slot-frame[data-grade="2"]::after,
.vault-card-popup-frame[data-grade="2"]::after {
    background-image: linear-gradient(
        100deg,
        transparent 0%,
        transparent 38%,
        rgba(200, 220, 240, 0.2) 42%,
        rgba(248, 252, 255, 0.72) 50%,
        rgba(180, 200, 228, 0.35) 56%,
        transparent 62%,
        transparent 100%
    );
}

.vault-slot-frame[data-grade="3"]::after,
.vault-card-popup-frame[data-grade="3"]::after {
    background-image: linear-gradient(
        100deg,
        transparent 0%,
        transparent 36%,
        rgba(255, 220, 80, 0.25) 41%,
        rgba(255, 248, 180, 0.78) 50%,
        rgba(255, 200, 60, 0.4) 57%,
        transparent 63%,
        transparent 100%
    );
    animation-duration: 2.35s;
}

.vault-slot-frame[data-grade="4"]::after,
.vault-card-popup-frame[data-grade="4"]::after {
    background-image: linear-gradient(
        100deg,
        transparent 0%,
        transparent 35%,
        rgba(200, 160, 255, 0.28) 40%,
        rgba(240, 220, 255, 0.75) 50%,
        rgba(168, 120, 224, 0.42) 58%,
        transparent 64%,
        transparent 100%
    );
    animation-duration: 2.15s;
}

.vault-slot-frame[data-grade="5"]::after,
.vault-card-popup-frame[data-grade="5"]::after {
    background-image: linear-gradient(
        100deg,
        transparent 0%,
        transparent 34%,
        rgba(255, 120, 190, 0.3) 39%,
        rgba(255, 248, 255, 0.82) 47%,
        rgba(255, 208, 80, 0.65) 52%,
        rgba(255, 100, 180, 0.38) 59%,
        transparent 65%,
        transparent 100%
    );
    animation-duration: 1.85s;
    animation-name: vault-card-shine-sweep-mythic;
}

@keyframes vault-card-shine-sweep {
    0% { background-position: 130% 0; }
    100% { background-position: -130% 0; }
}

@keyframes vault-card-shine-sweep-mythic {
    0% { background-position: 140% 0; opacity: 0.92; }
    45% { opacity: 1; }
    100% { background-position: -140% 0; opacity: 0.92; }
}

.vault-slot-frame .bag-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    image-rendering: pixelated;
}

.vault-slot-grade,
.vault-slot-mult,
.vault-slot-copies {
    position: absolute;
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.04em;
    line-height: 1.15;
    padding: 3px 4px;
    border: 2px solid #1a1208;
    z-index: 6;
    image-rendering: pixelated;
    pointer-events: none;
}

.game-drawer-slot-vault .vault-slot-grade,
.game-drawer-slot-vault .vault-slot-mult,
.game-drawer-slot-vault .vault-slot-copies {
    font-size: 13px;
    padding: 6px 7px;
    line-height: 1.2;
    max-width: calc(100% - 6px);
    white-space: nowrap;
    border-width: 2px;
}

.vault-slot-grade {
    top: 1px;
    left: 1px;
}

.vault-slot-mult {
    top: 1px;
    right: 1px;
    background: linear-gradient(180deg, #2a4a38 0%, #142820 100%);
    color: #b8f0c8;
    text-shadow: 1px 1px 0 #1a1208;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

.vault-slot-copies {
    bottom: 1px;
    right: 1px;
    left: auto;
    background: linear-gradient(180deg, #4a3820 0%, #2a1c10 100%);
    color: #ffd98a;
    text-shadow: 1px 1px 0 #1a1208;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

/* ── Pixel grade tags (vault slot + popup) ── */
.vault-grade-tag {
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        2px 2px 0 #1a1208;
}

.vault-slot-grade.vault-grade-tag {
    position: absolute;
    top: 1px;
    left: 1px;
    z-index: 6;
}

.vault-card-popup-grade-pill.vault-grade-tag,
.vault-card-popup-tag.vault-grade-tag {
    position: relative;
}

.vault-grade-tag::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.55;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.14) 0px,
            rgba(255, 255, 255, 0.14) 1px,
            transparent 1px,
            transparent 3px
        );
    image-rendering: pixelated;
}

.vault-grade-tag[data-grade]:not([data-grade="1"])::after {
    content: "";
    position: absolute;
    inset: -2px -40%;
    pointer-events: none;
    background: linear-gradient(
        100deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 35%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0.08) 65%,
        transparent 100%
    );
    animation: vault-tag-shine 2.4s steps(10) infinite;
    mix-blend-mode: screen;
}

@keyframes vault-tag-shine {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(220%); }
}

.vault-grade-tag[data-grade="1"],
.vault-slot-grade[data-grade="1"] {
    background:
        repeating-conic-gradient(#6a5038 0% 25%, #5a4430 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #9a7858 0%, #6a5038 48%, #8a6848 100%);
    color: #fff0d8;
    text-shadow: 1px 1px 0 #2a1c10;
    border-color: #2a1c10;
}

.vault-grade-tag[data-grade="2"],
.vault-slot-grade[data-grade="2"] {
    background:
        repeating-linear-gradient(90deg, #a8b8c8 0 2px, #dce8f4 2px 4px),
        repeating-conic-gradient(#b8c8d8 0% 25%, #98a8b8 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #f4f8fc 0%, #98a8b8 42%, #d0dce8 58%, #a0b0c0 100%);
    color: #1a2838;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85), 1px 1px 0 #4a5868;
    border-color: #3a4858;
}

.vault-grade-tag[data-grade="3"],
.vault-slot-grade[data-grade="3"] {
    background:
        repeating-linear-gradient(90deg, #d8a820 0 2px, #ffe878 2px 4px),
        repeating-conic-gradient(#e8c040 0% 25%, #c89818 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #fff8c0 0%, #d0a018 44%, #ffe060 56%, #c08810 100%);
    color: #3a2808;
    text-shadow: 0 1px 0 rgba(255, 248, 200, 0.9), 1px 1px 0 #5a4010;
    border-color: #5a4010;
}

.vault-grade-tag[data-grade="4"],
.vault-slot-grade[data-grade="4"] {
    background:
        repeating-linear-gradient(90deg, #9870d0 0 2px, #d0b0ff 2px 4px),
        repeating-conic-gradient(#b898e8 0% 25%, #8868c0 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #f0e8ff 0%, #8868c0 44%, #c8a8f0 58%, #7858a8 100%);
    color: #1a0838;
    text-shadow: 0 1px 0 rgba(240, 220, 255, 0.85), 1px 1px 0 #4a2878;
    border-color: #4a3080;
}

.vault-grade-tag[data-grade="5"],
.vault-slot-grade[data-grade="5"] {
    background:
        repeating-linear-gradient(90deg, #ff68b0 0 2px, #ffd060 2px 4px),
        repeating-conic-gradient(#ff98d0 0% 25%, #e878a8 0% 50%) 50% / 3px 3px,
        linear-gradient(180deg, #fff0f8 0%, #ff68c0 38%, #ffd050 52%, #e84898 100%);
    color: #fff8ff;
    text-shadow: 1px 1px 0 #6a1848, 0 0 0 #1a0818;
    border-color: #6a1848;
    animation: vault-grade-tag-mythic 1.2s steps(4) infinite;
}

@keyframes vault-grade-tag-mythic {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.14) saturate(1.12); }
}

.bag-slot-vault:active .vault-slot-frame,
.game-drawer-slot-vault:active .vault-slot-frame {
    transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
    .vault-slot-frame[data-grade]:not([data-grade="1"])::after,
    .vault-card-popup-frame[data-grade]:not([data-grade="1"])::after,
    .vault-grade-tag[data-grade]:not([data-grade="1"])::after,
    .vault-grade-tag[data-grade="5"],
    .vault-slot-grade[data-grade="5"] {
        animation: none !important;
    }
}

.game-drawer-hint {
    font-family: silkscreen, monospace;
    font-size: 7px;
    text-align: center;
    color: #8b7355;
    letter-spacing: 0.04em;
    margin: 0;
    padding-top: 10px;
    flex-shrink: 0;
}

.game-drawer-hero-empty {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 0;
    padding: 24px 20px;
    background: none;
    border: none;
    box-shadow: none;
    text-align: center;
}

.game-drawer-hero-empty .game-drawer-hero-icon {
    width: 112px;
    height: 112px;
    filter: drop-shadow(2px 3px 0 rgba(45, 36, 24, 0.4));
    animation: bag-idle-bob 2.4s steps(2, end) infinite;
}

.game-drawer-hero-empty .game-drawer-hero-text {
    max-width: 240px;
    font-size: 9px;
    line-height: 1.65;
}

.is-hold-locked {
    pointer-events: none;
}

[data-hold-ui^="drawer:"].is-hold-locked,
#game-drawer-empty[hidden] {
    display: none !important;
}

.game-bag-btn.is-hold-locked {
    opacity: 0.42;
    cursor: not-allowed;
    animation: none;
    pointer-events: none;
}

.game-bag-btn.is-hold-locked .game-bag-btn-img {
    filter: grayscale(1) brightness(0.85);
}

.game-bag-btn.is-hold-locked .game-bag-btn-frame {
    outline-color: #9ca3af;
    background:
        repeating-conic-gradient(#e5e7eb 0% 25%, #d1d5db 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #d1d5db 0%, #9ca3af 100%);
}

/* ── Item get popup (simple white pixel box) ── */
.item-get-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    padding: 16px;
    image-rendering: pixelated;
}

.item-get-popup.hidden {
    display: none;
}

.item-get-scrim {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(5, 5, 12, 0.55);
    cursor: pointer;
}

.item-get-box {
    position: relative;
    z-index: 1;
    width: min(300px, 92vw);
    padding: 16px 16px 14px;
    text-align: center;
    pointer-events: auto;
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 4px 4px,
        #fff8ea;
    border: 3px solid #2d2418;
    box-shadow:
        inset 0 0 0 2px #8b7355,
        5px 5px 0 rgba(0, 0, 0, 0.72);
}

.item-get-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #2d2418;
    background: #ffe566;
    color: #2d2418;
    font-family: silkscreen, monospace;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.35);
}

.item-get-close:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.item-get-headline {
    margin: 0 0 12px;
    padding: 0 32px;
    text-align: center;
    font-family: silkscreen, monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: #2a2218;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.65);
}

.item-get-stage {
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    min-height: 72px;
}

.item-get-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
}

.item-get-tag {
    margin: 0 0 6px;
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.12em;
    color: #6b5d48;
}

.item-get-name {
    margin: 0 0 8px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    color: #2a2218;
    line-height: 1.4;
}

.item-get-msg {
    margin: 0 0 14px;
    font-family: nunito, sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #4a3c28;
    line-height: 1.45;
}

.item-get-ok {
    width: 100%;
    font-size: 9px;
    letter-spacing: 0.06em;
}

.bag-empty-msg,
.game-drawer-empty-msg {
    grid-column: 1 / -1;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
    padding: 12px 8px;
}

#app-container {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #87ceeb;
    touch-action: none;
    overscroll-behavior: none;
}

#app-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.game-pad {
    --joystick-size: 160px;
    --joystick-stick: 62px;
    --quickslot-size: 54px;
    position: absolute;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    touch-action: none;
    user-select: none;
    image-rendering: pixelated;
    display: flex;
    align-items: flex-end;
    gap: 32px;
}

body.desktop-controls .game-joystick {
    display: none !important;
}

body.desktop-controls .game-pad {
    gap: 0;
}

@media (hover: hover) and (pointer: fine) {
    .game-joystick {
        display: none !important;
    }

    .game-pad {
        gap: 0;
    }
}

/* ── Quick gear bar (3 slots beside joystick) ── */
.game-quickbar {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    touch-action: manipulation;
    width: max-content;
}

.game-quickbar-anchor {
    position: relative;
    width: max-content;
}

.game-quickbar-box {
    position: relative;
    padding: 18px 12px 10px;
    border: 3px solid #2a2218;
    background:
        repeating-linear-gradient(
            90deg,
            #4a3c28 0 2px,
            #3d3224 2px 4px
        ),
        linear-gradient(180deg, #5c4a32 0%, #3d3224 55%, #2a2218 100%);
    box-shadow:
        0 0 0 2px #f8f8f0,
        0 0 0 4px #2a2218,
        4px 5px 0 rgba(26, 20, 14, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.12);
}

.game-quickbar-box::before,
.game-quickbar-box::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    background: #8a7a5a;
    border: 2px solid #2a2218;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.35);
    top: 5px;
}

.game-quickbar-box::before {
    left: 6px;
}

.game-quickbar-box::after {
    right: 6px;
}

.game-quickbar-label {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.28em;
    color: #ffe566;
    text-shadow: 1px 1px 0 #2a2218;
    pointer-events: none;
    white-space: nowrap;
}

.game-quickbar-slots {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.game-quickslot {
    position: relative;
    width: var(--quickslot-size);
    height: var(--quickslot-size);
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-quickslot-frame {
    position: absolute;
    inset: 0;
    border: 3px solid #2a2218;
    background:
        repeating-conic-gradient(#c8b898 0% 25%, #b8a888 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #e8dcc0 0%, #c4b498 45%, #9a8868 100%);
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.55),
        inset -2px -2px 0 rgba(0, 0, 0, 0.15),
        2px 3px 0 rgba(26, 20, 14, 0.35);
    pointer-events: none;
}

.game-quickslot-key {
    position: absolute;
    top: 2px;
    left: 3px;
    z-index: 2;
    font-family: silkscreen, monospace;
    font-size: 7px;
    line-height: 1;
    color: #2a2218;
    background: rgba(255, 248, 220, 0.88);
    border: 2px solid #2a2218;
    padding: 1px 3px 2px;
    pointer-events: none;
}

.game-quickslot-empty {
    position: absolute;
    inset: 10px;
    border: 2px dashed rgba(42, 34, 24, 0.28);
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0 3px,
            rgba(42, 34, 24, 0.06) 3px 6px
        );
    pointer-events: none;
}

.game-quickslot-icon {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    transform: translate(-50%, -50%);
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 2px 0 rgba(45, 36, 24, 0.4));
    pointer-events: none;
}

.game-quickslot.is-filled .game-quickslot-empty {
    opacity: 0;
}

.game-quickslot.is-filled .game-quickslot-icon {
    display: block;
}

.game-quickslot.is-selected .game-quickslot-frame {
    outline: 2px solid #7ee8c8;
    outline-offset: -5px;
    background:
        repeating-conic-gradient(#d8f8ec 0% 25%, #b8ecd8 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #a8f0d0 0%, #5cd4a8 100%);
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.65),
        inset -2px -2px 0 rgba(0, 0, 0, 0.12),
        0 0 0 2px #2a2218,
        0 0 10px rgba(94, 232, 168, 0.55),
        2px 3px 0 rgba(26, 20, 14, 0.35);
}

.game-quickslot.is-use-flash .game-quickslot-frame {
    background:
        repeating-conic-gradient(#fff8dc 0% 25%, #ffe566 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #ffe566 0%, #e6b800 100%);
}

.game-quickslot:active:not(:disabled) .game-quickslot-frame,
.game-quickslot.pressed:not(:disabled) .game-quickslot-frame {
    box-shadow:
        inset 3px 3px 0 rgba(255, 255, 255, 0.45),
        inset -1px -1px 0 rgba(0, 0, 0, 0.22),
        1px 1px 0 rgba(26, 20, 14, 0.35);
}

.game-quickslot:disabled {
    cursor: default;
    opacity: 0.72;
}

.game-quickbar-hint {
    position: relative;
    z-index: 1;
    margin: 0;
    width: 200px;
    height: 22px;
    min-height: 22px;
    max-height: 22px;
    overflow: hidden;
    flex-shrink: 0;
    font-family: silkscreen, monospace;
    font-size: 6px;
    letter-spacing: 0.04em;
    color: rgba(255, 248, 220, 0.92);
    text-shadow: 1px 1px 0 #2a2218;
    text-align: center;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transition: opacity 160ms steps(2, end);
}

.game-quickbar-hint.is-visible {
    opacity: 1;
}

.game-gear-popup {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px 16px calc(34px + 118px);
    pointer-events: none;
    image-rendering: pixelated;
}

.game-gear-popup:not(.hidden) {
    pointer-events: auto;
}

.game-gear-popup.hidden {
    display: none;
}

.game-gear-popup-scrim {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(6, 14, 28, 0.42);
    cursor: pointer;
}

.game-gear-popup-panel {
    position: relative;
    z-index: 1;
    width: min(320px, 94vw);
    padding: 14px 14px 12px;
    border: 3px solid #2a2218;
    background:
        repeating-conic-gradient(#fff8ea 0% 25%, #f4ecd8 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #fffaf0 0%, #efe4cf 100%);
    box-shadow:
        inset 0 0 0 2px #8b7355,
        0 0 0 2px #f8f8f0,
        0 0 0 4px #2a2218,
        5px 6px 0 rgba(26, 20, 14, 0.45);
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.game-gear-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #2a2218;
    background: #ffe566;
    color: #2a2218;
    font-family: silkscreen, monospace;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(45, 36, 24, 0.35);
}

.game-gear-popup-close:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.game-gear-popup-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4px 28px 10px;
}

.game-gear-popup-icon-ring {
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
    margin-bottom: 8px;
    border: 3px solid #2a2218;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 28%, #ffffff 0%, #d8ecff 38%, #7eb8e8 100%);
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.65),
        inset 0 -4px 0 rgba(42, 34, 24, 0.12),
        3px 3px 0 rgba(26, 20, 14, 0.28);
}

.game-gear-popup-icon {
    width: 64px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(1px 2px 0 rgba(26, 20, 14, 0.2));
}

.game-gear-popup-tag {
    margin: 0 0 4px;
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.14em;
    color: #5c8f6a;
}

.game-gear-popup-label {
    margin: 0 0 6px;
    font-family: silkscreen, monospace;
    font-size: 11px;
    line-height: 1.35;
    color: #2a2218;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.55);
}

.game-gear-popup-desc {
    margin: 0;
    font-family: nunito, sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    color: #5c4a32;
}

.game-gear-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-gear-popup-section {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: 7px;
    letter-spacing: 0.12em;
    color: #6b5d48;
    text-align: center;
}

.game-gear-popup-mode-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.game-gear-popup-btn {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 2px solid #2a2218;
    background: #fffaf0;
    font-family: silkscreen, monospace;
    font-size: 8px;
    line-height: 1.35;
    color: #2a2218;
    text-align: left;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(26, 20, 14, 0.22);
    touch-action: manipulation;
}

.game-gear-popup-btn small {
    display: block;
    margin-top: 3px;
    font-family: nunito, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    color: #5c4a32;
    opacity: 0.92;
}

.game-gear-popup-btn.is-active {
    background: linear-gradient(180deg, #a8f0d0 0%, #5cd4a8 100%);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.55),
        2px 2px 0 rgba(26, 20, 14, 0.22);
}

.game-gear-popup-btn--cast,
.game-gear-popup-btn--primary {
    text-align: center;
    letter-spacing: 0.08em;
    font-size: 9px;
}

.game-gear-popup-btn--cast {
    background: linear-gradient(180deg, #ffe566 0%, #e6b800 100%);
}

.game-gear-popup-btn--primary {
    background: linear-gradient(180deg, #9de8ff 0%, #4eb8e8 100%);
}

.game-gear-popup-btn--ghost {
    text-align: center;
    background: linear-gradient(180deg, #f0ebe0 0%, #d8cfc0 100%);
    color: #5c4a32;
    font-size: 8px;
}

.game-gear-popup-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.game-gear-popup-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.game-fishing-hud {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    z-index: 19;
    width: min(220px, 72vw);
    padding: 6px 8px 7px;
    border: 2px solid #2a2218;
    background: linear-gradient(180deg, rgba(12, 48, 88, 0.94) 0%, rgba(8, 32, 64, 0.96) 100%);
    box-shadow:
        0 0 0 1px rgba(140, 210, 255, 0.35),
        2px 3px 0 rgba(26, 20, 14, 0.35);
    pointer-events: none;
}

.game-fishing-hud.hidden {
    display: none;
}

.game-fishing-label {
    margin: 0 0 5px;
    font-family: silkscreen, monospace;
    font-size: 6px;
    line-height: 1.35;
    letter-spacing: 0.04em;
    color: #b8ecff;
    text-align: center;
    text-shadow: 1px 1px 0 #0a1e30;
}

.game-fishing-bar-track {
    height: 8px;
    border: 2px solid #2a2218;
    background: rgba(0, 0, 0, 0.35);
    box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.game-fishing-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg, #7ee8ff 0%, #2a9fd6 45%, #1a6fa8 100%);
    box-shadow: 0 0 8px rgba(94, 200, 255, 0.65);
    transition: width 80ms linear;
}

.game-joystick {
    width: var(--joystick-size);
    height: var(--joystick-size);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    cursor: grab;
}

.game-joystick.is-active {
    cursor: grabbing;
}

.game-joystick-base {
    position: relative;
    width: 100%;
    height: 100%;
    border: 4px solid #2a2218;
    border-radius: 50%;
    background:
        repeating-conic-gradient(rgba(255, 255, 255, 0.14) 0 25%, transparent 0 50%) 50% / 8px 8px,
        radial-gradient(circle at 50% 38%, #dff4ff 0%, #9ad4f5 42%, #5eb8e8 100%);
    box-shadow:
        0 0 0 3px #f8f8f0,
        0 0 0 5px #2a2218,
        4px 6px 0 rgba(26, 20, 14, 0.35),
        inset 0 4px 0 rgba(255, 255, 255, 0.55),
        inset 0 -5px 0 rgba(0, 0, 0, 0.12);
    overflow: visible;
}

.game-joystick-ring {
    position: absolute;
    inset: 14px;
    border: 3px dashed rgba(42, 34, 24, 0.28);
    border-radius: 50%;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.35),
        inset 0 0 12px rgba(42, 34, 24, 0.08);
}

.game-joystick-ring::before,
.game-joystick-ring::after {
    content: "";
    position: absolute;
    background: rgba(42, 34, 24, 0.22);
    pointer-events: none;
}

.game-joystick-ring::before {
    top: 50%;
    left: 8px;
    right: 8px;
    height: 3px;
    transform: translateY(-50%);
}

.game-joystick-ring::after {
    left: 50%;
    top: 8px;
    bottom: 8px;
    width: 3px;
    transform: translateX(-50%);
}

.game-joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--joystick-stick);
    height: var(--joystick-stick);
    transform: translate(-50%, -50%);
    border: 3px solid #2a2218;
    border-radius: 50%;
    background:
        repeating-linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.16) 0 3px,
            transparent 3px 6px
        ),
        radial-gradient(circle at 35% 30%, #ffe566 0%, #ffb347 38%, #e67a2e 100%);
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.65),
        inset -3px -3px 0 rgba(0, 0, 0, 0.18),
        0 3px 0 rgba(26, 20, 14, 0.35);
    pointer-events: none;
    transition: box-shadow 80ms steps(2, end);
}

.game-joystick.is-active .game-joystick-stick {
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.55),
        inset -2px -2px 0 rgba(0, 0, 0, 0.22),
        0 2px 0 rgba(26, 20, 14, 0.4);
}

.game-joystick.is-active .game-joystick-base {
    box-shadow:
        0 0 0 3px #f8f8f0,
        0 0 0 5px #2a2218,
        2px 3px 0 rgba(26, 20, 14, 0.35),
        inset 0 3px 0 rgba(255, 255, 255, 0.45),
        inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.join-toast-stack {
    position: absolute;
    left: 12px;
    bottom: 200px;
    z-index: 12;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    max-width: min(220px, 55vw);
    pointer-events: none;
}

.join-toast {
    font-family: silkscreen, monospace;
    font-size: 8px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(12, 12, 18, 0.42);
    padding: 7px 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.35);
    animation: joinToastFade 3.2s ease forwards;
}

@keyframes joinToastFade {
    0% { opacity: 0; transform: translateY(6px); }
    12% { opacity: 1; transform: translateY(0); }
    72% { opacity: 1; }
    100% { opacity: 0; }
}

.game-loading {
    position: fixed;
    inset: 0;
    z-index: 10150;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #6ecff5 0%, #4eb8e8 55%, #2a8fc4 100%);
    image-rendering: pixelated;
}

.game-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.game-loading-avatar {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-repeat: no-repeat;
    flex-shrink: 0;
    filter: drop-shadow(3px 3px 0 rgba(26, 20, 14, 0.25));
}

.game-loading-text {
    font-family: silkscreen, monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #fff8ea;
    text-shadow: 2px 2px 0 #2a2218;
}

/* ── Vending machine overlay (use_vending) — 2× readable scale ── */
body.vending-open {
    overflow: hidden;
}

.vending-screen {
    --vm: 2.4;
    position: fixed;
    inset: 0;
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(10px, env(safe-area-inset-top, 0px)) 12px max(10px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.vending-screen.hidden {
    display: none;
}

.vending-backdrop {
    position: absolute;
    inset: 0;
    background:
        repeating-conic-gradient(#1a1420 0% 25%, #121018 0% 50%) 50% / 6px 6px,
        radial-gradient(ellipse at 50% 30%, #2a2848 0%, #0a0810 70%);
}

.vending-room {
    position: relative;
    z-index: 1;
    width: min(calc(520px * var(--vm)), 96vw);
    max-height: calc(100dvh - 20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.vending-machine {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 20px);
    min-height: 0;
    overflow: hidden;
    padding: calc(10px * var(--vm));
    background:
        repeating-conic-gradient(#4a4458 0% 25%, #3a3448 0% 50%) 50% / calc(4px * var(--vm)) calc(4px * var(--vm)),
        linear-gradient(180deg, #5a5468 0%, #3a3448 100%);
    border: calc(4px * var(--vm)) solid #1a1420;
    box-shadow:
        inset 0 0 0 calc(2px * var(--vm)) #8a8498,
        calc(8px * var(--vm)) calc(8px * var(--vm)) 0 rgba(0, 0, 0, 0.65);
}

.vending-top-panel {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--vm));
    margin-bottom: calc(8px * var(--vm));
    padding: calc(6px * var(--vm)) calc(8px * var(--vm));
    flex-shrink: 0;
    background: #2a2438;
    border: calc(2px * var(--vm)) solid #1a1420;
    box-shadow: inset 0 calc(-2px * var(--vm)) 0 rgba(0, 0, 0, 0.35);
}

.vending-led-bank {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--vm));
    padding: calc(4px * var(--vm)) calc(6px * var(--vm));
    background: #1a1420;
    border: calc(2px * var(--vm)) solid #0a0810;
    box-shadow: inset 0 0 calc(8px * var(--vm)) rgba(0, 0, 0, 0.55);
}

.vending-top-wire {
    flex: 1;
    min-width: calc(40px * var(--vm));
    height: calc(4px * var(--vm));
    margin-left: auto;
    border-radius: calc(2px * var(--vm));
    background: linear-gradient(
        90deg,
        #e84a4a 0%,
        #e84a4a 18%,
        #e8c84a 18%,
        #e8c84a 36%,
        #4ae86a 36%,
        #4ae86a 54%,
        #4a9ae8 54%,
        #4a9ae8 72%,
        #a84ae8 72%,
        #a84ae8 90%,
        #e8e8f0 90%,
        #e8e8f0 100%
    );
    box-shadow: 0 0 calc(6px * var(--vm)) rgba(122, 232, 255, 0.35);
    animation: vending-wire-pulse 1.4s steps(2) infinite;
}

.vending-body {
    display: grid;
    grid-template-columns: minmax(calc(88px * var(--vm)), 1fr) minmax(0, 2.2fr) minmax(calc(88px * var(--vm)), 1fr);
    gap: calc(6px * var(--vm));
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.vending-side {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    align-self: stretch;
    height: 100%;
    min-height: 100%;
    min-width: 0;
}

.vending-side-rail {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(12px * var(--vm));
    width: calc(18px * var(--vm));
    padding: calc(6px * var(--vm)) 0;
}

.vending-side-rail .vending-wire {
    display: block;
    width: 100%;
    height: calc(5px * var(--vm));
    border-radius: 0;
    box-shadow: calc(2px * var(--vm)) calc(2px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
    animation: vending-wire-pulse 1.4s steps(2) infinite;
    transform: none;
}

.vending-side-left .vending-side-rail .vending-wire:nth-child(1) { animation-delay: 0s; }
.vending-side-left .vending-side-rail .vending-wire:nth-child(2) { animation-delay: 0.25s; }
.vending-side-left .vending-side-rail .vending-wire:nth-child(3) { animation-delay: 0.5s; }
.vending-side-right .vending-side-rail .vending-wire:nth-child(1) { animation-delay: 0.1s; }
.vending-side-right .vending-side-rail .vending-wire:nth-child(2) { animation-delay: 0.35s; }
.vending-side-right .vending-side-rail .vending-wire:nth-child(3) { animation-delay: 0.6s; }

.vending-side-plate {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: calc(8px * var(--vm));
    padding: calc(10px * var(--vm)) calc(8px * var(--vm));
    min-height: 100%;
    height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 28%),
        linear-gradient(180deg, #322c40 0%, #1a1420 100%);
    border: calc(2px * var(--vm)) solid #0a0810;
    box-shadow:
        inset 0 0 calc(14px * var(--vm)) rgba(0, 0, 0, 0.45),
        inset 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.08);
}

.vending-side-plate-stack {
    justify-content: flex-start;
}

.vending-side-plate .vending-chips-slot {
    margin-top: auto;
    flex-shrink: 0;
}

.vending-side-label {
    font-family: silkscreen, monospace;
    font-size: calc(5px * var(--vm));
    letter-spacing: 0.16em;
    text-align: center;
    color: #7ae8ff;
    text-shadow: 0 0 calc(4px * var(--vm)) rgba(122, 232, 255, 0.45);
}

.vending-side-btn {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(4px * var(--vm));
    width: 100%;
    min-height: calc(52px * var(--vm));
    padding: calc(8px * var(--vm)) calc(5px * var(--vm));
    text-align: center;
    line-height: 1.25;
}

.vending-side-plate-stack .vending-side-btn {
    min-height: calc(44px * var(--vm));
}

.vending-side-btn-text {
    display: block;
    font-size: calc(7px * var(--vm));
    letter-spacing: 0.05em;
    line-height: 1.35;
}

.vending-side-led {
    display: block;
    width: calc(8px * var(--vm));
    height: calc(8px * var(--vm));
    margin: 0 auto;
    border: calc(2px * var(--vm)) solid #1a1420;
    border-radius: 50%;
    background: #2a2438;
    box-shadow: inset calc(1px * var(--vm)) calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.15);
}

.vending-side-led-green {
    background: #4ae86a;
    box-shadow: 0 0 calc(8px * var(--vm)) #4ae86a;
    animation: vending-led-blink 1.2s steps(2) infinite;
}

.vending-side-led-amber {
    background: #e8c84a;
    box-shadow: 0 0 calc(8px * var(--vm)) #e8c84a;
    animation: vending-led-blink 0.9s steps(2) infinite 0.2s;
}

.vending-side-led-cyan {
    background: #4a9ae8;
    box-shadow: 0 0 calc(8px * var(--vm)) #4a9ae8;
    animation: vending-led-blink 1.5s steps(2) infinite 0.4s;
}

.vending-side-led-row {
    display: flex;
    justify-content: center;
    gap: calc(8px * var(--vm));
    margin-top: auto;
    padding-top: calc(4px * var(--vm));
    flex-shrink: 0;
}

.vending-side-left .vending-side-led-green {
    margin-top: 0;
    flex-shrink: 0;
}

/* SLOT B — hand-drawn yellow-green status LCD (machine stock + wallet) */
.vending-status-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(3px * var(--vm));
    width: 100%;
    margin-top: calc(4px * var(--vm));
}

.vending-status-bezel {
    position: relative;
    width: 100%;
    padding: calc(5px * var(--vm));
    /* asymmetric radii give it an organic, hand-drawn casing */
    border-radius: calc(8px * var(--vm)) calc(6px * var(--vm)) calc(9px * var(--vm)) calc(5px * var(--vm));
    background: linear-gradient(180deg, #3c3550 0%, #211a2c 100%);
    border: calc(2px * var(--vm)) solid #0a0810;
    box-shadow:
        inset 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.12),
        inset 0 0 calc(10px * var(--vm)) rgba(0, 0, 0, 0.5),
        0 calc(2px * var(--vm)) calc(4px * var(--vm)) rgba(0, 0, 0, 0.42);
}

/* tiny corner screws for a real-machine feel */
.vending-status-bezel::before,
.vending-status-bezel::after {
    content: "";
    position: absolute;
    width: calc(3px * var(--vm));
    height: calc(3px * var(--vm));
    border-radius: 50%;
    background: radial-gradient(circle at 34% 32%, #7b7490, #241d30);
    box-shadow: 0 0 0 calc(1px * var(--vm)) #0a0810;
}
.vending-status-bezel::before { top: calc(3px * var(--vm)); left: calc(3px * var(--vm)); }
.vending-status-bezel::after { bottom: calc(3px * var(--vm)); right: calc(3px * var(--vm)); }

.vending-status-glass {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: calc(2px * var(--vm));
    padding: calc(6px * var(--vm)) calc(6px * var(--vm)) calc(5px * var(--vm));
    /* slightly wobbly inner corners = sketched glass */
    border-radius: calc(4px * var(--vm)) calc(6px * var(--vm)) calc(3px * var(--vm)) calc(5px * var(--vm));
    background: radial-gradient(125% 90% at 50% -10%, #ecf578 0%, #c9dd33 42%, #a3ba26 100%);
    border: calc(1px * var(--vm)) solid #6f8016;
    box-shadow:
        inset 0 0 calc(9px * var(--vm)) rgba(74, 92, 8, 0.55),
        inset 0 calc(1px * var(--vm)) calc(2px * var(--vm)) rgba(255, 255, 255, 0.6);
}

.vending-status-scan {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(40, 52, 6, 0.14) 0,
        rgba(40, 52, 6, 0.14) calc(1px * var(--vm)),
        transparent calc(1px * var(--vm)),
        transparent calc(3px * var(--vm))
    );
    mix-blend-mode: multiply;
    opacity: 0.55;
    pointer-events: none;
}

.vending-status-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(70% 55% at 50% 0%, rgba(255, 255, 255, 0.5), transparent 70%);
    opacity: 0.7;
    pointer-events: none;
    animation: vending-status-flicker 3.4s ease-in-out infinite;
}

@keyframes vending-status-flicker {
    0%, 100% { opacity: 0.62; }
    45% { opacity: 0.78; }
    50% { opacity: 0.5; }
    55% { opacity: 0.74; }
}

.vending-status-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
    gap: calc(3px * var(--vm));
}

.vending-status-key {
    font-family: silkscreen, monospace;
    font-size: calc(4px * var(--vm));
    letter-spacing: 0.14em;
    color: #4a5a10;
    text-shadow: 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.35);
}

.vending-status-val {
    margin-left: auto;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--vm));
    letter-spacing: 0.02em;
    color: #232e08;
    text-shadow:
        0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.4),
        0 0 calc(3px * var(--vm)) rgba(60, 80, 4, 0.35);
}

.vending-status-divider {
    position: relative;
    z-index: 1;
    height: calc(1px * var(--vm));
    margin: calc(1px * var(--vm)) 0;
    background: repeating-linear-gradient(
        90deg,
        #6f8016 0,
        #6f8016 calc(2px * var(--vm)),
        transparent calc(2px * var(--vm)),
        transparent calc(4px * var(--vm))
    );
    opacity: 0.7;
}

.vending-status-caption {
    font-family: silkscreen, monospace;
    font-size: calc(3.5px * var(--vm));
    letter-spacing: 0.16em;
    color: #7ae8ff;
    text-shadow: 0 0 calc(3px * var(--vm)) rgba(122, 232, 255, 0.4);
    opacity: 0.72;
}

.vending-center {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.vending-bottom-deck {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    grid-template-rows: 1fr;
    gap: calc(6px * var(--vm));
    align-items: stretch;
    margin-top: calc(6px * var(--vm));
    padding: calc(6px * var(--vm));
    flex-shrink: 0;
    background: #2a2438;
    border: calc(2px * var(--vm)) solid #1a1420;
    box-shadow: inset 0 calc(2px * var(--vm)) calc(6px * var(--vm)) rgba(0, 0, 0, 0.35);
}

.vending-wire-red { background: #e84a4a; }
.vending-wire-yellow { background: #e8c84a; }
.vending-wire-green { background: #4ae86a; }
.vending-wire-blue { background: #4a9ae8; }
.vending-wire-purple { background: #a84ae8; }
.vending-wire-white { background: #e8e8f0; }

@keyframes vending-wire-pulse {
    0%, 100% { opacity: 0.55; filter: brightness(0.85); }
    50% { opacity: 1; filter: brightness(1.2); }
}

.vending-machine[data-led-state="busy"] .vending-side-led-green,
.vending-machine[data-led-state="boot"] .vending-side-led-green {
    animation-duration: 0.3s;
}

.vending-machine[data-led-state="error"] .vending-side-led-amber {
    background: #e84a4a;
    box-shadow: 0 0 calc(10px * var(--vm)) #e84a4a;
    animation-duration: 0.35s;
}

.vending-machine[data-led-state="ok"] .vending-side-led-cyan,
.vending-machine[data-led-state="ready"] .vending-side-led-cyan {
    background: #4ae86a;
    box-shadow: 0 0 calc(10px * var(--vm)) #4ae86a;
}

.vending-brand {
    margin-left: auto;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--vm));
    letter-spacing: 0.06em;
    color: #7ae8ff;
    text-shadow: 0 0 calc(6px * var(--vm)) rgba(122, 232, 255, 0.5);
}

.vending-led {
    width: calc(10px * var(--vm));
    height: calc(10px * var(--vm));
    border: calc(2px * var(--vm)) solid #1a1420;
    background: #2a2438;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.15);
}

.vending-machine[data-led-state="power"] .vending-led-power,
.vending-machine[data-led-state="boot"] .vending-led-power,
.vending-machine[data-led-state="ready"] .vending-led-ok,
.vending-machine[data-led-state="ok"] .vending-led-ok {
    background: #4ae86a;
    box-shadow: 0 0 8px #4ae86a;
    animation: vending-led-blink 0.8s steps(2) infinite;
}

.vending-machine[data-led-state="boot"] .vending-led-busy,
.vending-machine[data-led-state="busy"] .vending-led-busy {
    background: #e8c84a;
    box-shadow: 0 0 8px #e8c84a;
    animation: vending-led-blink 0.25s steps(2) infinite;
}

.vending-machine[data-led-state="error"] .vending-led-error {
    background: #e84a4a;
    box-shadow: 0 0 10px #e84a4a;
    animation: vending-led-blink 0.35s steps(2) infinite;
}

.vending-machine[data-led-state="busy"] .vending-led-power {
    background: #4ae86a;
    box-shadow: 0 0 6px #4ae86a;
}

@keyframes vending-led-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.vending-monitor-wrap {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.vending-monitor-bezel {
    padding: calc(8px * var(--vm));
    background: linear-gradient(180deg, #6a6478 0%, #4a4458 100%);
    border: calc(3px * var(--vm)) solid #1a1420;
    box-shadow: inset 0 calc(2px * var(--vm)) 0 rgba(255, 255, 255, 0.12);
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.vending-monitor-glass {
    position: relative;
    flex: 1 1 auto;
    min-height: calc(150px * var(--vm));
    height: auto;
    max-height: min(calc(220px * var(--vm)), 42dvh);
    overflow: hidden;
    background: #0a1a8a;
    border: calc(3px * var(--vm)) solid #0a0818;
    box-shadow:
        inset 0 0 calc(24px * var(--vm)) rgba(40, 120, 255, 0.35),
        inset 0 0 0 calc(2px * var(--vm)) #1a3aaa;
}

.vending-scanlines {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.18) 2px,
        rgba(0, 0, 0, 0.18) 4px
    );
    animation: vending-scan-drift 6s linear infinite;
}

.vending-monitor-glow {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 40%, rgba(120, 200, 255, 0.12) 0%, transparent 70%);
    animation: vending-glow-pulse 2s ease-in-out infinite;
}

@keyframes vending-scan-drift {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

@keyframes vending-glow-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.vending-grade-flash {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    --vending-grade-flash-dur: 4.2s;
}

.vending-grade-flash.hidden {
    display: none;
}

.vending-grade-flash-white {
    position: absolute;
    inset: -12%;
    background: #fff;
    opacity: 0;
    animation: vending-grade-white-blink var(--vending-grade-flash-dur) steps(1) forwards;
}

.vending-grade-flash-strobe {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.22) 0,
            rgba(255, 255, 255, 0.22) 1px,
            transparent 1px,
            transparent 4px
        ),
        radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.55) 38%, transparent 72%);
    opacity: 0;
    mix-blend-mode: screen;
    animation: vending-grade-strobe var(--vending-grade-flash-dur) ease-out forwards;
}

.vending-grade-flash-tier {
    position: relative;
    z-index: 2;
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(14px * var(--vm));
    letter-spacing: 0.14em;
    color: #0a1a8a;
    text-shadow:
        0 0 calc(8px * var(--vm)) #fff,
        0 calc(2px * var(--vm)) 0 rgba(0, 0, 0, 0.28);
    opacity: 0;
    transform: scale(1.2);
    animation: vending-grade-tier-pop var(--vending-grade-flash-dur) steps(1) forwards;
}

.vending-grade-flash-sub {
    position: relative;
    z-index: 2;
    margin: calc(6px * var(--vm)) 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--vm));
    letter-spacing: 0.16em;
    color: #1a2888;
    text-shadow: 0 0 calc(5px * var(--vm)) #fff;
    opacity: 0;
    animation: vending-grade-sub-pop var(--vending-grade-flash-dur) steps(1) forwards;
}

.vending-monitor-glass--grade-flash {
    animation: vending-glass-grade-pulse var(--vending-grade-flash-dur) steps(1) forwards;
}

@keyframes vending-grade-white-blink {
    0%, 2% { opacity: 0; }
    3%, 10% { opacity: 1; }
    11%, 16% { opacity: 0.08; }
    17%, 24% { opacity: 0.98; }
    25%, 30% { opacity: 0.1; }
    31%, 38% { opacity: 1; }
    39%, 44% { opacity: 0.12; }
    45%, 52% { opacity: 0.95; }
    53%, 58% { opacity: 0.14; }
    59%, 66% { opacity: 0.92; }
    67%, 72% { opacity: 0.16; }
    73%, 80% { opacity: 0.88; }
    81%, 86% { opacity: 0.2; }
    87%, 92% { opacity: 0.72; }
    93%, 97% { opacity: 0.35; }
    98%, 100% { opacity: 0; }
}

@keyframes vending-grade-strobe {
    0%, 4% { opacity: 0; transform: scale(1); }
    6%, 14% { opacity: 0.95; transform: scale(1.03); }
    16%, 22% { opacity: 0.1; transform: scale(1); }
    24%, 32% { opacity: 0.9; transform: scale(1.02); }
    34%, 40% { opacity: 0.12; }
    42%, 50% { opacity: 0.88; transform: scale(1.03); }
    52%, 58% { opacity: 0.14; }
    60%, 68% { opacity: 0.82; transform: scale(1.04); }
    70%, 76% { opacity: 0.16; }
    78%, 86% { opacity: 0.7; transform: scale(1.05); }
    88%, 94% { opacity: 0.25; transform: scale(1.04); }
    96%, 100% { opacity: 0; transform: scale(1.06); }
}

@keyframes vending-grade-tier-pop {
    0%, 14% { opacity: 0; transform: scale(1.28); }
    16%, 28% { opacity: 1; transform: scale(1); }
    30%, 40% { opacity: 0; transform: scale(1.12); }
    42%, 56% { opacity: 1; transform: scale(1); }
    58%, 68% { opacity: 0; transform: scale(1.1); }
    70%, 84% { opacity: 1; transform: scale(1); }
    86%, 100% { opacity: 0; transform: scale(0.96); }
}

@keyframes vending-grade-sub-pop {
    0%, 18% { opacity: 0; }
    20%, 32% { opacity: 1; }
    34%, 44% { opacity: 0; }
    46%, 60% { opacity: 1; }
    62%, 72% { opacity: 0; }
    74%, 88% { opacity: 1; }
    90%, 100% { opacity: 0; }
}

@keyframes vending-glass-grade-pulse {
    0%, 2% { filter: none; }
    3%, 10% { filter: brightness(3) saturate(0.2); }
    11%, 16% { filter: brightness(1.15); }
    17%, 24% { filter: brightness(2.6) saturate(0.25); }
    25%, 30% { filter: brightness(1.2); }
    31%, 38% { filter: brightness(2.9) saturate(0.2); }
    39%, 44% { filter: brightness(1.18); }
    45%, 52% { filter: brightness(2.4) saturate(0.3); }
    53%, 58% { filter: brightness(1.22); }
    59%, 66% { filter: brightness(2.2); }
    67%, 72% { filter: brightness(1.24); }
    73%, 80% { filter: brightness(2); }
    81%, 86% { filter: brightness(1.26); }
    87%, 92% { filter: brightness(1.7); }
    93%, 97% { filter: brightness(1.35); }
    98%, 100% { filter: none; }
}

.vending-monitor-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    min-height: 0;
    padding: calc(10px * var(--vm));
    box-sizing: border-box;
    font-family: silkscreen, monospace;
    color: #7ae8ff;
    text-shadow: 0 0 calc(4px * var(--vm)) rgba(122, 232, 255, 0.6);
    overflow: hidden;
}

.vending-monitor-inner:has(#vending-view-result:not(.hidden)) {
    display: flex;
    flex-direction: column;
    padding: calc(6px * var(--vm)) calc(8px * var(--vm));
}

.vending-view.hidden {
    display: none;
}

.vending-boot-text {
    margin: 0;
    font-family: inherit;
    font-size: calc(9px * var(--vm));
    line-height: 1.55;
    white-space: pre-wrap;
    color: #9cf0ff;
}

.vending-menu-title {
    margin: 0 0 calc(10px * var(--vm));
    font-size: calc(10px * var(--vm));
    color: #fff;
    text-align: center;
}

.vending-menu-line {
    margin: 0 0 calc(6px * var(--vm));
    font-size: calc(8px * var(--vm));
    letter-spacing: 0.04em;
}

.vending-menu-cursor,
.vending-soon-cursor {
    margin: calc(8px * var(--vm)) 0 0;
    font-size: calc(10px * var(--vm));
    animation: vending-cursor-blink 0.7s steps(2) infinite;
}

@keyframes vending-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.vending-error-code {
    margin: 0 0 calc(8px * var(--vm));
    font-size: calc(18px * var(--vm));
    color: #ff6a6a;
    text-align: center;
    animation: vending-error-flash 0.5s steps(2) infinite;
}

.vending-error-msg {
    margin: 0;
    font-size: calc(8px * var(--vm));
    line-height: 1.6;
    white-space: pre-wrap;
    color: #ff9a9a;
    text-align: center;
}

@keyframes vending-error-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.vending-soon-title {
    margin: 0 0 calc(8px * var(--vm));
    font-size: calc(12px * var(--vm));
    text-align: center;
    color: #ffe86a;
}

.vending-soon-msg {
    margin: 0;
    font-size: calc(8px * var(--vm));
    line-height: 1.6;
    white-space: pre-wrap;
    text-align: center;
    color: #b8e8ff;
}

.vending-shuffle-label {
    margin: 0 0 calc(8px * var(--vm));
    font-size: calc(9px * var(--vm));
    text-align: center;
    color: #fff;
    animation: vending-shuffle-text 0.4s steps(2) infinite;
}

@keyframes vending-shuffle-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.vending-shuffle-window {
    position: relative;
    height: min(calc(128px * var(--vm)), 100%);
    max-height: calc(128px * var(--vm));
    margin: 0 auto calc(6px * var(--vm));
    overflow: hidden;
    background: #061060;
    border: calc(2px * var(--vm)) solid #2a5ae8;
    box-shadow: inset 0 0 calc(16px * var(--vm)) rgba(0, 80, 255, 0.4);
}

.vending-shuffle-pointer {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: calc(4px * var(--vm));
    height: calc(74px * var(--vm));
    transform: translate(-50%, -50%);
    background: #ffe86a;
    box-shadow: 0 0 calc(8px * var(--vm)) #ffe86a;
    pointer-events: none;
}

.vending-shuffle-pointer::before,
.vending-shuffle-pointer::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: calc(8px * var(--vm)) solid transparent;
    border-right: calc(8px * var(--vm)) solid transparent;
}

.vending-shuffle-pointer::before {
    top: calc(-10px * var(--vm));
    border-bottom: calc(10px * var(--vm)) solid #ffe86a;
}

.vending-shuffle-pointer::after {
    bottom: calc(-10px * var(--vm));
    border-top: calc(10px * var(--vm)) solid #ffe86a;
}

.vending-shuffle-track-wrap {
    height: 100%;
    padding: calc(14px * var(--vm)) 0;
    box-sizing: border-box;
    overflow: hidden;
}

.vending-shuffle-track {
    display: flex;
    align-items: center;
    height: 100%;
    will-change: transform;
}

.vending-shuffle-card {
    flex: 0 0 calc(66px * var(--vm));
    width: calc(66px * var(--vm));
    height: calc(74px * var(--vm));
    padding: calc(4px * var(--vm));
    box-sizing: border-box;
}

.vending-shuffle-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: calc(2px * var(--vm)) solid #1a1420;
    background: #2a2848;
    image-rendering: pixelated;
    box-shadow: calc(2px * var(--vm)) calc(2px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
}

.vending-shuffle-status {
    margin: 0;
    font-size: calc(10px * var(--vm));
    text-align: center;
    letter-spacing: 0.2em;
    color: #7ae8ff;
}

.vending-result-headline {
    margin: 0 0 calc(2px * var(--vm));
    font-size: calc(9px * var(--vm));
    text-align: center;
    color: #4ae86a;
    flex-shrink: 0;
    animation: vending-result-pop 0.5s ease-out;
}

.vending-view-result--grade-up .vending-result-headline {
    color: #fff;
    text-shadow:
        0 0 calc(8px * var(--vm)) rgba(255, 255, 255, 0.95),
        0 0 calc(14px * var(--vm)) #7ae8ff;
    animation: vending-grade-headline-glow 2.2s ease-out;
}

.vending-view-result--grade-up .vending-result-mint-tag {
    color: #fff;
    background: linear-gradient(180deg, #e8f4ff 0%, #9ec8ff 45%, #5a8fd4 100%);
    border-color: #fff;
    box-shadow:
        0 0 calc(10px * var(--vm)) rgba(255, 255, 255, 0.75),
        inset 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.65);
}

@keyframes vending-grade-headline-glow {
    0% { opacity: 0; transform: scale(1.08); filter: brightness(2.5); }
    35% { opacity: 1; transform: scale(1); filter: brightness(1.4); }
    100% { opacity: 1; transform: scale(1); filter: none; }
}

.vending-view-result:not(.hidden) {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: calc(2px * var(--vm));
}

.vending-result-layout {
    display: flex;
    flex: 1;
    gap: calc(8px * var(--vm));
    align-items: stretch;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.vending-result-card {
    display: block;
    width: auto;
    height: 100%;
    max-height: 100%;
    max-width: 44%;
    aspect-ratio: 3 / 4;
    flex-shrink: 0;
    margin: 0;
    object-fit: contain;
    border: calc(2px * var(--vm)) solid #ffe86a;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.25);
    box-shadow:
        0 0 calc(10px * var(--vm)) rgba(255, 232, 106, 0.45),
        calc(3px * var(--vm)) calc(3px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
    animation: vending-result-pop 0.6s ease-out;
}

.vending-result-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    text-align: left;
    overflow: hidden;
}

.vending-result-name {
    margin: 0 0 calc(4px * var(--vm));
    font-size: calc(10px * var(--vm));
    line-height: 1.2;
    color: #fff;
    letter-spacing: 0.04em;
    word-break: break-word;
    flex-shrink: 0;
}

.vending-result-meta {
    margin: 0 0 calc(4px * var(--vm));
    font-size: calc(8px * var(--vm));
    line-height: 1.35;
    color: #7ae8ff;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.vending-result-spells {
    margin: 0;
    padding: 0;
    list-style: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.vending-result-spells li {
    margin: 0 0 calc(3px * var(--vm));
    padding: calc(3px * var(--vm)) calc(5px * var(--vm));
    font-size: calc(7px * var(--vm));
    line-height: 1.4;
    color: #d8f0ff;
    background: rgba(0, 40, 120, 0.4);
    border-left: calc(2px * var(--vm)) solid #4a9ae8;
}

.vending-result-spells li.vending-spell-def {
    border-left-color: #e8c84a;
    color: #ffe566;
}

.vending-result-equip {
    flex-shrink: 0;
    width: 100%;
    margin: calc(4px * var(--vm)) 0 0;
    padding: calc(7px * var(--vm)) calc(8px * var(--vm));
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--vm));
    letter-spacing: 0.06em;
    color: #0a1a8a;
    background: linear-gradient(180deg, #4ae86a 0%, #2a9a40 100%);
    border: calc(2px * var(--vm)) solid #1a1420;
    box-shadow:
        inset 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.35),
        0 calc(2px * var(--vm)) 0 #1a1420;
    cursor: pointer;
    animation: vending-result-pop 0.7s ease-out;
}

.vending-result-equip.hidden {
    display: none;
}

.vending-result-equip:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.vending-result-equip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@keyframes vending-result-pop {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

.vending-monitor-label {
    margin: calc(4px * var(--vm)) 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--vm));
    letter-spacing: 0.12em;
    text-align: center;
    color: #8a8498;
    flex-shrink: 0;
}

.vending-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: calc(8px * var(--vm));
    width: 100%;
    padding: calc(10px * var(--vm)) calc(8px * var(--vm));
    font-family: silkscreen, monospace;
    font-size: calc(9px * var(--vm));
    letter-spacing: 0.04em;
    text-align: center;
    color: #fff8ea;
    cursor: pointer;
    background:
        repeating-conic-gradient(#5a5468 0% 25%, #4a4458 0% 50%) 50% / calc(3px * var(--vm)) calc(3px * var(--vm)),
        linear-gradient(180deg, #6a6478 0%, #4a4458 100%);
    border: calc(3px * var(--vm)) solid #1a1420;
    box-shadow:
        inset 0 calc(-3px * var(--vm)) 0 rgba(0, 0, 0, 0.25),
        calc(3px * var(--vm)) calc(3px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
    transition: transform 0.05s ease;
}

.vending-btn .vending-btn-price {
    font-size: calc(6px * var(--vm));
    margin-top: calc(2px * var(--vm));
}

.vending-btn:active:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.vending-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.vending-btn-draw {
    flex-direction: column;
    gap: calc(4px * var(--vm));
    line-height: 1.2;
}

.vending-btn-price {
    display: block;
    font-size: calc(6px * var(--vm));
    color: #ffd838;
    text-shadow: calc(1px * var(--vm)) calc(1px * var(--vm)) 0 #283818;
}

.vending-btn-unaffordable .vending-btn-price {
    color: #ff8080;
}

.vending-btn-draw:not(:disabled) .vending-btn-led {
    background: #4ae86a;
    box-shadow: 0 0 6px #4ae86a;
}

.vending-btn-used {
    color: #aaa;
}

.vending-btn-led {
    flex-shrink: 0;
    width: calc(8px * var(--vm));
    height: calc(8px * var(--vm));
    border: calc(2px * var(--vm)) solid #1a1420;
    background: #3a3448;
}

.vending-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-column: 2;
    grid-row: 1;
    gap: calc(3px * var(--vm));
    padding: calc(4px * var(--vm));
    background: #2a2438;
    border: calc(2px * var(--vm)) solid #1a1420;
    align-self: stretch;
}

.vending-keypad span {
    height: calc(11px * var(--vm));
    background: #4a4458;
    border: calc(1px * var(--vm)) solid #1a1420;
    box-shadow: inset 0 calc(1px * var(--vm)) 0 rgba(255, 255, 255, 0.1);
}

.vending-exit {
    width: 100%;
    margin-top: auto;
    padding: calc(8px * var(--vm)) calc(4px * var(--vm));
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--vm));
    letter-spacing: 0.06em;
    line-height: 1.35;
    text-align: center;
    color: #ff9a9a;
    cursor: pointer;
    background: #3a2430;
    border: calc(2px * var(--vm)) solid #1a1420;
    box-shadow: calc(2px * var(--vm)) calc(2px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.vending-exit:active {
    transform: translate(calc(1px * var(--vm)), calc(1px * var(--vm)));
    box-shadow: calc(1px * var(--vm)) calc(1px * var(--vm)) 0 rgba(0, 0, 0, 0.5);
}

.vending-chips-slot,
.vending-card-slot {
    background: #1a1420;
    border: calc(2px * var(--vm)) solid #0a0810;
}

.vending-card-slot {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    height: 100%;
    min-height: calc(36px * var(--vm));
    align-self: stretch;
    transform: none;
    box-shadow: inset 0 calc(2px * var(--vm)) calc(4px * var(--vm)) rgba(0, 0, 0, 0.6);
}

.vending-chips-slot {
    position: relative;
    right: auto;
    bottom: auto;
    width: 100%;
    height: calc(5px * var(--vm));
    margin-top: 0;
    border-radius: calc(3px * var(--vm));
}

@media (max-height: 720px) {
    .vending-screen {
        --vm: 2.06;
    }

    .vending-monitor-glass {
        max-height: min(calc(190px * var(--vm)), 36dvh);
    }
}

@media (max-height: 600px) {
    .vending-screen {
        --vm: 1.86;
    }

    .vending-monitor-glass {
        max-height: min(calc(165px * var(--vm)), 32dvh);
    }
}

/* ── Trainer stats screen ── */

.trainer-stats-level-block {
    text-align: center;
    margin: 12px 0 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
}

.trainer-stats-level {
    font-family: silkscreen, monospace;
    font-size: calc(14px * var(--ui-scale));
    margin: 0 0 6px;
    color: #ffd838;
}

.trainer-stats-xp {
    font-size: calc(9px * var(--ui-scale));
    margin: 0 0 8px;
    color: var(--text-muted);
}

.trainer-stats-xpbar {
    height: 10px;
    background: #283818;
    border: 2px solid #142810;
    border-radius: 4px;
    overflow: hidden;
}

.trainer-stats-xpbar div {
    height: 100%;
    background: linear-gradient(90deg, #78c850, #ffd838);
    transition: width 0.3s ease;
}

.trainer-stats-req-hint {
    margin: 8px 0 0;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--ui-scale));
    line-height: 1.45;
    color: #ffe08a;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.trainer-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.trainer-stats-cell {
    padding: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--panel-border);
    border-radius: 6px;
}

.trainer-stats-label {
    display: block;
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.trainer-stats-val {
    font-family: silkscreen, monospace;
    font-size: 13px;
    color: #1a140e;
}

.trainer-stats-section-title {
    font-family: silkscreen, monospace;
    font-size: 10px;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.trainer-stats-history {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    max-height: 160px;
    overflow-y: auto;
}

.trainer-stats-history-row {
    padding: 8px 10px;
    margin-bottom: 4px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
}

.trainer-stats-history-row.won {
    background: rgba(120, 200, 80, 0.15);
    border-color: #487038;
}

.trainer-stats-history-row.lost {
    background: rgba(200, 80, 80, 0.12);
    border-color: #804040;
}

.trainer-stats-history-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px 0;
}

.lb-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Vending mint / grade feedback ── */
.vending-result-mint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: calc(6px * var(--vm)) calc(10px * var(--vm));
    margin: 0 0 calc(10px * var(--vm));
    padding: calc(6px * var(--vm)) calc(10px * var(--vm));
    border: calc(2px * var(--vm)) solid #3a6a48;
    background: linear-gradient(180deg, rgba(20, 48, 32, 0.92) 0%, rgba(12, 28, 20, 0.95) 100%);
    box-shadow: inset 0 0 0 calc(1px * var(--vm)) rgba(140, 220, 160, 0.2);
}

.vending-result-mint.hidden {
    display: none;
}

.vending-result-mint-tag {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--vm));
    letter-spacing: 0.1em;
    color: #b8f0c0;
    padding: calc(2px * var(--vm)) calc(6px * var(--vm));
    border: calc(1px * var(--vm)) solid #4a8a58;
    background: rgba(0, 0, 0, 0.25);
}

.vending-result-mint-detail {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--vm));
    letter-spacing: 0.04em;
    color: #d8ece0;
    line-height: 1.45;
    text-align: center;
}

/* ── Vault card grading popup (chunky pixel CRT) ── */
.vault-card-popup {
    position: fixed;
    inset: 0;
    z-index: 100010;
    display: grid;
    place-items: center;
    padding: 16px;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

.vault-card-popup.hidden {
    display: none;
}

.vault-card-popup-scrim {
    position: absolute;
    inset: 0;
    border: 0;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.18) 0px,
            rgba(0, 0, 0, 0.18) 1px,
            transparent 1px,
            transparent 3px
        ),
        rgba(6, 4, 10, 0.82);
    cursor: pointer;
}

.vault-card-popup-panel {
    position: relative;
    width: min(100%, 920px);
    max-height: min(94vh, 900px);
    overflow-x: hidden;
    overflow-y: auto;
    border: 4px solid #1a140c;
    border-radius: 2px;
    background:
        repeating-conic-gradient(#3a3428 0% 25%, #2e2820 0% 50%) 50% / 8px 8px,
        linear-gradient(180deg, #4a4034 0%, #221c16 55%, #14100c 100%);
    box-shadow:
        inset 0 0 0 2px #d8c8a0,
        inset 0 0 0 4px #1a140c,
        6px 6px 0 #0a0806,
        10px 10px 0 rgba(0, 0, 0, 0.35);
    padding: 14px 14px 16px;
    box-sizing: border-box;
    image-rendering: pixelated;
}

.vault-card-popup-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.07) 0px,
        rgba(0, 0, 0, 0.07) 1px,
        transparent 1px,
        transparent 4px
    );
    z-index: 0;
}

.vault-card-popup-panel[data-grade="2"] .vault-card-popup-glow,
.vault-card-popup-panel[data-grade="3"] .vault-card-popup-glow,
.vault-card-popup-panel[data-grade="4"] .vault-card-popup-glow,
.vault-card-popup-panel[data-grade="5"] .vault-card-popup-glow {
    display: none;
}

.vault-card-popup-glow {
    display: none;
}

.vault-card-popup-close {
    position: relative;
    flex-shrink: 0;
    z-index: 3;
    width: 40px;
    height: 26px;
    margin: 0;
    padding: 0;
    border: 3px solid #1a140c;
    border-radius: 1px;
    background:
        repeating-conic-gradient(#ffe566 0% 25%, #f5d84a 0% 50%) 50% / 4px 4px,
        #ffe566;
    color: #1a140c;
    font-family: silkscreen, monospace;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 3px 3px 0 #1a140c;
    image-rendering: pixelated;
}

.vault-card-popup-close:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #1a140c;
}

.vault-card-popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    padding-bottom: 10px;
    border-bottom: 3px solid #1a140c;
}

.vault-card-popup-header-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding-right: 4px;
}

.vault-card-popup-grade-pill {
    font-family: silkscreen, monospace;
    font-size: 13px;
    letter-spacing: 0.06em;
    padding: 6px 12px;
    border: 3px solid #1a140c;
    image-rendering: pixelated;
}

.vault-card-popup-grade-pill.vault-grade-tag {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        3px 3px 0 #1a140c;
}

.vault-card-popup-mult {
    font-family: silkscreen, monospace;
    font-size: 15px;
    letter-spacing: 0.06em;
    color: #98ffb0;
    text-shadow: 2px 2px 0 #0a2010;
    padding: 4px 8px;
    border: 2px solid #1a4030;
    background: #142820;
    box-shadow: inset 0 0 0 1px #3a8a58;
}

.vault-card-popup-stage {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    position: relative;
    z-index: 1;
}

.vault-card-popup-visual.vault-slot-visual {
    position: relative;
    inset: auto;
    width: min(
        300px,
        calc((min(94vh, 860px) - 96px) * 504 / 708),
        calc(100vw - 64px)
    );
    max-width: 100%;
    max-height: calc(min(94vh, 860px) - 96px);
    height: auto;
    margin: 0 auto;
    padding: 6px;
    box-sizing: border-box;
    overflow: visible;
    flex-shrink: 0;
}

.vault-card-popup-visual {
    position: relative;
    overflow: visible;
    flex-shrink: 0;
}

.vault-card-popup-info {
    position: relative;
    z-index: 2;
    min-width: 0;
    overflow: visible;
}

.vault-card-popup-frame {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 100%;
    border: 4px solid #1a140c;
    background:
        repeating-conic-gradient(#1a1814 0% 25%, #12100c 0% 50%) 50% / 4px 4px,
        #0e0c0a;
    padding: 4px;
    box-shadow:
        inset 0 0 0 2px #6a5840,
        2px 2px 0 #1a140c;
    overflow: hidden;
    image-rendering: pixelated;
    box-sizing: border-box;
}

.vault-card-popup-frame[data-grade="2"] {
    border-color: #3a4858;
    box-shadow: inset 0 0 0 2px #c8d8e8, 2px 2px 0 #1a140c;
}

.vault-card-popup-frame[data-grade="3"] {
    border-color: #5a4010;
    box-shadow: inset 0 0 0 2px #ffe878, 2px 2px 0 #1a140c;
}

.vault-card-popup-frame[data-grade="4"] {
    border-color: #4a3080;
    box-shadow: inset 0 0 0 2px #e0c8ff, 2px 2px 0 #1a140c;
}

.vault-card-popup-frame[data-grade="5"] {
    border-color: #6a1848;
    box-shadow:
        inset 0 0 0 2px #ffe0f0,
        2px 2px 0 #1a140c,
        inset 0 0 0 4px rgba(255, 208, 80, 0.65);
}

.vault-card-popup-art {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 504 / 708;
    object-fit: cover;
    image-rendering: pixelated;
    filter: contrast(1.08) saturate(1.05);
    vertical-align: top;
}

.vault-card-popup-tag {
    display: inline-block;
    margin: 0 0 8px;
    padding: 5px 10px;
    border: 2px solid #1a140c;
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    image-rendering: pixelated;
}

.vault-card-popup-tag.vault-grade-tag {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        2px 2px 0 #1a140c;
}

.vault-card-popup-name {
    margin: 0 0 8px;
    font-family: silkscreen, monospace;
    font-size: 16px;
    line-height: 1.3;
    color: #fff8ea;
    text-shadow: 2px 2px 0 #1a140c;
}

.vault-card-popup-meta {
    margin: 0 0 10px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    line-height: 1.55;
    color: #e8dcc0;
    text-shadow: 1px 1px 0 #1a140c;
}

.vault-card-popup-spells {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.vault-card-popup-spells li {
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 1.45;
    color: #f0e8d4;
    padding: 4px 6px;
    border: 2px solid #4a4030;
    border-left-width: 4px;
    background:
        repeating-conic-gradient(#2a2418 0% 25%, #221c14 0% 50%) 50% / 4px 4px,
        #2a2418;
    text-shadow: 1px 1px 0 #1a140c;
    image-rendering: pixelated;
}

.vault-card-popup-spells li.vault-spell-def {
    border-left-color: #58c8f0;
    background:
        repeating-conic-gradient(#182838 0% 25%, #142030 0% 50%) 50% / 4px 4px,
        #182838;
    color: #e8f8ff;
    text-shadow: 1px 1px 0 #0a1828;
}

.vault-card-popup-grade-panel {
    position: relative;
    z-index: 1;
    margin-top: 14px;
    padding: 10px 12px;
    border: 3px solid #1a140c;
    border-radius: 1px;
    background:
        repeating-conic-gradient(#1e1a14 0% 25%, #181410 0% 50%) 50% / 6px 6px,
        linear-gradient(180deg, #2a2418 0%, #14100c 100%);
    box-shadow: inset 0 0 0 2px #4a4030;
    image-rendering: pixelated;
    overflow: visible;
}

.vault-card-popup-grade-panel[data-grade="1"] {
    box-shadow: inset 0 0 0 2px #6a5840;
}

.vault-card-popup-grade-panel[data-grade="1"] .vault-card-popup-grade-label,
.vault-card-popup-grade-panel[data-grade="1"] .vault-card-popup-grade-count,
.vault-card-popup-grade-panel[data-grade="1"] .vault-card-popup-grade-hint,
.vault-card-popup-grade-panel[data-grade="1"] .vault-card-popup-minted {
    color: #fff4e0;
    text-shadow: 1px 1px 0 #1a140c;
}

.vault-card-popup-grade-panel[data-grade="1"] .vault-card-popup-minted {
    color: #d8c8a8;
}

.vault-card-popup-grade-panel[data-grade="2"] {
    background:
        repeating-conic-gradient(#8898a8 0% 25%, #788898 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #d8e4f0 0%, #8898a8 100%);
    box-shadow: inset 0 0 0 2px #e8f0f8, inset 0 -3px 0 rgba(58, 72, 88, 0.35);
    border-color: #3a4858;
}

.vault-card-popup-grade-panel[data-grade="2"] .vault-card-popup-grade-label,
.vault-card-popup-grade-panel[data-grade="2"] .vault-card-popup-grade-count,
.vault-card-popup-grade-panel[data-grade="2"] .vault-card-popup-grade-hint,
.vault-card-popup-grade-panel[data-grade="2"] .vault-card-popup-minted {
    color: #081828;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.92);
}

.vault-card-popup-grade-panel[data-grade="3"] {
    background:
        repeating-conic-gradient(#c89818 0% 25%, #b88810 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #fff0a0 0%, #d0a018 100%);
    box-shadow: inset 0 0 0 2px #fff8c0, inset 0 -3px 0 rgba(90, 64, 16, 0.35);
    border-color: #5a4010;
}

.vault-card-popup-grade-panel[data-grade="3"] .vault-card-popup-grade-label,
.vault-card-popup-grade-panel[data-grade="3"] .vault-card-popup-grade-count,
.vault-card-popup-grade-panel[data-grade="3"] .vault-card-popup-grade-hint,
.vault-card-popup-grade-panel[data-grade="3"] .vault-card-popup-minted {
    color: #3a2808;
    text-shadow: 0 1px 0 rgba(255, 248, 200, 0.85);
}

.vault-card-popup-grade-panel[data-grade="4"] {
    background:
        repeating-conic-gradient(#8868c0 0% 25%, #7858b0 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #e8d8ff 0%, #8868c0 100%);
    box-shadow: inset 0 0 0 2px #f0e8ff, inset 0 -3px 0 rgba(74, 48, 128, 0.35);
    border-color: #4a3080;
}

.vault-card-popup-grade-panel[data-grade="4"] .vault-card-popup-grade-label,
.vault-card-popup-grade-panel[data-grade="4"] .vault-card-popup-grade-count,
.vault-card-popup-grade-panel[data-grade="4"] .vault-card-popup-grade-hint,
.vault-card-popup-grade-panel[data-grade="4"] .vault-card-popup-minted {
    color: #1a0838;
    text-shadow: 0 1px 0 rgba(240, 220, 255, 0.85);
}

.vault-card-popup-grade-panel[data-grade="5"] {
    background:
        repeating-conic-gradient(#e878a8 0% 25%, #d86898 0% 50%) 50% / 4px 4px,
        linear-gradient(180deg, #ffe8f8 0%, #ff68c0 45%, #ffd050 100%);
    box-shadow: inset 0 0 0 2px #fff0f8, inset 0 -3px 0 rgba(106, 24, 72, 0.35);
    border-color: #6a1848;
}

.vault-card-popup-grade-panel[data-grade="5"] .vault-card-popup-grade-label,
.vault-card-popup-grade-panel[data-grade="5"] .vault-card-popup-grade-count,
.vault-card-popup-grade-panel[data-grade="5"] .vault-card-popup-grade-hint,
.vault-card-popup-grade-panel[data-grade="5"] .vault-card-popup-minted {
    color: #fff8ff;
    text-shadow: 1px 1px 0 #6a1848;
}

.vault-card-popup-grade-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 10px;
}

.vault-card-popup-grade-label {
    font-family: silkscreen, monospace;
    font-size: 9px;
    letter-spacing: 0.06em;
    line-height: 1.4;
    color: #c8b888;
    text-shadow: 1px 1px 0 #1a140c;
    flex: 1 1 120px;
    min-width: 0;
}

.vault-card-popup-grade-count {
    font-family: silkscreen, monospace;
    font-size: 11px;
    line-height: 1.35;
    color: #fff4d8;
    text-shadow: 2px 2px 0 #1a140c;
    flex-shrink: 0;
    text-align: right;
}

.vault-card-popup-progress-track {
    position: relative;
    height: 18px;
    border: 3px solid #1a140c;
    background:
        repeating-conic-gradient(#141210 0% 25%, #0e0c0a 0% 50%) 50% / 4px 4px,
        #141210;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
}

.vault-card-popup-progress-fill {
    height: 100%;
    width: 0;
    background:
        repeating-linear-gradient(
            90deg,
            #3a9a50 0px,
            #3a9a50 6px,
            #58c870 6px,
            #58c870 12px
        );
    transition: width 0.35s steps(8);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
    image-rendering: pixelated;
}

.vault-card-popup-grade-panel[data-grade="2"] .vault-card-popup-progress-fill {
    background: repeating-linear-gradient(90deg, #6888a8 0 6px, #98b8d8 6px 12px);
}

.vault-card-popup-grade-panel[data-grade="3"] .vault-card-popup-progress-fill {
    background: repeating-linear-gradient(90deg, #c89818 0 6px, #ffe060 6px 12px);
}

.vault-card-popup-grade-panel[data-grade="4"] .vault-card-popup-progress-fill {
    background: repeating-linear-gradient(90deg, #8868c0 0 6px, #c8a8f0 6px 12px);
}

.vault-card-popup-grade-panel[data-grade="5"] .vault-card-popup-progress-fill {
    background: repeating-linear-gradient(90deg, #e84898 0 6px, #ffd050 6px 12px);
}

.vault-card-popup-progress-ticks {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-evenly;
    pointer-events: none;
}

.vault-card-popup-progress-ticks span {
    width: 2px;
    background: rgba(255, 255, 255, 0.15);
}

.vault-card-popup-grade-hint {
    margin: 0 0 6px;
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 1.55;
    color: #e0d4b8;
    text-shadow: 1px 1px 0 #1a140c;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.vault-card-popup-minted {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: 9px;
    letter-spacing: 0.05em;
    color: #9a8a70;
    text-shadow: 1px 1px 0 #1a140c;
}

.vault-card-popup-info .vault-card-popup-btn--upgrade {
    width: 100%;
    margin-top: 10px;
}

.vault-card-popup-btn {
    font-family: silkscreen, monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    padding: 14px 14px;
    border: 3px solid #1a140c;
    cursor: pointer;
    text-align: center;
    image-rendering: pixelated;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.vault-card-popup-btn--upgrade {
    background:
        repeating-conic-gradient(#68e088 0% 25%, #48c068 0% 50%) 50% / 4px 4px,
        #48c068;
    color: #0a180c;
    box-shadow: 4px 4px 0 #1a5030;
}

.vault-card-popup-btn--upgrade.hidden {
    display: none;
}

.vault-card-popup-btn--upgrade:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vault-card-popup-btn--upgrade:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 #1a5030;
}

.vault-card-popup-btn--ghost {
    background:
        repeating-conic-gradient(#f8ecd0 0% 25%, #ece0c4 0% 50%) 50% / 4px 4px,
        #f0e6d0;
    color: #2a2218;
    box-shadow: 4px 4px 0 #6a5840;
}

.vault-card-popup-btn--ghost:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 #6a5840;
}

@media (max-width: 720px) {
    .vault-card-popup-panel {
        width: min(100%, 100%);
    }

    .vault-card-popup-stage {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .vault-card-popup-visual.vault-slot-visual {
        width: min(
            280px,
            calc((min(94vh, 860px) - 96px) * 504 / 708),
            calc(100vw - 48px)
        );
        margin: 0 auto;
    }

    .vault-card-popup-info {
        width: 100%;
    }

    .vault-card-popup-frame {
        width: 100%;
        max-width: none;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .vault-card-popup-header {
        flex-wrap: wrap;
    }

    .vault-card-popup-close {
        margin-left: auto;
    }

    .vault-card-popup-visual.vault-slot-visual {
        width: min(
            240px,
            calc((min(94vh, 860px) - 96px) * 504 / 708),
            calc(100vw - 40px)
        );
    }

    .vault-card-popup-frame {
        width: 100%;
        max-width: none;
    }

    .vault-card-popup-name {
        font-size: 14px;
        text-align: center;
    }

    .vault-card-popup-meta,
    .vault-card-popup-tag {
        text-align: center;
    }
}

/* ============================================================
   POKÉCARD MARKET — PokéTab CRT card exchange
   ============================================================ */

.poketab-market {
    gap: 6px;
}

.market-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.market-title {
    margin: 0;
    color: #9be9ff;
    text-shadow: 0 0 8px rgba(120, 220, 255, 0.55);
}

.market-wallet {
    flex: none;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.04em;
    color: #ffe98a;
    background: rgba(8, 30, 22, 0.75);
    border: 2px solid #2f6f5a;
    box-shadow: inset 0 0 8px rgba(120, 255, 200, 0.18), 0 0 6px rgba(120, 255, 200, 0.12);
    padding: 4px 8px;
    text-shadow: 0 0 6px rgba(255, 220, 120, 0.6);
}

.market-subtabs {
    display: flex;
    gap: 4px;
}

.market-subtab {
    flex: 1;
    appearance: none;
    cursor: pointer;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.45));
    letter-spacing: 0.06em;
    color: #8fd6c4;
    background: rgba(8, 30, 24, 0.6);
    border: 2px solid #24594a;
    padding: 6px 4px;
    text-transform: uppercase;
    transition: none;
}

.market-subtab.active {
    color: #06231b;
    background: linear-gradient(180deg, #8bffcf, #46d9a0);
    border-color: #bafff0;
    box-shadow: 0 0 10px rgba(120, 255, 200, 0.45);
    text-shadow: none;
}

.market-subtab:active {
    transform: translateY(1px);
}

.market-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.market-input,
.market-select {
    width: 100%;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.35));
    color: #d6fff0;
    background: rgba(6, 26, 20, 0.85);
    border: 2px solid #2c6553;
    padding: 5px 6px;
    outline: none;
    image-rendering: pixelated;
}

.market-pixel-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.market-pixel-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.35));
    color: #d6fff0;
    background: rgba(6, 26, 20, 0.92);
    border: 2px solid #2c6553;
    padding: 5px 6px;
    cursor: pointer;
    image-rendering: pixelated;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
    text-align: left;
}

.market-pixel-select-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-pixel-select-arrow {
    flex-shrink: 0;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.35));
    color: #7bffcb;
    line-height: 1;
}

.market-pixel-select.is-open .market-pixel-select-trigger {
    border-color: #7bffcb;
    box-shadow: 0 0 8px rgba(120, 255, 200, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.market-pixel-select.is-open .market-pixel-select-arrow {
    transform: rotate(180deg);
}

.market-pixel-select-menu {
    position: absolute;
    z-index: 120;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 2px;
    list-style: none;
    max-height: 148px;
    overflow-y: auto;
    background: #061a14;
    border: 2px solid #7bffcb;
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.45),
        0 0 12px rgba(120, 255, 200, 0.35);
    image-rendering: pixelated;
}

.market-pixel-select-menu.hidden {
    display: none;
}

.market-pixel-select-menu li {
    margin: 0;
    padding: 0;
}

.market-pixel-select-option {
    display: block;
    width: 100%;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.35));
    color: #b8f5df;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(44, 101, 83, 0.55);
    padding: 6px 5px;
    text-align: left;
    cursor: pointer;
    image-rendering: pixelated;
}

.market-pixel-select-menu li:last-child .market-pixel-select-option {
    border-bottom: none;
}

.market-pixel-select-option:hover,
.market-pixel-select-option:focus-visible {
    color: #06231b;
    background: linear-gradient(180deg, #8bffcf, #46d9a0);
    outline: none;
}

.market-pixel-select-option.is-active {
    color: #06231b;
    background: linear-gradient(180deg, #8bffcf, #46d9a0);
    box-shadow: inset 0 0 0 1px #bafff0;
}

.market-pixel-select-option:active {
    transform: translateY(1px);
}

.market-input {
    grid-column: 1 / -1;
}

.market-input::placeholder {
    color: #5f9a89;
}

.market-input:focus,
.market-select:focus {
    border-color: #7bffcb;
    box-shadow: 0 0 8px rgba(120, 255, 200, 0.4);
}

.market-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.market-panel.hidden {
    display: none;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
    padding: 2px 0 6px;
}

.market-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
    background: rgba(7, 28, 22, 0.82);
    border: 2px solid #235444;
    box-shadow: inset 0 0 10px rgba(90, 220, 180, 0.1);
    position: relative;
}

.market-card.is-sold,
.market-card.is-cancelled {
    opacity: 0.62;
}

.market-card[data-grade="3"] { border-color: #7a5c1e; }
.market-card[data-grade="4"] { border-color: #5a3f8f; }
.market-card[data-grade="5"] {
    border-color: #8f2b63;
    box-shadow: inset 0 0 12px rgba(255, 120, 190, 0.22), 0 0 8px rgba(255, 140, 200, 0.2);
}

.market-card-visual {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 7;
}

.market-card-mult {
    position: absolute;
    right: 2px;
    bottom: 2px;
    z-index: 5;
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    padding: 1px 3px;
    text-shadow: 0 0 4px rgba(120, 220, 255, 0.8);
}

.market-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.market-card-name {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.3));
    color: #eafff8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-card-sub {
    margin: 0;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.3));
    letter-spacing: 0.04em;
    color: #7fc9b6;
}

.market-card-power {
    margin: 0;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.3));
    color: #ffd873;
    text-shadow: 0 0 4px rgba(255, 200, 90, 0.4);
}

.market-card-seller {
    margin: 0;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.2));
    color: #6fae9e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    margin-top: auto;
    min-height: 0;
}

.market-card-foot .market-btn {
    flex: none;
    padding: 2px 5px;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.15));
    border-width: 1px;
    box-shadow: 1px 1px 0 #0a3327;
    line-height: 1.2;
}

.market-card-foot .market-btn--cancel {
    box-shadow: 1px 1px 0 #3a0f0f;
}

.market-card-owned {
    flex: none;
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.1));
    letter-spacing: 0.05em;
    padding: 1px 4px;
    line-height: 1.25;
    color: #7fc9b6;
    background: rgba(12, 36, 28, 0.85);
    border: 1px solid #2c5749;
}

.market-card-price {
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.15));
    color: #ffe98a;
    text-shadow: 0 0 5px rgba(255, 220, 110, 0.5);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-card-status {
    font-family: silkscreen, monospace;
    font-size: calc(6px * var(--pt-ui-font-mul, 1.25));
    letter-spacing: 0.05em;
    padding: 3px 5px;
    width: 100%;
    text-align: center;
}

.market-card-status--sold {
    color: #06231b;
    background: linear-gradient(180deg, #8bffcf, #46d9a0);
}

.market-card-status--cancelled {
    color: #ffb0b0;
    background: rgba(80, 20, 20, 0.6);
    border: 1px solid #7a3232;
}

.market-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 26px 12px;
    text-align: center;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.35));
    line-height: 1.7;
    color: #6fbfad;
}

.market-sell-cta {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    cursor: pointer;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.3));
    letter-spacing: 0.06em;
    color: #06231b;
    background: linear-gradient(180deg, #ffe27a, #f4b23c);
    border: 2px solid #fff2b0;
    box-shadow: 0 0 10px rgba(255, 200, 90, 0.4);
    padding: 8px;
    text-transform: uppercase;
}

.market-sell-cta:active {
    transform: translateY(1px);
}

/* --- Market shared buttons --- */

.market-btn {
    appearance: none;
    cursor: pointer;
    font-family: silkscreen, monospace;
    font-size: calc(7px * var(--pt-ui-font-mul, 1.25));
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 2px solid #0a2019;
    padding: 5px 8px;
    color: #06231b;
    white-space: nowrap;
}

.market-btn--buy {
    background: linear-gradient(180deg, #8bffcf, #3fd39a);
    border-color: #bafff0;
    box-shadow: 2px 2px 0 #0a3327;
}

.market-btn--buy:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #0a3327;
}

.market-btn--cancel {
    background: linear-gradient(180deg, #ff9a9a, #e35c5c);
    border-color: #ffd0d0;
    color: #2a0808;
    box-shadow: 2px 2px 0 #3a0f0f;
}

.market-btn--cancel:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #3a0f0f;
}

.market-btn--muted {
    background: rgba(20, 44, 36, 0.9);
    color: #6fae9e;
    border-color: #2c5749;
    cursor: default;
}

.market-btn--primary {
    flex: 1;
    background: linear-gradient(180deg, #8bffcf, #3fd39a);
    border-color: #bafff0;
    box-shadow: 3px 3px 0 #0a3327;
    padding: 9px;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.3));
}

.market-btn--primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.market-btn--primary:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 #0a3327;
}

.market-btn--ghost {
    flex: 1;
    background: rgba(16, 40, 32, 0.9);
    color: #bfeee0;
    border-color: #2c5749;
    padding: 9px;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.3));
}

/* --- Market history --- */

.market-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.market-history-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 7px;
    background: rgba(7, 28, 22, 0.75);
    border: 2px solid #235444;
}

.market-history-grade {
    flex: none;
}

.market-history-name {
    flex: 1;
    min-width: 0;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.25));
    color: #eafff8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-history-price {
    flex: none;
    font-family: silkscreen, monospace;
    font-size: calc(8px * var(--pt-ui-font-mul, 1.25));
    color: #ffe98a;
}

/* ============================================================
   MARKET MODALS (sell / pick / buy) — global overlays
   ============================================================ */

.market-modal {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.market-modal.hidden {
    display: none;
}

.market-modal-scrim {
    position: absolute;
    inset: 0;
    border: none;
    cursor: pointer;
    background: rgba(4, 12, 10, 0.86);
    backdrop-filter: blur(2px);
}

.market-modal-panel {
    position: relative;
    z-index: 1;
    width: min(360px, 100%);
    max-height: calc(100% - 20px);
    overflow-y: auto;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 3px),
        linear-gradient(180deg, #0d3229, #082019);
    border: 3px solid #34b98d;
    box-shadow: 0 0 0 3px #06140f, 0 0 24px rgba(80, 230, 180, 0.35);
    padding: 14px;
    image-rendering: pixelated;
}

.market-sell-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(120% 60% at 50% 0%, rgba(120, 255, 210, 0.18), transparent 70%);
    z-index: 0;
}

.market-sell-panel[data-grade="3"] { border-color: #e0b040; box-shadow: 0 0 0 3px #06140f, 0 0 24px rgba(230, 190, 80, 0.4); }
.market-sell-panel[data-grade="4"],
.market-buy-panel[data-grade="4"] { border-color: #a878e0; box-shadow: 0 0 0 3px #06140f, 0 0 24px rgba(180, 130, 240, 0.4); }
.market-sell-panel[data-grade="5"],
.market-buy-panel[data-grade="5"] { border-color: #ff68b0; box-shadow: 0 0 0 3px #06140f, 0 0 26px rgba(255, 130, 200, 0.45); }
.market-buy-panel[data-grade="3"] { border-color: #e0b040; box-shadow: 0 0 0 3px #06140f, 0 0 24px rgba(230, 190, 80, 0.4); }

.market-modal-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.market-modal-title {
    font-family: silkscreen, monospace;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: #b8ffe6;
    text-shadow: 0 0 8px rgba(120, 255, 200, 0.5);
}

.market-modal-close {
    flex: none;
    appearance: none;
    cursor: pointer;
    width: 26px;
    height: 26px;
    line-height: 1;
    font-size: 16px;
    color: #d6fff0;
    background: rgba(10, 40, 30, 0.8);
    border: 2px solid #2f7a62;
}

.market-modal-sub {
    position: relative;
    z-index: 1;
    margin: 0 0 10px;
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 1.6;
    color: #82c7b6;
}

.market-modal-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.market-sell-body {
    position: relative;
    z-index: 1;
}

.market-sell-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 2px dashed #2c6553;
}

.market-sell-visual {
    position: relative;
    flex: none;
    width: 84px;
    aspect-ratio: 5 / 7;
}

.market-sell-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.market-sell-name {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: 14px;
    color: #eafff8;
}

.market-sell-tag {
    align-self: flex-start;
}

.market-sell-stat {
    margin: 0;
    font-family: silkscreen, monospace;
    font-size: 9px;
    line-height: 1.6;
    color: #9bd8c8;
}

.market-sell-seller {
    margin: 4px 0 0;
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #7fc9b6;
}

.market-sell-label {
    display: block;
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #b8ffe6;
    margin-bottom: 6px;
}

.market-sell-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.market-sell-chip {
    font-family: silkscreen, monospace;
    font-size: 16px;
    color: #ffe98a;
}

.market-sell-input {
    flex: 1;
    font-family: silkscreen, monospace;
    font-size: 15px;
    color: #fff;
    background: rgba(4, 20, 15, 0.9);
    border: 2px solid #34b98d;
    padding: 8px 10px;
    outline: none;
}

.market-sell-input:focus {
    border-color: #7bffcb;
    box-shadow: 0 0 10px rgba(120, 255, 200, 0.4);
}

.market-sell-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(4, 20, 15, 0.7);
    border: 2px solid #235444;
}

.market-sell-brk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: silkscreen, monospace;
    font-size: 10px;
    color: #93cebe;
}

.market-sell-brk-net {
    padding-top: 6px;
    border-top: 1px dashed #2c6553;
    color: #eafff8;
}

.market-sell-brk-val {
    color: #ffe98a;
}

.market-sell-brk-fee {
    color: #ff9a9a;
}

.market-sell-error {
    min-height: 14px;
    margin: 8px 0 0;
    font-family: silkscreen, monospace;
    font-size: 10px;
    color: #ff9a9a;
    text-align: center;
}

/* --- Pick a card grid --- */

.market-pick-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 8px;
    max-height: 42vh;
    overflow-y: auto;
}

.market-pick-card {
    appearance: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px;
    background: rgba(7, 28, 22, 0.8);
    border: 2px solid #235444;
}

.market-pick-card:hover {
    border-color: #7bffcb;
    box-shadow: 0 0 10px rgba(120, 255, 200, 0.35);
}

.market-pick-card .vault-slot-visual {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 7;
}

.market-pick-name {
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #eafff8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   VAULT POPUP — sell / listed states
   ============================================================ */

.vault-card-popup-btn--sell {
    margin-top: 8px;
    background:
        repeating-conic-gradient(#2a5a8a 0% 25%, #24507c 0% 50%) 50% / 4px 4px,
        #285686;
    color: #eaf6ff;
    box-shadow: 4px 4px 0 #12314e;
}

.vault-card-popup-btn--sell:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 #12314e;
}

.vault-card-popup-btn--cancel {
    margin-top: 8px;
    background:
        repeating-conic-gradient(#a83a3a 0% 25%, #973232 0% 50%) 50% / 4px 4px,
        #a03636;
    color: #fff0f0;
    box-shadow: 4px 4px 0 #4a1414;
}

.vault-card-popup-btn--cancel:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 #4a1414;
}

.vault-card-popup-listed {
    margin: 10px 0 0;
    padding: 6px 8px;
    font-family: silkscreen, monospace;
    font-size: 10px;
    text-align: center;
    color: #ffe98a;
    background: rgba(40, 60, 30, 0.5);
    border: 2px dashed #7a8a3a;
}

.vault-card-popup-listed.hidden {
    display: none;
}

/* Vault slot "listed" marker */

.vault-slot-listed {
    position: absolute;
    left: 1px;
    bottom: 1px;
    z-index: 6;
    font-family: silkscreen, monospace;
    font-size: 8px;
    letter-spacing: 0.04em;
    color: #06231b;
    background: linear-gradient(180deg, #ffe27a, #f4b23c);
    padding: 1px 3px;
    box-shadow: 0 0 6px rgba(255, 200, 90, 0.5);
}

.vault-slot--listed .vault-slot-frame {
    outline: 2px solid rgba(255, 210, 100, 0.6);
    outline-offset: -2px;
}

/* --- In-realm wallet modals (POKEQUEST deposit / withdraw) --- */

.wallet-modal {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.wallet-modal.hidden {
    display: none;
}

.wallet-modal-scrim {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(8, 12, 18, 0.72);
    cursor: pointer;
}

.wallet-modal-panel {
    position: relative;
    width: min(100%, 440px);
    max-height: min(92vh, 720px);
    overflow-y: auto;
    background: #fff8ea;
    border: 4px solid var(--panel-border);
    outline: 3px solid var(--panel-edge);
    box-shadow: 8px 8px 0 var(--pixel-shadow);
    padding: 12px 14px 16px;
    image-rendering: pixelated;
}

.wallet-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.wallet-modal-title {
    font-family: silkscreen, monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #2a1f14;
}

.wallet-modal-close {
    font-family: silkscreen, monospace;
    font-size: 18px;
    line-height: 1;
    border: 2px solid #2a1f14;
    background: #f5e6c8;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

.wallet-modal-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wallet-modal-label {
    font-family: silkscreen, monospace;
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a6555;
    margin: 0;
}

.wallet-connect-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 4px;
    padding: 8px 10px;
    background: rgba(255, 248, 234, 0.85);
    border: 2px solid var(--panel-border);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
}

.wallet-connect-status {
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #111;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wallet-mini-btn--connect {
    flex-shrink: 0;
    background: #f5e6c8;
    color: #111;
    border: 2px solid #2a1f14;
}

.wallet-modal-note,
.wallet-modal-hint {
    font-size: 12px;
    line-height: 1.45;
    color: #5c4a3a;
    margin: 0;
}

.wallet-connect-gate {
    margin-top: 4px;
}

.wallet-connected-flow {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wallet-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.wallet-tab {
    font-family: silkscreen, monospace;
    font-size: 8px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 10px 8px;
    border: 2px solid #2a1f14;
    background: #f5e6c8;
    color: #2a1f14;
    cursor: pointer;
}

.wallet-tab.is-active {
    background: #2a1f14;
    color: #fff8ea;
}

.wallet-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wallet-tab-panel.hidden {
    display: none;
}

.wallet-balance-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.wallet-balance-card {
    padding: 8px 10px;
    background: #f5e6c8;
    border: 2px solid #c4a574;
}

.wallet-balance-value {
    font-family: silkscreen, monospace;
    font-size: 12px;
    color: #2a1f14;
    margin: 2px 0 0;
    word-break: break-all;
}

.wallet-address-row,
.wallet-sig-row,
.wallet-amount-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.wallet-address {
    flex: 1;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    word-break: break-all;
    padding: 8px;
    background: #f5e6c8;
    border: 2px solid #c4a574;
}

.wallet-input {
    flex: 1;
    font-family: silkscreen, monospace;
    font-size: 11px;
    padding: 8px;
    border: 2px solid #c4a574;
    background: #fff;
    min-width: 0;
}

.wallet-mini-btn {
    font-family: silkscreen, monospace;
    font-size: 9px;
    padding: 8px 10px;
    border: 2px solid #2a1f14;
    background: #f5e6c8;
    cursor: pointer;
    white-space: nowrap;
}

.wallet-mini-btn:hover {
    background: #e8d4a8;
}

.wallet-qr {
    align-self: center;
    border: 3px solid #2a1f14;
    image-rendering: pixelated;
}

.wallet-action-btn {
    font-family: silkscreen, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 12px;
    border: 3px solid #2a1f14;
    box-shadow: 4px 4px 0 var(--pixel-shadow);
    cursor: pointer;
    margin-top: 4px;
}

.wallet-action-btn--deposit {
    color: #06231b;
    background: linear-gradient(180deg, #8bffcf, #46d9a0);
}

.wallet-action-btn--withdraw {
    color: #fff;
    background: linear-gradient(180deg, #ff7b7b, #d93636);
}

.wallet-action-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.wallet-error {
    font-size: 12px;
    color: #b91c1c;
    margin: 0;
    min-height: 1em;
}

.wallet-success {
    font-family: silkscreen, monospace;
    font-size: 11px;
    color: #166534;
    text-align: center;
    margin: 0;
}

.wallet-verify-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(70, 217, 160, 0.12);
    border: 2px dashed #46d9a0;
}

.wallet-verify-step {
    font-family: silkscreen, monospace;
    font-size: 9px;
    margin: 0;
    color: #4a3728;
}

.wallet-verify-step.is-done {
    color: #166534;
}

.wallet-withdraw-chips,
.wallet-withdraw-receive {
    font-family: silkscreen, monospace;
    font-size: 16px;
    color: #2a1f14;
    margin: 0;
}

.wallet-withdraw-progress {
    font-family: silkscreen, monospace;
    font-size: 9px;
    color: #1a6b4f;
    margin: 0;
}

.wallet-modal-subtitle {
    font-family: silkscreen, monospace;
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a6555;
    margin: 10px 0 4px;
}

.wallet-history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 120px;
    overflow-y: auto;
}

.wallet-history-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    font-size: 11px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(196, 165, 116, 0.45);
}

.wallet-history-amt {
    font-family: silkscreen, monospace;
    font-size: 9px;
}

.wallet-history-row--in .wallet-history-amt {
    color: #166534;
}

.wallet-history-row--out .wallet-history-amt {
    color: #b91c1c;
}

.wallet-history-status {
    font-size: 10px;
    text-transform: capitalize;
    color: #7a6555;
}

.wallet-history-when {
    grid-column: 1 / -1;
    font-size: 10px;
    color: #9a8575;
}

.wallet-history-empty {
    font-size: 11px;
    color: #9a8575;
    margin: 0;
}

.wallet-solscan {
    color: #1a6b4f;
    text-decoration: underline;
    margin-left: 6px;
}

.wallet-confetti {
    position: absolute;
    top: 0;
    width: 6px;
    height: 10px;
    pointer-events: none;
    animation: wallet-confetti-fall 1.4s ease-out forwards;
}

@keyframes wallet-confetti-fall {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(220px) translateX(var(--wallet-drift, 0px)) rotate(540deg);
        opacity: 0;
    }
}

@media (max-width: 480px) {
    .game-hud-wallet-actions {
        grid-template-columns: 1fr;
    }

    .wallet-modal-panel {
        width: 100%;
        max-height: 94vh;
    }

    .wallet-address-row,
    .wallet-sig-row,
    .wallet-amount-row {
        flex-direction: column;
    }
}
