:root {
    --chess-bg: #0f172a;
    --chess-card: #111827;
    --chess-card-soft: #1f2937;
    --chess-text: #f8fafc;
    --chess-muted: #94a3b8;
    --chess-border: rgba(255,255,255,.08);
    --chess-accent: #facc15;
    --chess-accent-dark: #d97706;
}

body {
    background:
        radial-gradient(circle at top left, rgba(250, 204, 21, .14), transparent 32rem),
        radial-gradient(circle at bottom right, rgba(59, 130, 246, .12), transparent 28rem),
        var(--chess-bg);
    color: var(--chess-text);
    min-height: 100vh;
}

.card {
    background: rgba(17, 24, 39, .92);
    border: 1px solid var(--chess-border) !important;
    color: var(--chess-text);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.28) !important;
}

.form-label {
    color: var(--chess-text);
    font-weight: 600;
}

.form-control {
    background: rgba(15, 23, 42, .75);
    border: 1px solid var(--chess-border);
    color: var(--chess-text);
    border-radius: 12px;
    min-height: 44px;
}

.form-control:focus {
    background: rgba(15, 23, 42, .95);
    color: var(--chess-text);
    border-color: var(--chess-accent);
    box-shadow: 0 0 0 .2rem rgba(250, 204, 21, .18);
}

.form-control:-webkit-autofill {
    -webkit-text-fill-color: var(--chess-text);
    transition: background-color 9999s ease-in-out 0s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--chess-accent), var(--chess-accent-dark));
    border: none;
    color: #111827;
    font-weight: 700;
    border-radius: 12px;
    min-height: 44px;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #fde047, #f59e0b);
    color: #111827;
}

a {
    color: var(--chess-accent);
}

a:hover {
    color: #fde047;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.auth-card-title {
    font-weight: 800;
    letter-spacing: -.04em;
}

.auth-subtitle {
    color: var(--chess-muted);
    font-size: .95rem;
}

.chess-brand {
    text-align: center;
    margin-bottom: 20px;
}

.chess-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--chess-accent), var(--chess-accent-dark));
    color: #111827;
    font-size: 30px;
    font-weight: 900;
    box-shadow: 0 18px 40px rgba(250, 204, 21, .18);
}

.chess-brand-name {
    font-weight: 800;
    font-size: 1.15rem;
}

/* Dashboard */

.app-page {
    min-height: 100vh;
    padding-top: 24px;
}

.text-secondary {
    color: var(--chess-muted) !important;
}

.btn-outline-light {
    border-color: var(--chess-border);
    color: var(--chess-text);
}

.btn-outline-light:hover {
    background: rgba(255,255,255,.08);
    border-color: var(--chess-accent);
    color: var(--chess-accent);
}

.dashboard-card {
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    border-color: rgba(250, 204, 21, .35) !important;
    box-shadow: 0 28px 90px rgba(0,0,0,.35) !important;
}

.dashboard-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    background: rgba(250, 204, 21, .12);
    border: 1px solid rgba(250, 204, 21, .18);
    font-size: 24px;
}

/* Chess Board */

.chess-board-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
    overflow-x: hidden;
}

.chess-board {
    width: min(100%, 640px);
    max-width: 640px;
    aspect-ratio: 1 / 1;
    height: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 10px solid rgba(255,255,255,.08);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 100px rgba(0,0,0,.4);
}

.chess-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1 / 1;
    font-size: clamp(22px, 7vw, 58px);
    user-select: none;
    overflow: hidden;
}

.chess-square.light {
    background: #f0d9b5;
}

.chess-square.dark {
    background: #b58863;
}

.piece {
    line-height: 1;
    text-shadow: 0 4px 12px rgba(0,0,0,.22);
}

.piece-image {
    width: 78%;
    height: 78%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.square-rank,
.square-file {
    position: absolute;
    font-size: 12px;
    font-weight: 800;
    opacity: .75;
}

.square-rank {
    top: 6px;
    left: 8px;
}

.square-file {
    right: 8px;
    bottom: 5px;
}

.chess-square.light .square-rank,
.chess-square.light .square-file {
    color: #7c4f2c;
}

.chess-square.dark .square-rank,
.chess-square.dark .square-file {
    color: #f7ead8;
}

.chess-square.selected-square {
    outline: 4px solid rgba(250, 204, 21, .95);
    outline-offset: -4px;
}

.chess-square.invalid-square {
    outline: 4px solid rgba(239, 68, 68, .95);
    outline-offset: -4px;
}

/* Legal moves  */
.chess-square.legal-move::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(34,197,94,.85);
    position: absolute;
}

.chess-square.legal-capture::after {
    content: '';
    width: 70%;
    height: 70%;
    border-radius: 50%;
    border: 4px solid rgba(239, 68, 68, .9);
    position: absolute;
}

.king-in-check {
    outline: 4px solid #ef4444;
    outline-offset: -6px;
}

.king-in-check {
    outline: 4px solid #ef4444;
    outline-offset: -6px;
}

@media (max-width: 576px) {
    .app-page .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .piece-image {
        width: 75%;
        height: 75%;
    }

    .chess-board {
        width: calc(100vw - 24px);
        max-width: 100%;
        border-width: 6px;
    }

    .chess-square {
        font-size: clamp(20px, 7.5vw, 36px);
    }

    .square-rank,
    .square-file {
        font-size: 10px;
    }

    .square-rank {
        top: 3px;
        left: 5px;
    }

    .square-file {
        right: 5px;
        bottom: 3px;
    }
}
