:root {
    --bg-dark: #0d1117;
    --bg-gradient: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a1f26 100%);
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    
    --primary: #58a6ff;
    --primary-hover: #79b8ff;
    
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    
    --peg-exact: #f85149; /* Red */
    --peg-color: #f0f6fc; /* White */
    --peg-empty: #21262d;
    
    /* Game Colors - Vibrant */
    --c-1: #ff6b6b;
    --c-2: #ffd93d;
    --c-3: #6bcb77;
    --c-4: #4d96ff;
    --c-5: #9d4edd;
    --c-6: #ff922b;
}

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

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 10px;
}

/* Subtle Background Pattern */
.background-blobs {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(157, 78, 221, 0.08) 0%, transparent 50%);
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.4;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -20%; left: -10%;
    width: 40vw; height: 40vw;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.3) 0%, transparent 70%);
}

.blob-2 {
    bottom: -20%; right: -10%;
    width: 35vw; height: 35vw;
    background: radial-gradient(circle, rgba(157, 78, 221, 0.25) 0%, transparent 70%);
    animation-delay: -10s;
}

.blob-3 {
    top: 50%; left: 50%;
    width: 25vw; height: 25vw;
    background: radial-gradient(circle, rgba(107, 203, 119, 0.15) 0%, transparent 70%);
    animation-duration: 25s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(20px, 30px) scale(1.05); }
}

/* Layout */
.main-wrapper {
    width: 100%;
    max-width: 900px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    position: relative;
    z-index: 1;
}

/* Navigation */
.game-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

