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

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-panel: rgba(17, 24, 39, 0.95);
    --text-primary: #f0f0f0;
    --text-secondary: #9ca3af;
    --gold: #d4a843;
    --gold-light: #f0d078;
    --gold-dark: #a07820;
    --p1-color: #dc2626;
    --p1-light: #ef4444;
    --p1-dark: #991b1b;
    --p2-color: #1e1e1e;
    --p2-light: #4a4a4a;
    --p2-dark: #000000;
    --board-light: #e8c87a;
    --board-dark: #6b3a1f;
    --board-frame: #3d1f0d;
    --accent: #3b82f6;
    --danger: #ef4444;
    --success: #22c55e;
    --glass: rgba(255, 255, 255, 0.05);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 1;
}

.screen.active {
    display: flex;
}

.overlay-screen {
    z-index: 100;
    pointer-events: auto;
}

#how-to-play,
#settings-screen {
    z-index: 110;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* MAIN MENU */
#main-menu {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1040 50%, #0a0e1a 100%);
}

.menu-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.floating-piece {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    opacity: 0.08;
    animation: floatPiece 20s infinite ease-in-out;
}

.fp1 { background: var(--p1-color); top: 10%; left: 10%; animation-delay: 0s; }
.fp2 { background: var(--p2-color); top: 20%; right: 15%; animation-delay: -3s; width: 80px; height: 80px; }
.fp3 { background: var(--p1-color); bottom: 30%; left: 20%; animation-delay: -6s; }
.fp4 { background: var(--p2-color); bottom: 15%; right: 10%; animation-delay: -9s; width: 50px; height: 50px; }
.fp5 { background: var(--gold); top: 50%; left: 5%; animation-delay: -12s; width: 40px; height: 40px; }
.fp6 { background: var(--gold); bottom: 40%; right: 5%; animation-delay: -15s; width: 70px; height: 70px; }

@keyframes floatPiece {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -20px) rotate(90deg); }
    50% { transform: translate(-20px, 30px) rotate(180deg); }
    75% { transform: translate(20px, 20px) rotate(270deg); }
}

.menu-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.game-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    letter-spacing: 0.15em;
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    margin-bottom: 0.2em;
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.game-subtitle {
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    color: var(--text-secondary);
    letter-spacing: 0.4em;
    margin-bottom: 3em;
}

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

/* BUTTONS */
.btn {
    padding: 14px 48px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    min-width: 220px;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #1a1000;
    box-shadow: 0 4px 15px rgba(212, 168, 67, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 168, 67, 0.5);
}

.btn-secondary {
    background: var(--glass);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-sm {
    padding: 10px 32px;
    font-size: 0.85rem;
    min-width: 150px;
}

.btn-back {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 32px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 20px;
    min-width: 120px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.btn-back:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-game {
    background: var(--glass);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 20px;
    font-size: 0.8rem;
    min-width: auto;
    border-radius: var(--radius-sm);
}

.btn-game:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold);
}

/* PANELS */
.panel-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.panel {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-scroll {
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
}

.panel-scroll::-webkit-scrollbar {
    width: 6px;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 3px;
}

.panel-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 800;
    margin-bottom: 0.8em;
    color: var(--gold);
    letter-spacing: 0.08em;
}

.panel-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 1.5em 0 0.8em;
    letter-spacing: 0.05em;
}

/* MODE SELECT */
.mode-cards {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-card {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 30px 24px;
    width: 200px;
    min-width: 0;
    flex: 1 1 160px;
    max-width: 240px;
    transition: var(--transition);
    cursor: pointer;
}

.mode-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(212, 168, 67, 0.15);
}

.mode-card h3 {
    font-size: 0.9rem;
    margin: 10px 0 6px;
    letter-spacing: 0.05em;
}

.mode-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.mode-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.difficulty-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 100%;
}

.difficulty-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-difficulty {
    padding: 12px 28px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: var(--transition);
    flex: 0 1 auto;
    min-width: 100px;
}

.btn-difficulty:hover {
    border-color: var(--gold);
    background: rgba(212, 168, 67, 0.12);
    color: var(--gold-light);
    box-shadow: 0 0 12px rgba(212, 168, 67, 0.15), inset 0 0 8px rgba(212, 168, 67, 0.08);
}

