:root {
    --bg: #0b1117;
    --bg-soft: #111a21;
    --panel: rgba(14, 22, 31, 0.92);
    --line: rgba(170, 196, 213, 0.2);
    --text: #f4efe3;
    --muted: #a5b6bf;
    --gold: #d8aa63;
    --mint: #8fd6b6;
    --danger: #f06f5a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Bricolage Grotesque", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(240, 111, 90, 0.17), transparent 35%),
        radial-gradient(circle at 85% 8%, rgba(143, 214, 182, 0.14), transparent 28%),
        linear-gradient(180deg, #091017 0%, #0b1117 45%, #111b24 100%);
}

.page-shell {
    width: min(1200px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 28px;
}

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

.brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(145deg, var(--gold), #8a6333);
    color: #111;
}

.layout {
    display: grid;
    grid-template-columns: minmax(300px, 400px) minmax(320px, 1fr);
    gap: 16px;
}

.card {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    box-shadow: 0 22px 64px rgba(0, 0, 0, 0.35);
}

.auth-panel {
    padding: 20px;
}

.auth-panel h1,
.board-head h2 {
    margin: 0;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(2rem, 4.2vw, 2.8rem);
}

.muted {
    color: var(--muted);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.tab {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    cursor: pointer;
}

.tab.active {
    background: rgba(216, 170, 99, 0.18);
    border-color: rgba(216, 170, 99, 0.4);
}

.form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
}

input,
select {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    padding: 0 12px;
    font: inherit;
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid rgba(143, 214, 182, 0.45);
    outline-offset: 2px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 16px 0;
}

.quickplay {
    display: grid;
    gap: 10px;
}

.quickplay-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.btn {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 0 14px;
    font-weight: 700;
    font: inherit;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, var(--gold), #f4d193);
    color: #101010;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line);
    color: var(--text);
}

.btn.ghost {
    background: rgba(240, 111, 90, 0.08);
    border-color: rgba(240, 111, 90, 0.35);
    color: #ffd8d1;
}

.pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--muted);
    font-size: 0.86rem;
}

.status {
    margin: 12px 0 0;
    color: var(--mint);
    min-height: 1.25rem;
}

.board-panel {
    padding: 18px;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
}

.board-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
}

.board {
    width: min(74vh, 100%);
    max-width: 640px;
    aspect-ratio: 1;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
}

.square {
    display: grid;
    place-items: center;
    font-size: clamp(1.4rem, 4vw, 2.7rem);
    user-select: none;
    cursor: pointer;
}

.square.light {
    background: #d9c29e;
    color: #2a1d13;
}

.square.dark {
    background: #7a5f46;
    color: #fff7ed;
}

.square.selected {
    box-shadow: inset 0 0 0 4px rgba(136, 199, 255, 0.7);
}

.square.target::after {
    content: "";
    width: 36%;
    aspect-ratio: 1;
    border-radius: 999px;
    background: rgba(143, 214, 182, 0.45);
    position: absolute;
}

.board-foot {
    display: grid;
    gap: 8px;
}

.turn {
    margin: 0;
}

.moves {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    max-height: 160px;
    overflow: auto;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .board {
        width: 100%;
    }
}
