:root {
    --bg-color: #2c1e16;
    --wood-light: #d4a373;
    --wood-dark: #8b5a2b;
    --wood-empty: #4a3728;
    --bomb-color: #d90429;
    --hint-color: #4CAF50;
    --ui-blue: #2196F3;
}

* { box-sizing: border-box; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; }

body {
    margin: 0; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
    background-color: var(--bg-color); color: white;
    font-family: -apple-system, sans-serif;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; overflow: hidden;
    touch-action: none; overscroll-behavior: none;
}

.loading-logo { animation: pulseLogo 1.5s infinite alternate; width: 150px; }
.loading-text { font-size: 1.5rem; color: #aaa; margin-top: 20px; animation: fadeText 1.5s infinite alternate; }
@keyframes pulseLogo { 0% { transform: scale(0.9); opacity: 0.8; } 100% { transform: scale(1.1); opacity: 1; } }
@keyframes fadeText { 0% { opacity: 0.5; } 100% { opacity: 1; } }

.screen { width: 100%; max-width: 500px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; position: absolute; }
.hidden { display: none !important; z-index: -1; }

.logo { max-width: 150px; margin-bottom: 20px; pointer-events: none; }
h1 { font-size: 2.5rem; color: var(--wood-light); text-shadow: 2px 2px 0 #000; margin: 10px 0;}

button { background: var(--wood-dark); color: white; border: 2px solid var(--wood-light); padding: 15px 30px; font-size: 1.2rem; border-radius: 10px; margin: 10px; width: 80%; cursor: pointer; font-weight: bold; transition: transform 0.1s; }
button.bomb-btn { background: var(--bomb-color); border-color: #ffb3c1; }
button:active { transform: scale(0.95); }
.small-btn { background: transparent; border-color: #888; color: #ccc; font-size: 0.9rem; padding: 10px; margin: 5px 0; width: 50%; }
.menu-row { display: flex; justify-content: center; gap: 10px; width: 80%; }

/* Header & Scores */
.header { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.scores { display: flex; flex-direction: column; }
.score-board { font-size: 1.5rem; font-weight: bold; color: var(--wood-light); }
.high-score-board { font-size: 0.9rem; color: #aaa; font-weight: bold; }
.header button { width: auto; padding: 10px 20px; margin: 0; }

/* Bonus Toolbar */
.bonus-bar { display: flex; justify-content: space-around; width: 100%; max-width: 450px; background: rgba(0,0,0,0.3); padding: 10px; border-radius: 10px; margin-bottom: 15px; }
.bonus-btn { position: relative; width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; background: var(--wood-empty); border-radius: 8px; cursor: pointer; border: 2px solid transparent; transition: 0.2s; color: white;}
.bonus-btn svg { width: 24px; height: 24px; }
.bonus-btn.active { border-color: var(--ui-blue); background: rgba(33, 150, 243, 0.3); transform: scale(1.1); }
.bonus-btn.disabled { opacity: 0.3; pointer-events: none; }
.badge { position: absolute; top: -5px; right: -5px; background: var(--bomb-color); color: white; font-size: 0.7rem; font-weight: bold; width: 18px; height: 18px; display: flex; justify-content: center; align-items: center; border-radius: 50%; }
.bonus-status { width: 100%; text-align: center; color: var(--ui-blue); font-size: 0.9rem; margin-bottom: 5px; font-weight: bold; }

/* The Board */
.board { display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); gap: 2px; width: 100%; max-width: 450px; aspect-ratio: 1/1; background: #1a110c; padding: 4px; border-radius: 8px; position: relative; }
.cell { background: var(--wood-empty); border-radius: 4px; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: clamp(0.9rem, 4vw, 1.2rem); transition: background 0.1s; }
.cell.filled { background: var(--wood-light); box-shadow: inset 0 0 5px rgba(0,0,0,0.3); }
.cell.bomb { background: var(--bomb-color); color: white; box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }
.cell.highlight { background: rgba(255, 255, 255, 0.4) !important; box-shadow: inset 0 0 8px rgba(255,255,255,0.6); }
.cell.hint-highlight { background: var(--hint-color) !important; box-shadow: inset 0 0 15px var(--hint-color); }
.cell.selectable { animation: pulseSelect 1s infinite alternate; cursor: pointer; }

/* Animations */
.cell.clearing { animation: popClear 0.3s forwards ease-in; }
@keyframes popClear { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.8; } 100% { transform: scale(0); opacity: 0; } }
@keyframes pulseSelect { 0% { box-shadow: inset 0 0 0px var(--ui-blue); } 100% { box-shadow: inset 0 0 15px var(--ui-blue); } }
.shake { animation: screenShake 0.4s ease-in-out; }
@keyframes screenShake { 0% { transform: translate(0, 0); } 20% { transform: translate(-10px, 10px); } 40% { transform: translate(10px, -10px); } 60% { transform: translate(-10px, -10px); } 80% { transform: translate(10px, 10px); } 100% { transform: translate(0, 0); } }
.cell.exploding { animation: blast 0.8s forwards; z-index: 100; position: relative; }
@keyframes blast { 0% { transform: scale(1); background: yellow; box-shadow: 0 0 20px yellow; } 50% { transform: scale(5); background: red; opacity: 0.8; box-shadow: 0 0 100px red; } 100% { transform: scale(10); opacity: 0; } }

.instructions { margin: 10px 0; font-size: 0.9rem; color: #aaa; text-align: center; }

/* Tray */
.tray { display: flex; justify-content: space-around; align-items: center; width: 100%; max-width: 450px; height: 120px; gap: 5px; }
.tray-piece { display: grid; gap: 2px; padding: 5px; border-radius: 5px; cursor: grab; transition: transform 0.2s; }
.tray-piece.dragging { opacity: 0; } 
.tray-cell { width: clamp(25px, 8vw, 35px); height: clamp(25px, 8vw, 35px); border-radius: 4px; pointer-events: none;}
.tray-cell.filled { background: var(--wood-light); box-shadow: inset 0 0 4px rgba(0,0,0,0.4); }
.tray-cell.empty { background: transparent; }

/* Hardware-Accelerated Drag Ghost */
.ghost-piece { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 1000; display: grid; gap: 2px; opacity: 0.95; filter: drop-shadow(0 15px 15px rgba(0,0,0,0.6)); will-change: transform; }
.ghost-cell { border-radius: 4px; }
.ghost-cell.filled { background: var(--wood-light); box-shadow: inset 0 0 5px rgba(0,0,0,0.3); border: 1px solid rgba(0,0,0,0.3); }

/* Landing Page (Index.html only) */
.landing-body { overflow-y: auto; align-items: flex-start; padding-top: 40px; touch-action: auto; }
.landing-container { max-width: 600px; text-align: center; padding: 20px; }
.play-btn { display: inline-block; background: var(--wood-light); color: var(--bg-color); padding: 15px 30px; border-radius: 10px; font-size: 1.5rem; text-decoration: none; font-weight: bold; margin: 20px 0; }
.install-card { background: rgba(0,0,0,0.3); padding: 20px; border-radius: 10px; text-align: left; margin: 20px 0; line-height: 1.6; }
.update-banner { background: var(--bomb-color); color: white; padding: 12px; border-radius: 8px; margin-bottom: 20px; text-align: center; font-weight: bold; cursor: pointer; width: 90%; animation: pulse 2s infinite; }
.credits { margin-top: 20px; font-size: 0.9rem; color: #888; }
.credits a { color: var(--wood-light); text-decoration: none; font-weight: bold; }
@keyframes pulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 4, 41, 0.7); } 70% { transform: scale(1.05); box-shadow: 0 0 10px 10px rgba(217, 4, 41, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 4, 41, 0); } }
