/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --color-bg: #f5f3f0;
    --color-white: #ffffff;
    --color-light-gray: #e8e6e3;
    --color-medium-gray: #c4c1bc;
    --color-dark-gray: #6b6966;
    --color-text: #2c2a27;
    --color-accent: #b58863;
    --color-accent-dark: #8b6642;
    --color-board-light: #ebecd0;
    --color-board-dark: #b68860;
    --color-highlight: rgba(255, 255, 0, 0.4);
    --color-move-hint: rgba(0, 0, 0, 0.1);
    --color-eval-white: #f5f5f5;
    --color-eval-black: #1a1a1a;
    --color-success: #4caf50;
    --color-danger: #e53935;
    --color-info: #2196f3;
    
    --font-display: 'Crimson Text', Georgia, serif;
    --font-body: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
    --color-bg: #1a1a1a;
    --color-white: #2d2d2d;
    --color-light-gray: #3d3d3d;
    --color-medium-gray: #555555;
    --color-dark-gray: #aaaaaa;
    --color-text: #e8e8e8;
    --color-accent: #d4a574;
    --color-accent-dark: #b58863;
    --color-board-light: #d4d5b9;
    --color-board-dark: #9a7350;
    --color-highlight: rgba(255, 255, 0, 0.3);
    --color-move-hint: rgba(255, 255, 255, 0.15);
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

/* ===== SVG Icon Styles ===== */
.icon-svg {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    fill: currentColor;
}

.icon-svg.icon-sm {
    width: 0.875em;
    height: 0.875em;
}

.icon-svg.icon-lg {
    width: 1.25em;
    height: 1.25em;
}

.icon-svg.icon-xl {
    width: 1.5em;
    height: 1.5em;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-light-gray);
    padding: 0.75rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
    flex-wrap: nowrap;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    width: 42px;
    height: 42px;
    border: 2px solid var(--color-light-gray);
    border-radius: 50%;
    background: var(--color-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dark-mode-toggle:hover {
    border-color: var(--color-accent);
    transform: scale(1.05);
}

.dark-mode-toggle .icon-moon {
    display: none;
}

.dark-mode-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .dark-mode-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .dark-mode-toggle .icon-sun {
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 2rem;
    color: var(--color-accent);
}

.logo h1,
.logo .logo-text {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-text);
    white-space: nowrap;
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-tab {
    padding: 0.6rem 1.25rem;
    text-decoration: none;
    color: var(--color-text);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    /* Button reset for button elements */
    border: 2px solid var(--color-medium-gray);
    background: var(--color-white);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.nav-tab:hover {
    background: var(--color-light-gray);
    color: var(--color-text);
    border-color: var(--color-accent);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 2px solid var(--color-light-gray);
    border-radius: var(--radius-md);
    background: var(--color-white);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    z-index: 101;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-tab.active {
    background: var(--color-accent);
    color: var(--color-white);
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    /* Hidden by default with smooth transition */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.nav-dropdown:hover .nav-dropdown-menu {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.nav-dropdown-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: 0.7rem 1rem;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s ease;
}

.nav-dropdown-menu .dropdown-item:hover {
    background: var(--color-bg);
}

.nav-dropdown-menu .dropdown-item + .dropdown-item {
    border-top: 1px solid var(--color-border);
}

/* ===== Main Container ===== */
.main-container {
    flex: 1;
    display: grid;
    grid-template-columns: 32px auto 320px;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    align-items: start;
    justify-content: center;
}

/* When in play mode, use 2-column layout with larger board */
.main-container.play-mode {
    grid-template-columns: auto 320px;
    justify-content: center;
}

.main-container.play-mode .board-wrapper {
    width: min(850px, calc(100vh - 140px));
}

.main-container.play-mode .eval-bar-container {
    display: none;
}

/* Hide eval bar when toggled off */
.eval-bar-container.hidden {
    display: none !important;
}

/* Adjust grid when eval bar is hidden - desktop only */
@media (min-width: 993px) {
    .main-container:has(.eval-bar-container.hidden) {
        grid-template-columns: auto 320px;
        justify-content: center;
    }
}

/* ===== Evaluation Bar ===== */
.eval-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
}

.eval-bar {
    width: 28px;
    /* Match board height exactly */
    height: min(800px, calc(100vh - 160px));
    background: linear-gradient(to bottom, var(--color-eval-black) 50%, var(--color-eval-white) 50%);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md), inset 0 0 10px rgba(0,0,0,0.1);
    border: 2px solid var(--color-medium-gray);
}

.eval-bar-white,
.eval-bar-black {
    position: absolute;
    width: 100%;
    transition: height 0.5s ease;
}

.eval-bar-white {
    bottom: 0;
    background: var(--color-eval-white);
    height: 50%;
}

.eval-bar-black {
    top: 0;
    background: var(--color-eval-black);
    height: 50%;
}

.eval-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-accent);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    white-space: nowrap;
}

