:root {
    --ui-scale: 0.9;
    --bg: #05060d;
    --text: #efeaff;
    --muted: #a9a0c8;
    --panel-line: rgba(137, 108, 223, 0.24);
    --gold-soft: #b7a4ff;
    --gold-deep: #5a46a8;
    --ink-blue: #0f1630;
    --wood-shadow: rgba(3, 3, 10, 0.88);
    --shadow: rgba(0, 0, 0, 0.6);
    --accent-glow: rgba(112, 97, 255, 0.34);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    background:
        radial-gradient(circle at 15% 20%, rgba(120, 76, 255, 0.2), transparent 28%),
        radial-gradient(circle at 82% 18%, rgba(56, 112, 255, 0.2), transparent 24%),
        radial-gradient(circle at 50% 0%, rgba(192, 155, 255, 0.08), transparent 30%),
        linear-gradient(180deg, #131227 0%, #090811 46%, #03040a 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at center, rgba(160, 131, 255, 0.16) 0 2px, transparent 2px),
        linear-gradient(rgba(134, 119, 214, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(134, 119, 214, 0.03) 1px, transparent 1px);
    background-size: 120px 120px, 40px 40px, 40px 40px;
    opacity: 0.45;
    pointer-events: none;
    mask-image: radial-gradient(circle at center, black 42%, transparent 100%);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at center, transparent 0 180px, rgba(132, 105, 245, 0.1) 181px 183px, transparent 184px),
        radial-gradient(circle at center, transparent 0 320px, rgba(87, 118, 255, 0.08) 321px 323px, transparent 324px);
    opacity: 0.7;
    pointer-events: none;
}

.app-shell {
    width: min(calc(1080px / var(--ui-scale)), calc((100% - 110px) / var(--ui-scale)));
    margin: 0 auto;
    padding: 28px 0 64px;
    transform: scale(var(--ui-scale));
    transform-origin: top center;
}

/* Glassmorphism & Panel Styling */
.panel,
.opening-stage {
    background: transparent;
    backdrop-filter: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    position: relative;
}

.panel::before,
.opening-stage::before {
    content: none;
}

.panel::after {
    content: none;
}

.hero {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 8px 0 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    border-radius: 0;
    position: relative;
    overflow: visible;
}

.hero-copy,
.hero-stats {
    position: relative;
    z-index: 1;
}

.hero-copy {
    width: 100%;
    text-align: center;
    padding: 12px 0 8px;
}

.hero-copy::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -12px;
    width: min(520px, 78vw);
    height: 180px;
    transform: translateX(-50%);
    background:
        radial-gradient(circle at center, rgba(245, 238, 255, 0.2) 0, rgba(159, 121, 255, 0.12) 28%, rgba(87, 118, 255, 0.04) 55%, transparent 76%);
    filter: blur(18px);
    pointer-events: none;
    z-index: -1;
}

@keyframes rotateSlow {
    100% { transform: rotate(360deg); }
}

.glitch {
    font-family: 'Cinzel', serif;
    font-size: clamp(2.5rem, 5vw, 4.4rem);
    margin: 0;
    font-weight: 700;
    color: #f8f5ff;
    background: linear-gradient(180deg, #ffffff 0%, #f3eaff 38%, #cdb8ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(151, 113, 255, 0.18), 0 10px 34px rgba(0, 0, 0, 0.36);
    letter-spacing: 0.22em;
    line-height: 1.12;
    position: relative;
    display: inline-block;
    padding: 0.08em 0.12em 0.22em;
}

.glitch::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 56%;
    height: 2px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), rgba(191, 164, 255, 0.8), transparent);
    box-shadow: 0 0 18px rgba(153, 116, 255, 0.24);
}

.hero-subtitle {
    margin: 10px 0 0;
    color: #b9afd8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.42em;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.32);
}

.page-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-top: 38px;
    padding: 0;
    position: relative;
    z-index: 1;
}

.page-tab {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(228, 219, 255, 0.68);
    padding: 0 0 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.25s ease, opacity 0.25s ease;
    position: relative;
    overflow: visible;
    box-shadow: none;
}

.page-tab:hover {
    color: rgba(248, 245, 255, 0.9);
}

.page-tab.is-active {
    color: #fcfaff;
}

.page-tab.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), transparent);
}

.page-stack {
    margin-top: 24px;
    overflow: visible;
    position: relative;
}

@keyframes navSlideGlow {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(120%);
    }
}

.page-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    padding-right: 0;
}

.page-view[hidden] {
    display: none !important;
}

.page-view:last-child {
    padding-right: 0;
    padding-left: 0;
}

.page-tab-secondary {
    background: rgba(17, 15, 35, 0.72);
}

.page-actions {
    display: flex;
    justify-content: center;
}

.panel-header {
    padding-bottom: 16px;
    border-bottom: 0;
    margin-bottom: 18px;
}

.opening-header {
    margin-bottom: 18px;
}

