/* ============================================================
   Lava Chess — Dark Volcanic Theme, Mobile-First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

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

:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --text: #e0e0e0;
    --text-muted: #8888aa;
    --lava: #ff4500;
    --lava-glow: #ff6a00;
    --lava-dark: #cc3700;
    --white-sq: #b8c6db;
    --black-sq: #4a6fa5;
    --selected: rgba(255, 215, 0, 0.5);
    --legal-move: rgba(0, 255, 100, 0.35);
    --last-move: rgba(255, 255, 0, 0.15);
    --danger: #ff4444;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 420px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Header */
header {
    text-align: center;
    width: 100%;
}
header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}
#status-bar {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 4px 12px;
    background: var(--bg-card);
    border-radius: 20px;
    display: inline-block;
}

/* Board */
#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(calc(100vw - 24px), 400px);
    height: min(calc(100vw - 24px), 400px);
    border: 3px solid #333;
    border-radius: 4px;
    overflow: hidden;
    touch-action: manipulation;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(8vw, 38px);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.square.white { background: var(--white-sq); }
.square.black { background: var(--black-sq); }

.square.selected {
    background: var(--selected) !important;
    box-shadow: inset 0 0 0 3px gold;
}

.square.legal-target::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: var(--legal-move);
}

.square.legal-target.has-piece::after {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    background: transparent;
    border: 3px solid var(--legal-move);
}

.square.last-move {
    background: var(--last-move) !important;
}

/* Lava Animation */
.square.lava {
    animation: lavaErupt 1.5s ease-out;
}

@keyframes lavaErupt {
    0% {
        background: var(--lava) !important;
        box-shadow: 0 0 30px var(--lava-glow), inset 0 0 20px var(--lava-dark);
        transform: scale(1.1);
    }
    30% {
        background: var(--lava-glow) !important;
        box-shadow: 0 0 50px var(--lava), inset 0 0 30px var(--lava-dark);
        transform: scale(1.05);
    }
    100% {
        background: inherit;
        box-shadow: none;
        transform: scale(1);
    }
}

.square .lava-emoji {
    position: absolute;
    font-size: min(10vw, 44px);
    animation: lavaRise 1.2s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes lavaRise {
    0% { opacity: 0; transform: scale(0.3) translateY(20px); }
    30% { opacity: 1; transform: scale(1.3) translateY(-5px); }
    70% { opacity: 1; transform: scale(1) translateY(-5px); }
    100% { opacity: 0; transform: scale(0.8) translateY(-30px); }
}

/* Piece removal animation */
.square .piece-remove {
    animation: pieceRemove 0.8s ease-out forwards;
}

@keyframes pieceRemove {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); color: var(--lava); }
    100% { opacity: 0; transform: scale(0) rotate(180deg); }
}

/* Captured pieces */
.captured-row {
    display: flex;
    gap: 2px;
    min-height: 28px;
    font-size: 1.2rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding: 2px 8px;
}

/* Message bar */
#message-bar {
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 28px;
    text-align: center;
    color: var(--lava-glow);
}

/* Controls */
#controls {
    display: flex;
    gap: 8px;
    width: 100%;
}
#controls button {
    flex: 1;
    padding: 12px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid #333;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
#controls button:active {
    background: var(--lava-dark);
}

/* Lava Log */
#lava-log {
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-muted);
}
#lava-log summary {
    cursor: pointer;
    padding: 8px;
    text-align: center;
}
#lava-entries {
    max-height: 150px;
    overflow-y: auto;
    padding: 4px 8px;
}
.lava-entry {
    padding: 2px 0;
    border-bottom: 1px solid #222;
}
.lava-entry .victim { color: var(--lava); font-weight: 600; }

/* Check indicator */
.square.in-check {
    box-shadow: inset 0 0 15px var(--danger), 0 0 10px var(--danger);
}

/* Coordinate labels */
.square .coord {
    position: absolute;
    font-size: 0.5rem;
    color: rgba(0,0,0,0.3);
    font-weight: 600;
}
.square .coord-file { bottom: 1px; right: 3px; }
.square .coord-rank { top: 1px; left: 3px; }

/* Responsive */
@media (min-width: 420px) {
    #board {
        width: 400px;
        height: 400px;
    }
}
