/* --- General Styles --- */
body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #3f3f3f; /* Dark background */
    color: #fff; /* Default text color */
    font-family: 'Press Start 2P', cursive, monospace; /* Use a pixel font if available, fallback to monospace */
    font-size: 0.9em;
    margin: 0;
    overflow-y: auto;
    user-select: none; /* Prevent selecting text */
    /* Optional: Add a background pattern */
    background-image:
        linear-gradient(45deg, #2f2f2f 25%, transparent 25%),
        linear-gradient(-45deg, #2f2f2f 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2f2f2f 75%),
        linear-gradient(-45deg, transparent 75%, #2f2f2f 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, 10px 0px;
}

/* Import a pixel font if desired (add this to your HTML head or CSS) */
/* @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); */


/* --- Layout --- */
.game-wrapper {
    display: grid;
    grid-template-columns: 200px auto 200px; /* Left panel, game area, right panel */
    grid-gap: 20px;
    padding: 20px;
    border: 5px solid #00ffff; /* Cyan border */
    box-shadow: 0 0 10px #00ffff;
    background-color: #000; /* Inner background black */
    position: relative; /* For game over message */
}

.panel {
    /* Basic panel styling */
    padding: 10px;
    border: 3px solid #00ffff;
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.left-panel {
    /* Specific styling for the left panel if needed */
}

.right-panel {
    /* Specific styling for the right panel if needed */
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Game Board Grid --- */
.grid-container {
    display: grid;
    /* grid-template-columns/rows and cell size set by JS */
    grid-gap: 1px; /* Gap between cells */
    background-color: #333; /* Grid lines color */
    border: 5px solid #00ffff; /* Cyan border */
    margin: auto; /* Center the grid */
    position: relative;
    overflow: hidden; /* Hide pieces spawning above */
}

.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: #000; /* Empty cell color */
    box-sizing: border-box;
    /* Optional: Inner border for empty cells */
    /* border: 1px solid #111; */
}

/* --- Ghost Piece Style --- */
.grid-cell.ghost {
    background-color: transparent !important; /* Ensure no background color */
    border: 2px dashed rgba(0, 255, 255, 0.5); /* Cyan dashed outline */
    /* Optional: A slightly darker outline */
    /* border: 2px dashed #008b8b; */
    box-sizing: border-box; /* Include border in size */
    /* Ensure ghost is behind the actual piece visually if they overlap */
    position: relative;
    z-index: 1;
}


/* --- Block Colors (Matching NES palette feel) --- */
/* Using slightly adjusted colors and white highlights/borders */
.block { /* Base style for filled cells */
    box-sizing: border-box;
    border: 1px solid #fff; /* White border */
}

.block-cyan { background-color: #00ffff; } /* I */
.block-blue { background-color: #0000ff; } /* J */
.block-orange { background-color: #ff7f00; } /* L (closer to orange) */
.block-yellow { background-color: #ffff00; } /* O */
.block-green { background-color: #00ff00; } /* S */
.block-purple { background-color: #800080; } /* T */
.block-red { background-color: #ff0000; } /* Z */


/* --- UI Panels --- */
h2 {
    color: #00ffff; /* Cyan headings */
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1em;
}

.game-type, .lines-panel {
     border: 3px solid #00ffff;
     padding: 5px 10px;
     margin-bottom: 10px;
     background-color: #1a1a1a;
     color: #fff;
     font-size: 1.1em;
}

.lines-panel {
    margin-bottom: 15px; /* More space below LINES */
    font-size: 1.2em;
}

.score-panel, .next-panel, .level-panel {
    width: 100%; /* Take full width of parent panel */
    padding: 10px 0; /* Inner padding */
    text-align: center;
}

.score-panel div, .level-panel div {
    font-size: 1.5em;
    margin-bottom: 15px; /* Space after scores/level */
    color: #ffff00; /* Yellow color for values */
}

#personal-best {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.next-panel {
    flex-grow: 1; /* Take up available space */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.next-grid-container {
    display: grid;
    /* Size set by JS */
    grid-gap: 1px;
    background-color: #333;
    border: 3px solid #00ffff;
    margin-top: 10px;
    overflow: hidden;
    box-sizing: content-box; /* Ensure border is outside the grid size */
}

.next-grid-cell {
    width: var(--next-cell-size); /* Size set by JS */
    height: var(--next-cell-size);
    background-color: #000;
    box-sizing: border-box;
}

.next-grid-cell.block { /* Inherit base block style */
     box-sizing: border-box;
     border: 1px solid #fff; /* White border */
}

.next-grid-cell.block-cyan { background-color: #00ffff; }
.next-grid-cell.block-blue { background-color: #0000ff; }
.next-grid-cell.block-orange { background-color: #ff7f00; }
.next-grid-cell.block-yellow { background-color: #ffff00; }
.next-grid-cell.block-green { background-color: #00ff00; }
.next-grid-cell.block-purple { background-color: #800080; }
.next-grid-cell.block-red { background-color: #ff0000; }


.stats-panel {
    flex-grow: 1; /* Take up available space */
     width: 100%;
     text-align: center;
     display: flex;
     flex-direction: column;
     align-items: center;
}

#stats-container {
    width: 100%;
    margin-top: 10px;
    text-align: left; /* Align stats text */
    font-size: 1.2em;
    color: #ffff00; /* Yellow for counts */
}

.stat-row {
     display: flex;
     align-items: center;
     margin-bottom: 5px;
     padding-left: 10px;
}

.stat-block-preview {
     width: calc(var(--cell-size) * 1.5); /* Roughly 1.5 times main cell size */
     height: var(--cell-size);
     display: inline-flex; /* Use flex for inner block display */
     justify-content: center;
     align-items: center;
     margin-right: 10px;
     border: 1px solid #555; /* Small border around the preview area */
     box-sizing: border-box;
     flex-shrink: 0; /* Don't shrink the preview area */
}

/* Simple way to show a miniature block color */
.stat-block-preview div {
    width: calc(var(--cell-size) * 0.8); /* Make the inner block smaller */
    height: calc(var(--cell-size) * 0.8);
    box-sizing: border-box;
    border: 1px solid #fff; /* White border */
}

.stat-block-preview .block-cyan { background-color: #00ffff; }
.stat-block-preview .block-blue { background-color: #0000ff; }
.stat-block-preview .block-orange { background-color: #ff7f00; }
.stat-block-preview .block-yellow { background-color: #ffff00; }
.stat-block-preview .block-green { background-color: #00ff00; }
.stat-block-preview .block-purple { background-color: #800080; }
.stat-block-preview .block-red { background-color: #ff0000; }


/* --- Game Over Message --- */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.9); /* More opaque */
    color: #fff;
    font-size: 2em;
    z-index: 20; /* Ensure it's above everything */
    display: none; /* Hidden by default */
    border: 5px solid #ff0000; /* Red border */
    box-shadow: 0 0 10px #ff0000;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
}

.game-over button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 0.8em;
    cursor: pointer;
    background-color: #00ffff;
    color: #000;
    border: 3px solid #008b8b;
    font-family: 'Press Start 2P', cursive, monospace;
}

.game-over button:hover {
    background-color: #008b8b;
    color: #fff;
    border-color: #00ffff;
}


/* --- Main Container (vertical layout) --- */
.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 12px 40px;
    width: 100%;
    box-sizing: border-box;
}


/* --- Game + chat row (chat on the right) --- */
.game-and-chat-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 1200px;
    flex-wrap: wrap;
}

.game-and-chat-row .game-wrapper {
    flex: 0 1 auto;
}

/* Left column: Tetris + leaderboard stacked, same width & centered as a unit */
.game-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    flex: 0 1 auto;
    min-width: 0;
}


/* --- View defaults (JS controls which is shown) --- */
#main-menu,
#tetris-view {
    display: none;
}

/* --- Main menu --- */
.main-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 52px 24px 72px;
    min-width: 320px;
}

.main-menu-title {
    font-size: 2.6em;
    color: #00ffff;
    letter-spacing: 12px;
    text-shadow: 0 0 16px #00ffff, 0 0 40px rgba(0,255,255,0.35);
}

.main-menu-greeting {
    font-size: 0.4em;
    color: #888;
    margin: -16px 0 0;
    letter-spacing: 1px;
}

/* Game cards row */
.menu-games-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
}

.menu-game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: #080808;
    border: 3px solid #00ffff;
    box-shadow: 0 0 14px rgba(0,255,255,0.2);
    padding: 20px 20px 18px;
    width: 170px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.12s, border-color 0.15s;
    user-select: none;
}

.menu-game-card:hover,
.menu-game-card:focus {
    box-shadow: 0 0 28px rgba(0,255,255,0.65), 0 0 6px #00ffff;
    transform: translateY(-4px);
    outline: none;
}

.menu-game-card--soon {
    border-color: #333;
    box-shadow: none;
    cursor: default;
    opacity: 0.5;
}
.menu-game-card--soon:hover,
.menu-game-card--soon:focus {
    box-shadow: none;
    transform: none;
}

/* --- Tetris mini-board preview --- */
.mgc-preview {
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mgc-preview--tetris {
    background: #000;
    border: 2px solid #222;
    padding: 4px;
    box-sizing: border-box;
}

.mgc-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
}

.mgc-board .b         { background: #111; border-radius: 1px; }
.mgc-board .b.c       { background: #00ffff; }
.mgc-board .b.o       { background: #ff9900; }
.mgc-board .b.p       { background: #aa00ff; }
.mgc-board .b.y       { background: #ffff00; }
.mgc-board .b.g       { background: #00dd44; }
.mgc-board .b.r       { background: #ff2244; }

/* --- Uno fan preview --- */
.mgc-preview--uno {
    background: #0d0d0d;
    border: 2px solid #222;
}

.uno-fan {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: -8px;
    position: relative;
    height: 68px;
    width: 80px;
}

.uno-c {
    width: 38px;
    height: 56px;
    border-radius: 4px;
    border: 2px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55em;
    color: #fff;
    font-family: 'Press Start 2P', cursive, monospace;
    position: absolute;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.uno-c--red    { background: #cc1111; transform: rotate(-18deg) translateX(-22px); z-index: 1; }
.uno-c--blue   { background: #1155cc; transform: rotate(0deg); z-index: 2; }
.uno-c--yellow { background: #ccaa00; transform: rotate(18deg) translateX(22px); z-index: 1; font-size: 0.38em; }

.uno-num { line-height: 1; }

/* Card name & CTA */
.mgc-name {
    font-size: 0.6em;
    color: #00ffff;
    letter-spacing: 3px;
    text-align: center;
}

.menu-game-card--soon .mgc-name {
    color: #555;
}

.mgc-cta {
    font-size: 0.42em;
    font-family: 'Press Start 2P', cursive, monospace;
    padding: 6px 14px;
    background: #003333;
    color: #00ffff;
    border: 2px solid #00ffff;
    letter-spacing: 2px;
    transition: background 0.12s, color 0.12s;
    pointer-events: none;
}

.menu-game-card:hover .mgc-cta,
.menu-game-card:focus .mgc-cta {
    background: #00ffff;
    color: #000;
}

.mgc-soon {
    font-size: 0.32em;
    color: #444;
    letter-spacing: 2px;
    border: 1px solid #333;
    padding: 4px 8px;
}

@media (max-width: 500px) {
    .main-menu-title { font-size: 1.6em; letter-spacing: 7px; }
    .menu-game-card { width: 140px; padding: 14px 12px; }
    .mgc-preview { width: 70px; height: 70px; }
}

/* Game area top bar — lines count centred, MENU button on the left */
.game-area-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 4px;
}

.lines-panel-spacer {
    /* mirrors the MENU button width so the lines count stays centred */
    visibility: hidden;
    padding: 5px 10px;
    font-size: 0.45em;
}

.back-to-menu-btn {
    font-size: 0.45em;
    font-family: 'Press Start 2P', cursive, monospace;
    background: transparent;
    color: #888;
    border: 2px solid #555;
    padding: 5px 10px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
    white-space: nowrap;
}

.back-to-menu-btn:hover {
    color: #000;
    background: #00ffff;
    border-color: #00ffff;
}

/* --- Username modal --- */
.username-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.username-modal[hidden] {
    display: none;
}

.username-modal-box {
    background: #000;
    border: 4px solid #00ffff;
    box-shadow: 0 0 30px #00ffff, 0 0 60px rgba(0,255,255,0.2);
    padding: 36px 32px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 340px;
    width: calc(100vw - 40px);
    box-sizing: border-box;
}

.username-modal-title {
    font-size: 1.3em;
    color: #00ffff;
    letter-spacing: 4px;
    text-align: center;
    text-shadow: 0 0 10px #00ffff;
}

.username-modal-sub {
    font-size: 0.38em;
    color: #aaa;
    text-align: center;
    line-height: 1.8;
    margin: 0;
}

.username-modal-label {
    font-size: 0.4em;
    color: #666;
    letter-spacing: 1px;
    align-self: flex-start;
}

#username-modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 0.7em;
    font-family: 'Press Start 2P', cursive, monospace;
    background: #111;
    color: #fff;
    border: 2px solid #444;
    outline: none;
    text-align: center;
    letter-spacing: 2px;
}

#username-modal-input:focus {
    border-color: #00ffff;
}

#username-modal-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.7em;
    font-family: 'Press Start 2P', cursive, monospace;
    background: #003333;
    color: #00ffff;
    border: 2px solid #00ffff;
    cursor: pointer;
    letter-spacing: 3px;
    transition: background 0.15s, color 0.15s;
}

#username-modal-btn:hover:not(:disabled) {
    background: #00ffff;
    color: #000;
}

#username-modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.username-modal-feedback {
    font-size: 0.38em;
    min-height: 1.4em;
    color: #ff6666;
    text-align: center;
    margin: 0;
    line-height: 1.6;
}

/* --- Live Chat (right sidebar) --- */
.chat-wrapper {
    width: 300px;
    max-width: calc(100vw - 24px);
    flex: 0 0 auto;
    border: 5px solid #00ffff;
    box-shadow: 0 0 10px #00ffff;
    background-color: #000;
    padding: 12px 14px 14px;
    box-sizing: border-box;
    position: sticky;
    top: 12px;
    align-self: flex-start;
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
}

.chat-wrapper h2 {
    text-align: center;
    font-size: 0.85em;
    margin: 0 0 8px;
    color: #00ffff;
}

.chat-identity-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 8px;
}

#chat-status-line {
    font-size: 0.45em;
    color: #888;
    margin: 0;
    text-align: center;
    line-height: 1.5;
}

.chat-change-name-btn {
    font-size: 0.35em;
    font-family: 'Press Start 2P', cursive, monospace;
    padding: 3px 6px;
    background: transparent;
    color: #555;
    border: 1px solid #444;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.4;
}

.chat-change-name-btn:hover {
    color: #aaa;
    border-color: #777;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 160px;
    max-height: min(42vh, 320px);
    height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0d0d0d;
    border: 2px solid #333;
    padding: 8px 8px;
    font-size: 0.5em;
    line-height: 1.35;
    margin-bottom: 8px;
    word-break: break-word;
}

.chat-line {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #222;
}

.chat-line:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.chat-sender-label {
    font-size: 0.95em;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: normal;
}

.chat-line--other .chat-sender-label {
    color: #ffaa44;
}

.chat-line--me .chat-sender-label {
    color: #44ffaa;
}

.chat-msg-text {
    color: #e8e8e8;
    padding-left: 2px;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-input-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-label {
    font-size: 0.4em;
    color: #666;
    text-align: left;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}

#chat-input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    font-size: 0.52em;
    font-family: 'Press Start 2P', cursive, monospace;
    background: #111;
    color: #fff;
    border: 2px solid #444;
    outline: none;
}

#chat-input:focus {
    border-color: #00ffff;
}

#chat-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#chat-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#chat-send-btn {
    padding: 6px 8px;
    font-size: 0.5em;
    font-family: 'Press Start 2P', cursive, monospace;
    background: #003333;
    color: #00ffff;
    border: 2px solid #00ffff;
    cursor: pointer;
    flex-shrink: 0;
}

#chat-send-btn:hover {
    background: #00ffff;
    color: #000;
}

.chat-feedback {
    font-size: 0.4em;
    min-height: 1.2em;
    margin: 6px 0 0;
    color: #888;
}

.chat-hint {
    font-size: 0.35em;
    color: #555;
    margin: 6px 0 0;
    line-height: 1.4;
}

.active-players-count {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #333;
    font-size: 0.48em;
    color: #00ffff;
    text-align: center;
    letter-spacing: 1px;
}

@media (max-width: 900px) {
    .game-and-chat-row {
        flex-direction: column;
        align-items: center;
    }

    .chat-wrapper {
        position: relative;
        top: auto;
        width: 100%;
        max-width: 660px;
        max-height: none;
    }

    .chat-messages {
        max-height: 240px;
    }
}


/* --- Leaderboard (same horizontal span as game-wrapper above) --- */
.leaderboard-wrapper {
    width: 100%;
    border: 5px solid #00ffff;
    box-shadow: 0 0 10px #00ffff;
    background-color: #000;
    padding: 15px 20px;
    box-sizing: border-box;
}

.leaderboard-wrapper h2 {
    text-align: center;
    font-size: 1.2em;
    margin-bottom: 15px;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.65em;
}

#leaderboard-table th {
    color: #00ffff;
    padding: 6px 10px;
    border-bottom: 2px solid #00ffff;
    text-align: center;
    letter-spacing: 1px;
}

#leaderboard-table td {
    color: #ffff00;
    padding: 6px 10px;
    text-align: center;
    border-bottom: 1px solid #222;
}

#leaderboard-table tr.rank-gold td  { color: #ffd700; }
#leaderboard-table tr.rank-silver td { color: #c0c0c0; }
#leaderboard-table tr.rank-bronze td { color: #cd7f32; }

#leaderboard-table tr.admin-row td {
    color: #ff7f00;
    background-color: #1a0d00;
    border-bottom: 1px solid #ff7f00;
}

.admin-star {
    color: #ff7f00;
    font-size: 1.1em;
}


/* --- Name Input (game over screen) --- */
.name-input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 10px 0 15px;
}

.name-input-section p {
    margin: 0;
    font-size: 0.5em;
    color: #00ffff;
}

#player-name {
    width: 90px;
    padding: 8px;
    font-size: 0.9em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #000;
    color: #ffff00;
    border: 3px solid #00ffff;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 8px;
    outline: none;
}

#player-name:focus {
    border-color: #ffff00;
    box-shadow: 0 0 8px #ffff00;
}

#submit-score-button {
    padding: 8px 16px;
    font-size: 0.45em;
    cursor: pointer;
    background-color: #ffff00;
    color: #000;
    border: 3px solid #ff7f00;
    font-family: 'Press Start 2P', cursive, monospace;
}

#submit-score-button:hover {
    background-color: #ff7f00;
    color: #fff;
    border-color: #ffff00;
}

#submit-score-button:disabled {
    background-color: #555;
    color: #888;
    border-color: #333;
    cursor: default;
}

#submit-feedback {
    font-size: 0.4em;
    min-height: 1.5em;
    color: #00ff00;
}


/* --- Admin Panel --- */
.admin-panel {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #222;
    font-size: 0.55em;
}

#admin-login-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#admin-password-input {
    padding: 5px 8px;
    font-size: 1em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #111;
    color: #fff;
    border: 2px solid #444;
    outline: none;
    width: 160px;
}

#admin-password-input:focus {
    border-color: #00ffff;
}

#admin-login-btn {
    padding: 5px 10px;
    font-size: 1em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #333;
    color: #00ffff;
    border: 2px solid #00ffff;
    cursor: pointer;
}