/* Labels inside the eval bar with inverted colors */
.eval-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.eval-label.white {
    bottom: 6px;
    color: var(--color-eval-black); /* Dark text on white background */
}

.eval-label.black {
    top: 6px;
    color: var(--color-eval-white); /* White text on black background */
}

/* ===== Board Section ===== */
.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

/* Promotion Bar */
.promotion-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.promotion-bar.hidden {
    display: none;
}

.promotion-label {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.promotion-piece {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    background: var(--color-white);
    border: 2px solid transparent;
}

.promotion-piece:hover {
    transform: scale(1.15);
    border-color: var(--color-success);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.promotion-piece img {
    width: 42px;
    height: 42px;
    pointer-events: none;
}

.promotion-cancel {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    margin-left: 0.5rem;
    transition: all 0.2s;
}

.promotion-cancel:hover {
    background: var(--color-danger);
    transform: scale(1.1);
}

/* Chess Board Wrapper */
.board-wrapper {
    position: relative;
    width: min(800px, calc(100vh - 160px));
    padding: 4px;
}

/* Chess Board */
#chessBoard {
    width: 100%;
    box-shadow: var(--shadow-lg);
    border-radius: 0 !important; /* Boards should not inherit --radius-md */
    touch-action: none; /* Prevent page scroll on mobile when dragging pieces */
    -webkit-touch-callout: none; /* Prevent iOS callout on long press */
    -webkit-user-select: none;
    user-select: none;
}

/* Board color system (default, grayscale, green tint) */
:root {
    --board-light-square: #ebecd0;
    --board-dark-square: #b68860;
    --board-light-piece: #b68860;
    --board-dark-piece: #ebecd0;
}

[data-theme="dark"] {
    --board-light-square: #d4d5b9;
    --board-dark-square: #9a7350;
    --board-light-piece: #9a7350;
    --board-dark-piece: #d4d5b9;
}

[data-board-theme="grayscale"] {
    --board-light-square: #dddddd;
    --board-dark-square: #8f8f8f;
    --board-light-piece: #8f8f8f;
    --board-dark-piece: #dddddd;
}

[data-theme="dark"][data-board-theme="grayscale"] {
    --board-light-square: #c2c2c2;
    --board-dark-square: #6f6f6f;
    --board-light-piece: #6f6f6f;
    --board-dark-piece: #c2c2c2;
}

[data-board-theme="green"] {
    --board-light-square: #d9e9d1;
    --board-dark-square: #6f9262;
    --board-light-piece: #6f9262;
    --board-dark-piece: #d9e9d1;
}

[data-theme="dark"][data-board-theme="green"] {
    --board-light-square: #c7dcc0;
    --board-dark-square: #56774b;
    --board-light-piece: #56774b;
    --board-dark-piece: #c7dcc0;
}

[data-board-theme="blue"] {
    --board-light-square: #d1e0e9;
    --board-dark-square: #5a7a8f;
    --board-light-piece: #5a7a8f;
    --board-dark-piece: #d1e0e9;
}

[data-theme="dark"][data-board-theme="blue"] {
    --board-light-square: #b8d0de;
    --board-dark-square: #4a6578;
    --board-light-piece: #4a6578;
    --board-dark-piece: #b8d0de;
}

.white-1e1d7 {
    background-color: var(--board-light-square) !important;
    color: var(--board-light-piece);
}

.black-3c85d {
    background-color: var(--board-dark-square) !important;
    color: var(--board-dark-piece);
}

/* Prevent long-press save image on chess pieces */
#chessBoard img,
.board-b72b1 img,
.piece-417db {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none; /* Let parent handle touch events */
}

/* But allow the piece container to receive events */
.piece-417db {
    pointer-events: auto;
}

/* Spare piece trays must receive pointer events for drag-to-add in analysis */
#chessBoard [class*="spare-pieces"] img,
#chessBoard [class*="spare-pieces"] .piece-417db {
    pointer-events: auto !important;
    cursor: grab;
}

/* Spare piece rows: hidden by default, toggled open via button */
#chessBoard [class*="spare-pieces"] {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
}

/* Show spare pieces when toggled open */
.spare-pieces-visible #chessBoard [class*="spare-pieces"] {
    display: flex;
}

/* Hide spare pieces when replaying a loaded game (overrides toggle) */
.analysis-game-loaded #chessBoard [class*="spare-pieces"] {
    display: none !important;
}

