:root {
    --bg-dark: #1a1a1a;
    --panel-bg: #262626;
    --panel-border: #383838;
    --magenta-neon: #ff00ff;
    --cyan-neon: #34e2e4;
    --gold: #fcb900;
    --text-main: #ffffff;
    --text-dim: #929292;
    --nokia-green: #8f9a6d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px 10px;
    overflow-x: hidden;
}

/* Header & Logo */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1320px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.brand-titles h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-main);
}

.brand-titles .tagline {
    font-size: 0.8rem;
    color: var(--magenta-neon);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Arcade Cabinet Container */
.main-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    width: 100%;
    max-width: 1320px;
}

@media (min-width: 1000px) {
    .main-layout {
        grid-template-columns: minmax(560px, 840px) minmax(340px, 1fr);
    }
}

.arcade-card {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    position: relative;
}

/* HUD */
.hud-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    font-family: monospace;
}

.score-display {
    font-size: 1.15rem;
    font-weight: bold;
}

.score-val {
    color: var(--magenta-neon);
    font-size: 1.35rem;
    margin-left: 4px;
}

.era-badge {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

/* Canvas Screen */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 28 / 20;
    max-width: 840px;
    border: 3px solid #000000;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 0, 255, 0.15);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #000000;
}

/* Stage Announcement Slot (Always reserves fixed height so canvas never shifts) */
.stage-banner-slot {
    width: 100%;
    height: 44px;
    min-height: 44px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-banner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 6px;
    background: #181818;
    border: 2px solid transparent;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.88rem;
    letter-spacing: 0.5px;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    pointer-events: none;
}

.stage-banner.active {
    opacity: 1;
    transform: scale(1.0);
    pointer-events: auto;
}

.stage-banner.banner-green {
    border-color: #00e676;
    color: #00e676;
    box-shadow: 0 0 16px rgba(0, 230, 118, 0.4);
}

.stage-banner.banner-magenta {
    border-color: var(--magenta-neon);
    color: var(--magenta-neon);
    box-shadow: 0 0 18px rgba(255, 0, 255, 0.5);
}

.stage-banner.banner-gold {
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 18px rgba(252, 185, 0, 0.5);
}

/* Replay Bar (Positioned ABOVE canvas so it never hides game view) */
.replay-bar {
    width: 100%;
    background: #142a2b;
    border: 1px solid var(--cyan-neon);
    color: var(--cyan-neon);
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    box-shadow: 0 0 12px rgba(52, 226, 228, 0.25);
}

.replay-info strong {
    color: #ffffff;
}

.replay-controls {
    display: flex;
    gap: 6px;
}

/* Arcade Controls Panel */
.controls-bar {
    width: 100%;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Buttons */
.btn {
    background: var(--magenta-neon);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(255, 0, 255, 0.4);
    transition: all 0.15s ease-in-out;
}

.btn:hover {
    background: #e600e6;
    box-shadow: 0 0 18px rgba(255, 0, 255, 0.7);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #393939;
    color: #ffffff;
    box-shadow: none;
}

.btn-secondary:hover {
    background: #484848;
    box-shadow: none;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    border: none;
}

.btn-replay {
    background: var(--cyan-neon);
    color: #000000;
}

.btn-replay:hover {
    background: #19b2b4;
}

/* Mobile D-Pad */
.dpad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
    gap: 6px;
}

@media (min-width: 850px) {
    .dpad-container {
        display: none; /* Hide on desktop */
    }
}

.dpad-row {
    display: flex;
    gap: 6px;
}

.dpad-btn {
    width: 52px;
    height: 52px;
    background: #333333;
    border: 2px solid #4a4a4a;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.dpad-btn:active {
    background: var(--magenta-neon);
    border-color: #ffffff;
}

/* Side Column Container */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

/* Staff Devoured Session Collection Card */
.collection-card {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

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

.collection-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--gold);
    margin: 0;
}

.collection-title-group {
    display: flex;
    flex-direction: column;
}

.staff-slots-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.staff-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slot-avatar-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111111;
    border: 2px solid #333333;
    transition: border-color 0.3s, box-shadow 0.3s, filter 0.3s;
    overflow: visible;
}

.slot-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    transition: filter 0.3s, opacity 0.3s;
}

.slot-name {
    font-size: 0.72rem;
    font-weight: 700;
    margin-top: 5px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: color 0.3s;
}

