/* The look of the page and of the HTML parts of the game (the words and
   buttons). The space scene itself is drawn on the canvas by game.js.

   Sizes use "cqw": 1cqw is 1% of the game box's width. The game box is 1600
   game pixels wide, so 1cqw = 16 game pixels. That way the words and buttons
   grow and shrink together with the game when the browser window changes size. */

html, body {
    margin: 0;
    height: 100%;
    background: #111;
    overflow: hidden;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Segoe UI", system-ui, sans-serif;
    user-select: none;          /* no text highlighting while playing */
}

/* The game box: as big as fits in the window, always 16 by 9. */
#game {
    position: relative;
    width: min(100vw, calc(100vh * 16 / 9));
    aspect-ratio: 16 / 9;
    background: black;
    container-type: inline-size;   /* lets everything inside use cqw */
    overflow: hidden;
    touch-action: none;            /* fingers steer the ship instead of scrolling the page */
}

#screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Top left: 10 game pixels in from the corner, 10-point text in the ship's color. */
#info {
    position: absolute;
    left: 0.625cqw;
    top: 0.625cqw;
    font-size: 1.04cqw;
    white-space: pre;
    pointer-events: none;
}

/* Top right: the button, then the three lines, side by side. */
#scoreboard {
    position: absolute;
    top: 0.5cqw;
    right: 0.75cqw;
    display: flex;
    align-items: center;
    gap: 0.75cqw;
    font-size: 1.67cqw;          /* 16 point, like Score in the C# version */
    font-weight: bold;
}

/* Score, Lives and Shields: left-justified, in a column wide enough for
   its longest line, so nothing jumps sideways when the numbers change. */
#lines {
    width: 15cqw;
    line-height: 1.2;
    color: white;
    pointer-events: none;
}
#lines div { white-space: pre; }   /* keep the spaces in "Shields: 2   ON: 6s" */

#lives.last-life { color: rgb(255, 90, 90); }
#shields         { color: rgb(70, 150, 255); }
#shields.none    { color: gray; }

/* START / RESET: a rectangle with rounded corners, in the same font as Score. */
#start {
    width: 7.1cqw;
    height: 3.2cqw;
    font: inherit;
    color: white;
    border-radius: 0.4cqw;
    border: 0.13cqw solid;
    cursor: pointer;
}
.start       { background: rgba(40, 150, 70, 0.82);  border-color: rgb(90, 200, 120); }
.reset       { background: rgba(200, 40, 40, 0.82);  border-color: rgb(240, 110, 110); }
#start:active { filter: brightness(1.25); }

/* The gray ship buttons at the bottom left, just above the ground, in rows
   of 3 to leave room for the launch pad. */
#ship-buttons {
    position: absolute;
    left: 0.75cqw;
    bottom: 2.9cqw;
    display: grid;
    grid-template-columns: repeat(3, 10.625cqw);
    gap: 0.625cqw;
}
#ship-buttons[hidden] { display: none; }

.ship-button {
    width: 10.625cqw;
    height: 3cqw;
    padding: 0 0 0 0.375cqw;
    display: flex;
    align-items: center;
    gap: 0.5cqw;
    background: rgb(90, 90, 90);
    color: white;
    border: 0.1cqw solid rgb(130, 130, 130);
    border-radius: 0.5cqw;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.ship-button canvas {
    width: 2.375cqw;
    height: 2.375cqw;
    background: black;
    flex: none;
}
.ship-button .number { display: block; font-size: 0.83cqw; }
.ship-button .name   { display: block; font-size: 0.94cqw; font-weight: bold; }

/* The chosen ship: lighter gray, black writing, a border in the ship's own
   color (game.js sets that color). */
.ship-button.chosen {
    background: rgb(150, 150, 150);
    color: black;
    border-width: 0.19cqw;
}

/* Bottom: which keys do what. */
#keys {
    position: absolute;
    left: 0.625cqw;
    bottom: 0.4cqw;
    font-size: 1.04cqw;
    white-space: pre;
    pointer-events: none;
}