.rarity-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.rarity-summary-card {
    padding: 14px 12px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(26, 22, 50, 0.9), rgba(11, 11, 22, 0.96)),
        radial-gradient(circle at top, rgba(160, 132, 255, 0.08), transparent 58%);
    border: 1px solid rgba(141, 111, 234, 0.16);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 10px 24px rgba(0,0,0,0.18);
    text-align: center;
}

.rarity-summary-card span {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.92;
}

.rarity-summary-card strong {
    display: block;
    font-size: 1.55rem;
    font-weight: 800;
    color: #fff;
}

.empty-state {
    margin: 22px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.7;
}

.panel {
    padding: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 0;
    margin-bottom: 24px;
}

.panel-title {
    font-family: 'Cinzel', serif;
    font-size: 1.26rem;
    margin: 0;
    letter-spacing: 0.18em;
    color: #f1eeff;
    text-shadow: 0 0 14px rgba(135, 105, 243, 0.18);
}

.pack-probabilities {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.probability-item {
    flex: 1;
    min-width: 120px;
    padding: 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(36, 26, 70, 0.66), rgba(16, 14, 28, 0.88));
    border: 1px solid rgba(125, 103, 214, 0.18);
    text-align: center;
    transition: background 0.3s ease;
}

.probability-item:hover {
    background: linear-gradient(180deg, rgba(46, 34, 90, 0.74), rgba(18, 16, 32, 0.92));
}

.probability-item .label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.probability-item strong {
    font-size: 1.2rem;
    font-weight: 700;
}

.action-button {
    border: 1px solid rgba(142, 113, 245, 0.42);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(68, 49, 140, 0.98), rgba(23, 17, 49, 0.98)),
        radial-gradient(circle at top, rgba(171, 145, 255, 0.22), transparent 50%);
    color: #f2ecff;
    padding: 11px 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-button:hover:not(:disabled) {
    box-shadow: 0 0 24px rgba(128, 102, 255, 0.26), 0 10px 24px rgba(0, 0, 0, 0.28);
    transform: translateY(-2px);
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255,255,255,0.1);
    color: var(--muted);
    background: rgba(255,255,255,0.05);
}

.glass-select {
    appearance: none;
    background: rgba(23, 19, 47, 0.88) url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a892ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 1rem center;
    background-size: 1em;
    border: 1px solid rgba(125, 102, 214, 0.24);
    color: #f4efff;
    padding: 12px 40px 12px 20px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.glass-select option {
    background: #1a2035;
    color: #fff;
}

.opening-stage {
    padding: 44px 0 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

.pack-panel {
    padding-top: 0;
}

.pack-panel .panel-header {
    margin-bottom: 8px;
}

.opening-header {
    text-align: center;
    margin-bottom: 6px;
}

.neon-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    color: #fff;
    letter-spacing: 0.2em;
    margin: 0 0 8px;
}

.sub-text {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0;
}

.card-stage {
    position: relative;
    width: 100%;
    min-height: 620px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 2000px;
    margin: 0;
    overflow: visible;
}

.stage-light {
    position: absolute;
    inset: 18% 22% 18%;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(247, 241, 222, 0.18) 0%, rgba(188, 161, 255, 0.08) 34%, rgba(88, 118, 213, 0.04) 56%, transparent 76%);
    filter: blur(42px);
    opacity: 0;
    transform: scale(0.84);
    pointer-events: none;
    z-index: 2;
}

.stage-ring,
.stage-veil {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.stage-ring {
    inset: 24% 30%;
    border-radius: 50%;
    border: 1px solid rgba(228, 220, 255, 0.18);
    box-shadow: 0 0 18px rgba(166, 136, 255, 0.08), inset 0 0 12px rgba(255, 248, 216, 0.04);
    opacity: 0;
    transform: scale(0.68);
    z-index: 2;
}

.stage-veil {
    inset: 20% 18% 14%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 52%, rgba(255, 247, 223, 0.1) 0%, rgba(204, 185, 255, 0.06) 34%, transparent 66%),
        linear-gradient(115deg, transparent 30%, rgba(248, 239, 214, 0.12) 49%, transparent 66%);
    filter: blur(24px);
    opacity: 0;
    transform: scale(0.9) rotate(-10deg);
    z-index: 1;
    mask-image: radial-gradient(circle at center, transparent 0 24%, black 52%, transparent 84%);
}

.card-stage.is-bursting .stage-light {
    animation: stageBloom 0.9s ease-out forwards;
}

.card-stage.is-bursting .stage-ring {
    animation: stageHalo 1s ease-out forwards;
}

.card-stage.is-bursting .stage-veil {
    animation: stageVeil 1.05s ease-out forwards;
}

