/* AggroChess — SHIFT design system */
:root {
    --bg-color: #050505;
    --surface-color: #121212;
    --surface-2: #181818;
    --border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --danger: #ef4444;

    --sq-light: #d8dde7;
    --sq-dark: #5f6e8b;
    --sq-last: rgba(59, 130, 246, 0.42);
    --sq-select: rgba(59, 130, 246, 0.65);

    --font-main: 'Inter', sans-serif;
    --font-heading: 'Space Grotesk', sans-serif;
    --container-width: 1200px;
    --transition-fast: 0.3s ease;
    --transition-smooth: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
    font-size: 16px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.12), transparent 70%);
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
}

h1,
h2,
h3 {
    font-family: var(--font-heading);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 700;
}

p {
    color: var(--text-secondary);
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.text-gradient {
    background: linear-gradient(to right, #fff, #999);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.85rem 1.5rem;
    background: var(--text-primary);
    color: var(--bg-color);
    font-weight: 600;
    border: 1px solid var(--text-primary);
    border-radius: 4px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--text-primary);
    color: var(--bg-color);
}

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

.btn-full {
    width: 100%;
    margin-top: 1rem;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    width: 100%;
    padding: 1.25rem 0;
    z-index: 100;
    background: rgba(5, 5, 5, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.05em;
    color: #fff;
    font-family: var(--font-heading);
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.logo-sub {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-secondary);
    padding-left: 0.6rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.nav-link:hover {
    opacity: 1;
}

/* Layout */
.play {
    flex: 1;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 2.5rem;
    align-items: start;
    padding-top: 2.5rem;
    padding-bottom: 3rem;
}

.board-area {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
    min-width: 0;
}

.player-tag {
    min-height: 2.3rem;
    width: min(100%, 640px);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-secondary);
}

.player-tag.to-move {
    color: var(--text-primary);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    flex: none;
}

.dot.white {
    background: #fff;
}

.dot.black {
    background: #111;
}

.to-move .dot {
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Board */
.board-wrap {
    position: relative;
    width: min(100%, 640px);
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(59, 130, 246, 0.08);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sq.light {
    background: var(--sq-light);
}

.sq.dark {
    background: var(--sq-dark);
}

.sq.last::before,
.sq.selected::before,
.sq.check::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sq.last::before {
    background: var(--sq-last);
}

.sq.selected::before {
    background: var(--sq-select);
}

.sq.check::before {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.95) 0%, rgba(239, 68, 68, 0.55) 40%, transparent 75%);
}

.sq.target::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(5, 5, 5, 0.28);
    pointer-events: none;
}

.sq.target.occupied::after {
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 50%;
    box-shadow: inset 0 0 0 5px rgba(5, 5, 5, 0.3);
}

.piece {
    position: relative;
    width: 92%;
    height: 92%;
    z-index: 1;
    pointer-events: none;
    -webkit-user-drag: none;
}

.sq.mine {
    cursor: grab;
}

.piece.dragging-origin {
    opacity: 0.3;
}

.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}

.coord {
    position: absolute;
    font-size: clamp(0.55rem, 1.6vw, 0.75rem);
    font-weight: 700;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

.coord.rank {
    top: 4%;
    left: 5%;
}

.coord.file {
    bottom: 4%;
    right: 6%;
}

.sq.light .coord {
    color: var(--sq-dark);
}

.sq.dark .coord {
    color: var(--sq-light);
}

/* Overlays */
.overlay,
.loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 5, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    transition: opacity var(--transition-fast);
}

.hidden {
    display: none !important;
}

.promo-card,
.result-card {
    background: var(--surface-color);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    max-width: 85%;
}