/* Toggle button for spare pieces */
.spare-toggle-btn {
    display: none; /* hidden by default; shown in analysis via JS */
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--color-border, rgba(148,163,184,0.5));
    background: var(--color-white, #fff);
    color: var(--color-dark-gray, #4b5563);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: background 0.15s, transform 0.15s, color 0.15s;
    position: absolute;
    bottom: -34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
}
.spare-toggle-btn:hover {
    background: var(--color-light-gray, #f3f4f6);
}
.spare-toggle-btn.active {
    background: var(--color-accent, #4c6ef5);
    color: #fff;
    border-color: var(--color-accent, #4c6ef5);
}
[data-theme="dark"] .spare-toggle-btn {
    background: var(--color-white, #0f172a);
    border-color: rgba(51,65,85,0.7);
    color: #e5e7eb;
}
[data-theme="dark"] .spare-toggle-btn:hover {
    background: #1e293b;
}
[data-theme="dark"] .spare-toggle-btn.active {
    background: var(--color-accent, #4c6ef5);
    color: #fff;
    border-color: var(--color-accent, #4c6ef5);
}

/* Make room for the toggle button below the board */
.board-wrapper {
    margin-bottom: 36px;
}

/* Arrow Canvas */
.board-wrapper #arrowCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    background: transparent;
    display: none;
}

.board-wrapper #arrowCanvas.visible {
    display: block;
}

/* FEN Display */
.fen-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 480px;
}

.fen-display label {
    font-weight: 600;
    color: var(--color-dark-gray);
    font-size: 0.85rem;
}

.fen-display input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.8rem;
    background: var(--color-bg);
}

.fen-display button {
    padding: 0.4rem 0.6rem;
    border: none;
    background: var(--color-light-gray);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Player Info Display */
.player-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: min(800px, calc(100vh - 160px));
}

.player-info.hidden {
    display: none;
}

.player-info.player-top {
    margin-bottom: 0.5rem;
}

.player-info.player-bottom {
    margin-top: 0.5rem;
}

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-light-gray);
    flex-shrink: 0;
}

.player-avatar[src=""],
.player-avatar:not([src]) {
    display: none;
}

.player-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-name .rating {
    font-weight: 400;
    color: var(--color-dark-gray);
    font-size: 0.85rem;
}

.player-name .result {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
}

.player-name .result.win {
    background: #e8f5e9;
    color: #2e7d32;
}

.player-name .result.loss {
    background: #ffebee;
    color: #c62828;
}

.player-name .result.draw {
    background: #fff3e0;
    color: #e65100;
}

[data-theme="dark"] .player-info {
    background: var(--color-panel-bg);
}

[data-theme="dark"] .player-name .result.win {
    background: #1b5e20;
    color: #a5d6a7;
}

[data-theme="dark"] .player-name .result.loss {
    background: #5d1a1a;
    color: #ef9a9a;
}

[data-theme="dark"] .player-name .result.draw {
    background: #4a3000;
    color: #ffcc80;
}

/* ===== Control Panel ===== */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-left: 1rem;
}

.panel-section {
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.panel-section h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--color-accent-dark);
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Page Hero Section */
.page-hero {
    text-align: center;
    padding: 1.5rem 1rem 0.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.page-hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

.page-hero .hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: var(--color-dark-gray);
    margin: 0;
}

[data-theme="dark"] .page-hero h1 {
    color: #f0f0f0;
}

[data-theme="dark"] .page-hero .hero-subtitle {
    color: #aaa;
}

@media (max-width: 768px) {
    .page-hero {
        padding: 1rem 1rem 0.25rem;
    }
    
    .page-hero h1 {
        font-size: 1.3rem;
    }
    
    .page-hero .hero-subtitle {
        font-size: 0.85rem;
    }
}

.panel-section h3,
.panel-section .panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--color-dark-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-section p {
    font-size: 0.9rem;
    color: var(--color-dark-gray);
    line-height: 1.5;
}

/* Social Buttons */
.social-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
}

.social-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-btn.facebook { background: #1877f2; color: white; }
.social-btn.twitter { background: #000; color: white; }
.social-btn.reddit { background: #ff4500; color: white; }
.social-btn.email { background: var(--color-dark-gray); color: white; }

.social-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Game Controls */
.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.control-btn.share-success {
    background: var(--color-success);
    color: #fff;
}

[data-theme="dark"] .control-btn.share-success {
    background: #1b5e20;
    color: #e9f5e9;
}

.control-btn .icon {
    font-size: 1.1rem;
}

.control-btn.auto-analyze {
    background: var(--color-dark-gray);
    color: white;
}

.control-btn.auto-analyze.active {
    background: var(--color-success);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }
    50% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.8); }
}

.control-btn.back {
    background: var(--color-light-gray);
    color: var(--color-text);
}

.control-btn.back:hover {
    background: var(--color-medium-gray);
}