#admin-login-btn:hover {
    background-color: #00ffff;
    color: #000;
}

#admin-feedback {
    color: #ff0000;
    font-size: 0.9em;
}

#admin-active-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-badge {
    color: #ff7f00;
    letter-spacing: 1px;
}

#admin-logout-btn {
    padding: 5px 10px;
    font-size: 1em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #1a0000;
    color: #ff0000;
    border: 2px solid #ff0000;
    cursor: pointer;
}

#admin-logout-btn:hover {
    background-color: #ff0000;
    color: #fff;
}

.delete-score-btn {
    background: none;
    border: 2px solid #ff0000;
    color: #ff0000;
    font-size: 1em;
    cursor: pointer;
    padding: 2px 7px;
    font-family: 'Press Start 2P', cursive, monospace;
    line-height: 1;
}

.delete-score-btn:hover {
    background-color: #ff0000;
    color: #fff;
}


/* --- Grief Controls --- */
.admin-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.grief-controls {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid #333;
}

.grief-title {
    font-size: 0.8em;
    color: #ff7f00;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.grief-btn-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.grief-btn {
    padding: 6px 10px;
    font-size: 0.75em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #1a0000;
    color: #ff4444;
    border: 2px solid #ff4444;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.grief-btn:hover {
    background-color: #ff4444;
    color: #fff;
}