.promo-card p {
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.promo-choices {
    display: flex;
    gap: 0.5rem;
}

.promo-choices button {
    width: clamp(48px, 11vw, 72px);
    height: clamp(48px, 11vw, 72px);
    background: var(--sq-light);
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.promo-choices button:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.promo-choices img {
    width: 100%;
    height: 100%;
}

.result-card h2 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    margin-bottom: 0.5rem;
}

.result-card p {
    margin-bottom: 1.25rem;
}

.loading {
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Panel */
.panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.panel-head h1 {
    font-size: clamp(2.4rem, 5vw, 3.4rem);
    font-weight: 800;
    margin-bottom: 0.6rem;
}

.tagline {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.card {
    background: var(--surface-color);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.2rem;
}

.card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
}

.seg {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.55rem 0;
    border-radius: 4px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.seg:hover {
    color: var(--text-primary);
}

.seg.active {
    background: var(--surface-2);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.6);
}

.status {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status .pulse {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 0 0 var(--accent-glow);
    animation: pulse 1.2s ease-out infinite;
    flex: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 var(--accent-glow);
    }

    100% {
        box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
    }
}

.engine-line {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.moves-card {
    display: flex;
    flex-direction: column;
}

.moves {
    list-style: none;
    max-height: 230px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 2.6rem 1fr 1fr;
    row-gap: 2px;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.moves:empty::before {
    content: 'No moves yet.';
    grid-column: 1 / -1;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.moves .num {
    color: #666;
}

.moves .mv {
    padding: 0 0.4rem;
    border-radius: 3px;
}

.moves .mv[data-ply] {
    cursor: pointer;
    transition: background 0.15s ease;
}

.moves .mv[data-ply]:hover {
    background: rgba(255, 255, 255, 0.06);
}

.moves .mv.current {
    background: rgba(59, 130, 246, 0.22);
    color: #fff;
}

.moves .sac {
    color: var(--accent-color);
    font-weight: 600;
}

.actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}

.actions .btn {
    padding: 0.7rem 0;
    font-size: 0.9rem;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translate(-50%, 24px);
    opacity: 0;
    visibility: hidden;
    background: var(--surface-color);
    border: 1px solid rgba(59, 130, 246, 0.6);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.8rem 1.4rem;
    border-radius: 999px;
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.35);
    transition: transform var(--transition-smooth), opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}

/* Footer */
.site-footer {
    padding: 2rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.credit {
    color: #666;
}

/* Responsive */
@media (max-width: 960px) {
    .play {
        grid-template-columns: 1fr;
        gap: 1.75rem;
        padding-top: 1.25rem;
    }

    .panel {
        width: min(100%, 640px);
        margin: 0 auto;
    }

    /* on small screens: what you need while playing comes first */
    .tabs { order: 1; }
    .tab-panel { order: 2; }
    .panel-head { order: 3; margin-top: 1rem; }
    .status-card { order: 1; }
    .actions { order: 2; }
    .moves-card { order: 3; }
    .setup-card { order: 4; }
}

@media (max-width: 600px) {
    .navbar {
        padding: 1rem 0;
    }

    .nav-links {
        gap: 1.25rem;
    }

    .logo {
        font-size: 1.3rem;
    }

    .logo-sub {
        font-size: 0.85rem;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ------------------------------------------------------------------
   v2 additions: tabs, navigation, new game intro, review, history
   ------------------------------------------------------------------ */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: #fff;
    opacity: 0.85;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}

.icon-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.06);
}

.link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-btn:hover {
    color: #fff;
}

.tag-acc {
    margin-left: auto;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--accent-color);
}

/* move navigation under the board */
.nav-row {
    width: min(100%, 640px);
    display: grid;
    grid-template-columns: 44px 44px 1fr 44px 44px;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.2rem;
}

.nav-btn {
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-color);
    color: #fff;
    font-size: 0.85rem;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.nav-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: rgba(59, 130, 246, 0.6);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.nav-pos {
    text-align: center;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* tabs */
.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.6rem 0;
    margin-bottom: -1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab:hover {
    color: #fff;
}

.tab.active {
    color: #fff;
    border-bottom-color: var(--accent-color);
}

.tab-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* new game: banner + pieces dealt onto the board */
.newgame-banner {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.1rem 0;
    background: linear-gradient(90deg, transparent, rgba(5, 5, 5, 0.88) 18%, rgba(5, 5, 5, 0.88) 82%, transparent);
    border-top: 1px solid rgba(59, 130, 246, 0.6);
    border-bottom: 1px solid rgba(59, 130, 246, 0.6);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.newgame-banner.show {
    animation: banner 1.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ng-kicker {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--accent-color);
}

.ng-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    letter-spacing: -0.02em;
}

@keyframes banner {
    0% { opacity: 0; visibility: visible; transform: translateY(-50%) scaleY(0.2); }
    15% { opacity: 1; transform: translateY(-50%) scaleY(1); }
    75% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; transform: translateY(-50%) scaleY(1); }
}

.board-wrap.dealing {
    animation: boardGlow 1.1s ease-out;
}

.board-wrap.dealing .piece {
    animation: deal 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--row) * 45ms);
}

