:root {
    --bg: #0E1116;
    --panel: #050608;
    --panel-line: #1E242D;
    --hero-bg: #0A0C0B;
    --text: #F2F4F7;
    --text-soft: #D6DBE2;
    --muted: #A9B1BC;
    --accent: #FFC72C;
    --accent-hover: #FFE08A;
    --green: #7EE2A8;
    --error: #FF8A3D;
    --paper: #F4EFE3;
    --ink: #14171C;
    --ink-soft: #3A404B;
    --ink-muted: #5B6270;
    --paper-line: #B9B2A2;

    --font-display: 'Big Shoulders Display', 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-body: 'Inter', system-ui, sans-serif;

    --gutter: clamp(16px, 5vw, 64px);
}

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

html {
    color-scheme: dark;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.5;
}

a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-hover);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(16px, 4vw, 48px) var(--gutter) 64px;
    display: flex;
    flex-direction: column;
    gap: clamp(24px, 4vw, 44px);
}

main {
    display: flex;
    flex-direction: column;
    gap: clamp(24px, 4vw, 44px);
}

/* Buttons */

.button {
    font: 700 16px/1 var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    padding: 16px 22px;
    cursor: pointer;
}

.button:hover {
    background: var(--accent-hover);
}

.link-button {
    font: 400 14px/1.2 var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 8px 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.link-button:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* Header */

.site-header {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 24px;
    font-family: var(--font-mono);
    font-size: clamp(13px, 2.5vw, 18px);
    letter-spacing: 0.18em;
    color: var(--muted);
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.user-name {
    color: var(--accent);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: var(--hero-bg);
}

.hero img {
    display: block;
    width: 100%;
    height: auto;
}

.hero-fade {
    position: absolute;
    inset: 0 0 auto 0;
    height: 30%;
    background: linear-gradient(180deg, var(--hero-bg) 0%, rgba(10, 12, 11, 0) 100%);
}

.hero h1 {
    position: absolute;
    top: 3%;
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    white-space: nowrap;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(36px, 9.3vw, 112px);
    line-height: 1;
    text-transform: uppercase;
    color: var(--accent);
}

.intro {
    margin: 0;
    max-width: 960px;
    font-size: clamp(19px, 3vw, 30px);
    line-height: 1.4;
    color: var(--text-soft);
}

/* Game board */

.board {
    background: var(--panel);
    border-radius: 20px;
    padding: clamp(14px, 3vw, 28px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: inset 0 0 0 2px var(--panel-line);
}

.board-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: clamp(14px, 2.5vw, 18px);
    letter-spacing: 0.16em;
    color: var(--muted);
}

.badge {
    font-weight: 700;
    color: var(--bg);
    background: var(--green);
    padding: 6px 12px;
    border-radius: 6px;
    letter-spacing: 0.1em;
}

.games {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
    gap: 16px;
}

.status {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.status.is-error {
    color: var(--error);
}

/* Game card */

.game {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: inset 0 0 0 2px var(--panel-line);
}

.game-image {
    aspect-ratio: 2 / 1;
    background: var(--hero-bg);
}

.game-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-image.is-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 2px 0;
    border-radius: 12px 12px 0 0;
    border: 2px dashed var(--panel-line);
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.game-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: clamp(16px, 3vw, 24px);
}

.game-label {
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.game-title {
    margin: -8px 0 0;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(36px, 6vw, 48px);
    line-height: 1;
    text-transform: uppercase;
    color: var(--accent);
}

.game-facts {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.game-facts dt {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.14em;
    color: var(--muted);
}

.game-facts dd {
    margin: 2px 0 0;
    font-size: 20px;
    font-weight: 700;
}

.game-facts-wide {
    grid-column: 1 / -1;
}

.game-description {
    margin: 0;
    color: var(--text-soft);
}

.game-description:empty {
    display: none;
}

/* Leaderboard */

.leaderboard {
    margin-top: auto;
    padding-top: 16px;
    border-top: 3px dashed var(--panel-line);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-head {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.leaderboard-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 16px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 3.5ch minmax(0, 1fr) auto;
    gap: 12px;
    align-items: baseline;
    padding: 8px 10px;
    border-radius: 6px;
}

.leaderboard-row + .leaderboard-row {
    border-top: 1px solid var(--panel-line);
}

.leaderboard-row .rank {
    color: var(--muted);
}

.leaderboard-row .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-row .score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.leaderboard-row.is-me {
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
}

.leaderboard-row.is-me .rank {
    color: var(--bg);
}

.leaderboard-row.is-me + .leaderboard-row,
.leaderboard-row + .leaderboard-row.is-me {
    border-top-color: transparent;
}

.me-tag {
    margin-left: 8px;
    font-size: 11px;
    letter-spacing: 0.12em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--accent);
}

.leaderboard-gap {
    padding: 0 10px;
    color: var(--muted);
    letter-spacing: 0.3em;
}

.leaderboard-empty {
    padding: 8px 10px;
    color: var(--muted);
}

.leaderboard-note {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
}

.leaderboard-toggle {
    align-self: flex-start;
}

.submit-button {
    width: 100%;
}

/* Name dialog */

.name-dialog {
    width: min(520px, calc(100% - 32px));
    padding: 0;
    border: 0;
    border-radius: 22px;
    background: var(--paper);
    color: var(--ink);
}

.name-dialog::backdrop {
    background: rgba(5, 6, 8, 0.8);
}

.name-dialog form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: clamp(20px, 5vw, 36px);
}

.dialog-label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.16em;
    color: var(--ink-muted);
}

.name-dialog h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 44px;
    line-height: 1;
    text-transform: uppercase;
}

.name-dialog label {
    font-size: 16px;
    color: var(--ink-soft);
}

.name-dialog input {
    font: 700 22px/1.2 var(--font-body);
    color: var(--ink);
    background: #FFFFFF;
    border: 2px solid var(--paper-line);
    border-radius: 10px;
    padding: 12px 14px;
}

.name-dialog input:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 0;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    margin-top: 6px;
    padding-top: 18px;
    border-top: 3px dashed var(--paper-line);
}

.name-dialog .link-button {
    color: var(--ink-muted);
}

.name-dialog .button {
    background: var(--ink);
    color: var(--accent);
}

.name-dialog .button:hover {
    background: var(--ink-soft);
}