.grief-btn:active {
    transform: scale(0.95);
}

.grief-taunt-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#taunt-input {
    flex: 1;
    min-width: 140px;
    max-width: 320px;
    padding: 6px 8px;
    font-size: 0.65em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #111;
    color: #fff;
    border: 2px solid #ff7f00;
    outline: none;
}

#taunt-input:focus {
    border-color: #ffff00;
    box-shadow: 0 0 6px #ff7f00;
}

.grief-btn-taunt {
    padding: 6px 10px;
    font-size: 0.75em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #1a1000;
    color: #ff7f00;
    border: 2px solid #ff7f00;
    cursor: pointer;
    flex-shrink: 0;
}

.grief-btn-taunt:hover {
    background-color: #ff7f00;
    color: #000;
}


/* --- Grief Notification (floating popup) --- */
@keyframes griefPop {
    0%   { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
    15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

.grief-notification {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(160, 0, 0, 0.96);
    color: #fff;
    padding: 16px 32px;
    font-family: 'Press Start 2P', cursive, monospace;
    font-size: 0.9em;
    z-index: 9999;
    border: 4px solid #ff0000;
    box-shadow: 0 0 40px #ff0000;
    text-align: center;
    pointer-events: none;
    animation: griefPop 2.5s ease-in-out forwards;
    white-space: nowrap;
}

.grief-notification--taunt {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    transform: none;
    margin: 0;
    white-space: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: clamp(8px, 3vmin, 32px);
    border-width: 0;
    border: none;
    font-size: clamp(2.5rem, 14vmin, min(28vmin, 22vw));
    line-height: 1.05;
    letter-spacing: 0.02em;
    word-break: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    hyphens: auto;
    text-align: center;
    border-color: transparent;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.5);
    background: rgba(40, 15, 0, 0.94);
    color: #ffcc00;
    text-shadow:
        0 0 2px #000,
        0 0 4px #000,
        4px 4px 0 #ff4400,
        -2px -2px 0 #000;
    animation: griefTauntIn 0.4s ease-out forwards;
    z-index: 10000;
}

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


/* --- Grief fullscreen image (admin) --- */
.grief-image-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #333;
}