.sq {
    --row: 0;
}

@keyframes deal {
    from { opacity: 0; transform: translateY(-30%) scale(0.7); }
    to { opacity: 1; transform: none; }
}

@keyframes boardGlow {
    0% { box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(59, 130, 246, 0.8); }
    100% { box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px 0 rgba(59, 130, 246, 0.08); }
}

/* classification badge on the board */
.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 3;
    min-width: 34%;
    height: 34%;
    padding: 0 3px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: clamp(0.55rem, 1.6vw, 0.8rem);
    line-height: 1;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 3px;
    margin-right: 0.35rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    vertical-align: middle;
    line-height: 1;
}

/* result overlay */
.result-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.result-actions .btn {
    padding: 0.7rem 1.2rem;
}

/* review */
.review-hint {
    font-size: 0.95rem;
}

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--bg-color);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent-color);
    box-shadow: 0 0 12px var(--accent-glow);
    transition: width 0.25s ease;
}

.progress-text {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

#review-done {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.summary-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 0.5rem;
}

.sp-name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    margin-bottom: 0.3rem;
}

.sp-acc {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2rem;
    line-height: 1.1;
}

.sp-elo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--accent-color);
    margin-top: 0.4rem;
}

.sp-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.eval-graph {
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.eval-graph svg {
    display: block;
    width: 100%;
    height: 100%;
}

.class-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.class-table th {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    padding-bottom: 0.3rem;
}

.class-table td {
    padding: 0.2rem 0;
    text-align: center;
}

.class-table td:first-child {
    text-align: left;
    color: var(--text-secondary);
}

.move-detail {
    font-size: 0.92rem;
    min-height: 2.8rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.det-eval {
    margin-left: 0.4rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.det-best {
    color: #81b64c;
    font-size: 0.88rem;
}

.review-moves {
    max-height: 300px;
}

.fineprint {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
}

/* history */
.history-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.history {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 520px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.6rem;
}

.h-result {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
}

.h-result.win { background: rgba(129, 182, 76, 0.2); color: #81b64c; }
.h-result.loss { background: rgba(250, 65, 45, 0.18); color: #fa412d; }
.h-result.draw { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

.h-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.h-title {
    font-weight: 600;
    font-size: 0.88rem;
}

.h-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.h-actions {
    display: flex;
    gap: 0.3rem;
    flex: none;
}

.h-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: #fff;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.5rem;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.h-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(59, 130, 246, 0.6);
}

.h-del:hover {
    border-color: var(--danger);
    color: var(--danger);
}

@media (max-width: 600px) {
    .hide-sm {
        display: none;
    }

    .actions .btn {
        font-size: 0.82rem;
    }
}

.result-actions .btn {
    min-width: 9.5rem;
}

/* ------------------------------------------------------------------
   v3 additions: arrows, clocks, time controls, live game state
   ------------------------------------------------------------------ */
.arrows {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.badge {
    z-index: 4;
}

.board-hint {
    width: min(100%, 640px);
    text-align: center;
    font-size: 0.75rem;
    color: #5d5d5d;
}

@media (hover: none), (pointer: coarse) {
    .board-hint {
        display: none;
    }
}

.clock {
    margin-left: 0.6rem;
    min-width: 5.6rem;
    text-align: right;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    background: var(--surface-color);
    border: 1px solid var(--border);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
}

.clock.running {
    background: #e8e8e8;
    color: #050505;
    border-color: #e8e8e8;
}

.clock.low.running {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.clock.low:not(.running) {
    color: var(--danger);
}

.tc-label {
    margin-top: 1rem;
}

.tc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.tc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.5rem 0 0.45rem;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.tc strong {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    line-height: 1.2;
    color: inherit;
}

.tc span {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.tc:hover {
    color: var(--text-primary);
}

.tc.active {
    background: var(--surface-2);
    color: var(--text-primary);
    border-color: rgba(59, 130, 246, 0.8);
}

.live-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: liveDot 1.6s ease-out infinite;
}

@keyframes liveDot {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    100% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@media (max-width: 960px) {
    .panel[data-state="setup"] .setup-card {
        order: 0;
    }
}

@media (max-width: 600px) {
    .clock {
        font-size: 1.05rem;
        min-width: 4.8rem;
    }
}

/* captured pieces + material balance next to each player */
.captured {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    overflow: hidden;
    flex: 0 1 auto;
}

.cap-group {
    display: inline-flex;
    flex: none;
}

.cap-group img {
    width: 22px;
    height: 22px;
}

/* black pieces need a light edge to show up on the dark background */
.cap-group img[src$="/bP.svg"],
.cap-group img[src$="/bN.svg"],
.cap-group img[src$="/bB.svg"],
.cap-group img[src$="/bR.svg"],
.cap-group img[src$="/bQ.svg"] {
    filter: drop-shadow(0 0 0.7px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 0.7px rgba(255, 255, 255, 0.95));
}

.cap-group img + img {
    margin-left: -12px;
}

.cap-score {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: none;
}

@media (max-width: 600px) {
    .cap-group img {
        width: 18px;
        height: 18px;
    }

    .cap-group img + img {
        margin-left: -10px;
    }

    .captured {
        gap: 0.2rem;
    }
}

#name-top,
#name-bottom {
    flex: none;
    white-space: nowrap;
}

/* queued premove */
.sq.premove::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(239, 68, 68, 0.45);
    pointer-events: none;
}

.premove-tag {
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}

/* ------------------------------------------------------------------
   Community: Discord, socials, contact
   ------------------------------------------------------------------ */
.nav-discord {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: #5865f2;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.nav-discord:hover {
    background: #4752c4;
    transform: translateY(-1px);
}

.community-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    color: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.community-card:hover {
    border-color: rgba(88, 101, 242, 0.7);
    background: #15161f;
}

.community-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #5865f2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.community-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.community-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
}

.community-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.community-arrow {
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.community-card:hover .community-arrow {
    transform: translateX(3px);
    color: #fff;
}

.footer-inner {
    align-items: center;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.footer-mail {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.footer-mail:hover {
    color: #fff;
}

.footer-socials {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.social-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.social-icon:hover {
    color: #fff;
    border-color: rgba(59, 130, 246, 0.7);
    background: rgba(255, 255, 255, 0.04);
}

.footer-credits {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.25rem;
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: #5d5d5d;
}

.footer-credits a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 960px) {
    .community-card {
        order: 5;
    }
}

@media (max-width: 600px) {
    .nav-discord {
        padding: 0.5rem;
    }

    .footer-left,
    .footer-socials,
    .footer-credits {
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .footer-mail {
        font-size: 0.8rem;
    }
}