/* Smaller undo button in game controls */
.game-controls .control-btn.back {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.control-btn.move {
    background: var(--color-success);
    color: white;
    font-size: 1rem;
    padding: 1rem;
}

.control-btn.move:hover {
    background: #43a047;
}

.control-btn.move.calculating {
    background: var(--color-info);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Import Section */
.import-section {
    margin-top: 1rem;
    border-top: 1px solid var(--color-light-gray);
    padding-top: 1rem;
}

.import-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.import-tab {
    flex: 1;
    min-width: fit-content;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--color-light-gray);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text);
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-tab:hover {
    background: var(--color-light-gray);
}

.import-tab.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.import-content {
    display: none;
}

.import-content.active {
    display: block;
}

.import-content textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.8rem;
    resize: vertical;
    background: var(--color-bg);
    color: var(--color-text);
}

.import-content input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.month-select {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.month-select select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--color-bg);
    color: var(--color-text);
}

.import-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    transition: all 0.2s;
}

.import-btn:hover {
    background: var(--color-accent-dark);
}

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

.games-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.75rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

.games-list.hidden {
    display: none;
}

.game-item {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-light-gray);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.game-item:last-child {
    border-bottom: none;
}

.game-item:hover {
    background: var(--color-light-gray);
}

.game-item .game-players {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.game-item .game-result {
    color: var(--color-dark-gray);
    font-size: 0.75rem;
}

.game-item .game-date {
    color: var(--color-dark-gray);
    font-size: 0.7rem;
}

/* Move Navigation */
.move-navigation {
    margin-top: 0.5rem;
    border-top: none;
    padding-top: 0;
}

.move-navigation.hidden {
    display: none;
}

.nav-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.nav-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0;
    border-bottom: none;
}

.move-list {
    max-height: 150px;
    overflow-y: auto;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-light-gray);
    margin-top: 5px;
}

.nav-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--color-light-gray);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--color-light-gray);
}

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

/* Share game link UI */
.share-game-output {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-dark-gray);
    word-break: break-all;
}

[data-theme="dark"] .share-game-btn {
    background: #1a1a1a;
    border-color: #3d3d3d;
    color: #e0e0e0;
}

[data-theme="dark"] .share-game-btn:hover {
    background: #2a2a2a;
}

[data-theme="dark"] .share-game-output {
    color: #e0e0e0;
}

[data-theme="dark"] .import-tab {
    border-color: #3d3d3d;
}

[data-theme="dark"] .import-content textarea,
[data-theme="dark"] .import-content input[type="text"],
[data-theme="dark"] .month-select select,
[data-theme="dark"] .games-list,
[data-theme="dark"] .move-list,
[data-theme="dark"] .nav-btn {
    background: #1a1a1a;
    border-color: #3d3d3d;
    color: #e0e0e0;
}

[data-theme="dark"] .game-item {
    border-color: #3d3d3d;
    background: #252525;
}

[data-theme="dark"] .game-item:hover {
    background: #3d3d3d;
}

/* When a full game is loaded in analysis, hide hero + lower content but keep footer */
body.analysis-game-loaded .home-hero,
body.analysis-game-loaded section.seo-content {
    display: none !important;
}

[data-theme="dark"] .game-item .game-players {
    color: #fff;
}

[data-theme="dark"] .game-item .game-result {
    color: #aaa;
}

[data-theme="dark"] .game-item .game-date {
    color: #888;
}

[data-theme="dark"] .nav-btn:hover {
    background: #2d2d2d;
}

/* Engine Output */
.engine-output {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-family: monospace;
    font-size: 0.8rem;
    max-height: 100px;
    overflow-y: auto;
}

.output-line {
    margin-bottom: 0.25rem;
    color: var(--color-dark-gray);
}

.output-line.best-move {
    color: var(--color-success);
    font-weight: 700;
}

.output-line.eval {
    color: var(--color-info);
}

/* Move History for AI Mode */
.move-history-ai {
    display: none;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.5rem;
}

.game-controls.game-active .move-history-ai {
    display: block;
}

.game-controls.game-active .engine-output {
    display: none;
}

.move-history-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.move-history-list {
    max-height: 180px;
    overflow-y: auto;
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* Move rows */
.move-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--color-border);
}

.move-row:last-child {
    border-bottom: none;
}

.move-num {
    font-family: var(--font-body);
    color: var(--color-dark-gray);
    min-width: 1.5rem;
    font-weight: 600;
}

.move-white, .move-black {
    font-family: var(--font-body);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: default;
    transition: all 0.2s ease;
}

.move-white {
    background: #f5f5f5;
    color: #333;
}

.move-black {
    background: #333;
    color: #fff;
}


/* Clickable moves after game ends */
.move-history-ai.game-ended .move-white,
.move-history-ai.game-ended .move-black {
    cursor: pointer;
}

.move-history-ai.game-ended .move-white:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.move-history-ai.game-ended .move-black:hover {
    background: #444;
    transform: scale(1.05);
}