.booster-pack {
    --rip-open: 0;
    --drag-x: 0px;
    --drag-y: 0px;
    --card-peek: 0;
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    position: absolute;
    width: min(100%, 780px);
    aspect-ratio: 1407 / 768;
    border: 0;
    background: transparent;
    color: #fff;
    overflow: visible;
    cursor: grab;
    transform:
        translate(var(--drag-x), var(--drag-y))
        rotateY(calc(-8deg + var(--rip-open) * 6deg + var(--tilt-y)))
        rotateX(calc(4deg - var(--rip-open) * 4deg + var(--tilt-x)))
        rotateZ(calc(var(--rip-open) * -1.5deg))
        translateZ(50px)
        scale(calc(1 + var(--rip-open) * 0.02));
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.4s ease;
    z-index: 10;
    box-shadow: none;
    filter: drop-shadow(-12px 20px 24px rgba(0, 0, 0, 0.42));
    touch-action: none;
}

.booster-pack:active {
    cursor: grabbing;
}

.booster-pack:hover {
    transform:
        translate(var(--drag-x), var(--drag-y))
        rotateY(calc(-2deg + var(--rip-open) * 4deg + var(--tilt-y)))
        rotateX(calc(1deg - var(--rip-open) * 2deg + var(--tilt-x)))
        translateZ(80px)
        scale(calc(1.02 + var(--rip-open) * 0.02));
    filter: drop-shadow(0 28px 32px rgba(0, 0, 0, 0.52));
}

.booster-pack.is-ripping {
    animation: packShake 0.26s ease-out both;
}

.booster-pack.is-opened {
    animation: packVanish 0.72s ease-out forwards;
}

.pack-body,
.pack-top {
    position: absolute;
    inset: 0;
    background-image: url("image/pack2.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    filter: saturate(0.98) contrast(1.01);
}

.pack-body {
    clip-path: polygon(
        0 0,
        100% 0,
        100% 100%,
        0 100%
    );
    opacity: calc(1 - max(0, var(--rip-open) - 0.08) * 0.08);
}

.pack-top {
    opacity: clamp(0, calc((var(--rip-open) - 0.12) * 4), 1);
    clip-path: polygon(
        0 0,
        100% 0,
        100% 16.5%,
        56% 16.5%,
        52.5% calc(16.5% + var(--rip-open) * 2.6%),
        50% calc(16.5% + var(--rip-open) * 3.2%),
        47.5% calc(16.5% + var(--rip-open) * 2.6%),
        44% 16.5%,
        0 16.5%
    );
    transform-origin: 82% 62%;
    transform:
        translateX(calc(max(0, var(--rip-open) - 0.12) * 120px))
        translateY(calc(max(0, var(--rip-open) - 0.12) * -10px))
        rotateZ(calc(max(0, var(--rip-open) - 0.12) * 22deg))
        rotateX(calc(max(0, var(--rip-open) - 0.12) * 18deg));
    filter: saturate(0.98) contrast(1.01) drop-shadow(0 10px 10px rgba(0, 0, 0, 0.16));
}

.booster-pack[data-rip-state="tearing"] .pack-body,
.booster-pack[data-rip-state="opened"] .pack-body {
    clip-path: polygon(
        0 16.5%,
        44% 16.5%,
        47.5% calc(16.5% + var(--rip-open) * 2.6%),
        50% calc(16.5% + var(--rip-open) * 3.2%),
        52.5% calc(16.5% + var(--rip-open) * 2.6%),
        56% 16.5%,
        100% 16.5%,
        100% 100%,
        0 100%
    );
}

.pack-contents {
    position: absolute;
    inset: 18% 16% 10%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    z-index: -1;
    clip-path: inset(calc(36% - var(--card-peek) * 30%) 0 0 0);
}

.pack-card {
    position: relative;
    width: 32%;
    aspect-ratio: 63 / 88;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(244, 240, 255, 0.96), rgba(201, 190, 240, 0.92)),
        linear-gradient(135deg, rgba(114, 89, 205, 0.2), rgba(22, 23, 58, 0.08));
    border: 1px solid rgba(92, 73, 171, 0.28);
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.22);
    transform-origin: center bottom;
    opacity: 0;
}

.pack-card::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(223, 216, 247, 0.74)),
        linear-gradient(135deg, rgba(119, 85, 211, 0.18), transparent 60%);
}

.pack-card-center {
    transform:
        translateY(calc(64px - var(--card-peek) * 78px))
        scale(calc(0.98 + var(--card-peek) * 0.03));
}

.booster-pack[data-rip-state="opened"] .pack-card {
    opacity: 1;
    animation: innerCardLift 0.62s ease-out both;
}

.pack-top-label,
.pack-center-glyph,
.pack-logo,
.pack-bottom-copy {
    display: none;
}

.foil-tear-line {
    clip-path: polygon(0 0, calc(var(--rip-open) * 100%) 0, calc(min(100%, (var(--rip-open) * 100%) + 5%)) 100%, 0 100%);
}

.pack-top-label {
    position: absolute;
    top: 24px;
    width: 100%;
    text-align: center;
    color: #f7f2ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
    z-index: 2;
}

.pack-center-glyph {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 10, 22, 0.04), rgba(6, 10, 22, 0) 70%);
    pointer-events: none;
}
.pack-center-glyph::before {
    content: none;
}

.pack-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    line-height: 1;
    font-weight: 800;
    text-align: center;
    color: #efe8ff;
    text-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 0 18px rgba(149, 117, 255, 0.22);
    width: 100%;
    z-index: 2;
}

