:root {
    --bg-color: #0d0d0d; --text-color: #ecf0f1; --board-bg: #2c3e50;
    --cell-bg: #bdc3c7; --cell-dark: #95a5a6; --panel-bg: rgba(255, 255, 255, 0.08);
    --log-bg: #000000; --log-text: #2ecc71; --p1-color: #c0392b; --p2-color: #2980b9;
    --accent: #27ae60; --modal-bg: #1e272e; --drawer-bg: #1a1a1a;
}
body.light-mode {
    --bg-color: #f5f6fa; --text-color: #2f3640; --board-bg: #dcdde1;
    --cell-bg: #ffffff; --cell-dark: #dfe4ea; --panel-bg: rgba(0, 0, 0, 0.05);
    --log-bg: #ffffff; --log-text: #1b1464; --modal-bg: #ffffff; --drawer-bg: #ffffff;
}
body { font-family: 'Segoe UI', Tahoma, sans-serif; background-color: var(--bg-color); color: var(--text-color); display: flex; flex-direction: column; align-items: center; margin: 0; padding: 0; min-height: 100dvh; touch-action: manipulation; transition: background 0.3s; overflow: hidden; }
#menu-btn { position: fixed; top: 15px; left: 15px; z-index: 10001; background: var(--accent); color: white; border: none; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
#side-drawer { position: fixed; top: 0; left: -300px; width: 260px; height: 100%; box-sizing: border-box; background: var(--drawer-bg); z-index: 10000; padding: 80px 20px 20px; box-shadow: 5px 0 25px rgba(0,0,0,0.6); transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; gap: 6px; overflow-y: auto;}
#side-drawer.open { left: 0; }
#side-drawer button { width: 100%; padding: 14px; border: none; border-radius: 6px; background: #333; color: white; font-weight: bold; cursor: pointer; text-align: left; font-size: 14px; transition: 0.2s; }
#side-drawer button:hover { background: #444; padding-left: 20px; }
.main-container { width: 100%; max-width: 100%; padding: 10px; display: flex; flex-direction: column; align-items: center; height: 100dvh; box-sizing: border-box; justify-content: center; position: relative; overflow-y: auto; }
.player-panel { width: 100%; max-width: 800px; padding: 15px; margin-bottom: 10px; border-radius: 12px; background: var(--panel-bg); text-align: center; }
.active-label { color: var(--accent); font-weight: 900; letter-spacing: 2px; font-size: 1.4em; }
#board-wrapper { width: 100%; max-width: min(1200px, 95vw, calc(65dvh * (9 / 8))); position: relative; background-color: var(--board-bg); padding: 8px; border-radius: 10px; box-shadow: 0 15px 45px rgba(0,0,0,0.8); transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.flipped { transform: rotate(180deg); }
#board { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; width: 100%; }
.cell { background-color: var(--cell-bg); aspect-ratio: 1 / 1; display: flex; justify-content: center; align-items: center; cursor: pointer; border-radius: 4px; position: relative; }
.cell.dark { background-color: var(--cell-dark); }
.cell.selected { box-shadow: inset 0 0 0 5px #f1c40f; background-color: #f39c12; }
.trail-arrow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 5; pointer-events: none; filter: drop-shadow(0px 0px 4px rgba(0,0,0,0.5)); }
.piece { width: 94%; height: 94%; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 4px; color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.4); z-index: 2; }
.piece-icon-container { width: 100%; height: 55%; display: flex; justify-content: center; align-items: center; }
.piece-icon-container svg { fill: currentColor; height: 90%; width: auto; max-width: 90%; }
.piece-text { height: 25%; display: flex; align-items: center; font-weight: bold; font-size: clamp(7px, 1.2vw + 0.5vh, 16px); text-transform: uppercase; white-space: nowrap; }
.player1-piece { background-color: var(--p1-color); }
.player2-piece { background-color: var(--p2-color); }
.hidden-piece { background-color: #34495e; color: #7f8c8d; }
#activity-log { width: 100%; max-width: 800px; height: 110px; background-color: var(--log-bg); color: var(--log-text); margin: 15px 0 5px 0; padding: 15px; border-radius: 8px; font-size: 17px; font-weight: bold; overflow-y: auto; border: 2px solid var(--text-color); line-height: 1.5; box-sizing: border-box; }
.log-num { color: #f1c40f; margin-right: 10px; }
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 10005; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; }
.modal-content { background: var(--modal-bg); color: var(--text-color); padding: 30px; border-radius: 15px; max-width: 550px; max-height: 85vh; overflow-y: auto; border: 3px solid var(--accent); width: 100%; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px; }
.help-box { background: rgba(255,255,255,0.05); padding: 10px; border-radius: 8px; font-size: 0.9em; }
.help-box h4 { margin: 0 0 5px 0; color: var(--accent); }
#pass-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 99999; display: none; flex-direction: column; justify-content: center; align-items: center; }
#win-overlay { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100; padding: 20px 40px; border-radius: 15px; background: rgba(0, 0, 0, 0.85); border: 3px solid var(--accent); text-align: center; pointer-events: none; width: 80%; }
#win-overlay.show { display: block; pointer-events: auto; }
.flipped #win-overlay { transform: translate(-50%, -50%) rotate(180deg); }
#win-overlay h2 { margin: 0 0 8px 0; font-size: clamp(18px, 4vw, 32px); letter-spacing: 3px; }
#win-overlay p { margin: 0; font-size: clamp(12px, 2.5vw, 18px); opacity: 0.85; }
@keyframes combatBurst { 0% { transform: scale(1); box-shadow: inset 0 0 0 0 rgba(255,80,80,0); background-color: inherit; } 10% { transform: scale(1.2); box-shadow: inset 0 0 25px rgba(255,60,60,1), 0 0 30px rgba(255,200,50,0.9); background-color: rgba(255,60,30,0.4); } 25% { transform: scale(0.88) rotate(-3deg); box-shadow: inset 0 0 20px rgba(255,100,50,0.8), 0 0 20px rgba(255,150,50,0.7); } 40% { transform: scale(1.12) rotate(3deg); box-shadow: inset 0 0 18px rgba(255,80,40,0.7), 0 0 18px rgba(255,100,50,0.6); background-color: rgba(255,80,30,0.3); } 55% { transform: scale(0.93) rotate(-2deg); } 70% { transform: scale(1.06) rotate(1deg); box-shadow: inset 0 0 10px rgba(255,80,80,0.4), 0 0 10px rgba(255,100,50,0.3); } 85% { transform: scale(0.98); } 100% { transform: scale(1); box-shadow: inset 0 0 0 0 rgba(255,80,80,0); background-color: inherit; } }
.combat-cell { animation: combatBurst 0.8s ease-out; z-index: 10; position: relative; }
#casualties-modal .modal-content, #replay-modal .modal-content { max-width: 500px; }
.cas-section { margin-bottom: 18px; }
.cas-section h3 { margin: 0 0 8px 0; font-size: 1em; letter-spacing: 1px; }
.cas-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cas-piece { display: flex; flex-direction: column; align-items: center; padding: 6px 8px; border-radius: 6px; min-width: 56px; font-size: 0.75em; text-align: center; }
.cas-piece svg { width: 22px; height: 22px; fill: currentColor; margin-bottom: 2px; }
.cas-piece.p1 { background: var(--p1-color); color: white; }
.cas-piece.p2 { background: var(--p2-color); color: white; }
.cas-empty { color: #888; font-style: italic; font-size: 0.9em; padding: 4px 0; }
#score-modal .modal-content { max-width: 480px; }
.score-section { margin-bottom: 18px; }
.score-section h3 { margin: 0 0 10px 0; font-size: 1.05em; letter-spacing: 1px; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.score-card { background: rgba(255,255,255,0.06); padding: 12px 8px; border-radius: 8px; text-align: center; }
.score-card .score-val { font-size: 1.5em; font-weight: 900; color: var(--accent); }
.score-card .score-lbl { font-size: 0.7em; opacity: 0.6; text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.score-pts { color: #f1c40f; font-weight: 900; font-size: clamp(11px, 2.5vw, 16px); letter-spacing: 1px; margin-top: 4px; }