.move-white.active-move,
.move-black.active-move {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

[data-theme="dark"] .move-history-ai {
    background: #1a1a1a;
}

[data-theme="dark"] .move-white {
    background: #e0e0e0;
    color: #222;
}

[data-theme="dark"] .move-row {
    border-color: #333;
}

/* Turn Selector */
.turn-buttons {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.turn-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--color-light-gray);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1 1 50%;
    transition: all 0.2s;
    background: var(--color-white);
}

.turn-btn .piece-icon {
    font-size: 1.2rem;
}

.turn-btn.white {
    color: var(--color-text);
}

.turn-btn.white.active {
    background: var(--color-board-light);
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(181, 136, 99, 0.3);
    color: #2c2a27; /* Always dark text on light background */
}

.turn-btn.black {
    color: var(--color-text);
}

.turn-btn.black.active {
    background: var(--color-dark-gray);
    border-color: var(--color-text);
    color: white;
    box-shadow: 0 0 0 3px rgba(44, 42, 39, 0.3);
}

.turn-btn:hover:not(.active) {
    border-color: var(--color-accent);
    background: var(--color-light-gray);
}

/* Utility Footer */
.utility-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.utility-buttons {
    display: flex;
    gap: 0.5rem;
}

.utility-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.5rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-dark-gray);
    transition: all 0.2s;
}

.utility-btn:hover {
    background: var(--color-light-gray);
    border-color: var(--color-accent);
    color: var(--color-text);
}

.utility-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.utility-btn.active:hover {
    background: var(--color-accent-dark);
}

/* Depth Control */
.depth-control {
    text-align: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-light-gray);
}

.depth-control label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-dark-gray);
    margin-bottom: 0.5rem;
}

.depth-control #depthValue {
    color: var(--color-accent);
    font-weight: 700;
}

.depth-control input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-light-gray);
    outline: none;
    -webkit-appearance: none;
}

.depth-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* Arrow Canvas - old rule removed, now in .board-wrapper */

/* ===== Footer ===== */
/* Ensure main content pushes footer to bottom */
main {
    flex: 1;
}

.footer {
    background: var(--color-white);
    border-top: 1px solid var(--color-light-gray);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.85rem;
    margin-top: auto;
    color: var(--color-dark-gray);
}

.footer a,
.footer a:visited {
    color: var(--color-accent);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Chessboard.js Overrides ===== */
.board-b72b1 {
    border-radius: 0 !important; /* Boards should not inherit --radius-md */
    touch-action: none; /* Prevent scroll on mobile touch */
}

/* Ensure pieces are draggable on mobile without triggering scroll */
.board-b72b1 .piece-417db {
    touch-action: none;
    cursor: grab;
    transition: transform 0.05s ease-out;
}

.board-b72b1 .piece-417db:active {
    cursor: grabbing;
}

/* Smooth piece movement */
.board-b72b1 .square-55d63 img {
    transition: none;
}

.square-55d63 {
    transition: background-color 0.15s ease;
    border-radius: 0 !important; /* Squares should not inherit --radius-md */
}

/* Ensure all chessboard elements don't inherit --radius-md */
#board,
#chessboard,
#chessBoard,
#puzzleBoard,
.board-b72b1,
.square-55d63 {
    border-radius: 0 !important;
}

.highlight-white {
    background-color: rgba(255, 255, 0, 0.5) !important;
}

.highlight-black {
    background-color: rgba(255, 255, 0, 0.5) !important;
}

/* Highlight colors – match AI (game-pages): hint/capture no bg on light, only dot/ring */
.highlight-hint[class*="black-"] {
    background-color: #9a7040 !important;
}

.highlight-hint {
    position: relative;
}

.highlight-hint::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32%;
    height: 32%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    pointer-events: none;
}

.highlight-legal::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

/* Best move highlight (analyzer only) */
.highlight-move-from {
    background-color: rgba(0, 180, 0, 0.5) !important;
}

.highlight-move-to {
    background-color: rgba(0, 220, 0, 0.5) !important;
}

/* Last move highlight - green strokes */
.highlight-last-from[class*="white-"],
.highlight-last-to[class*="white-"] {
    box-shadow: inset 0 0 0 6px rgba(76, 175, 80, 0.75) !important;
}

.highlight-last-from[class*="black-"],
.highlight-last-to[class*="black-"] {
    box-shadow: inset 0 0 0 6px rgba(76, 175, 80, 0.75) !important;
}

.highlight-last-to .piece-417db {
    filter: drop-shadow(0 0 6px rgba(76, 175, 80, 0.8)) drop-shadow(0 0 10px rgba(76, 175, 80, 0.5));
    transition: filter 0.3s ease;
}

[data-theme="dark"] .highlight-last-from[class*="white-"],
[data-theme="dark"] .highlight-last-to[class*="white-"] {
    box-shadow: inset 0 0 0 6px rgba(76, 175, 80, 0.8) !important;
}

