/* Portal-style CSS variables */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a2e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-dim: #666;
    --accent-gold: #ffd700;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-pink: #ff6b9d;
    --accent-green: #22c55e;
    --accent-orange: #ff8c00;
    --accent-red: #ff4444;
    --border-color: #333355;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Background Effects */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.bg-orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: var(--accent-orange);
    top: -100px;
    left: -100px;
}

.bg-orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: var(--accent-purple);
    bottom: -50px;
    right: -50px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(5deg); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s ease, background 0.3s ease;
    position: absolute;
    left: 16px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.back-btn svg {
    width: 18px;
    height: 18px;
}

header h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--accent-orange);
    text-shadow: 0 0 30px rgba(255, 140, 0, 0.5);
}

.subtitle {
    font-family: 'Jua', sans-serif;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Game Container */
.game-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 20px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    gap: 8px;
    margin-bottom: 10px;
    font-family: 'Fira Code', monospace;
}

.status-left, .status-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    gap: 4px;
    color: var(--text-dim);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.stat-hp { color: #ff6666; }
.stat-atk { color: var(--accent-orange); }
.stat-def { color: var(--accent-cyan); }
.stat-gold { color: var(--accent-gold); }
.stat-floor { color: var(--accent-green); }

/* Game Display */
.game-display {
    background: #000;
    border: 3px solid var(--border-color);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    image-rendering: pixelated;
    touch-action: none;
}

/* Minimap */
.minimap-container {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 2px;
    z-index: 10;
}

#minimapCanvas {
    display: block;
    width: 120px;
    height: 84px;
    image-rendering: pixelated;
}

/* Message Log */
.message-log {
    height: 60px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.5;
    margin-top: 10px;
    font-family: 'Fira Code', monospace;
}

.msg { color: var(--text-dim); }
.msg-combat { color: #ff8888; }
.msg-item { color: #88ff88; }
.msg-special { color: var(--accent-gold); }
.msg-danger { color: var(--accent-red); }

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 4px;
}

.d-spacer {
    /* Empty spacer for plus-shaped D-pad layout */
}

.d-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    min-width: 52px;
    min-height: 52px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.d-btn:hover {
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent-orange);
}

.d-btn:active {
    background: var(--accent-orange);
    color: #000;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.action-btn {
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font-family: 'Jua', sans-serif;
    min-height: 48px;
}

.action-btn:hover {
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent-orange);
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overscroll-behavior: contain;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-orange);
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    max-width: 90%;
    box-shadow: 0 0 30px rgba(255, 140, 0, 0.3);
}

.modal-title {
    color: var(--accent-gold);
    font-family: 'Black Han Sans', sans-serif;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
}

.inv-item {
    padding: 8px 12px;
    background: var(--bg-card);
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    border: 1px solid transparent;
    text-align: left;
    width: 100%;
}

.inv-item:hover {
    background: rgba(255, 140, 0, 0.2);
    color: var(--text-primary);
    border-color: var(--accent-orange);
}

.inv-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
    font-size: 12px;
}

.modal-close {
    margin-top: 15px;
    width: 100%;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.modal-close:hover {
    background: var(--accent-orange);
    color: #000;
    border-color: var(--accent-orange);
}

/* Title Screen */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

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

.title-logo {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 24px;
    color: var(--accent-orange);
    margin-bottom: 8px;
    text-shadow: 0 0 20px var(--accent-orange);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 20px var(--accent-orange); }
    to { text-shadow: 0 0 40px var(--accent-orange), 0 0 60px var(--accent-gold); }
}

.title-sub {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 25px;
}

