*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: rgb(22, 22, 22);
    color: rgb(242, 242, 242);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

#stage {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

#frame {
    position: relative;
    width: 600px;
}

#hud {
    height: 50px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    color: rgba(242, 242, 242, 0.92);
    font-size: 18px;
    letter-spacing: 0.02em;
}

.hud-left  { text-align: left; }
.hud-mid   {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}
.hud-right { text-align: right; }

#hud-mode {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.65;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.hud-lives {
    margin-left: 14px;
}

#game {
    display: block;
    width: 600px;
    height: 600px;
    background: rgb(22, 22, 22);
    border: 2px solid rgba(242, 242, 242, 0.35);
    image-rendering: auto;
    touch-action: none;
}

/* Menu container; views render inside. */
#menu {
    position: absolute;
    inset: 0;
    background: rgb(22, 22, 22);
    z-index: 2;
}

#menu[hidden] { display: none; }

.menu-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 28px;
    height: 100%;
}

.menu-view[hidden] { display: none; }

#menu h1 {
    margin: 0 0 20px;
    font-size: 70px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: underline;
    text-underline-offset: 8px;
    text-decoration-thickness: 4px;
    color: rgb(242, 242, 242);
}

#menu button {
    width: 600px;
    height: 72px;
    margin-bottom: 8px;
    /* center text both axes — default button rendering can leave large fonts top-aligned */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid transparent;
    background: transparent;
    color: rgb(242, 242, 242);
    font-family: inherit;
    font-size: 55px;
    font-weight: 500;
    cursor: pointer;
}

#menu button:focus,
#menu button:focus-visible {
    background: rgba(242, 242, 242, 0.1);
    border-color: rgba(242, 242, 242, 0.55);
    outline: none;
}

#menu button:active {
    background: rgba(242, 242, 242, 0.18);
}

/* "Settings · Leaderboard" footer row on the main menu — two narrower buttons. */
.menu-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

#menu .menu-row button {
    width: auto;
    height: auto;
    padding: 8px 22px;
    font-size: 36px;
    margin-bottom: 0;
}


/* Settings sub-view rows: each holds either a single label/checkbox or a radio group. */
.settings-row {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-bottom: 18px;
    color: rgb(242, 242, 242);
    font-size: 22px;
    user-select: none;
}

.settings-label {
    opacity: 0.7;
}

.settings-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.settings-row input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: rgb(180, 220, 190);
}

/* Settings sub-view: each row is its own 2-col grid so per-row vertical alignment works.
   Single-row settings use align-items: center (label and control vertically centered);
   the stacked Color theme row uses align-items: start so the label sits at the top of
   the radio stack. Column 1 is fixed at 200px so all labels right-align across rows. */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
    color: rgb(242, 242, 242);
    font-size: 22px;
    user-select: none;
}

.settings-row-grid {
    display: grid;
    grid-template-columns: 200px auto;
    column-gap: 22px;
    align-items: center;
}

.settings-row-grid.stacked {
    align-items: start;
}

.settings-grid .settings-label {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.settings-grid label.settings-label {
    cursor: pointer;
}

.settings-grid .settings-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.settings-grid .settings-control.stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.settings-grid .settings-control label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.settings-grid input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: rgb(180, 220, 190);
}

/* Leaderboard sub-view */
.leaderboard-controls {
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
}

.leaderboard-controls select {
    background: rgb(36, 36, 40);
    color: rgb(242, 242, 242);
    border: 1px solid rgba(242, 242, 242, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 18px;
    cursor: pointer;
}

.leaderboard-table {
    width: 520px;
    color: rgb(242, 242, 242);
    font-size: 18px;
    margin-bottom: 20px;
    min-height: 280px;
}

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

.leaderboard-table th,
.leaderboard-table td {
    padding: 6px 12px;
    text-align: left;
}

.leaderboard-table th {
    opacity: 0.6;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(242, 242, 242, 0.2);
}

.leaderboard-table td.col-rank     { width: 40px;  opacity: 0.55; }
.leaderboard-table td.col-initials { width: 56px; font-weight: 600; letter-spacing: 0.06em; }
.leaderboard-table td.col-score    { font-weight: 600; width: 90px; }
.leaderboard-table td.col-date     { opacity: 0.7;  font-size: 16px; }
.leaderboard-table td.col-time     { opacity: 0.7;  font-size: 16px; white-space: nowrap; }

.leaderboard-empty,
.leaderboard-loading {
    text-align: center;
    padding-top: 50px;
    opacity: 0.55;
}