[data-theme="dark"] .highlight-last-from[class*="black-"],
[data-theme="dark"] .highlight-last-to[class*="black-"] {
    box-shadow: inset 0 0 0 6px rgba(76, 175, 80, 0.8) !important;
}

[data-theme="dark"] .highlight-last-to .piece-417db {
    filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.9)) drop-shadow(0 0 12px rgba(76, 175, 80, 0.6));
}

/* Selected square – match AI: #d4c9a0 light, #9a7040 black */
.highlight-selected[class*="white-"] {
    background-color: #d4c9a0 !important;
}

.highlight-selected[class*="black-"] {
    background-color: #9a7040 !important;
}

/* Capture hint – match AI: no bg on light, #9a7040 on black, ring only */
.highlight-capture[class*="black-"] {
    background-color: #9a7040 !important;
}

.highlight-capture {
    position: relative;
}

.highlight-capture::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: transparent;
    border: 5px solid rgba(0, 0, 0, 0.2);
    pointer-events: none;
    box-sizing: border-box;
}

/* Check highlight on king */
.highlight-check {
    background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0.8) 0%, rgba(200, 0, 0, 0.4) 40%, transparent 70%) !important;
}

/* Touch feedback glow effect */
.touch-glow {
    animation: touchPulse 0.2s ease-out;
}

@keyframes touchPulse {
    0% {
        box-shadow: inset 0 0 0 0 rgba(100, 180, 255, 0.8);
    }
    50% {
        box-shadow: inset 0 0 15px 5px rgba(100, 180, 255, 0.6);
    }
    100% {
        box-shadow: inset 0 0 0 0 rgba(100, 180, 255, 0);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 28px auto 280px;
        gap: 1.5rem;
        padding: 1.5rem;
        justify-content: center;
    }
    
    .main-container.play-mode {
        grid-template-columns: auto 280px;
        gap: 1.5rem;
        justify-content: center;
    }
    
    .board-wrapper {
        width: min(700px, calc(100vh - 160px));
    }
    
    .eval-bar {
        height: min(700px, calc(100vh - 160px));
    }
    
    .main-container.play-mode .board-wrapper {
        width: min(750px, calc(100vh - 140px));
    }
}

/* Tablet - iPad landscape and similar */
@media (max-width: 1024px) {
    .logo .logo-text {
        font-size: 1.4rem;
    }
    
    .logo-icon {
        font-size: 1.6rem;
    }
    
    .nav-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .header-container {
        gap: 0.5rem;
    }
}

@media (max-width: 992px) {
    .main-container {
        grid-template-columns: 1fr;
        max-width: min(calc(100vw - 1.5rem), calc(100vh - 280px));
        margin: 0 auto;
    }
    
    .main-container.play-mode {
        grid-template-columns: 1fr;
        max-width: min(calc(100vw - 1.5rem), calc(100vh - 280px));
        margin: 0 auto;
    }
    
    .eval-bar-container {
        flex-direction: row;
        justify-content: center;
        order: 1;
    }
    
    .eval-bar {
        width: 300px;
        height: 32px;
        background: linear-gradient(to right, var(--color-eval-black) 50%, var(--color-eval-white) 50%);
    }
    
    .eval-bar-white {
        right: 0;
        top: 0;
        height: 100%;
        width: 50%;
    }
    
    .eval-bar-black {
        left: 0;
        top: 0;
        height: 100%;
        width: 50%;
    }
    
    /* Labels horizontal positioning for mobile */
    .eval-label {
        top: 50%;
        transform: translateY(-50%);
    }
    
    .eval-label.black {
        left: 8px;
        top: 50%;
        bottom: auto;
    }
    
    .eval-label.white {
        right: 8px;
        left: auto;
        bottom: auto;
        top: 50%;
    }
    
    .board-section {
        order: 2;
        width: 100%;
    }
    
    .control-panel {
        order: 3;
        margin-left: 0;
        width: 100%;
    }
    
    .board-wrapper {
        width: 100%;
        max-width: 100%;
    }
    
    #chessBoard {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .header {
        padding: 0.5rem 1rem;
    }
    
    .header-container {
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .dark-mode-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .main-container {
        padding: 1rem;
    }
    
    .piece-bank {
        flex-wrap: wrap;
    }
    
    .piece-item {
        width: 38px;
        height: 38px;
    }
    
    .piece-item img {
        width: 32px;
        height: 32px;
    }
}

/* ===== Loading States ===== */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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


/* ===== Analysis Controls ===== */
/* Generic hidden class */
.hidden {
    display: none !important;
}

.analysis-controls.hidden,
.panel-section.analysis-controls.hidden {
    display: none !important;
}

/* ===== Game Controls ===== */
/* Matches analysis-controls styling - uses default .panel-section styles */

