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

:root {
    --bg-dark: #0a0b10;
    --bg-panel: rgba(22, 25, 40, 0.75);
    --border-color: rgba(255, 255, 255, 0.12);
    --neon-cyan: #00f0ff;
    --neon-magenta: #ff007f;
    --neon-yellow: #ffd700;
    --amiga-blue: #0077ff;
    --text-main: #f0f4f8;
    --text-muted: #8a99ad;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(0, 119, 255, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 127, 0.1) 0%, transparent 50%);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 6px 0;
    overflow-x: hidden;
}

/* Title Bar with About button */
.title-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 6px;
}

.app-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.25rem;
    color: #ffffff;
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
    letter-spacing: 2px;
    margin: 0;
    flex: 1;
    text-align: center;
}

.btn-about {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-about:hover, .btn-about.active {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 10px var(--neon-cyan);
    transform: translateY(-50%) !important;
}

/* Game Main Layout Container */
.game-container {
    position: relative;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 119, 255, 0.15);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 960px;
    width: 95%;
}

/* About Overlay (covers entire game container except title bar) */
.about-overlay {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 7, 16, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.about-overlay.hidden {
    display: none;
}

.about-card {
    background: rgba(18, 22, 38, 0.95);
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.25);
    border-radius: 10px;
    padding: 16px 20px;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.about-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 16 / 9;
    margin: 0 auto 8px auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #000;
}

.about-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.about-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.about-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    color: var(--neon-yellow);
    letter-spacing: 1px;
}

.btn-close-about {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-close-about:hover {
    color: #fff;
    background: rgba(255, 0, 80, 0.4);
}

.about-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e2e8f0;
}

.about-body h3 {
    font-size: 0.85rem;
    color: var(--neon-cyan);
    margin-bottom: 6px;
}

.about-links-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.about-link-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.yt-btn {
    background: rgba(255, 0, 0, 0.15);
    border-color: rgba(255, 0, 0, 0.4);
    color: #ff6b6b;
}

.yt-btn:hover {
    background: rgba(255, 0, 0, 0.35);
    border-color: #ff3333;
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 0, 0, 0.4);
    transform: translateY(-1px);
}

.archive-btn {
    background: rgba(0, 229, 255, 0.15);
    border-color: rgba(0, 229, 255, 0.4);
    color: var(--neon-cyan);
}

.archive-btn:hover {
    background: rgba(0, 229, 255, 0.35);
    border-color: var(--neon-cyan);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
    transform: translateY(-1px);
}

/* Loading Screen Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: #060812;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: rgba(18, 22, 38, 0.9);
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 35px rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 240, 255, 0.2);
    border-top: 4px solid var(--neon-cyan);
    border-right: 4px solid var(--neon-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.1rem;
    color: var(--neon-yellow);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    animation: pulse 1s ease-in-out infinite alternate;
}

.loading-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* HUD Top Bar */
.hud-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    background: rgba(10, 12, 20, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px 8px;
    margin-bottom: 6px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hud-level-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
}

.hud-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    white-space: nowrap;
}

.hud-val {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: var(--neon-yellow);
    white-space: nowrap;
}

/* Canvas Viewport */
.canvas-wrapper {
    position: relative;
    border: 4px solid #1e2235;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    background: #000;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 672px;
    height: 544px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 21 / 17;
}

/* Player Inventory Bar */
.inventory-bar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.inv-card {
    position: relative;
    background: rgba(12, 15, 26, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
    overflow: hidden;
    cursor: default;
}

.inv-controls-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 11, 22, 0.95);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(4px);
    z-index: 5;
}

