:root { --bg-color: #ffffff; --text-color: #1e293b; --btn-bg: #e2e8f0; --btn-hover: #cbd5e1; --primary: #3b82f6; --board-bg: #f8fafc; --cell-border: #cbd5e1; --cell-bg: #e2e8f0; --wall-color: #64748b; --wall-hover: rgba(59, 130, 246, 0.6); --p1-color: #ef4444; --p2-color: #3b82f6; --target-p1-bg: rgba(239, 68, 68, 0.15); --target-p2-bg: rgba(59, 130, 246, 0.15); }
body.dark-mode { --bg-color: #0f172a; --text-color: #f8fafc; --btn-bg: #334155; --btn-hover: #475569; --board-bg: #1e293b; --cell-border: #334155; --cell-bg: #475569; --wall-color: #f8fafc; --wall-hover: rgba(248, 250, 252, 0.5); --target-p1-bg: rgba(239, 68, 68, 0.25); --target-p2-bg: rgba(59, 130, 246, 0.25); }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-color); transition: 0.3s; display: flex; flex-direction: column; min-height: 100vh; }
body.no-scroll { overflow: hidden; touch-action: none; }

.top-bar { display: flex; justify-content: space-between; align-items: center; padding: max(20px, env(safe-area-inset-top)) 20px 20px 20px; width: 100%; }
.icon-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-color); cursor: pointer; transition: 0.2s; padding: 8px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.icon-btn:hover { color: var(--primary); transform: scale(1.1); }
.lang-btn { font-size: 1rem; font-weight: bold; border: 2px solid var(--text-color); border-radius: 50%; width: 36px; height: 36px; padding: 0; }
.lang-btn:hover { border-color: var(--primary); }
.right-icons { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }

.container { display: flex; flex-direction: column; align-items: center; justify-content: center; flex-grow: 1; padding: 20px; width: 100%; }
h1 { margin-bottom: 20px; font-size: 2.5rem; text-align: center; }

.diff-selector { display: flex; background-color: var(--btn-bg); border-radius: 8px; overflow: hidden; margin-bottom: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); width: 100%; max-width: 320px; }
.diff-btn { flex: 1; padding: 10px 15px; border: none; background: transparent; color: var(--text-color); font-weight: bold; cursor: pointer; transition: 0.3s; }
.diff-btn.active[data-diff="easy"] { background-color: #22c55e; color: white; }
.diff-btn.active[data-diff="medium"] { background-color: #eab308; color: white; }
.diff-btn.active[data-diff="hard"] { background-color: #ef4444; color: white; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 2000; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-content { background-color: var(--board-bg); color: var(--text-color); padding: 30px; border-radius: 12px; width: 100%; max-width: 500px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 2px solid var(--cell-border); }
.modal-content h2 { margin-bottom: 20px; color: var(--primary); text-align: center; font-size: 1.8rem; }
.modal-content p { white-space: pre-line; text-align: left; line-height: 1.6; margin-bottom: 25px; font-size: 1rem; }
.close-btn { background-color: var(--primary); color: white; border: none; padding: 12px; font-size: 1.1rem; font-weight: bold; border-radius: 8px; cursor: pointer; width: 100%; transition: 0.2s; }
.close-btn:hover { filter: brightness(1.1); }

.fb-input { width: 100%; padding: 12px; margin-bottom: 15px; border-radius: 8px; border: 1px solid var(--cell-border); background-color: var(--bg-color); color: var(--text-color); font-family: inherit; font-size: 1rem; }
.fb-file-label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: var(--text-color); }
.fb-input-file { margin-bottom: 20px; width: 100%; color: var(--text-color); }
.primary-btn { background-color: #22c55e; color: white; border: none; padding: 12px; font-size: 1.1rem; font-weight: bold; border-radius: 8px; cursor: pointer; width: 100%; transition: 0.2s; }
.primary-btn:hover { background-color: #16a34a; }
.mt-2 { margin-top: 10px; }
.status-msg { text-align: center; margin-top: 10px; font-weight: bold; }
.menu-divider { border: 1px solid var(--cell-border); margin: 15px 0; opacity: 0.5; }

.game-layout { display: flex; flex-direction: row; gap: 30px; align-items: center; justify-content: center; width: 100%; max-width: 1200px; }
.side-hud { display: flex; flex-direction: column; width: 220px; }
.board-column { display: flex; flex-direction: column; align-items: center; justify-content: center; width: auto; }

.player-card { padding: 15px; border-radius: 10px; background-color: var(--board-bg); border: 2px solid var(--cell-border); box-shadow: 0 4px 6px rgba(0,0,0,0.1); width: 100%; }
.human-card { border-left: 5px solid var(--p1-color); }
.ai-card { border-left: 5px solid var(--p2-color); }
.player-card h3 { margin-bottom: 5px; font-size: 1.2rem; }

.timer-and-drags { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px; width: 100%; }
.drag-wall-btn { width: 60px; height: 60px; background: var(--btn-bg); border: 2px dashed var(--cell-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; user-select: none; transition: 0.2s; }
.drag-wall-btn:active { cursor: grabbing; background: var(--btn-hover); }
.icon-h { width: 35px; height: 10px; background: var(--p1-color); border-radius: 3px; pointer-events: none; }
.icon-v { width: 10px; height: 35px; background: var(--p1-color); border-radius: 3px; pointer-events: none; }

.dragging-clone { position: fixed; pointer-events: none; z-index: 9999; opacity: 0.9; transform: translate(-50%, -50%); box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.dragging-clone.h { width: 70px; height: 16px; background: var(--p1-color); border-radius: 4px; }
.dragging-clone.v { width: 16px; height: 70px; background: var(--p1-color); border-radius: 4px; }

@media (max-width: 850px) {
    .game-layout { flex-direction: column; gap: 15px; }
    .side-hud { width: 100%; flex-direction: row; justify-content: center; gap: 15px; }
    .left-hud { order: 1; }
    .right-hud { order: 2; }
    .board-column { order: 3; width: 100%; }
    .player-card { max-width: 200px; text-align: center; }
}

.timer-box { margin: 0; font-family: 'Orbitron', monospace; font-size: 1.8rem; font-weight: bold; background-color: var(--cell-border); color: var(--text-color); padding: 6px 15px; border-radius: 8px; width: 140px; display: flex; justify-content: center; align-items: center; text-align: center; box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); }
.blink-yellow { animation: flashYellow 1s 5; }
.blink-red-fast { animation: flashRed 1s infinite; }
.rapid-blink { animation: flashRed 0.2s 5; }
.flash-red-once { animation: flashRed 1s 1; }
.timeout-red { background-color: #9B111E !important; color: white !important; }
.timeout-green { background-color: #22c55e !important; color: white !important; }
@keyframes flashYellow { 0%, 100% { background-color: var(--cell-border); color: var(--text-color); } 50% { background-color: #eab308; color: white; } }
@keyframes flashRed { 0%, 100% { background-color: var(--cell-border); color: var(--text-color); } 50% { background-color: #9B111E; color: white; } }

.board-container { padding: 15px; border-radius: 8px; background-color: var(--board-bg); box-shadow: 0 10px 20px rgba(0,0,0,0.2); border: 2px solid var(--cell-border); width: min(95vw, 474px); height: min(95vw, 474px); }
.interlock-grid { display: grid; grid-template-columns: repeat(8, 42fr 12fr) 42fr; grid-template-rows: repeat(8, 42fr 12fr) 42fr; width: 100%; height: 100%; background-color: var(--board-bg); }
.cell { background-color: var(--cell-bg); border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; width: 100%; height: 100%; }
.cell:hover { filter: brightness(0.9); }
.cell.valid-move { box-shadow: inset 0 0 10px rgba(34, 197, 94, 0.8); }
.cell.target-p1 { background-color: var(--target-p1-bg); border: 1px dashed rgba(239, 68, 68, 0.3); }
.cell.target-p2 { background-color: var(--target-p2-bg); border: 1px dashed rgba(59, 130, 246, 0.3); }
.wall-h, .wall-v, .intersection { width: 100%; height: 100%; }
.wall-h { background-color: transparent; transition: 0.1s; }
.wall-v { background-color: transparent; transition: 0.1s; }
.intersection { background-color: transparent; }
.wall-hover { background-color: var(--primary) !important; opacity: 0.8; box-shadow: 0 0 10px var(--primary); border-radius: 2px; }
.wall-placed { background-color: var(--wall-color) !important; border-radius: 2px; cursor: not-allowed; }

.pawn { width: 70%; height: 70%; border-radius: 50%; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.pawn.p1 { background: radial-gradient(circle at 30% 30%, #f87171, #dc2626); }
.pawn.p2 { background: radial-gradient(circle at 30% 30%, #60a5fa, #2563eb); }

.status-area { text-align: center; margin-top: 20px; }
#status { margin-bottom: 15px; height: 30px; }
#restart { padding: 12px 24px; font-weight: bold; background-color: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; width: 100%; transition: 0.2s; }
#restart:hover { filter: brightness(1.1); }
.ad-container { margin-top: 40px; display: flex; justify-content: center; align-items: center; width: 100%; min-height: 90px; overflow: hidden; }

/* Menu Lateral Atualizado com Flexbox */
.side-menu { position: fixed; top: 0; left: -250px; width: 250px; height: 100%; background-color: var(--board-bg); box-shadow: 2px 0 10px rgba(0,0,0,0.2); transition: 0.3s; z-index: 1000; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; }
.side-menu.open { left: 0; }
.side-menu h2 { margin-bottom: 30px; color: var(--primary); border-bottom: 2px solid var(--cell-border); padding-bottom: 10px; font-size: 1.5rem;}
.side-menu ul { list-style: none; }
.side-menu li { margin-bottom: 15px; }
.side-menu a, .menu-bottom a { text-decoration: none; color: var(--text-color); font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.side-menu a.active { color: var(--primary); font-weight: bold; }
.menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999; }
.menu-overlay.open { display: block; }

.menu-category { font-size: 0.85rem; font-weight: bold; color: var(--primary); opacity: 0.7; margin-bottom: 8px; letter-spacing: 1px; pointer-events: none; }
.mt-3 { margin-top: 25px; }