/* Ensure all game control buttons work on mobile */
.game-controls button,
.game-controls select {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.game-controls.hidden,
.panel-section.game-controls.hidden {
    display: none !important;
}

/* Elements to hide in play mode */
.turn-selector.hidden,
.depth-control.hidden,
.fen-display.hidden,
.utility-footer.hidden,
.panel-section.hidden {
    display: none !important;
}

.game-controls h3,
.game-controls .panel-title {
    color: var(--color-dark-gray);
    margin-bottom: 0.75rem;
}

/* Game controls layout with flexbox for reordering */
.game-controls {
    display: flex;
    flex-direction: column;
}

.game-settings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    order: 1;
}

.game-controls .game-status {
    order: 2;
}

.game-controls .control-btn.start-game {
    order: 3;
}

.game-controls .captured-pieces-ai {
    order: 4;
}

.game-controls .engine-output {
    order: 5;
}

/* When game is in progress, move settings to bottom */
.game-controls.game-active .game-settings {
    order: 10;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-light-gray);
}

.game-controls.game-active .game-status {
    order: 1;
}

.game-controls.game-active .control-btn.start-game {
    order: 2;
}

.game-controls.game-active .captured-pieces-ai {
    order: 3;
}

.game-controls.game-active .engine-output {
    order: 4;
}

.control-btn.start-game {
    width: 100%;
    background: var(--color-success);
    color: white;
    font-size: 1rem;
    padding: 0.85rem;
    margin-bottom: 0.5rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.control-btn.start-game:hover {
    background: #43a047;
}

.control-btn.start-game.stop-game {
    background: #d32f2f;
}

.control-btn.start-game.stop-game:hover {
    background: #b71c1c;
}

/* Disabled states for game controls */
.color-btn.disabled,
.color-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Play vs AI button highlighting */
.play-vs-ai-btn {
    background: linear-gradient(135deg, var(--color-success) 0%, #2e7d32 100%) !important;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.play-vs-ai-btn:hover {
    background: linear-gradient(135deg, #43a047 0%, #1b5e20 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

/* Captured pieces display for AI mode */
.captured-pieces-ai {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-light-gray);
}

.captured-section {
    margin-bottom: 0.5rem;
}

.captured-section:last-child {
    margin-bottom: 0;
}

.captured-pieces-ai .captured-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-dark-gray);
    margin-bottom: 0.25rem;
    display: block;
}

.captured-pieces-ai .captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    min-height: 1.5rem;
    font-size: 1.25rem;
    line-height: 1;
}

.captured-pieces-ai .captured-list .captured-piece {
    width: 24px;
    height: 24px;
    opacity: 0.9;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}

.captured-pieces-ai .captured-list .captured-piece:hover {
    transform: scale(1.2);
    opacity: 1;
}

/* Recently captured piece pulsing animation */
.captured-pieces-ai .captured-list .captured-piece.recent-capture {
    animation: capturedPulse 1.5s ease-in-out infinite;
}

@keyframes capturedPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1.1);
    }
    50% {
        opacity: 0.4;
        transform: scale(1);
    }
}

[data-theme="dark"] .captured-pieces-ai {
    background: #1a1a1a;
    border-color: #3d3d3d;
}

[data-theme="dark"] .captured-pieces-ai .captured-list .captured-piece {
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5)) drop-shadow(0 0 1px rgba(255,255,255,0.8));
}

.difficulty-select select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-light-gray);
}

.play-color-select,
.difficulty-select {
    margin-bottom: 0.75rem;
}

.play-color-select label,
.difficulty-select label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-dark-gray);
    margin-bottom: 0.5rem;
}

.color-buttons {
    display: flex;
    gap: 0.5rem;
}

.color-btn {
    flex: 1;
    padding: 0.6rem;
    border: 2px solid var(--color-light-gray);
    background: var(--color-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.color-btn.white.active {
    background: #f5f5f5;
    border-color: var(--color-text);
    box-shadow: inset 0 0 0 2px var(--color-accent);
    color: #2c2a27; /* Always dark text on light background */
}

.color-btn.black.active {
    background: var(--color-text);
    border-color: var(--color-text);
    color: white;
}

.color-btn:hover:not(.active) {
    border-color: var(--color-accent);
}

.difficulty-select select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--color-white);
    color: var(--color-text);
    cursor: pointer;
}

/* Dark mode styles for play controls */
[data-theme="dark"] .color-btn {
    background: #3d3d3d;
    border-color: #555;
    color: #e8e8e8;
}

[data-theme="dark"] .color-btn.white.active {
    background: #f5f5f5;
    color: #2c2a27;
}

[data-theme="dark"] .color-btn.black.active {
    background: #2c2a27;
    color: #fff;
    border-color: #555;
}

[data-theme="dark"] .difficulty-select select {
    background: #3d3d3d;
    color: #e8e8e8;
    border-color: #555;
}

[data-theme="dark"] .difficulty-select label,
[data-theme="dark"] .play-color-select label {
    color: #e8e8e8;
}

