:root {
    --bg-color: #111;
    --table-border: #8b5a2b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    color: white;
    touch-action: none;
}

body.mobile-mode {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* --- HUD & UI BUTTONS --- */
#mobile-btn {
    position: fixed;
    top: 15px; 
    left: 15px;
    z-index: 2000;
    background: rgba(30, 30, 30, 0.8);
    color: white;
    border: 2px solid #00ffcc;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    padding: 10px 15px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

body.mobile-mode #mobile-btn { 
    display: none; 
}

#options-btn {
    position: fixed;
    bottom: 15px; 
    left: 15px;
    z-index: 2000;
    background: rgba(30, 30, 30, 0.8);
    color: white;
    border: 2px solid #ffaa00;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    padding: 10px 15px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

#options-btn:active, #mobile-btn:active {
    transform: scale(0.95);
}

/* --- STATS HUD (Top Right) --- */
#stats-panel {
    position: fixed;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #00ffcc;
    padding: 10px;
    border: 1px solid #00ffcc;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    z-index: 2000;
    pointer-events: none;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

#stats-panel div { margin-bottom: 4px; }
#stats-panel div:last-child { margin-bottom: 0; }
#stats-panel strong { color: white; margin-right: 5px; }
#stats-panel span {
    display: inline-block;
    width: 35px;
    text-align: right;
    color: #ffaa00;
}

body.mobile-mode #stats-panel {
    font-size: 10px; 
    top: 10px;
    right: 10px;
}

/* --- CALIBRATION & OPTIONS UI --- */
#ui-layer, #options-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2500;
    text-align: center;
    transition: opacity 0.5s ease;
}

#menu, #calibration-screen, #options-menu {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-width: 90%;
    width: 350px;
}

h1 { margin-bottom: 15px; color: #00ffcc; }
h2 { margin-bottom: 10px; color: #ffaa00; }
p { margin-bottom: 20px; font-size: 1.1rem; color: #ccc; }

#start-btn, #close-options-btn {
    background: #00ffcc;
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}

#close-options-btn {
    background: #ffaa00;
}

#start-btn:active, #close-options-btn:active { transform: scale(0.95); }
#countdown { font-size: 4rem; font-weight: bold; color: #ff4444; }
.hidden { display: none !important; }

/* Options Inputs */
select {
    background: #333;
    color: #fff;
    border: 2px solid #ffaa00;
    padding: 10px;
    font-size: 1rem;
    border-radius: 6px;
    margin-top: 10px;
    width: 100%;
    outline: none;
    cursor: pointer;
}

input[type=range] {
    width: 100%;
    margin-top: 15px;
    cursor: pointer;
    accent-color: #00ffcc;
}

#board-size-val {
    color: #00ffcc;
}

/* --- 3D SCENE & TABLE --- */
#game-container {
    position: absolute;
    top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#screen {
    width: 600px; 
    height: 600px; 
    position: relative;
    transform-origin: center center;
    perspective: 1200px; 
    flex-shrink: 0;
    transition: transform 0.1s ease-out; /* Smooth transition when using slider */
}

#table {
    width: 100%;
    height: 100%;
    background-color: var(--table-border);
    padding: 8px; 
    border-radius: 10px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.9), inset 0 0 15px rgba(0,0,0,0.6);
    transform-style: preserve-3d;
    transform: rotateX(0deg) rotateY(0deg); 
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-color: #fff;
    border: 2px solid #222;
    border-radius: 4px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
}