.grief-image-title {
    font-size: 0.75em;
    color: #ff7f00;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.grief-image-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.image-paste-zone {
    flex: 1;
    min-width: 160px;
    max-width: 280px;
    padding: 8px 10px;
    font-size: 0.55em;
    line-height: 1.4;
    color: #ccc;
    background: #111;
    border: 2px dashed #555;
    cursor: text;
    outline: none;
}

.image-paste-zone:focus {
    border-color: #ff7f00;
    color: #fff;
}

.grief-btn-image {
    padding: 6px 10px;
    font-size: 0.7em;
    font-family: 'Press Start 2P', cursive, monospace;
    background-color: #0a1a0a;
    color: #44ff44;
    border: 2px solid #44ff44;
    cursor: pointer;
    flex-shrink: 0;
}

.grief-btn-image:hover {
    background-color: #44ff44;
    color: #000;
}

.image-grief-feedback {
    display: block;
    width: 100%;
    margin-top: 6px;
    font-size: 0.5em;
    min-height: 1.2em;
}


/* --- Grief image overlay (all players) --- */
.grief-image-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    margin: 0;
    padding: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: griefTauntIn 0.35s ease-out forwards;
}

.grief-image-overlay img {
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    user-select: none;
}


/* --- Personal best toast --- */
.pb-toast {
    position: fixed;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    text-align: center;
    padding: 18px 36px;
    background: linear-gradient(180deg, #2a2000 0%, #0d0a00 100%);
    border: 4px solid #ffd700;
    box-shadow: 0 0 24px #ffd700, inset 0 0 20px rgba(255, 215, 0, 0.12);
    font-family: 'Press Start 2P', cursive, monospace;
    pointer-events: none;
    animation: pbToastIn 0.45s ease-out forwards;
}

.pb-toast-title {
    font-size: 0.65em;
    color: #ffd700;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.pb-toast-score {
    font-size: 1.1em;
    color: #fff;
    text-shadow: 2px 2px 0 #b8860b;
}

@keyframes pbToastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-16px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}


/* --- Blackout effect --- */
.grid-container.blackout .grid-cell,
.grid-container.blackout .grid-cell.block,
.grid-container.blackout .grid-cell.ghost {
    background-color: #000 !important;
    border-color: #000 !important;
}