.btn-difficulty.selected {
    border-color: var(--gold);
    background: rgba(212, 168, 67, 0.18);
    color: var(--gold-light);
    box-shadow: 0 0 16px rgba(212, 168, 67, 0.25), inset 0 0 10px rgba(212, 168, 67, 0.1);
}

.btn-difficulty[data-diff="easy"]:hover {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.15), inset 0 0 8px rgba(34, 197, 94, 0.08);
}

.btn-difficulty[data-diff="easy"].selected {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.25), inset 0 0 10px rgba(34, 197, 94, 0.1);
}

.btn-difficulty[data-diff="hard"]:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15), inset 0 0 8px rgba(239, 68, 68, 0.08);
}

.btn-difficulty[data-diff="hard"].selected {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.25), inset 0 0 10px rgba(239, 68, 68, 0.1);
}

/* HOW TO PLAY */
.rules-content {
    padding: 0 10px;
}

.rule-section {
    margin-bottom: 20px;
}

.rule-section h3 {
    font-size: 0.95rem;
    color: var(--gold);
    margin-bottom: 6px;
    letter-spacing: 0.08em;
}

.rule-section p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.rule-section strong {
    color: var(--text-primary);
}

.control-label {
    color: var(--gold) !important;
    font-weight: 700;
    margin-top: 10px;
    margin-bottom: 4px !important;
}

