* { box-sizing: border-box; }

html {
    font-family: "Courier New", monospace;
    font-size: 14px;
}

body {
    background: #0b0b0b;
    color: #ddd;
    margin: 0;
    padding: 2ch;
}

#container {
    max-width: 960px;
    margin: auto;
}

header h1 {
    color: #eee;
    font-size: 2.6rem;
    letter-spacing: 0.2em;
    margin: 0.2em 0 0;
    text-shadow: 0 0 12px #f00;
}

.accent { color: #d22; }

.tagline {
    color: #999;
    margin: 0.3em 0 1em;
}

#player-bar {
    display: flex;
    align-items: center;
    gap: 0.6em;
    background: #161616;
    border: 1px solid #333;
    padding: 0.6em;
    margin-bottom: 1em;
    flex-wrap: wrap;
}

#player-bar label { color: #d22; font-weight: bold; }

#player-bar input {
    background: #000;
    color: #eee;
    border: 1px solid #444;
    padding: 0.4em 0.6em;
    font-family: inherit;
    width: 16em;
}

button {
    background: #2a0d0d;
    color: #eee;
    border: 1px solid #d22;
    padding: 0.4em 1em;
    font-family: inherit;
    cursor: pointer;
}

button:hover { background: #d22; color: #000; }

.right { margin-left: auto; }

#name-status.good { color: #4d4; }
#name-status.bad  { color: #d44; }

#game-area {
    position: relative;
    overflow: auto;
}

canvas#canvas {
    background-color: #000;
    /* Zoom-/Zoom+ drive --gscale; CSS scaling keeps the SDL mouse mapping
       correct (browser zoom does not - it desyncs devicePixelRatio). */
    width: calc(100% * var(--gscale, 1));
    aspect-ratio: 4 / 3;
    display: block;
    margin: auto;
    border: 1px solid #333;
    /* crisp upscale of the native 320x200 frame - the browser's default
       bilinear filtering smears it into a blur */
    image-rendering: pixelated;
}

#game-area:fullscreen {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#game-area:fullscreen canvas#canvas {
    width: min(100vw, calc(100vh * 4 / 3)) !important;
    height: auto;
    border: none;
}

#loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d22;
    font-size: 1.6rem;
    letter-spacing: 0.3em;
    pointer-events: none;
}

#name-gate {
    position: absolute;
    inset: 0;
    display: none; /* doom.js flips to flex when the engine is ready but no name is saved */
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #d22;
    font-size: 1.3rem;
    letter-spacing: 0.2em;
    line-height: 2;
    pointer-events: none;
}


#toast {
    position: fixed;
    left: 50%;
    bottom: 2em;
    transform: translateX(-50%) translateY(200%);
    transition: transform 0.3s ease;
    background: #1a1a1a;
    border: 1px solid #d22;
    box-shadow: 0 0 20px rgba(220, 30, 30, 0.4);
    padding: 0.9em 1.4em;
    max-width: 90%;
    z-index: 10;
}

#toast.show { transform: translateX(-50%) translateY(0); }

#scoreboard {
    margin-top: 1em;
    background: #161616;
    border: 1px solid #333;
    padding: 1em;
    /* wider than the 960px page column so full "City, Country" names fit;
       centered breakout, capped at the viewport */
    width: min(1280px, calc(100vw - 4ch));
    margin-left: 50%;
    transform: translateX(-50%);
    overflow-x: auto;
}

.board-tabs {
    display: flex;
    gap: 0.6em;
    margin-bottom: 0.8em;
    flex-wrap: wrap;
}

.board-tabs .tab.active { background: #d22; color: #000; }

.board-tabs select {
    background: #000;
    color: #eee;
    border: 1px solid #444;
    font-family: inherit;
    padding: 0.3em;
}

#board-table {
    width: 100%;
    border-collapse: collapse;
}

#board-table th, #board-table td {
    border-bottom: 1px solid #2a2a2a;
    padding: 0.4em 0.6em;
    text-align: left;
    /* never squeeze names into wrapped lines - the panel scrolls instead */
    white-space: nowrap;
}

#board-table th { color: #d22; }

#board-table tr:first-child td { color: #ffd700; font-weight: bold; }

footer {
    margin-top: 1.5em;
    color: #777;
    font-size: 0.85rem;
}