.pack-bottom-copy {
    position: absolute;
    bottom: 30px;
    width: 100%;
    text-align: center;
    font-family: 'Inter', sans-serif;
    color: #f2ecff;
    font-size: 0.9rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
    z-index: 2;
}

.rip-instructions {
    color: #b7afd8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    height: 20px;
}

/* Card Spreading Animations */
.spread-fan {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}

.spread-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 255px;
    transform-origin: center center;
    opacity: 0;
    pointer-events: auto;
}

.spread-card.card-slot-0 { --tx: -330px; --ty: 0px; --rot: -15deg; --delay: 0.1s; }
.spread-card.card-slot-1 { --tx: -110px; --ty: -34px; --rot: -5deg; --delay: 0.2s; z-index: 6;}
.spread-card.card-slot-2 { --tx: 110px; --ty: -34px; --rot: 5deg; --delay: 0.3s; z-index: 6;}
.spread-card.card-slot-3 { --tx: 330px; --ty: 0px; --rot: 15deg; --delay: 0.4s; }

/* In case of 5 cards */
.spread-card.card-slot-0-5 { --tx: -334px; --ty: 18px; --rot: -20deg; --delay: 0.1s; }
.spread-card.card-slot-1-5 { --tx: -168px; --ty: -22px; --rot: -10deg; --delay: 0.2s; z-index: 6;}
.spread-card.card-slot-2-5 { --tx: 0px; --ty: -48px; --rot: 0deg; --delay: 0.3s; z-index: 7;}
.spread-card.card-slot-3-5 { --tx: 168px; --ty: -22px; --rot: 10deg; --delay: 0.4s; z-index: 6;}
.spread-card.card-slot-4-5 { --tx: 334px; --ty: 18px; --rot: 20deg; --delay: 0.5s; }

.spread-card.is-visible {
    animation: dealCard 1.08s cubic-bezier(0.2, 0.9, 0.32, 1) forwards;
    animation-delay: var(--delay);
}

@keyframes dealCard {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.54) translateY(180px) rotateX(58deg) rotateZ(-6deg);
    }
    55% {
        opacity: 1;
        transform: translate(calc(-50% + var(--tx) * 0.78), calc(-50% + var(--ty) * 0.78)) scale(1.02) rotate(calc(var(--rot) * 1.08));
    }
    100% {
        opacity: 1;
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
    }
}

/* TCG Card Base Design */
.inventory-grid,
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
}

.tcg-card {
    position: relative;
    border-radius: 20px;
    aspect-ratio: 63 / 88;
    background: #0b0b0b;
    overflow: hidden;
    isolation: isolate;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
    cursor: grab;
}

.tcg-card:active {
    cursor: grabbing;
}

.tcg-card.is-dragging {
    opacity: 0.68;
    transform: scale(0.98);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.tcg-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    padding: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-face-front {
    z-index: 2;
}

.card-face-back {
    transform: rotateY(180deg);
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.tcg-card:hover {
    transform: translateY(-8px) scale(1.03) rotateX(3deg);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.58);
    z-index: 10;
}

.tcg-card.is-unowned {
    opacity: 0.52;
    filter: grayscale(0.9) saturate(0.02) brightness(0.28) contrast(1.02);
}

.tcg-card.is-unowned .card-art-window {
    background: linear-gradient(145deg, rgba(10, 11, 17, 0.98), rgba(7, 8, 14, 0.99) 58%, rgba(9, 10, 16, 0.98)) !important;
}

.tcg-card.is-unowned .card-art-image {
    background-image: none !important;
    background-color: #0b0c12;
}

.tcg-card.is-unowned .formula-sigil-anim,
.tcg-card.is-unowned .formula-sigil-anim::before {
    display: none !important;
}

.tcg-card.is-unowned .card-art-window::before {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
    box-shadow: inset 0 0 24px rgba(255,255,255,0.025), 0 20px 30px rgba(0,0,0,0.2);
    opacity: 0.74;
    z-index: 1;
}

.tcg-card.is-unowned .card-art-window::after {
    content: "?";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 4, 8, 0.82);
    color: rgba(255, 255, 255, 0.92);
    font-family: 'Cinzel', serif;
    font-size: 5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
    pointer-events: none;
    z-index: 2;
}

.tcg-card.is-unowned:hover {
    opacity: 0.58;
    filter: grayscale(0.82) saturate(0.04) brightness(0.34) contrast(1.04);
}

.tcg-card.is-unowned:hover .card-art-window::after {
    background: rgba(3, 4, 8, 0.58);
}

.tcg-card::after {
    display: none;
}

.tcg-card:focus-visible {
    outline: 2px solid rgba(121, 214, 227, 0.9);
    outline-offset: 4px;
}

.tcg-card:hover::after {
    opacity: 1;
    transform: translateX(150%) skewX(-15deg);
}