/* Locked state */
.staff-slot.locked .slot-avatar-wrap {
    border: 2px dashed rgba(255, 255, 255, 0.25);
    background: #141414;
}

.staff-slot.locked .slot-avatar {
    display: none;
}

.staff-slot.locked .slot-question {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.5rem;
    font-weight: 900;
    font-family: monospace, sans-serif;
    color: rgba(255, 255, 255, 0.45);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
    user-select: none;
    transition: color 0.3s;
}

.staff-slot.locked:hover .slot-question {
    color: var(--gold);
}

.staff-slot.locked .slot-badge {
    display: none;
}

.staff-slot.locked .slot-name {
    color: var(--text-dim);
    letter-spacing: normal;
}

/* Unlocked state */
.staff-slot.unlocked .slot-avatar-wrap {
    border: 2px solid var(--gold);
    box-shadow: 0 0 14px rgba(252, 185, 0, 0.45);
    background: #000000;
}

.staff-slot.unlocked .slot-question {
    display: none;
}

.staff-slot.unlocked .slot-avatar {
    display: block;
    filter: none;
    opacity: 1;
}

.staff-slot.unlocked .slot-name {
    color: #ffffff;
    letter-spacing: normal;
    text-shadow: 0 0 6px rgba(252, 185, 0, 0.4);
}

.slot-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: var(--gold);
    color: #000000;
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 10px;
    border: 1.5px solid #000000;
    box-shadow: 0 0 6px rgba(252, 185, 0, 0.8);
    z-index: 2;
}

/* Impact animation when head arrives */
@keyframes slotImpact {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.35);
    }
    70% {
        transform: scale(0.92);
    }
    100% {
        transform: scale(1);
    }
}

.staff-slot.slot-impact {
    animation: slotImpact 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.staff-slot.slot-impact .slot-avatar-wrap {
    box-shadow: 0 0 25px rgba(252, 185, 0, 0.9), 0 0 45px rgba(255, 255, 255, 0.8);
}

/* Flying Staff Head Animation */
.flying-staff-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.flying-staff-head {
    position: absolute;
    top: 0;
    left: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2.5px solid var(--gold);
    box-shadow: 0 0 20px var(--gold), 0 0 40px rgba(252, 185, 0, 0.7);
    background: #000000;
    overflow: hidden;
    will-change: transform, opacity;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flying-staff-head img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Staff announcement banner styling */
.stage-banner.banner-staff {
    background: rgba(20, 20, 20, 0.95);
    border-color: var(--gold);
    box-shadow: 0 0 22px rgba(252, 185, 0, 0.55);
    padding: 4px 12px;
}

.staff-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.staff-banner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    object-fit: cover;
    box-shadow: 0 0 10px rgba(252, 185, 0, 0.6);
    flex-shrink: 0;
}

.staff-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.staff-banner-name {
    color: var(--gold);
    font-weight: 900;
    letter-spacing: 0.5px;
}

.staff-banner-quote {
    color: #ffffff;
    font-style: italic;
    font-weight: 600;
}

.staff-banner-pts {
    background: rgba(252, 185, 0, 0.2);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-left: 4px;
}

/* Leaderboard Card */
.leaderboard-card {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

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

.leaderboard-title-group {
    display: flex;
    flex-direction: column;
}

.leaderboard-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--cyan-neon);
}

.table-wrapper {
    overflow-y: auto;
    max-height: 440px;
}

.leaderboard-card .table-wrapper {
    overflow-y: visible;
    overflow-x: hidden;
    max-height: none;
}

/* Custom Arcade Scrollbar */
.custom-scrollbar::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
    background: #151515;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: #383838;
    border-radius: 4px;
    border: 1px solid rgba(255, 0, 255, 0.25);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--magenta-neon);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.6);
}

.custom-scrollbar,
.table-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #383838 #151515;
}

.leaderboard-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--panel-border);
}

.btn-block {
    width: 100%;
    display: block;
    text-align: center;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.leaderboard-table th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 600;
    padding: 6px 8px;
    border-bottom: 1px solid var(--panel-border);
}

.leaderboard-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.leaderboard-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.col-rank {
    font-weight: bold;
    color: var(--gold);
    width: 35px;
}

.col-score.highlight {
    font-weight: bold;
    color: var(--magenta-neon);
}

.col-attempts {
    width: 62px;
    font-size: 0.8rem;
}

