/* --- Global Casino Theme and Reset --- */
:root {
    --bg-dark: #121212;
    --felt-green: #004d40; 
    --felt-border: #8b4513; 
    --accent-gold: #ffc107;
    --text-light: #eee;
    --text-dark: #333;
    --red: #d32f2f;
    --black: #111;
    --green: #388e3c;
    --orange-neon: #ff4500;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at 50% 50%, #200000 0%, #000 100%); 
    font-family: 'Poppins', sans-serif;
    color: var(--text-light); 
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Top Bar (Layout Fix) --- */
.topbar {
    width: 100%; max-width: 1200px; display: flex; justify-content: space-between;
    align-items: center; padding: 10px 0; margin-bottom: 20px;
    border-bottom: 2px solid var(--accent-gold);
}
.brand { font-size: 1.5em; font-weight: 800; color: var(--accent-gold); }
.actions { display: flex; align-items: center; gap: 15px; }
.wallet-display { 
    font-size: 1.2em; font-weight: 700; background-color: var(--accent-gold); 
    color: var(--text-dark); padding: 5px 10px; border-radius: 5px; 
}
.logout-btn { padding: 8px 12px; font-weight: 600; background-color: var(--red); color: white; text-decoration: none; border-radius: 5px; }


/* --- Main Layout Container --- */
.container {
    width: 100%; max-width: 1200px;
    display: grid;
    grid-template-columns: 320px 1fr; /* Wheel side vs Table side */
    gap: 20px;
}

/* --- Left Panel (Wheel) --- */
.card {
    background-color: var(--felt-green); padding: 15px; border-radius: 15px;
    border: 5px solid var(--felt-border); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}
.wheel-wrap {
    position: relative; width: 280px; height: 280px; margin: 20px auto; 
    border-radius: 50%; border: 6px solid var(--accent-gold);
}
#wheel { 
    width: 100%; height: 100%; border-radius: 50%; 
    transition: transform 5.6s cubic-bezier(.17,.67,.12,1); 
}

/* Pointer Direction */
#pointer { 
    position: absolute; left: 50%; top: 0px; 
    transform: translateX(-50%) translateY(-100%); 
    width: 0; height: 0; border-left: 15px solid transparent;
    border-right: 15px solid transparent; border-bottom: 30px solid var(--orange-neon); 
    z-index: 40; filter: drop-shadow(0 3px 6px #000);
}

.center-knob {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
    width: 60px; height: 60px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--accent-gold),#d49d1f);
    z-index: 35; border: 4px solid rgba(0,0,0,0.28);
}

.history-section { width: 100%; margin-top: 15px; }
.history { 
    max-height: 150px; overflow-y: auto; background: rgba(0, 0, 0, 0.4); 
    padding: 8px; border-radius: 8px; margin-top: 5px;
}
.history-item { font-size: 13px; padding: 4px; border-bottom: 1px dashed rgba(255, 255, 255, 0.05); }


/* --- Right Panel (Betting Table) --- */
.right-panel {
    background: var(--felt-green); display: flex; flex-direction: column; gap: 10px;
}

.result-display-area { text-align: center; }
.result { font-size: 1.4em; font-weight: 800; padding: 10px; border-radius: 8px; background-color: rgba(0, 0, 0, 0.3); }

/* --- Chips Selection (FIXED to show text) --- */
.chip-select-row {
    display: flex; align-items: center; gap: 10px; padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.2); border-radius: 8px; flex-wrap: wrap; 
}
.chips { display: flex; gap: 5px; flex-wrap: wrap; flex-grow: 1; }

.chip-circle {
    /* FIX: Added styles for positioning chip text */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;

    width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); transition: transform 0.1s, border-color 0.1s;
    display: inline-block;
}
.chip-value-text {
    font-size: 10px; 
    font-weight: 800;
    color: var(--text-dark); /* Default text color */
    line-height: 1; 
    mix-blend-mode: difference; /* Ensures visibility on light/dark backgrounds */
}
.chip-circle.selected {
    border-color: var(--accent-gold); box-shadow: 0 0 10px var(--accent-gold); transform: scale(1.1);
}
.large-chip { width: 32px; height: 32px; }
.request-btn { background-color: #007bff; color: white; border: none; cursor: pointer; padding: 8px 12px; border-radius: 5px; }


/* --- Betting Table Grid Layout FIX --- */
.main-betting-grid { display: flex; flex-direction: column; gap: 0px; margin-top: 10px; }

.bet-cell {
    padding: 6px 4px; border: 1px solid rgba(255, 255, 255, 0.5); background-color: rgba(0, 0, 0, 0.1);
    color: white; font-weight: 600; cursor: pointer; transition: box-shadow 0.2s;
    font-size: 12px; text-align: center; min-height: 40px; 
}

/* Grid Sections */
.row-thirds { display: grid; grid-template-columns: repeat(3, 1fr); }
.outside-bets { display: grid; grid-template-columns: repeat(6, 1fr); }

/* Number Grid FIX (3x12 format) */
.number-grid-container {
    display: grid;
    grid-template-columns: 1fr repeat(3, 1fr); /* 1 Zero + 3 Number Columns */
    grid-template-rows: repeat(12, 1fr); /* 12 Rows for 36 Numbers */
    gap: 0px; 
    border: 1px solid rgba(255, 255, 255, 0.5); 
}
.number-grid-container .bet-cell { border: none; margin: 0; height: 100%; display: flex; align-items: center; justify-content: center; }

/* Zero Cell Positioning */
.zero-bet { grid-row: 1 / span 12; grid-column: 1 / 2; font-size: 1.5em; background-color: var(--green); }

/* Number Cell Positioning (1-36) - CRUCIAL FIX */
.number-cell:nth-child(3n+2) { grid-column: 2; }
.number-cell:nth-child(3n+3) { grid-column: 3; }
.number-cell:nth-child(3n+4) { grid-column: 4; }

/* Color classes must use defined variables */
.red-bet { background-color: var(--red); }
.black-bet { background-color: var(--black); }
.green-bet { background-color: var(--green); }


/* Column Bets (2 to 1) */
.row-column { 
    display: grid; grid-template-columns: 1fr repeat(3, 1fr);
    height: 40px; margin-top: 2px;
}
.row-column .column-filler { visibility: hidden; } 

/* Action Bar */
.action-bar {
    display: flex; justify-content: space-around; padding: 10px 0;
    background-color: rgba(0, 0, 0, 0.3); border-radius: 8px;
}
.btn-spin {
    padding: 12px 20px; border-radius: 8px; border: none;
    background: linear-gradient(45deg, var(--orange-neon), #ff8a00); color: #fff; 
    font-weight: 800; cursor: pointer; font-size: 18px; box-shadow: 0 0 15px rgba(255, 138, 0, 0.5);
    flex-grow: 1; margin-right: 10px;
}
.btn-clear, .btn-repeat {
    padding: 10px 15px; border-radius: 8px; border: none;
    background-color: #555; color: white; cursor: pointer; font-weight: 600;
}