/* Rarity Backgrounds */
.tcg-card[data-rarity="Bronze"] { background: #0b0b0b; }
.tcg-card[data-rarity="Silver"] { background: #0b0b0b; }
.tcg-card[data-rarity="Gold"] { background: #0b0b0b; }
.tcg-card[data-rarity="Platinum"] { background: #0b0b0b; }
.tcg-card[data-rarity="Legendary"] { background: #0b0b0b; animation: none; }

@keyframes holoGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* New Card Layout Styles */
.card-header {
    display: none;
}

.card-rarity-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 6px;
    min-width: 45px;
    text-align: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.card-name {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.card-formula-bar {
    display: none;
}

.card-formula-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-style: italic;
    color: #fff;
    margin: 0;
    text-shadow: 0 0 8px rgba(121, 214, 227, 0.6);
}

.card-art-window {
    position: relative;
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    border: none;
    background: transparent;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-art-image {
    position: absolute;
    inset: 0;
    background-image: var(--card-art);
    background-size: cover;
    background-position: center;
    transform: none;
    filter: none;
    background-color: #0b0b0b;
}

.card-back-image {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background-image: var(--card-back-art);
    background-size: cover;
    background-position: center;
    border: none;
    box-shadow: none;
    overflow: hidden;
    background-color: #0b0b0b;
}

.card-back-image::before {
    display: none;
}

.card-back-glow {
    display: none;
}

.art-overlay {
    display: none;
}

.formula-sigil-anim {
    display: none;
}

.formula-sigil-anim::before {
    display: none;
}

.tcg-card.is-generated-art .card-art-window {
    background:
        linear-gradient(145deg, rgba(11, 12, 18, 0.98), rgba(7, 8, 14, 0.99) 58%, rgba(9, 10, 16, 0.98));
}

.tcg-card.is-generated-art .card-art-image {
    background-image: none;
    background-size: cover;
    mix-blend-mode: normal;
}

.tcg-card.is-generated-art .formula-sigil-anim {
    display: none;
}

.tcg-card.is-generated-art .formula-sigil-anim::before {
    display: none;
}

.tcg-card.is-generated-art .card-art-window::before {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
    box-shadow: inset 0 0 24px rgba(255,255,255,0.03), 0 20px 30px rgba(0,0,0,0.2);
    opacity: 0.78;
    z-index: 1;
}

.card-meta-overlay {
    display: none;
}

.card-discoverer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-year {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted);
}

.card-stat-grid {
    display: none;
}

.card-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.stat-gem {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 2px;
    text-align: center;
}

.card-flavor {
    font-size: 0.75rem;
    line-height: 1.3;
    color: #94a3b8;
    font-style: italic;
    min-height: 3.2em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Original frame adjustments */
.card-frame {
    padding: 0;
    width: 100%;
    height: 100%;
}

/* Rarities */
.bronze { background: rgba(166, 124, 82, 0.2); color: #e6c2a1; border: 1px solid rgba(166, 124, 82, 0.4); }
.silver { background: rgba(226, 232, 240, 0.2); color: #f8fafc; border: 1px solid rgba(226, 232, 240, 0.4); }
.gold { background: rgba(212, 175, 55, 0.2); color: #fef08a; border: 1px solid rgba(212, 175, 55, 0.4); }
.platinum { background: rgba(129, 230, 217, 0.2); color: #e6fffa; border: 1px solid rgba(129, 230, 217, 0.4); }
.legendary { background: rgba(213, 126, 235, 0.2); color: #fbcfe8; border: 1px solid rgba(213, 126, 235, 0.4); text-shadow: 0 0 8px rgba(213,126,235,0.6); }

.rarity-chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.legend-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.battle-panel-copy {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.battle-panel-header {
    align-items: flex-start;
}

.battle-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.battle-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.battle-sidebar,
.battle-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.battle-card-panel {
    padding: 22px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(19, 17, 38, 0.94), rgba(10, 10, 20, 0.96)),
        radial-gradient(circle at top, rgba(160, 132, 255, 0.1), transparent 60%);
    border: 1px solid rgba(134, 108, 223, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 30px rgba(0, 0, 0, 0.2);
}

.battle-card-panel h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.02rem;
    letter-spacing: 0.1em;
}

.battle-kicker {
    margin: 0 0 8px;
    color: #b8aef0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.battle-helper {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.battle-deck-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.battle-deck-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.battle-deck-chip strong {
    font-size: 0.94rem;
}

.battle-deck-chip span {
    color: var(--muted);
    font-size: 0.84rem;
}

.battle-deck-chip.is-empty {
    justify-content: center;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.battle-scoreboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.battle-score-card,
.battle-center-status {
    padding: 20px 22px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(21, 18, 42, 0.94), rgba(8, 8, 17, 0.98)),
        radial-gradient(circle at top, rgba(134, 108, 223, 0.1), transparent 58%);
    border: 1px solid rgba(134, 108, 223, 0.18);
    text-align: center;
}

.battle-score-card span,
.battle-center-status span {
    display: block;
    color: #b8aef0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.battle-score-card strong,
.battle-center-status strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    color: #fff;
}

.battle-metric-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(126, 104, 215, 0.16);
    border: 1px solid rgba(157, 134, 247, 0.24);
}

.battle-arena {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
}

.battle-combatant {
    padding: 22px;
    min-height: 560px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(15, 14, 31, 0.94), rgba(8, 8, 17, 0.98)),
        radial-gradient(circle at center, rgba(153, 126, 255, 0.08), transparent 58%);
    border: 1px solid rgba(141, 115, 232, 0.16);
}

.battle-field-slot {
    min-height: 470px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 18px;
    border-radius: 24px;
    border: 1px dashed rgba(169, 156, 214, 0.2);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    padding: 18px;
}

.battle-placeholder {
    text-align: center;
    color: var(--muted);
    line-height: 1.8;
    max-width: 220px;
}

.battle-showcase-card {
    width: min(100%, 280px);
    cursor: default;
}

.battle-showcase-card:hover {
    transform: none;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}

.battle-versus {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.battle-versus-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 1px solid rgba(196, 182, 255, 0.24);
    background: radial-gradient(circle, rgba(171, 145, 255, 0.22), rgba(18, 15, 35, 0.98));
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    letter-spacing: 0.12em;
    color: #fff;
}

.battle-status {
    margin: 0;
    color: #f3edff;
    line-height: 1.7;
}

.battle-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.battle-section-head h3 {
    margin: 0;
}

.battle-hand,
.battle-roster {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.battle-hand {
    min-height: 260px;
}

.battle-card-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.battle-card-shell .tcg-card {
    cursor: pointer;
}

.battle-card-shell .tcg-card:hover {
    transform: translateY(-6px) scale(1.01);
}

.battle-card-shell.is-locked .tcg-card,
.battle-card-shell.is-disabled .tcg-card {
    cursor: default;
}

.battle-card-shell.is-disabled .tcg-card {
    opacity: 0.46;
    filter: grayscale(0.7);
}

.battle-card-shell.is-locked .tcg-card {
    box-shadow: 0 0 0 2px rgba(156, 132, 255, 0.55), 0 16px 32px rgba(0, 0, 0, 0.42);
}

.battle-card-shell.is-spent .tcg-card {
    opacity: 0.36;
    filter: grayscale(0.92) brightness(0.6);
}

.battle-card-shell.is-playable .tcg-card {
    box-shadow: 0 0 0 2px rgba(126, 210, 255, 0.34), 0 18px 32px rgba(0, 0, 0, 0.45);
}

.battle-card-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #efeaff;
    text-align: center;
    font-size: 0.88rem;
    line-height: 1.4;
}

.battle-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 620px;
    overflow-y: auto;
    padding-right: 4px;
}

.battle-log-entry {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #e9e3ff;
    line-height: 1.65;
    font-size: 0.9rem;
}

.battle-log-entry strong {
    color: #fff;
}

.battle-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

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

.battle-modal-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 15%, rgba(154, 117, 255, 0.18), transparent 28%),
        radial-gradient(circle at 80% 22%, rgba(78, 133, 255, 0.18), transparent 24%),
        linear-gradient(180deg, rgba(4, 5, 10, 0.92), rgba(3, 4, 8, 0.98));
    backdrop-filter: blur(14px);
}

.battle-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100vh;
    padding: 30px 34px 34px;
    overflow-y: auto;
}

.battle-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.battle-modal-header h2 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    letter-spacing: 0.12em;
}

.battle-modal-subtitle {
    margin: 10px 0 0;
    color: var(--muted);
}

.battle-modal-close {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 11, 20, 0.7);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
}

.battle-modal-scoreboard {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 220px;
    gap: 18px;
    margin-bottom: 24px;
}

.battle-modal-score,
.battle-modal-center {
    padding: 20px 24px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(19, 17, 38, 0.94), rgba(8, 9, 17, 0.98)),
        radial-gradient(circle at top, rgba(150, 122, 255, 0.12), transparent 62%);
    border: 1px solid rgba(144, 117, 235, 0.18);
}

.battle-modal-score {
    text-align: center;
}

.battle-modal-score span,
.battle-modal-center span {
    display: block;
    color: #b8aef0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.battle-modal-score strong,
.battle-modal-center strong {
    display: block;
    margin-top: 8px;
    font-size: 2.4rem;
    color: #fff;
}

.battle-modal-score small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.battle-modal-status {
    margin: 10px 0 0;
    color: #f0ebff;
    line-height: 1.7;
}

.battle-modal-arena {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
    margin-bottom: 24px;
}

.battle-modal-column,
.battle-modal-center-column,
.battle-modal-hand-wrap,
.battle-modal-log-panel {
    padding: 24px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(16, 15, 31, 0.96), rgba(7, 8, 14, 0.98)),
        radial-gradient(circle at top, rgba(141, 115, 232, 0.1), transparent 60%);
    border: 1px solid rgba(141, 115, 232, 0.16);
}

.battle-modal-center-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: center;
}

.battle-modal-versus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 1px solid rgba(196, 182, 255, 0.24);
    background: radial-gradient(circle, rgba(171, 145, 255, 0.24), rgba(18, 15, 35, 0.98));
    font-family: 'Cinzel', serif;
    font-size: 1.9rem;
    letter-spacing: 0.12em;
    color: #fff;
}

