@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&family=Press+Start+2P&display=swap');

:root {
    --primary-pink: #ec4899;
    --primary-pink-hover: #db2777;
    --accent-glow: rgba(236, 72, 153, 0.45);
    --gold: #fbbf24;
    --bg-dark: #09090b;
    --surface-dark: rgba(18, 14, 28, 0.94);
    --arcade-font: 'Press Start 2P', monospace;
    --ui-font: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 15%, rgba(236, 72, 153, 0.15) 0%, transparent 60%),
        linear-gradient(180deg, #09090b 0%, #130d22 100%);
    color: #ffffff;
    font-family: var(--ui-font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#app-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Canvas Container */
#canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1280px;
    max-height: 720px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 40px rgba(236, 72, 153, 0.25);
    border-radius: 16px;
    overflow: hidden;
    background: #000;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Top Unified Arcade HUD (Anchored to Canvas) */
#hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    font-family: var(--arcade-font);
    font-size: 11px;
    letter-spacing: 1px;
    z-index: 10;
    pointer-events: none;
    box-sizing: border-box;
}

.hud-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    color: #f472b6;
    font-size: 9px;
    text-shadow: 0 0 8px rgba(236, 72, 153, 0.6);
}

.hud-value {
    color: #ffffff;
    text-shadow: 2px 2px #000;
}

#hud-player-name {
    color: #fbbf24;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.hud-btn {
    pointer-events: auto;
    background: rgba(10, 8, 18, 0.65);
    border: 1px solid rgba(236, 72, 153, 0.4);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-family: var(--ui-font);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-btn:hover {
    background: rgba(236, 72, 153, 0.35);
    border-color: var(--primary-pink);
    transform: translateY(-1px);
    box-shadow: 0 0 14px rgba(236, 72, 153, 0.5);
}

.hud-btn:active {
    transform: translateY(1px);
}

#btn-toggle-fullscreen.active {
    background: rgba(236, 72, 153, 0.25);
    border-color: #fbbf24;
    color: #fbbf24;
}

/* Fullscreen Mode Enhancements */
#app-wrapper:fullscreen,
#app-wrapper:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-container:fullscreen,
#canvas-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

/* Fullscreen Overlays */
.overlay-screen {
    position: absolute;
    inset: 0;
    background: rgba(10, 8, 18, 0.78);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Menu & Result Cards */
.card-menu {
    background: var(--surface-dark);
    border: 2px solid rgba(236, 72, 153, 0.45);
    border-radius: 24px;
    padding: 32px 40px;
    text-align: center;
    max-width: 580px;
    width: 90%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 45px rgba(236, 72, 153, 0.3);
    animation: cardAppear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardAppear {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.game-title {
    font-family: var(--arcade-font);
    font-size: 24px;
    color: #ffffff;
    margin-bottom: 6px;
    text-shadow: 0 0 16px var(--primary-pink);
}

.game-subtitle {
    font-size: 14px;
    color: #cbd5e1;
    margin-bottom: 20px;
}

/* Name Input Section */
.name-entry-box {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.name-label {
    font-size: 13px;
    font-weight: 600;
    color: #f472b6;
    letter-spacing: 0.5px;
}

#player-name-input {
    width: 100%;
    max-width: 320px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(236, 72, 153, 0.6);
    border-radius: 12px;
    padding: 12px 18px;
    font-family: var(--arcade-font);
    font-size: 13px;
    color: #ffffff;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
}

#player-name-input:focus {
    border-color: #f43f5e;
    box-shadow: 0 0 18px rgba(244, 63, 94, 0.6);
    background: rgba(0, 0, 0, 0.7);
}

/* Leaderboard */
.leaderboard-section {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: left;
}

.leaderboard-title {
    font-family: var(--arcade-font);
    font-size: 10px;
    color: var(--gold);
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 1px;
}

.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--arcade-font);
    font-size: 9px;
    padding: 4px 8px;
    border-radius: 6px;
    color: #cbd5e1;
}

.leaderboard-row.highlight-row {
    background: rgba(236, 72, 153, 0.3);
    color: #fbcfe8;
    border: 1px solid var(--primary-pink);
    animation: pulseHighlight 1.5s infinite;
}

@keyframes pulseHighlight {
    0%, 100% { box-shadow: 0 0 8px rgba(236, 72, 153, 0.4); }
    50% { box-shadow: 0 0 16px rgba(236, 72, 153, 0.8); }
}

.lb-rank { color: #94a3b8; width: 26px; }
.lb-name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: var(--gold); }

/* High Score Badge */
.high-score-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #000;
    font-family: var(--arcade-font);
    font-size: 10px;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.7);
    animation: bounceBadge 1s infinite alternate;
}

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