.brand-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(90deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.games-hub-link {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.games-hub-link:hover {
    color: var(--primary-hover);
    opacity: 0.95;
}

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Game Layout Split */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    flex-grow: 1;
    min-height: 0; /* Allow flex child to scroll internally */
}

/* Board Area */
.board-container {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

/* Custom Scrollbar */
.board-container::-webkit-scrollbar {
    width: 8px;
}
.board-container::-webkit-scrollbar-track {
    background: transparent;
}
.board-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 16px;
    background: rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.row.active {
    background: rgba(255,255,255,0.08);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.row-number {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-right: 20px;
    opacity: 0.5;
}

.slots {
    display: flex;
    gap: 15px;
    flex-grow: 1;
    justify-content: center;
}

.slot {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(145deg, #3d4555, #2a2f3d);
    box-shadow: 
        4px 4px 8px rgba(0,0,0,0.4),
        -2px -2px 6px rgba(255,255,255,0.05),
        inset 2px 2px 4px rgba(255,255,255,0.1),
        inset -2px -2px 4px rgba(0,0,0,0.3);
    border: none;
    transition: all 0.2s;
}

.row.active .slot {
    cursor: pointer;
    background: linear-gradient(145deg, #3d4555, #2a2f3d);
    box-shadow: 
        4px 4px 8px rgba(0,0,0,0.4),
        -2px -2px 6px rgba(255,255,255,0.05),
        inset 2px 2px 4px rgba(255,255,255,0.15),
        inset -2px -2px 4px rgba(0,0,0,0.2);
    border: none;
    outline: 2px dashed rgba(255,255,255,0.3);
    outline-offset: 3px;
}

.row.active .slot:hover {
    outline-color: rgba(255,255,255,0.6);
    transform: translateY(-2px);
}

/* Peg Feedback Grid */
.feedback {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-left: 20px;
}

.peg {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #334155;
    transition: transform 0.3s;
}

.peg.exact {
    background-color: var(--peg-exact);
    box-shadow: 0 0 8px var(--peg-exact);
}

.peg.color {
    background-color: var(--peg-color);
    box-shadow: 0 0 8px var(--peg-color);
}

/* Controls Panel */
.controls-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
}

.turn-indicator {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    justify-items: center;
}

.color-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* Actions buttons container */
.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.color-btn:hover {
    transform: translateY(-5px);
}

.color-btn.selected::after {
    content: '';
    position: absolute;
    top: -5px; right: -5px; bottom: -5px; left: -5px;
    border: 3px solid white;
    border-radius: 50%;
    animation: spin 4s linear infinite;
}

.btn {
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4338ca);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.btn-primary:not(:disabled):hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #334155;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.glass-panel {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 40px;
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal:not(.hidden) .glass-panel {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 15px; right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal:hover {
    color: white;
}

.rules-section {
    margin: 20px 0;
    text-align: left;
}

.rule-item {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: flex-start;
}

.rule-step {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.legend {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 12px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.peg-example {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.peg-example.exact { background: var(--peg-exact); box-shadow: 0 0 5px var(--peg-exact); }
.peg-example.color { background: var(--peg-color); box-shadow: 0 0 5px var(--peg-color); }
.peg-example.empty { background: var(--peg-empty); border: 1px solid #555; }

/* Colors Utility - 3D spheres with glow */
.slot.c-1, .color-btn.c-1 { 
    background: radial-gradient(circle at 30% 30%, #ff9999, var(--c-1) 50%, #cc3333) !important; 
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}
.slot.c-2, .color-btn.c-2 { 
    background: radial-gradient(circle at 30% 30%, #ffeb80, var(--c-2) 50%, #cca300) !important; 
    box-shadow: 0 4px 20px rgba(255, 217, 61, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}
.slot.c-3, .color-btn.c-3 { 
    background: radial-gradient(circle at 30% 30%, #a3e4aa, var(--c-3) 50%, #3d9e47) !important; 
    box-shadow: 0 4px 20px rgba(107, 203, 119, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}
.slot.c-4, .color-btn.c-4 { 
    background: radial-gradient(circle at 30% 30%, #8fc1ff, var(--c-4) 50%, #2a6dbf) !important; 
    box-shadow: 0 4px 20px rgba(77, 150, 255, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}
.slot.c-5, .color-btn.c-5 { 
    background: radial-gradient(circle at 30% 30%, #c994f5, var(--c-5) 50%, #6a2b9a) !important; 
    box-shadow: 0 4px 20px rgba(157, 78, 221, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}
.slot.c-6, .color-btn.c-6 { 
    background: radial-gradient(circle at 30% 30%, #ffb366, var(--c-6) 50%, #cc6600) !important; 
    box-shadow: 0 4px 20px rgba(255, 146, 43, 0.5), inset -3px -3px 8px rgba(0,0,0,0.3), inset 3px 3px 8px rgba(255,255,255,0.4) !important;
    border: none !important;
}

.secret-reveal-container {
    margin: 20px 0;
    padding: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
}

.secret-reveal {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.center-text {
    text-align: center;
}

.full-width {
    width: 100%;
}

/* Nav buttons group */
.nav-buttons {
    display: flex;
    gap: 8px;
}

.nav-buttons .icon-btn {
    padding: 8px 12px;
}

.nav-buttons .icon-btn i {
    font-size: 1rem;
}

/* Settings Modal */
.settings-section {
    margin: 25px 0;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.setting-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.setting-options button {
    padding: 10px 18px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.setting-options button:hover {
    border-color: rgba(255,255,255,0.3);
    color: var(--text-main);
}

.setting-options button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Statistics Modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 25px 0;
}

.stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Game Summary in Game Over modal */
.game-stats-summary {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
}

.summary-item {
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Hint Button */
.btn-hint {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
}

.btn-hint:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn-hint:disabled {
    background: #334155;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-hint i {
    margin-right: 5px;
}

/* Hint revealed slot */
.slot.hint-revealed {
    animation: hintPulse 0.5s ease-out;
}

@keyframes hintPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); box-shadow: 0 0 20px rgba(251, 191, 36, 0.8); }
    100% { transform: scale(1); }
}

/* Hint info in rules */
.hint-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 10px;
    font-size: 0.9rem;
    color: #fbbf24;
}

.hint-info i {
    font-size: 1.2rem;
}

/* Confetti */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Mobile Optimization */
@media (max-width: 800px) {
    body {
        align-items: flex-start;
        padding: 5px;
    }

    .main-wrapper {
        padding: 5px;
        gap: 10px;
    }

    .game-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .game-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 15px;
        border-radius: 12px;
    }

    .brand-block {
        width: 100%;
        gap: 4px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .games-hub-link {
        font-size: 0.82rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .icon-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .board-container {
        padding: 10px;
        border-radius: 16px;
        max-height: none;
    }

    .row {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .row-number {
        font-size: 0.9rem;
        margin-right: 10px;
    }

    .slots {
        gap: 8px;
    }

    .slot {
        width: 38px;
        height: 38px;
    }

    .feedback {
        margin-left: 10px;
        gap: 4px;
        padding: 4px;
    }

    .peg {
        width: 10px;
        height: 10px;
    }

    .controls-panel {
        padding: 15px;
        border-radius: 16px;
        gap: 15px;
        position: sticky;
        bottom: 5px;
        background: rgba(13, 17, 23, 0.95);
        backdrop-filter: blur(20px);
    }

    .panel-header {
        padding-bottom: 10px;
    }

    .panel-header h3 {
        font-size: 0.95rem;
    }

    .turn-indicator {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .color-palette {
        gap: 10px;
    }

    .color-btn {
        width: 45px;
        height: 45px;
    }

    .btn {
        padding: 12px;
        font-size: 0.9rem;
    }

    .actions {
        gap: 8px;
    }

    /* Modal adjustments */
    .glass-panel {
        padding: 25px;
        border-radius: 16px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .rule-item {
        gap: 10px;
        margin-bottom: 12px;
    }

    .legend {
        padding: 12px;
    }

    .legend-item {
        gap: 10px;
        margin-bottom: 8px;
    }

    /* Mobile stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    /* Mobile nav */
    .nav-buttons {
        gap: 5px;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .nav-buttons .icon-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Mobile settings */
    .setting-options button {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* Mobile hint button */
    .btn-hint {
        font-size: 0.85rem;
        padding: 10px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .slot {
        width: 32px;
        height: 32px;
    }

    .color-btn {
        width: 40px;
        height: 40px;
    }

    .slots {
        gap: 6px;
    }

    .row-number {
        display: none;
    }
}