.battle-modal-round-summary {
    color: #efeaff;
    line-height: 1.7;
}

.battle-modal-board {
    min-height: 410px;
    margin-top: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    border-radius: 24px;
    border: 1px dashed rgba(169, 156, 214, 0.2);
    padding: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
}

.battle-modal-hand-wrap,
.battle-modal-log-panel {
    margin-bottom: 24px;
}

.battle-modal-hand {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.battle-play-button {
    border: 1px solid rgba(126, 210, 255, 0.3);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(32, 73, 120, 0.92), rgba(18, 24, 49, 0.96));
    color: #f6fbff;
    padding: 10px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.battle-play-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.battle-board-card {
    width: min(100%, 250px);
}

.battle-mini-stat {
    color: #c9bfff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

@keyframes packShake {
    0%, 100% { transform: translate(var(--drag-x), var(--drag-y)) rotateY(-1deg) rotateX(0) translateX(0); }
    25% { transform: translate(var(--drag-x), var(--drag-y)) rotateY(-1.8deg) rotateZ(-0.3deg) translateX(-3px); }
    50% { transform: translate(var(--drag-x), var(--drag-y)) rotateY(1.6deg) rotateZ(0.3deg) translateX(3px); }
    75% { transform: translate(var(--drag-x), var(--drag-y)) rotateY(-1.2deg) rotateZ(-0.15deg) translateX(-2px); }
}

@keyframes packVanish {
    0% {
        transform: translate(var(--drag-x), var(--drag-y)) scale(1);
        opacity: 1;
        filter: brightness(1) blur(0);
    }
    50% {
        transform: translate(var(--drag-x), calc(var(--drag-y) - 8px)) scale(1.02) rotateZ(-0.4deg);
        filter: brightness(1.03) blur(0.5px);
    }
    100% {
        transform: translate(var(--drag-x), calc(var(--drag-y) - 16px)) scale(1.04) rotateZ(-0.8deg);
        opacity: 0;
        filter: brightness(1.08) blur(2px);
    }
}

@keyframes stageBloom {
    0% {
        opacity: 0;
        transform: scale(0.84);
    }
    45% {
        opacity: 0.18;
        transform: scale(0.94);
    }
    100% {
        opacity: 0;
        transform: scale(1.02);
    }
}

@keyframes stageHalo {
    0% {
        opacity: 0;
        transform: scale(0.68);
    }
    42% {
        opacity: 0.12;
        transform: scale(0.82);
    }
    100% {
        opacity: 0;
        transform: scale(0.96);
    }
}

@keyframes stageVeil {
    0% {
        opacity: 0;
        transform: scale(0.9) rotate(-12deg);
    }
    48% {
        opacity: 0.1;
        transform: scale(0.94) rotate(-4deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.98) rotate(2deg);
    }
}

@keyframes innerCardLift {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    60% {
        opacity: 1;
        transform: translateY(calc(62px - var(--card-peek) * 36px)) scale(1);
    }
    100% {
        opacity: 1;
        transform: translateY(calc(64px - var(--card-peek) * 78px)) scale(calc(0.98 + var(--card-peek) * 0.03));
    }
}

/* Inventory Item (Mini display) */
.inventory-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    transition: background 0.3s ease, transform 0.3s ease;
}

.inventory-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-3px);
}

