:root {
    --bg-primary: #121824;
    --bg-secondary: #1a2332;
    --bg-card: #222d40;
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --accent-red: #ef4444;
    --accent-black: #334155;
    --gold: #f59e0b;
    --gold-hover: #d97706;
    --success: #10b981;
    --info: #06b6d4;
    --wood-board: #d2a679;
    --wood-grid: #5c3a21;
    --chess-light: #f0d9b5;
    --chess-dark: #b58863;
    --border-radius: 12px;
    --box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #e2e8f0;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --wood-board: #e6c594;
    --wood-grid: #6e4726;
    --box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1500px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    gap: 16px;
}

.hidden { display: none !important; }

/* Online Users Grid */
.online-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 180px;
    overflow-y: auto;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.08);
}

.user-item-card {
    background: var(--bg-card);
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
}

.user-item-card:hover {
    transform: scale(1.03);
    background: rgba(245, 158, 11, 0.15);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.user-item-card.busy {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #64748b;
}

.user-name-tag {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.busy { background: #ef4444; }

/* ELO Badge */
.elo-badge {
    background: var(--gold);
    color: #111;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
}

/* AI Evaluation Bar */
.eval-bar-box {
    width: 100%;
    height: 12px;
    background: #334155;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.eval-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #f59e0b);
    transition: width 0.3s ease;
}

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

/* LOGIN MODAL STYLING */
.login-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.login-box {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 48px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    border: 1px solid var(--gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.login-logo { font-size: 3.5rem; }

.login-box h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gold);
}

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

.input-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.input-group input {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.15);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    outline: none;
}

.input-group input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 800;
}

.btn-quick {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.btn-quick:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}


.user-greeting {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
}

.btn-sm {
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

.matchmaking-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--gold);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(245, 158, 11, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chat-messages {
    height: 120px;
    overflow-y: auto;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-msg {
    padding: 2px 4px;
    border-radius: 4px;
}

.chat-input-box {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.chat-input-box input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* HOME LANDING SCREEN STYLING */
.home-screen {
    width: 100%;
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.landing-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 36px 48px;
    width: 100%;
    max-width: 820px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    border: 1px solid rgba(245, 158, 11, 0.3);
    display: flex;
    flex-direction: column;
    gap: 28px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.landing-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.landing-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.landing-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.selection-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.selection-section h2 {
    font-size: 1.1rem;
    color: var(--gold);
    font-weight: 700;
}

.game-cards-container, .mode-cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.game-choice-card, .mode-choice-card {
    background: var(--bg-secondary);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: var(--border-radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.game-choice-card:hover, .mode-choice-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.game-choice-card.active, .mode-choice-card.active {
    border-color: var(--gold);
    background: rgba(245, 158, 11, 0.12);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.2);
}

.game-card-icon, .mode-card-icon {
    font-size: 2.5rem;
}

.game-card-info h3, .mode-choice-card h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.game-card-info p, .mode-choice-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.3;
}

.grade-landing-selector {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    padding: 10px 16px;
}

.landing-dropdown {
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

.landing-dropdown option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-start {
    padding: 16px 24px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #111;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3);
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-start:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 28px rgba(245, 158, 11, 0.4);
}

/* GAME PLAY SCREEN STYLING */
.game-screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(255,255,255,0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-home {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--gold);
    color: var(--gold);
}

.app-icon { font-size: 2.2rem; }

.logo-area h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.grade-badge-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--gold);
}

.grade-badge-selector label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gold);
}

.grade-dropdown {
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
}

.grade-dropdown option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.icon-btn {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    transform: scale(1.1);
    background: var(--gold);
    color: #000;
}

.main-content {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 20px;
    flex: 1;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 8px;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.badge {
    background: var(--gold);
    color: #000;
    font-weight: 800;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
}

.tutorial-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    min-height: 120px;
}

.tutorial-text h3 {
    color: var(--gold);
    margin-bottom: 6px;
    font-size: 1rem;
}

.tutorial-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary { background: var(--gold); color: #111; }
.btn-primary:hover { background: var(--gold-hover); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: #f97316; color: #fff; }
.btn-info { background: var(--info); color: #fff; }

.toggle-group {
    display: flex;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn.active {
    background: var(--gold);
    color: #000;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.move-history-list {
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.move-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.move-item.red, .move-item.white { border-left: 3px solid var(--accent-red); }
.move-item.black { border-left: 3px solid var(--accent-black); }

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.player-bar {
    width: 100%;
    max-width: 520px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    font-size: 1.5rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-name { font-weight: 700; font-size: 0.95rem; }
.player-status { font-size: 0.75rem; color: var(--text-secondary); }

.timer {
    font-size: 1.2rem;
    font-weight: 800;
    font-family: monospace;
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--gold);
}

.board-wrapper {
    position: relative;
    border-radius: 12px;
    padding: 16px;
    background: #271910;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    border: 8px solid #3d2314;
}

.board-wrapper.mode-cotuong {
    width: 520px;
    height: 580px;
    background: var(--wood-board);
}

.xiangqi-board {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--wood-grid) 2px, transparent 2px),
        linear-gradient(90deg, var(--wood-grid) 2px, transparent 2px);
    background-size: 12.5% 11.111%;
    background-position: 0 0;
    border: 2px solid var(--wood-grid);
}

.xiangqi-board::before {
    content: "SÔNG SỞ HÀ      HÁN GIỚI";
    position: absolute;
    top: 44.444%;
    left: 2px;
    right: 2px;
    height: 11.111%;
    background: var(--wood-board);
    display: flex;
    align-items: center;
    justify-content: space-around;
    font-family: 'Noto Serif TC', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--wood-grid);
    letter-spacing: 4px;
    pointer-events: none;
    z-index: 1;
}

.palace-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.piece {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Serif TC', serif;
    font-size: 1.5rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.4);
    z-index: 10;
    transform: translate(-50%, -50%);
}

.piece.red {
    background: radial-gradient(circle, #fff5f5 0%, #fecaca 60%, #ef4444 100%);
    color: #b91c1c;
    border: 2px solid #991b1b;
}

.piece.black {
    background: radial-gradient(circle, #f8fafc 0%, #cbd5e1 60%, #475569 100%);
    color: #0f172a;
    border: 2px solid #1e293b;
}

.piece.selected {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 0 16px #f59e0b, 0 8px 12px rgba(0,0,0,0.5);
    z-index: 20;
}

.board-wrapper.mode-covua {
    width: 520px;
    height: 520px;
    background: #271910;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border-radius: 4px;
    overflow: hidden;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    font-size: 2.5rem;
    user-select: none;
}

.square.light { background-color: var(--chess-light); }
.square.dark { background-color: var(--chess-dark); }
.square.selected { background-color: #769656 !important; }

.square .piece-sym {
    transition: transform 0.15s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.square .piece-sym.w { color: #ffffff; text-shadow: 0 0 2px #000; }
.square .piece-sym.b { color: #111111; }

.move-target {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #10b981;
    border: 3px solid #ffffff;
    box-shadow: 0 0 12px #10b981, 0 0 20px #06b6d4;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 99;
    animation: pulse 1.2s infinite;
}

.square .move-target { transform: none; }

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.board-controls {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 520px;
}

.board-controls .btn { flex: 1; }

.game-overlay, .promotion-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 100;
}

.game-overlay.hidden, .promotion-modal.hidden { display: none; }

.overlay-box, .promotion-box {
    background: var(--bg-card);
    padding: 24px 36px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--box-shadow);
    border: 1px solid var(--gold);
}

.promotion-choices {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.promo-btn {
    padding: 10px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--gold);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
}

.promo-btn:hover { background: var(--gold); color: #000; }

.goals-list {
    list-style: none;
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goals-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--text-secondary);
}

.captured-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 30px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 6px;
}

@media (max-width: 1200px) {
    .main-content { grid-template-columns: 1fr; }
    .board-wrapper.mode-cotuong { width: 440px; height: 490px; }
    .board-wrapper.mode-covua { width: 440px; height: 440px; }
    .piece { width: 40px; height: 40px; font-size: 1.25rem; }
    .square { font-size: 2.1rem; }
    .game-cards-container, .mode-cards-container { grid-template-columns: 1fr; }
    .landing-card { padding: 24px; }
}


@media (max-width: 500px) {
    .board-wrapper.mode-cotuong { width: 320px; height: 355px; padding: 12px; }
    .board-wrapper.mode-covua { width: 320px; height: 320px; padding: 6px; }
    .piece { width: 30px; height: 30px; font-size: 0.95rem; }
    .square { font-size: 1.6rem; }
}

/* ── CSS 3D Perspective Board ──────────────────────────────────── */

.board-wrapper.mode-3d {
    perspective: 900px;
    perspective-origin: 50% 0%;
    background: radial-gradient(ellipse at 50% 0%, #2a1a0e 0%, #0d1117 80%);
    box-shadow:
        0 0 60px rgba(245,158,11,0.18),
        0 30px 60px rgba(0,0,0,0.7),
        inset 0 0 30px rgba(0,0,0,0.4);
    border-color: #5c3a1e;
}

.board3d-scene {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.board-3d-tilt {
    transform: rotateX(30deg) scale(0.92);
    transform-origin: 50% 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow:
        0 40px 80px rgba(0,0,0,0.8),
        0 20px 40px rgba(0,0,0,0.6);
}

/* Pieces lift up in 3D mode */
.board-3d-tilt .piece {
    transform: translate(-50%, -50%) translateZ(8px);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow:
        0 6px 16px rgba(0,0,0,0.5),
        0 2px 4px rgba(0,0,0,0.3),
        inset 0 2px 4px rgba(255,255,255,0.4);
}

.board-3d-tilt .piece:hover {
    transform: translate(-50%, -50%) translateZ(22px) scale(1.15);
    box-shadow:
        0 18px 36px rgba(0,0,0,0.7),
        0 6px 12px rgba(0,0,0,0.4),
        0 0 20px rgba(245,158,11,0.4);
}

.board-3d-tilt .piece.selected {
    transform: translate(-50%, -50%) translateZ(26px) scale(1.2);
    box-shadow:
        0 0 28px rgba(245,158,11,0.9),
        0 20px 40px rgba(0,0,0,0.7);
}

/* Valid move targets in 3D */
.board-3d-tilt .valid-target {
    box-shadow:
        0 0 20px rgba(34,197,94,0.8),
        0 8px 20px rgba(0,0,0,0.5),
        inset 0 2px 4px rgba(255,255,255,0.3);
    transform: translate(-50%, -50%) translateZ(4px);
    animation: pulse3d 1.2s ease-in-out infinite;
}

@keyframes pulse3d {
    0%, 100% { box-shadow: 0 0 20px rgba(34,197,94,0.8), 0 8px 20px rgba(0,0,0,0.5); }
    50% { box-shadow: 0 0 36px rgba(34,197,94,1), 0 12px 28px rgba(0,0,0,0.6); }
}

/* Chess squares lift in 3D */
.board-3d-tilt .square {
    transform: translateZ(2px);
    transition: transform 0.12s ease;
}

.board-3d-tilt .square:hover {
    transform: translateZ(10px);
    z-index: 5;
}

/* 3D toggle button active state */
.btn-3d-toggle {
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    border: 1px solid rgba(139,92,246,0.4);
}