.inv-card:hover .inv-controls-overlay {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.inv-ctrl-row {
    font-size: 0.75rem;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.inv-ctrl-row .key-badge {
    font-size: 0.7rem;
    padding: 2px 5px;
}

.inv-p1 { border-left: 4px solid #55aaff; }
.inv-p2 { border-left: 4px solid #ff5555; }
.inv-p3 { border-left: 4px solid #55ff55; }
.inv-p4 { border-left: 4px solid #ff77ee; }

.inv-card.dead {
    opacity: 0.45;
    filter: grayscale(80%);
}

.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}

.inv-identity {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inv-avatar-canvas {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.inv-player-badge {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    font-weight: bold;
}

.inv-p1 .inv-player-badge { color: #55aaff; }
.inv-p2 .inv-player-badge { color: #ff5555; }
.inv-p3 .inv-player-badge { color: #55ff55; }
.inv-p4 .inv-player-badge { color: #ff77ee; }

.inv-score {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: var(--neon-yellow);
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 230, 0, 0.25);
}

.inv-status {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4ade80;
}

.inv-card.dead .inv-status {
    color: #f87171;
}

.inv-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    padding: 4px 6px;
    gap: 4px;
}

.inv-stat {
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: bold;
    color: #e2e8f0;
}

.inv-stat .inv-icon {
    font-size: 0.85rem;
}

.inv-item-canvas {
    width: 14px;
    height: 14px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: inline-block;
    vertical-align: middle;
}

.inv-stat.inv-special {
    color: var(--neon-yellow);
    text-shadow: 0 0 5px rgba(255, 230, 0, 0.5);
}

/* Control Buttons & Sliders */
.controls-bar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.btn {
    background: linear-gradient(135deg, #1e2438 0%, #121524 100%);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 3px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--amiga-blue) 0%, #0044bb 100%);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 0 16px rgba(0, 119, 255, 0.6);
}

/* Level & Options Selectors */
.selector-select {
    background: #121524;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    outline: none;
}

.selector-select:focus {
    border-color: var(--neon-cyan);
}

/* Visual Player Mode Picker */
.player-mode-picker {
    position: relative;
    display: inline-block;
}

.player-picker-btn {
    background: #121524;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    transition: all 0.2s ease;
}

.player-picker-btn:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.picker-current-avatars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.picker-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.player-picker-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: rgba(14, 18, 32, 0.98);
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    padding: 4px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 110px;
    animation: fadeIn 0.15s ease;
}

.player-picker-dropdown.hidden {
    display: none;
}

.player-picker-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.player-picker-item:hover {
    background: rgba(0, 240, 255, 0.2);
}

.player-picker-item.selected {
    background: rgba(0, 240, 255, 0.3);
    border: 1px solid rgba(0, 240, 255, 0.5);
}

.item-avatars {
    display: flex;
    align-items: center;
    gap: 4px;
}

.picker-avatar {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Overlays & Modals */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 7, 18, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 16px;
}

.overlay.hidden {
    display: none;
}

.victory-card {
    background: linear-gradient(145deg, rgba(20, 26, 46, 0.95), rgba(10, 14, 28, 0.95));
    border: 1px solid rgba(0, 229, 255, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 229, 255, 0.25);
    border-radius: 16px;
    padding: 20px 28px;
    text-align: center;
    max-width: 90%;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.victory-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.winner-avatar {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.25) 0%, rgba(10, 15, 30, 0.6) 80%);
    border: 2px solid var(--neon-cyan);
    border-radius: 50%;
    box-shadow: 0 0 18px rgba(0, 229, 255, 0.6), inset 0 0 10px rgba(0, 229, 255, 0.3);
    padding: 6px;
}

.victory-icon-badge {
    position: absolute;
    bottom: -4px;
    right: -6px;
    font-size: 1.4rem;
    filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
    animation: bounceBadge 0.6s infinite alternate ease-in-out;
}

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

.victory-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.1rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.8), 2px 2px 0 #000;
    margin: 0 0 8px 0;
    line-height: 1.4;
    letter-spacing: 1px;
}

.victory-sub {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 12px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.victory-score-pill {
    display: inline-block;
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: var(--neon-cyan);
    font-family: monospace;
    font-weight: bold;
    font-size: 0.95rem;
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

/* Legend Controls Panel */
.legend-panel {
    margin-top: 16px;
    width: 100%;
    background: rgba(10, 12, 20, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.key-badge {
    background: #20263b;
    border: 1px solid #343e5c;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #fff;
}

/* Modal Windows */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Scoreboard & Timer */
.hud-score-badge {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}
.hud-score-p1 { color: #55aaff; border-color: rgba(85, 170, 255, 0.4); }
.hud-score-p2 { color: #ff5555; border-color: rgba(255, 85, 85, 0.4); }
.hud-score-p3 { color: #55ff55; border-color: rgba(85, 255, 85, 0.4); }
.hud-score-p4 { color: #ff77ee; border-color: rgba(255, 119, 238, 0.4); }

.hud-timer {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.85rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px var(--neon-cyan);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    max-width: 500px;
}

.option-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}