.inventory-item h3 {
    margin: 12px 0 8px;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
}

.mini-expression {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: #e2e8f0;
    margin: 0 0 12px;
}

.mini-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 4px 0;
}

.count-chip {
    background: rgba(255,255,255,0.1);
    padding: 4px 8px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #fff;
}

@media (max-width: 1024px) {
    .hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .card-stage {
        min-height: 620px;
    }

    .rarity-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .spread-card {
        width: 220px;
    }
    
    .spread-card.card-slot-0-5 { --tx: -350px; --ty: 10px; --rot: -20deg; }
    .spread-card.card-slot-1-5 { --tx: -180px; --ty: -20px; --rot: -10deg; }
    .spread-card.card-slot-2-5 { --tx: 0px; --ty: -40px; --rot: 0deg; }
    .spread-card.card-slot-3-5 { --tx: 180px; --ty: -20px; --rot: 10deg; }
    .spread-card.card-slot-4-5 { --tx: 350px; --ty: 10px; --rot: 20deg; }
    
    .spread-card.card-slot-0 { --tx: -300px; --ty: 0px; --rot: -15deg; }
    .spread-card.card-slot-1 { --tx: -100px; --ty: -30px; --rot: -5deg; }
    .spread-card.card-slot-2 { --tx: 100px; --ty: -30px; --rot: 5deg; }
    .spread-card.card-slot-3 { --tx: 300px; --ty: 0px; --rot: 15deg; }

    .battle-layout,
    .battle-modal-arena,
    .battle-modal-scoreboard {
        grid-template-columns: 1fr;
    }

    .battle-hand,
    .battle-roster,
    .battle-modal-hand {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .app-shell {
        width: 100%;
        padding: 20px 16px;
        transform: none;
    }
    
    .hero {
        padding: 6px 0 0;
    }

    .page-nav {
        gap: 10px;
    }

    .page-tab {
        width: 100%;
        text-align: center;
    }

    .page-view {
        padding-right: 0;
    }

    .page-view:last-child {
        padding-left: 0;
    }
    
    .glitch {
        font-size: 2.6rem;
        letter-spacing: 0.14em;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-banner {
        padding: 0;
    }
    
    .opening-stage {
        padding: 28px 4px 28px;
    }

    .card-stage {
        min-height: 460px;
    }

    .booster-pack {
        width: min(100%, 620px);
    }

    .inventory-grid,
    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .battle-layout {
        grid-template-columns: 1fr;
    }

    .battle-header-actions,
    .battle-section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .battle-hand,
    .battle-roster,
    .battle-modal-hand {
        grid-template-columns: 1fr;
    }

    .battle-modal-dialog {
        padding: 20px 16px 28px;
    }

    .battle-modal-board {
        min-height: 280px;
    }

    .rarity-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .spread-card {
        width: 180px;
    }
    
    .spread-card.card-slot-0-5 { --tx: -180px; --ty: 20px; --rot: -15deg; }
    .spread-card.card-slot-1-5 { --tx: -90px; --ty: -10px; --rot: -5deg; }
    .spread-card.card-slot-2-5 { --tx: 0px; --ty: -20px; --rot: 0deg; }
    .spread-card.card-slot-3-5 { --tx: 90px; --ty: -10px; --rot: 5deg; }
    .spread-card.card-slot-4-5 { --tx: 180px; --ty: 20px; --rot: 15deg; }
}

.hidden {
    display: none !important;
}

.modal-open {
    overflow: hidden;
}

.card-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.card-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 12, 0.78);
    backdrop-filter: blur(16px);
}