.attempts-pill {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--cyan-neon);
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 10px;
    display: inline-block;
}

.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }

/* Game Over Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--magenta-neon);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.4);
    border-radius: 12px;
    width: 90%;
    max-width: 440px;
    padding: 24px;
    text-align: center;
}

/* Scrollable game-over panel, including the Discord tournament instructions. */
#gameOverModal .modal-content {
    max-width: 600px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

.discord-tournament-notice {
    margin-top: 16px;
    padding: clamp(12px, 3vw, 20px);
    border: 2px solid var(--gold);
    border-radius: 10px;
    background: rgba(252, 185, 0, 0.08);
    text-align: left;
}

.discord-tournament-notice h3 {
    color: var(--gold);
    font-size: clamp(1.25rem, 4vw, 1.65rem);
    line-height: 1.25;
    margin: 0 0 12px;
}

.discord-tournament-notice p,
.discord-tournament-notice figcaption {
    font-size: 1rem;
    line-height: 1.5;
}

.discord-tournament-notice figure {
    margin: 14px 0 0;
}

.discord-tournament-notice img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

.discord-tournament-notice figcaption {
    margin-top: 10px;
}

.discord-nickname-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
}

/* Full All-Scores Modal */
.modal-content.all-scores-modal {
    max-width: 1080px;
    width: 94vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 24px 28px;
    border-color: var(--cyan-neon);
    box-shadow: 0 0 35px rgba(52, 226, 228, 0.35);
}

.all-scores-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.all-scores-header h2 {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--cyan-neon);
    letter-spacing: 0.5px;
    margin: 0 0 4px 0;
}

.scores-search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.search-input {
    flex: 1;
    background: #141414;
    border: 1px solid #444444;
    border-radius: 6px;
    color: #ffffff;
    padding: 9px 14px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--cyan-neon);
    box-shadow: 0 0 10px rgba(52, 226, 228, 0.35);
}

.score-count-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid #444444;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.82rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.all-scores-table-wrapper {
    max-height: 54vh;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
}

@media (max-width: 850px) {
    .all-scores-table-wrapper {
        overflow-x: auto;
    }
}

.all-scores-table {
    width: 100%;
    border-collapse: collapse;
}

.all-scores-table th {
    position: sticky;
    top: 0;
    background: #1b1b1b;
    z-index: 2;
    padding: 10px 14px;
}

.all-scores-table td {
    padding: 10px 14px;
    white-space: nowrap;
}

.all-scores-table .col-rank {
    width: 60px;
}

.all-scores-table .col-score {
    width: 80px;
    font-size: 1rem;
}

.all-scores-table .col-dur {
    width: 90px;
}

.all-scores-table .col-staff {
    width: 110px;
}

.all-scores-table .col-date {
    width: 170px;
    min-width: 160px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.all-scores-table .col-action {
    width: 90px;
    text-align: center;
}

.modal-content h2 {
    font-size: 1.6rem;
    font-weight: 900;
    color: #ff3333;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.game-over-stats {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    text-align: left;
    font-size: 0.9rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.staff-trophies {
    margin: 15px 0;
    text-align: left;
}

.staff-trophies h3 {
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.trophy-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.staff-trophy-pill {
    background: rgba(252, 185, 0, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 12px;
}

.submission-box {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nickname-input {
    background: #111111;
    border: 1px solid var(--panel-border);
    color: #ffffff;
    padding: 10px;
    border-radius: 6px;
    font-size: 1rem;
    text-align: center;
    font-weight: bold;
}

.nickname-input:focus {
    outline: none;
    border-color: var(--magenta-neon);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.4);
}

.modal-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.status-loading { color: var(--cyan-neon); font-size: 0.8rem; }
.status-success { color: #00d084; font-size: 0.85rem; font-weight: bold; }
.status-error { color: #ff3333; font-size: 0.85rem; }

/* Unsubmitted Warning Modal */
.warning-modal {
    border-color: var(--gold) !important;
    box-shadow: 0 0 35px rgba(252, 185, 0, 0.45) !important;
    max-width: 440px;
}

.warning-title {
    color: var(--gold) !important;
    font-size: 1.35rem !important;
    letter-spacing: 0.5px;
}

.warning-desc {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 15px 0;
    color: #e2e2e2;
}

.column-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.btn-dim {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid #444444;
}

.btn-dim:hover {
    color: #ffffff;
    border-color: #666666;
}

.hidden { display: none !important; }