/* BATTLE OVER: a dark red box across the middle. */
#banner {
    position: absolute;
    left: 20%;
    top: 38%;
    width: 60%;
    height: 24%;
    box-sizing: border-box;
    background: rgba(40, 0, 0, 0.78);
    border: 0.25cqw solid rgb(255, 60, 60);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
#banner[hidden] { display: none; }
#banner .big   { font-size: 5.6cqw; font-weight: bold; line-height: 1.1; }
#banner .small { font-size: 1.67cqw; white-space: pre; }
#banner.win    { background: rgba(0, 50, 10, 0.8); border-color: rgb(80, 220, 110); }

/* The friend's line under Shields (2 players only). */
#other { color: rgb(255, 200, 90); font-size: 0.8em; }

/* Top middle: HOST / JOIN, and messages about the connection. */
#versus {
    position: absolute;
    top: 0.5cqw;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3cqw;
    font-size: 1.04cqw;
    color: rgb(255, 200, 90);
}
#versus[hidden] { display: none; }
#versus-buttons { display: flex; align-items: center; gap: 0.5cqw; }
#versus .or[hidden], #versus input[hidden] { display: none; }
#versus-buttons[hidden] { display: none; }
#versus button {
    font: bold 1.04cqw "Segoe UI", system-ui, sans-serif;
    padding: 0.3cqw 0.8cqw;
    color: white;
    background: rgb(150, 100, 20);
    border: 0.1cqw solid rgb(255, 200, 90);
    border-radius: 0.4cqw;
    cursor: pointer;
}
#versus button[hidden] { display: none; }
#versus input {
    width: 4.5cqw;
    font: bold 1.04cqw "Segoe UI", system-ui, sans-serif;
    padding: 0.25cqw 0.4cqw;
    text-align: center;
    border-radius: 0.3cqw;
    border: 0.1cqw solid rgb(255, 200, 90);
    background: black;
    color: white;
}
#versus-status { white-space: pre; text-align: center; }

/* START while waiting for the other player. */
.ready { background: rgba(40, 110, 60, 0.6); border-color: rgb(120, 170, 130); }

/* The INSTRUCTIONS button, next to the control pad. game.js sets its left
   and top (in %) each frame so it follows the pad. Same blue as the pad. */
#instructions-button {
    position: absolute;
    width: 9.375cqw;            /* 150 game pixels */
    height: 2.75cqw;            /* 44 game pixels */
    font: bold 0.95cqw "Segoe UI", system-ui, sans-serif;
    color: white;
    background: rgba(40, 90, 170, 0.82);
    border: 0.13cqw solid rgb(150, 200, 255);
    border-radius: 0.625cqw;
    box-shadow: 0.25cqw 0.4cqw 0 rgba(0, 0, 0, 0.35);   /* floats like the pad */
    cursor: pointer;
}
#instructions-button:active { filter: brightness(1.35); }
#instructions-button[hidden] { display: none; }

/* The instructions: a dark box with a blue border in the middle of the
   game. Only the box scrolls, not the page. */
#instructions {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 47.5cqw;             /* 760 game pixels */
    max-height: 37.5cqw;        /* 600 game pixels */
    box-sizing: border-box;
    padding: 0.6cqw 1.6cqw 1.2cqw;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;        /* a finger can scroll it */
    background: rgb(8, 14, 35);
    border: 0.19cqw solid rgb(70, 150, 255);
    color: white;
    font-size: 1.2cqw;
    line-height: 1.35;
    user-select: text;
}
#instructions[hidden] { display: none; }
#instructions h1 { color: yellow; font-size: 2.1cqw; margin: 0.4cqw 0; }
#instructions h2 { color: rgb(120, 190, 255); font-size: 1.4cqw; margin: 1.3cqw 0 0.2cqw; }
#instructions p  { margin: 0.3cqw 0; }