.card-modal-dialog {
    position: relative;
    width: min(1120px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    margin: 0;
    overflow: auto;
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(147, 112, 255, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(88, 118, 213, 0.12), transparent 30%),
        linear-gradient(180deg, rgba(20, 17, 43, 0.98), rgba(8, 9, 18, 0.98));
    border: 1px solid rgba(139, 108, 223, 0.24);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(68, 57, 122, 0.38);
}

.card-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(87, 63, 181, 0.98), rgba(28, 21, 67, 0.98));
    color: #f0ebff;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 2;
}

.card-modal-layout {
    display: grid;
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
    gap: 24px;
    padding: 28px;
    align-items: start;
}

.card-modal-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(31, 24, 64, 0.72), rgba(12, 13, 26, 0.72)),
        radial-gradient(circle at top, rgba(178, 155, 255, 0.12), transparent 56%);
    border: 1px solid rgba(152, 126, 255, 0.12);
}

.modal-card-3d {
    width: min(100%, 340px);
}

.modal-preview-card {
    width: 100%;
}

.card-modal-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-content: start;
    padding-top: 6px;
}

.modal-kicker {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #bfaeff;
    grid-column: 1 / -1;
}

.card-modal-info h3 {
    margin: 0;
    font-size: clamp(1.7rem, 2.6vw, 2.7rem);
    line-height: 1.08;
    grid-column: 1 / -1;
}

.modal-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    grid-column: 1 / -1;
}

.modal-score {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(52, 40, 106, 0.82);
    color: #ebe5ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.modal-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    grid-column: 1 / -1;
}

.modal-meta-grid > div,
.modal-section,
.modal-stat {
    border: 1px solid rgba(134, 110, 216, 0.14);
    background:
        linear-gradient(180deg, rgba(38, 28, 79, 0.56), rgba(14, 14, 28, 0.84)),
        radial-gradient(circle at top, rgba(146, 118, 255, 0.08), transparent 58%);
    border-radius: 18px;
}

.modal-meta-grid > div {
    padding: 14px;
}

.meta-label {
    display: block;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.modal-section {
    padding: 16px;
}

.modal-section-wide {
    grid-column: 1 / -1;
}

.modal-section h4 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.modal-section p,
.modal-meta-grid strong {
    margin: 0;
    line-height: 1.58;
    color: #f8fafc;
}

.modal-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.modal-stat {
    padding: 14px;
}

.modal-stat span {
    display: block;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}

.modal-stat strong {
    font-size: 1.7rem;
    color: #fff;
}

@media (max-width: 900px) {
    .card-modal-dialog {
        width: min(100vw - 24px, 1120px);
        height: auto;
        max-height: calc(100vh - 24px);
        margin: 0;
        overflow: auto;
    }

    .card-modal-layout {
        grid-template-columns: 1fr;
        padding: 20px;
        height: auto;
    }

    .card-modal-info,
    .modal-meta-grid,
    .modal-stats {
        grid-template-columns: 1fr;
    }
}
