:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --cell-bg: #334155;
    --cell-border: #475569;
    --q1-bg-start: #312e81; /* Indigo 900 */
    --q1-bg-end: #4338ca;   /* Indigo 700 */
    --btn-primary-bg: #0ea5e9;
    --btn-primary-hover: #0284c7;
    --btn-secondary-bg: #334155;
    --btn-secondary-hover: #475569;
    --font-main: 'Outfit', sans-serif;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--sidebar-bg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    border-right: 1px solid var(--cell-border);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-radius: 12px;
}

.stat-box {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    font-feature-settings: "tnum";
}

/* Controls */
.controls-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.control-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.size-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--cell-bg);
    padding: 0.25rem;
    border-radius: 8px;
}

.size-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 600;
}

.size-btn.active {
    background: var(--btn-primary-bg);
    color: white;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--btn-primary-bg);
    color: white;
    flex: 2;
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--text-primary);
    flex: 1;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--btn-secondary-hover);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-image: radial-gradient(var(--cell-bg) 1px, transparent 1px);
    background-size: 40px 40px;
}

.game-board-container {
    padding: 2rem;
    background: var(--sidebar-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.game-grid {
    display: grid;
    /* Grid template cols/rows will be set by JS */
    gap: 4px;
}

.cell {
    width: 60px;
    height: 60px;
    background-color: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    border-radius: 4px;
    color: var(--text-secondary);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s;
    user-select: none;
}

/* Q1 Highlight */
.cell.in-q1 {
    background: linear-gradient(135deg, var(--q1-bg-start), var(--q1-bg-end));
    color: white;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

.cell.correct-value {
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.row-flip {
  margin-left: 1rem;
}

.col-flip {
  margin-top: 1rem;
}

/* Flip Buttons */
.flip-btn {
    background: transparent;
    border: 1px solid var(--cell-border);
    color: var(--text-secondary);
    width: 60px;
    height: 60px;
    border-radius: 4px;
    padding: 0;
    font-size: 1.2rem;
}

.flip-btn:hover {
    background: var(--cell-bg);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.flip-anim {
    animation: flip 0.3s ease-in-out;
}

@keyframes flip {
    0% { transform: scaleX(1); }
    50% { transform: scaleX(0); background-color: var(--btn-primary-bg); color: transparent; }
    100% { transform: scaleX(1); }
}

.instructions p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    border-top: 1px solid var(--cell-border);
    padding-top: 1rem;
}

#fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

#winner-banner {
    background: linear-gradient(45deg, #ffd700, #ffa500);
    color: #fff;
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#winner-banner.pulsing {
    animation: pulse-gold 1.5s infinite;
}

#winner-banner.hidden {
    visibility: hidden;
}

@keyframes pulse-gold {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(255, 215, 0, 0.9); }
    100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); }
}