.title-btn {
    padding: 12px 40px;
    background: rgba(255, 140, 0, 0.15);
    border: 2px solid var(--accent-orange);
    border-radius: 6px;
    color: var(--accent-orange);
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.title-btn:hover {
    background: var(--accent-orange);
    color: #000;
    box-shadow: 0 0 30px rgba(255, 140, 0, 0.5);
}

.title-legend {
    color: var(--text-dim);
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
    margin-top: 20px;
}

/* Game Content Article */
.game-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.game-content h2 {
    font-family: 'Black Han Sans', sans-serif;
    color: var(--accent-gold);
    font-size: 1.3rem;
    margin-bottom: 12px;
    margin-top: 20px;
}

.game-content h2:first-child {
    margin-top: 0;
}

.game-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

.tip-box {
    background: var(--bg-card);
    border-left: 3px solid var(--accent-orange);
    padding: 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 12px;
}

.tip-box p {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.tip-box p:last-child {
    margin-bottom: 0;
}

.tip-box strong {
    color: var(--accent-orange);
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--accent-gold);
}

/* Fullscreen mode */
body.fullscreen-active .game-wrapper {
    flex: 1;
    max-height: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.fullscreen-active .game-display {
    flex: 1;
    width: min(100%, calc((100vh - 280px) * 10 / 7));
    width: min(100%, calc((100dvh - 280px) * 10 / 7));
    max-width: min(100%, calc((100vh - 280px) * 10 / 7));
    max-width: min(100%, calc((100dvh - 280px) * 10 / 7));
}

body.fullscreen-active #gameCanvas {
    width: 100%;
    height: 100%;
}

body.fullscreen-active .controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.fullscreen-active .container {
    padding-bottom: 180px !important;
}

/* Mobile + Fullscreen combined */
@media (max-width: 600px) {
    body.fullscreen-active .game-wrapper {
        flex: none;
    }

    body.fullscreen-active .game-display {
        flex: none;
        width: min(100%, calc(100dvh - 300px));
        max-width: min(100%, calc(100dvh - 300px));
    }

    body.fullscreen-active .controls {
        position: static;
        background: transparent;
        backdrop-filter: none;
        border-top: none;
        padding: 8px 16px;
        padding-bottom: 0;
    }

    body.fullscreen-active .container {
        padding-bottom: 0 !important;
    }

    body.fullscreen-active .d-pad {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }

    body.fullscreen-active .d-btn {
        min-width: 60px;
        min-height: 60px;
        font-size: 30px;
    }

    body.fullscreen-active .action-btn {
        min-height: 56px;
        font-size: 18px;
    }
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .back-btn {
        position: relative;
        left: 0;
        margin-bottom: 10px;
    }

    .header-top {
        flex-direction: column;
        gap: 8px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .status-bar {
        font-size: 10px;
        padding: 6px 10px;
    }

    .d-pad {
        grid-template-columns: repeat(3, 56px);
        grid-template-rows: repeat(3, 56px);
    }

    .d-btn {
        font-size: 28px;
        min-width: 56px;
        min-height: 56px;
    }

    .action-btn {
        font-size: 16px;
        padding: 12px 16px;
        min-height: 52px;
    }

}

/* Continue Modal */
.continue-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overscroll-behavior: contain;
}

.continue-modal.active {
    opacity: 1;
    visibility: visible;
}

.continue-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    border: 2px solid var(--accent-orange);
    box-shadow: 0 10px 40px rgba(255, 140, 0, 0.3);
    max-width: 320px;
    width: 90%;
}

.continue-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.continue-modal-info {
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 25px;
}

.continue-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.continue-modal .continue-btn {
    padding: 14px 30px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-orange), #cc7000);
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.continue-modal .continue-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 20px rgba(255, 140, 0, 0.5);
}

.continue-modal .newgame-btn {
    padding: 12px 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.continue-modal .newgame-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* Shop Modal */
.shop-modal-content {
    min-width: 300px;
    max-width: 90%;
}

.shop-gold {
    text-align: center;
    font-size: 18px;
    color: var(--accent-gold);
    margin-bottom: 12px;
    font-family: 'Fira Code', monospace;
}

.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.shop-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Jua', sans-serif;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.shop-tab.active {
    background: var(--accent-orange);
    color: #000;
    border-color: var(--accent-orange);
}

.shop-tab:hover:not(.active) {
    background: rgba(255, 140, 0, 0.2);
}

.shop-items {
    max-height: 200px;
    overflow-y: auto;
}

.shop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-card);
    margin-bottom: 4px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.shop-item:hover {
    border-color: var(--accent-orange);
}