/* Action Buttons */
.retro-btn {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
    border: 2px solid #fbcfe8;
    color: #ffffff;
    font-family: var(--arcade-font);
    font-size: 11px;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.45);
    transition: all 0.2s ease;
}

.retro-btn:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.7);
    background: linear-gradient(135deg, #f43f5e 0%, #db2777 100%);
}

.retro-btn:active:not([disabled]) {
    transform: translateY(1px);
}

.retro-btn.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: none;
    margin-top: 8px;
    font-size: 9px;
    padding: 8px 16px;
}

.retro-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.retro-btn[disabled], .btn-disabled {
    background: #374151 !important;
    border-color: #4b5563 !important;
    color: #9ca3af !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

/* Venture Modal Card (100% Video Reference Match: Translucent White Frosted Glass + Giant Floating Mushroom) */
#venture-modal {
    background: rgba(10, 8, 20, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

#venture-modal .modal-card {
    position: relative;
    width: 92%;
    max-width: 960px;
    min-height: 400px;
    background: rgba(235, 245, 255, 0.26); /* Translucent whitish frosted glass matching reference video */
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 4px dashed rgba(255, 255, 255, 0.98);
    border-radius: 28px;
    padding: 36px 48px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), inset 0 0 35px rgba(255, 255, 255, 0.35);
    animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-sizing: border-box;
}

@keyframes modalPop {
    from { transform: scale(0.88); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-mushroom-container {
    flex-shrink: 0;
    width: 320px;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

#modal-mushroom-img {
    width: 100%;
    height: 100%;
    max-width: 320px;
    max-height: 320px;
    object-fit: contain;
    transform: scale(1.10);
    filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.7));
    animation: floatShroom 2.5s ease-in-out infinite;
}

@keyframes floatShroom {
    0% { transform: translateY(0px) rotate(0deg) scale(1.10, 1.10); }
    50% { transform: translateY(-14px) rotate(1.2deg) scale(1.13, 1.07); }
    100% { transform: translateY(0px) rotate(0deg) scale(1.10, 1.10); }
}

.modal-body {
    flex-grow: 1;
    min-width: 0; /* Critical: prevents flex blowout on long strings */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-self: stretch;
    gap: 16px;
}

#modal-venture-title {
    display: none !important; /* Reference video has no separate title header */
}

#modal-venture-text {
    font-family: var(--arcade-font);
    font-size: 11.5px;
    line-height: 2.25;
    color: #ffffff;
    letter-spacing: 0.6px;
    text-shadow: 2px 2px 0px #000000, -1px -1px 0px #000000, 1px -1px 0px #000000, -1px 1px 0px #000000, 0px 2px 4px rgba(0, 0, 0, 0.8);
    white-space: pre-wrap; /* Preserves normal spaces and word boundaries */
    word-break: break-word; /* Wraps cleanly at word boundaries */
    overflow-wrap: break-word;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 8px;
    box-sizing: border-box;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

/* Custom Scrollbar for Modal Text */
#modal-venture-text::-webkit-scrollbar {
    width: 6px;
}
#modal-venture-text::-webkit-scrollbar-thumb {
    background: rgba(236, 72, 153, 0.6);
    border-radius: 3px;
}
#modal-venture-text::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 4px;
    flex-shrink: 0;
}

#modal-close-btn {
    white-space: nowrap;
    padding: 10px 22px;
    font-size: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.5);
}

/* Victory CTA */
.join-us-container {
    cursor: pointer;
    margin: 14px auto;
    transition: transform 0.2s ease;
}

.join-us-container:hover {
    transform: scale(1.04);
}

.join-us-img {
    max-width: 240px;
    height: auto;
    filter: drop-shadow(0 6px 14px rgba(236, 72, 153, 0.5));
}

/* Loading Screen */
#loading-overlay {
    background: #09090b;
    z-index: 100;
}

.loading-bar {
    width: 280px;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ec4899, #f43f5e);
    transition: width 0.2s ease;
}

/* Mobile Virtual Touch Controls */
#touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 0 24px;
    justify-content: space-between;
    z-index: 40;
    pointer-events: none;
}

.touch-dpad, .touch-actions {
    display: flex;
    gap: 14px;
    pointer-events: auto;
}

.touch-btn {
    width: 58px;
    height: 58px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-family: var(--arcade-font);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.touch-btn:active {
    background: rgba(236, 72, 153, 0.5);
    border-color: var(--primary-pink);
    transform: scale(0.92);
}

.btn-jump-action {
    background: rgba(236, 72, 153, 0.35);
    border-color: var(--primary-pink);
    width: 64px;
    height: 64px;
}

@media (max-width: 900px), (hover: none) {
    #touch-controls {
        display: flex;
    }
}
