* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: #f5f7fb;
    color: #16202a;
    font-family: Arial, Helvetica, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

button {
    border: 0;
    cursor: pointer;
    font: inherit;
    touch-action: manipulation;
}

button:disabled {
    cursor: default;
    opacity: 0.45;
}

.game-shell {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

h1 {
    margin: 0 0 6px;
    font-size: 2rem;
}

p {
    margin: 0;
}

.scorebox {
    min-width: 96px;
    padding: 10px 14px;
    border: 1px solid #d9e0ea;
    border-radius: 8px;
    background: #fff;
    text-align: center;
}

.scorebox span,
.history span {
    display: block;
    color: #667085;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.scorebox strong {
    display: block;
    font-size: 1.35rem;
    letter-spacing: 0.08em;
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.panel-form,
.lobby-panel {
    padding: 16px;
    border: 1px solid #d9e0ea;
    border-radius: 8px;
    background: #fff;
}

.panel-form h2,
.lobby-panel h2 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}

.panel-form label {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
    color: #344054;
    font-weight: 700;
}

.panel-form input {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #c7d0dd;
    border-radius: 8px;
    font: inherit;
}

.lobby-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    margin-bottom: 24px;
}

.lobby-actions {
    display: flex;
    align-items: start;
    gap: 8px;
}

.secondary-button {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 8px;
    background: #eef2f6;
    color: #16202a;
    font-weight: 700;
}

.players {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
}

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f5f7fb;
}

.player-row strong {
    font-size: 1.1rem;
}

.word-panel {
    min-height: 130px;
    display: grid;
    place-items: center;
    margin-bottom: 24px;
}

.word-boxes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.word-box {
    width: clamp(34px, 8vw, 56px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-bottom: 4px solid #1f6feb;
    background: #fff;
    border-radius: 6px 6px 2px 2px;
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 700;
}

.word-box.revealed {
    border-color: #17803d;
}

.answer {
    margin-top: 14px;
    color: #17803d;
    font-weight: 700;
}

.controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.primary-button,
.solve-form button {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 8px;
    background: #1f6feb;
    color: #fff;
    font-weight: 700;
}

.solve-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.solve-form input {
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #c7d0dd;
    border-radius: 8px;
    font: inherit;
    text-transform: uppercase;
}

.letters {
    display: grid;
    grid-template-columns: repeat(13, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 22px;
}

.letter-tile {
    aspect-ratio: 1;
    border-radius: 8px;
    background: #fff;
    color: #16202a;
    box-shadow: inset 0 0 0 1px #d9e0ea;
    font-weight: 800;
}

.letter-tile:not(:disabled):hover {
    background: #eaf2ff;
}

.history {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.history > div {
    min-height: 72px;
    padding: 12px;
    border: 1px solid #d9e0ea;
    border-radius: 8px;
    background: #fff;
}

.history strong {
    display: block;
    margin-top: 8px;
    overflow-wrap: anywhere;
}

@media (max-width: 620px) {
    .game-shell {
        padding: 16px;
    }

    .topbar,
    .setup-grid,
    .lobby-panel,
    .controls,
    .history {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .letters {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
}

[hidden] { display: none !important; }
.site-nav { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.site-nav > a { font-weight: bold; font-size: 1.3rem; }
.site-nav > button { margin-left: auto; }
#navbarResponsive { width: 100%; display: flex; justify-content: flex-end; align-items: center; gap: 24px; flex-wrap: wrap; }
a { color: inherit; }
.account-page { max-width: 850px; }
.account-page .panel-form { max-width: 550px; }
.panel-form select { padding: 12px; font: inherit; }
.checkbox-label { display: flex !important; align-items: center; gap: 10px; }
.checkbox-label input { width: auto; }
.user-list { display: grid; gap: 10px; overflow-wrap: anywhere; }
#game-settings { font-size: 1.4rem; }
#game-options { margin: 10px 0; }