.shop-item-name {
    flex: 1;
    color: var(--text-secondary);
    font-size: 12px;
}

.shop-item-price {
    color: var(--accent-gold);
    font-size: 12px;
    font-family: 'Fira Code', monospace;
    margin: 0 12px;
}

.shop-item-price.sell-price {
    color: var(--accent-green);
}

.shop-buy-btn, .shop-sell-btn {
    padding: 4px 12px;
    background: var(--accent-purple);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.shop-buy-btn:hover, .shop-sell-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.shop-sell-btn {
    background: var(--accent-green);
}

.shop-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
    font-size: 12px;
}

/* Inventory Item Row */
.inv-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.inv-item-row .inv-item {
    flex: 1;
    margin-bottom: 0;
}

.inv-discard-btn {
    padding: 8px 10px;
    background: rgba(255, 68, 68, 0.2);
    border: 1px solid var(--accent-red);
    border-radius: 6px;
    color: var(--accent-red);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.inv-discard-btn:hover {
    background: var(--accent-red);
    color: #fff;
}

/* ====== Story Modal ====== */
.story-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.story-modal.active {
    opacity: 1;
    visibility: visible;
}

.story-modal-content {
    width: 90%;
    max-width: 360px;
    text-align: center;
}

.story-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--accent-gold);
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.story-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.story-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
}

.story-card:hover {
    border-color: var(--accent-gold);
    background: var(--bg-card);
    transform: translateX(4px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.15);
}

.story-card:active {
    transform: translateX(2px) scale(0.98);
}

.story-card-icon {
    font-size: 2rem;
    width: 48px;
    text-align: center;
    flex-shrink: 0;
}

.story-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.story-card-name {
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
}

.story-card-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ====== Star Wars Crawl ====== */
.story-crawl-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    z-index: 300;
    overflow: hidden;
    perspective: 300px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.story-crawl-overlay.active {
    opacity: 1;
}

.story-crawl-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
    transform-style: preserve-3d;
}

.story-crawl-text {
    position: absolute;
    bottom: -100%;
    width: 80%;
    max-width: 500px;
    text-align: center;
    transform: rotateX(25deg);
    transform-origin: center bottom;
    animation: crawl 18s linear forwards;
}

.story-crawl-text p {
    font-family: 'Jua', sans-serif;
    font-size: 1.5rem;
    line-height: 2;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    margin: 0;
}

@keyframes crawl {
    0% { bottom: -100%; }
    100% { bottom: 250%; }
}

.story-crawl-skip {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    z-index: 301;
    transition: all 0.2s ease;
}

.story-crawl-skip:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ====== Ending Scene ====== */
.ending-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.ending-overlay.active {
    opacity: 1;
}

.ending-content {
    text-align: center;
    padding: 30px;
    max-width: 360px;
    width: 90%;
}

.ending-character {
    font-size: 5rem;
    animation: endingBounce 1s ease-out, endingGlow 2s ease-in-out 1s infinite alternate;
    margin-bottom: 16px;
}

@keyframes endingBounce {
    0% { transform: scale(0) translateY(40px); opacity: 0; }
    50% { transform: scale(1.3) translateY(-10px); opacity: 1; }
    70% { transform: scale(0.9) translateY(5px); }
    100% { transform: scale(1) translateY(0); }
}

@keyframes endingGlow {
    0% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3)); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.6)); }
}

.ending-rescue {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.6rem;
    color: var(--accent-gold);
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    animation: fadeInUp 0.8s ease-out 0.5s both;
}

.ending-happy {
    font-family: 'Jua', sans-serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 24px;
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.ending-stats {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    animation: fadeInUp 0.8s ease-out 1.1s both;
}

.ending-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ending-stat-row:last-child {
    border-bottom: none;
}

.ending-stat-row span:last-child {
    color: var(--accent-gold);
}

.ending-restart-btn {
    padding: 14px 40px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-orange), #cc7000);
    color: #000;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fadeInUp 0.8s ease-out 1.4s both;
    min-height: 44px;
}

.ending-restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255, 140, 0, 0.5);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