.control-btn.new-game {
    width: 100%;
    background: var(--color-info);
    color: white;
    margin-top: 0.5rem;
}

.control-btn.new-game:hover {
    background: #1976d2;
}

/* Hide analysis-only buttons in play mode */
.play-mode .analysis-only {
    display: none;
}

/* Game Status Messages */
.game-status {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
    margin-bottom: 0.75rem;
    background: #f5f5f5;
    color: var(--color-dark-gray);
}

.game-status.thinking {
    background: #fff3e0;
    color: #e65100;
    animation: pulse 1.5s infinite;
}

/* Animated thinking dots */
.thinking-dots::after {
    content: '';
    animation: thinkingDots 1.5s infinite;
}

@keyframes thinkingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.game-status.your-turn {
    background: #e8f5e9;
    color: #2e7d32;
}

.game-status.game-over {
    background: #fce4ec;
    color: #c2185b;
}

.game-status.win {
    background: #c8e6c9;
    color: #1b5e20;
}

.game-status.lose {
    background: #ffcdd2;
    color: #b71c1c;
}

/* ===== Logo Accent ===== */
.logo a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.logo-accent {
    color: var(--color-accent);
}

/* ===== Mobile Menu Button ===== */
/* Hamburger menu hidden - only 2 buttons, always visible */
.mobile-menu-btn {
    display: none !important;
}

/* ===== Google Ads Containers ===== */
.ad-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-light-gray);
}

.ad-container ins {
    max-width: 100%;
}

.ad-top {
    border-bottom: 1px solid var(--color-medium-gray);
}

.ad-bottom {
    border-top: 1px solid var(--color-medium-gray);
    margin-top: 2rem;
}

/* ===== SEO Content Sections ===== */
.seo-content {
    background: var(--color-white);
    padding: 3rem 1.5rem;
    border-top: 1px solid var(--color-light-gray);
}

.seo-container {
    max-width: 1200px;
    margin: 0 auto;
}

.seo-content h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--color-text);
    text-align: center;
    margin-bottom: 2rem;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .seo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.seo-card {
    background: var(--color-bg);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.seo-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.seo-card h3 {
    font-size: 1.1rem;
    color: var(--color-accent-dark);
    margin-bottom: 0.75rem;
}

.seo-card p {
    font-size: 0.95rem;
    color: var(--color-dark-gray);
    line-height: 1.6;
}

.seo-about {
    background: var(--color-bg);
}

.seo-about p {
    max-width: 800px;
    margin: 0 auto 1rem;
    text-align: center;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-dark-gray);
}

/* ===== Enhanced Footer ===== */
[data-theme="dark"] .footer {
    /* Same layout as light mode, just dark colors */
    background: #0b0f17;
    color: #e8e8e8;
    border-top-color: #1f2937;
}


/* ===== Enhanced Mobile Responsiveness ===== */
@media (max-width: 768px) {
    /* Reorder header: logo first, hamburger, then tools (gear) on right */
    .header-container {
        gap: 0.5rem;
        position: relative;
    }
    
    .logo {
        order: 1;
        flex: 1;
    }
    
    .mobile-menu-toggle {
        display: flex;
        order: 2;
    }
    
    .header-tools {
        order: 3;
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Nav tabs hidden by default, shown when .open */
    .nav-tabs {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-white);
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.25rem;
        border-bottom: 1px solid var(--color-light-gray);
        box-shadow: var(--shadow-md);
        display: none;
        z-index: 100;
    }
    
    .nav-tabs.open {
        display: flex;
    }
    
    .nav-tab {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    .ad-container {
        min-height: 60px;
        padding: 0.25rem;
    }
    
    .seo-content {
        padding: 2rem 1rem;
    }
    
    .seo-content h2 {
        font-size: 1.5rem;
    }
    
    .seo-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .logo h1,
    .logo .logo-text {
        font-size: 1.2rem;
    }
    
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .main-container {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .panel-section {
        padding: 0.75rem;
    }
    
    .control-btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .turn-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .footer {
        padding: 1.5rem 1rem;
    }
    
    .footer-links {
        gap: 1rem;
    }
}

/* ===== Touch-friendly improvements ===== */
@media (hover: none) and (pointer: coarse) {
    .control-btn,
    .turn-btn,
    .utility-btn,
    .promotion-piece {
        min-height: 48px;
    }
    
    .nav-tab {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Ensure all buttons work on mobile touch */
.control-btn,
.turn-btn,
.utility-btn,
.nav-tab,
.color-btn,
.promotion-piece,
.promotion-cancel,
.social-btn,
button,
select {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

/* ===== Print Styles ===== */
@media print {
    .ad-container,
    .header,
    .control-panel,
    .seo-content,
    .footer {
        display: none;
    }
    
    .main-container {
        display: block;
    }
    
    .board-section {
        margin: 0 auto;
    }
}