/* SETTINGS */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--glass);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-row span {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.toggle-btn {
    padding: 6px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.1em;
    min-width: 60px;
}

.toggle-btn.on {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.toggle-btn.off {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

/* GAME SCREEN */
#game-screen {
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
    flex-shrink: 0;
}

.player-hud {
    min-width: 140px;
}

.hud-right {
    text-align: right;
}

.hud-center {
    text-align: center;
    flex: 1;
}

.hud-name {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.p1-color { color: var(--p1-light); }
.p2-color { color: var(--text-primary); }

.hud-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.hud-pieces {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--gold);
}

.hud-captured, .hud-kings {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.turn-indicator {
    display: inline-block;
    padding: 4px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    transition: var(--transition);
}

.turn-indicator.p1-turn {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid var(--p1-color);
    color: var(--p1-light);
}

.turn-indicator.p2-turn {
    background: rgba(100, 100, 100, 0.2);
    border: 1px solid #555;
    color: #ccc;
}

.game-status {
    font-size: 0.8rem;
    color: var(--gold);
    margin-top: 4px;
}

/* BOARD */
.board-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    min-height: 0;
}

.board-frame {
    background: linear-gradient(145deg, #5a3015 0%, #3d1f0d 50%, #2a1508 100%);
    border-radius: 12px;
    padding: 8px;
    box-shadow:
        0 0 0 2px rgba(212, 168, 67, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    touch-action: none;
}

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

.cell.light {
    background: linear-gradient(135deg, #e8c87a 0%, #d4b56a 100%);
}

.cell.dark {
    background: linear-gradient(135deg, #6b3a1f 0%, #5a2e18 100%);
}

.cell.dark:hover {
    background: linear-gradient(135deg, #7a4425 0%, #6b3a1f 100%);
}

.cell.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    animation: pulseDot 1.2s ease-in-out infinite;
    z-index: 5;
    pointer-events: none;
}

.cell.legal-capture::after {
    content: '';
    position: absolute;
    width: 55%;
    height: 55%;
    border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.7);
    background: rgba(239, 68, 68, 0.15);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    animation: pulseCapture 1s ease-in-out infinite;
    z-index: 5;
    pointer-events: none;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

@keyframes pulseCapture {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}

/* PIECES */
.piece {
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.piece.p1 {
    background: radial-gradient(circle at 35% 35%, #ff6b6b, var(--p1-color) 50%, var(--p1-dark) 100%);
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.piece.p2 {
    background: radial-gradient(circle at 35% 35%, #666, var(--p2-color) 50%, var(--p2-dark) 100%);
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.15),
        inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.piece.selected {
    transform: scale(1.15);
    box-shadow:
        0 0 0 3px var(--gold),
        0 0 20px rgba(212, 168, 67, 0.5),
        0 3px 8px rgba(0, 0, 0, 0.4);
    z-index: 20;
}

.piece.has-capture {
    box-shadow:
        0 0 0 2px rgba(239, 68, 68, 0.6),
        0 0 12px rgba(239, 68, 68, 0.3),
        0 3px 8px rgba(0, 0, 0, 0.4);
}

.piece.king::after {
    content: '♛';
    font-size: 1.4em;
    color: var(--gold-light);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    filter: drop-shadow(0 0 3px rgba(212, 168, 67, 0.5));
}

.piece.king {
    box-shadow:
        0 0 0 2px var(--gold),
        0 0 12px rgba(212, 168, 67, 0.3),
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.piece.captured {
    animation: captureAnim 0.4s ease-out forwards;
}

@keyframes captureAnim {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.piece.promoting {
    animation: promoteAnim 0.6s ease-out;
}

@keyframes promoteAnim {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* BOTTOM BAR */
.game-bottom-bar {
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    z-index: 10;
}

.multi-jump-banner {
    text-align: center;
    padding: 8px;
    margin-bottom: 8px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--p1-light);
    letter-spacing: 0.05em;
    animation: bannerPulse 2s ease-in-out infinite;
}

@keyframes bannerPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* AI THINKING */
.ai-thinking-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: all;
}

.ai-thinking-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--gold);
}

.thinking-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(212, 168, 67, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* VICTORY */
.victory-panel {
    max-width: 500px;
}

.victory-icon {
    font-size: 4rem;
    margin-bottom: 10px;
    animation: victoryBounce 1s ease-out;
}

@keyframes victoryBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.victory-title {
    font-size: clamp(1.3rem, 4vw, 2rem) !important;
    margin-bottom: 0.5em !important;
}

.victory-stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.draw-message {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* CONFETTI */
.confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 200;
}

/* SHAKE */
.screen-shake {
    animation: shake 0.3s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-3px, 2px); }
    40% { transform: translate(3px, -2px); }
    60% { transform: translate(-2px, -1px); }
    80% { transform: translate(2px, 1px); }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .game-hud {
        padding: 6px 12px;
    }

    .hud-name {
        font-size: 0.8rem;
    }

    .hud-stats {
        font-size: 0.75rem;
    }

    .hud-pieces {
        font-size: 0.95rem;
    }

    .hud-captured, .hud-kings {
        font-size: 0.65rem;
    }

    .turn-indicator {
        font-size: 0.75rem;
        padding: 3px 14px;
    }

    .board-wrapper {
        padding: 6px;
    }

    .board-frame {
        padding: 5px;
    }

    .piece.king::after {
        font-size: 1.1em;
    }

    .game-bottom-bar {
        padding: 6px 12px;
    }

    .btn-game {
        padding: 6px 14px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .player-hud {
        min-width: 80px;
    }

    .hud-name {
        font-size: 0.7rem;
    }

    .hud-captured, .hud-kings {
        display: none;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .game-subtitle {
        font-size: 0.7rem;
        margin-bottom: 2em;
    }

    .btn {
        min-width: 180px;
        padding: 12px 36px;
        font-size: 0.85rem;
    }

    .panel {
        padding: 24px;
    }

    .mode-cards {
        flex-direction: column;
        align-items: center;
    }

    .mode-card {
        width: 100%;
        max-width: 250px;
    }

    .difficulty-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-difficulty {
        width: 180px;
    }
}

@media (max-height: 500px) {
    .game-hud {
        padding: 4px 12px;
    }

    .hud-name {
        font-size: 0.7rem;
    }

    .board-wrapper {
        padding: 4px;
    }

    .board-frame {
        padding: 4px;
    }
}

/* MOBILE / TOUCH RESPONSIVENESS */
html {
    min-height: 100%;
    height: 100%;
    overflow: hidden;
}
body {
    min-height: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}
.screen {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}
.panel-overlay {
    padding: max(16px, env(safe-area-inset-top))
             max(16px, env(safe-area-inset-right))
             max(16px, env(safe-area-inset-bottom))
             max(16px, env(safe-area-inset-left));
}
.panel {
    width: min(600px, 100%);
    max-width: 100%;
}
.panel-scroll {
    max-height: min(85vh, 85dvh);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.board-wrapper {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.board-frame {
    max-width: 100%;
    max-height: 100%;
}
.board {
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
}
.game-hud, .game-bottom-bar {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
}
.game-bottom-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.bottom-controls { flex-wrap: wrap; }
.btn, .btn-game, .btn-back, .btn-difficulty, .toggle-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
@media (max-width: 600px) {
    .menu-content { width: min(92vw, 360px); padding: 16px; }
    .game-title { font-size: clamp(2.4rem, 15vw, 4rem); letter-spacing: .1em; }
    .game-subtitle { font-size: .65rem; letter-spacing: .25em; margin-bottom: 2em; }
    .btn { width: 100%; min-width: 0; padding: 13px 20px; }
    .panel { width: 100%; padding: 24px 18px; border-radius: 14px; }
    .panel-title { font-size: clamp(1.25rem, 7vw, 1.8rem); }
    .mode-cards { flex-direction: column; gap: 12px; margin: 14px 0; }
    .mode-card { width: 100%; max-width: none; padding: 18px 16px; }
    .mode-card .btn { width: auto; min-width: 140px; }
    .difficulty-buttons { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
    .btn-difficulty { width: 100%; min-width: 0; padding: 11px 6px; font-size: .75rem; }
    .settings-list { gap: 8px; margin: 14px 0; }
    .setting-row { gap: 12px; padding: 11px 12px; }
    .setting-row span { font-size: .76rem; text-align: left; }
    .toggle-btn { flex: 0 0 58px; min-width: 58px; padding: 7px 10px; }
    .rules-content { padding: 0 2px; }
    .rule-section { margin-bottom: 14px; }
    .rule-section h3 { font-size: .82rem; }
    .rule-section p { font-size: .8rem; line-height: 1.45; }
    .btn-back { width: 100%; min-width: 0; margin-top: 14px; }
    .game-hud { display: grid; grid-template-columns: minmax(70px,1fr) auto minmax(70px,1fr); gap: 6px; padding-top: 6px; padding-bottom: 6px; }
    .player-hud { min-width: 0; }
    .hud-center { min-width: 0; }
    .hud-name { font-size: .68rem; white-space: nowrap; }
    .hud-stats { font-size: .68rem; }
    .hud-pieces { font-size: .88rem; }
    .hud-captured, .hud-kings { display: none; }
    .turn-indicator { max-width: 42vw; padding: 4px 7px; font-size: .62rem; letter-spacing: .03em; white-space: nowrap; }
    .game-status { font-size: .68rem; }
    .board-wrapper { padding: 4px; }
    .board-frame { padding: 4px; border-radius: 9px; }
    .game-bottom-bar { padding-top: 6px; }
    .multi-jump-banner { font-size: .68rem; padding: 6px 8px; margin-bottom: 6px; }
    .bottom-controls { gap: 8px; }
    .btn-game { flex: 1 1 0; min-width: 0; padding: 8px; font-size: .65rem; }
    .ai-thinking-content { max-width: calc(100vw - 32px); padding: 13px 16px; font-size: .75rem; }
}
@media (max-width: 380px) {
    .panel { padding: 20px 14px; }
    .game-title { font-size: 2.3rem; }
    .hud-name { font-size: .62rem; }
    .turn-indicator { font-size: .55rem; padding: 4px 5px; }
    .btn-game { font-size: .58rem; padding-left: 5px; padding-right: 5px; }
}
@media (orientation: landscape) and (max-height: 600px) {
    .game-hud { padding-top: 4px; padding-bottom: 4px; }
    .board-wrapper { padding: 2px 4px; }
    .game-bottom-bar { padding-top: 4px; }
    .multi-jump-banner { padding: 4px 8px; margin-bottom: 4px; }
    .btn-game { padding-top: 5px; padding-bottom: 5px; }
    .panel { padding: 16px; }
    .panel-scroll { max-height: 90vh; max-height: 90dvh; }
}
