/* ===========================
   GLOBAL & GLASSMORPHISM STYLES
=========================== */
:root {
    --primary-bg: #050505;
    --container-bg: rgba(0, 0, 0, 0.6); 
    --text-color: #f1f2f6; 
    --btn-color: #ff4757;
    --btn-hover: #ff6b81;
    --secondary-btn: #2ed573;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden; 
}

.prism-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; 
}

/* App Container Layout */
.app-container {
    background: var(--container-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9); 
    max-width: 800px; 
    width: 90%;
    max-height: 90vh; 
    overflow-y: auto; 
    backdrop-filter: blur(15px); 
    border: 1px solid rgba(255, 255, 255, 0.08); 
    display: flex; 
    flex-direction: row; 
    align-items: flex-start;
    box-sizing: border-box; /* Ensures padding doesn't blow out width */
}

/* Custom Glassmorphism Scrollbar */
.app-container::-webkit-scrollbar { width: 8px; }
.app-container::-webkit-scrollbar-track { background: transparent; border-radius: 10px; }
.app-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 10px; }
.app-container::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

/* Vertical Sidebar Tabs */
.tabs { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    background: rgba(255, 255, 255, 0.05); 
    border-radius: 10px; 
    padding: 15px 10px; 
    min-width: 140px; 
    margin-right: 30px; 
    flex-shrink: 0; /* FIX: Prevents the sidebar from ever being squished */
}

.tab-btn { 
    background: transparent; 
    color: rgba(255, 255, 255, 0.6); 
    border-radius: 8px; 
    padding: 12px 10px; 
    font-size: 1rem; 
    border: none; 
    cursor: pointer; 
    text-align: left; 
    transition: all 0.2s;
}

.tab-btn.active { 
    background: rgba(255, 255, 255, 0.1); 
    color: #fff; 
    box-shadow: inset 3px 0 0 var(--btn-color); 
    font-weight: bold;
}

.tab-btn:hover:not(.active) { 
    background: rgba(236, 204, 104, 0.2); 
    color: #eccc68; 
    padding-left: 15px; 
}

.content-area {
    flex: 1; 
    min-width: 0; /* FIX: Prevents content from pushing past container bounds */
    display: flex;
    flex-direction: column;
    align-items: center; 
    text-align: center;
    width: 100%;
}

.tab-content { display: none; width: 100%; animation: fadeIn 0.3s ease-in-out; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

h2 { margin-top: 0; margin-bottom: 20px; font-size: 1.5rem; color: #fff; }

/* ===========================
   COMPONENT STYLES
=========================== */

/* Wheel */
.wheel-wrapper { position: relative; display: flex; justify-content: center; align-items: center; margin: 20px 0; }
.pointer { position: absolute; top: -15px; z-index: 10; width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent; border-top: 30px solid #fff; filter: drop-shadow(0 4px 2px rgba(0,0,0,0.5)); }
canvas.wheel-canvas { border-radius: 50%; box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99); }

/* User Guessing Buttons (Coins & Dice) */
.coin-selection { margin-bottom: 20px; width: 100%; }
.coin-selection p { margin: 0 0 10px 0; font-weight: bold; color: rgba(255, 255, 255, 0.8); }
.radio-group { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.radio-group input[type="radio"] { display: none; }
.radio-group label { padding: 8px 20px; background-color: rgba(255,255,255,0.05); border-radius: 20px; cursor: pointer; font-weight: bold; color: rgba(255,255,255,0.6); transition: all 0.2s ease; border: 1px solid transparent; }
.radio-group label:hover { background-color: rgba(255,255,255,0.1); }
.radio-group input[type="radio"]:checked + label { background-color: var(--btn-color); color: white; box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3); border-color: rgba(255,255,255,0.2); }

/* Coin */
.coin-wrapper { perspective: 800px; margin: 30px auto; width: 120px; height: 120px; }
#coin { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 3s cubic-bezier(0.17, 0.67, 0.12, 0.99); }
.coin-side { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; font-weight: bold; color: white; box-shadow: inset 0 0 20px rgba(0,0,0,0.3), 0 5px 15px rgba(0,0,0,0.5); border: 5px solid #fff; }
.heads { background: linear-gradient(45deg, #f1c40f, #f39c12); }
.tails { background: linear-gradient(45deg, #bdc3c7, #7f8c8d); transform: rotateY(180deg); }

/* Dice */
.dice-wrapper { margin: 30px 0; }
#dice { font-size: 5rem; display: inline-block; user-select: none; color: #fff; }
.rolling { animation: roll 0.6s infinite ease-in-out; }
@keyframes roll { 0% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(1.2); } 100% { transform: rotate(360deg) scale(1); } }

/* Inputs & Buttons */
.controls { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; text-align: left; width: 100%; max-width: 350px; margin-left: auto; margin-right: auto;}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group label { color: rgba(255,255,255,0.7); font-size: 0.9rem; }
input[type="text"] { padding: 10px; border: 1px solid rgba(255,255,255,0.1); border-radius: 5px; font-size: 1rem; outline: none; background: rgba(0,0,0,0.3); color: #fff; width: 100%; box-sizing: border-box;}
input[type="text"]:focus { border-color: var(--btn-color); background: rgba(0,0,0,0.5); }

button { padding: 12px 20px; font-size: 1rem; font-weight: bold; color: white; border: none; border-radius: 50px; cursor: pointer; transition: background 0.3s, transform 0.1s; }
button:active { transform: scale(0.98); }
button:disabled { background-color: #57606f; color: rgba(255,255,255,0.5); cursor: not-allowed; }

.action-btn { background-color: var(--btn-color); width: 80%; margin: 10px auto; display: block; }
.action-btn:hover { background-color: var(--btn-hover); }
.secondary-btn { background-color: var(--secondary-btn); width: 100%; box-sizing: border-box;}
.secondary-btn:hover { background-color: #26de81; }
.result-text { margin-top: 15px; font-size: 1.3rem; font-weight: bold; color: #2ed573; min-height: 30px; text-align: center;}

/* ===========================
   BULLETPROOF RESPONSIVE DESIGN
=========================== */
/* FIX: Triggers on narrow widths OR short heights (like phones turned sideways) */
@media (max-width: 850px), (max-height: 650px) {
    .app-container {
        flex-direction: column; 
        align-items: center;
        padding: 20px 15px; /* Smaller padding saves screen space */
    }

    .tabs { 
        flex-direction: row; 
        width: 100%; 
        margin-right: 0; 
        margin-bottom: 20px; 
        overflow-x: auto; /* Swipable if it gets too narrow */
        padding: 10px;
        box-sizing: border-box;
    }
    
    .tab-btn { 
        text-align: center; 
        white-space: nowrap; 
        padding: 10px 15px;
    }
    
    .tab-btn.active { 
        box-shadow: inset 0 -3px 0 var(--btn-color); 
    }
    
    .tab-btn:hover:not(.active) { 
        padding-left: 10px; 
    }

    /* Scales the wheel down smoothly so it doesn't break the container */
    canvas.wheel-canvas { 
        width: 100%; 
        max-width: 280px; 
        height: auto; 
    }
}