@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #030308;
    --grid-bg: #070812;
    --panel-bg: rgba(12, 12, 28, 0.65);
    --panel-border: rgba(0, 240, 240, 0.15);
    --neon-cyan: #00f0f0;
    --neon-magenta: #ff007f;
    --neon-purple: #9d4edd;
    --neon-green: #39ff14;
    --neon-yellow: #fff200;
    --neon-orange: #ff7b00;
    --text-primary: #ffffff;
    --text-muted: #8395b0;
    --font-header: 'Orbitron', sans-serif;
    --font-body: 'Outfit', sans-serif;
    
    /* Number Colors (Cyber Neon Palette) */
    --color-1: #00f0f0; /* Cyan */
    --color-2: #00fa9a; /* SpringGreen */
    --color-3: #39ff14; /* Neon Green */
    --color-4: #ccff00; /* Lime */
    --color-5: #fff200; /* Yellow */
    --color-6: #ffa500; /* Orange */
    --color-7: #ff5722; /* Deep Orange */
    --color-8: #ff0055; /* Hot Pink */
    --color-9: #b000ff; /* Neon Purple */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(157, 78, 221, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 240, 240, 0.08) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    text-align: center;
    padding: 1.5rem 1rem 0.5rem;
}

.logo {
    font-family: var(--font-header);
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 5px;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 25px rgba(0, 240, 240, 0.25);
    display: inline-block;
    animation: titleGlow 4s ease-in-out infinite alternate;
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 0.1rem;
}

/* Layout container */
.game-container {
    max-width: 1100px;
    width: 100%;
    margin: auto;
    padding: 1rem;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    flex-grow: 1;
}

/* Panels */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 220px;
    flex-shrink: 0;
}

.panel-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 1.25rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    text-align: center;
    transition: all 0.3s ease;
}

.panel-card:hover {
    border-color: rgba(255, 0, 127, 0.35);
    box-shadow: 0 0 18px rgba(255, 0, 127, 0.08);
}

.panel-card h2 {
    font-family: var(--font-header);
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-family: var(--font-header);
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

/* Combo Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
    border-radius: 3px;
    transition: width 0.1s linear;
}

/* Board Wrapper */
.board-wrapper {
    position: relative;
    border-radius: 16px;
    background: var(--grid-bg);
    box-shadow: 0 0 35px rgba(0, 240, 240, 0.12), inset 0 0 25px rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(0, 240, 240, 0.25);
    padding: 8px;
    flex-grow: 0;
    max-width: 500px;
    width: 100%;
    aspect-ratio: 1 / 1;
}

/* 10x10 Grid Board */
.grid-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 5px;
    width: 100%;
    height: 100%;
}

/* Grid Cells */
.cell {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    position: relative;
    box-sizing: border-box;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Color mappings for numbers */
.num-1 { color: var(--color-1); text-shadow: 0 0 8px rgba(0, 240, 240, 0.4); }
.num-2 { color: var(--color-2); text-shadow: 0 0 8px rgba(0, 250, 154, 0.4); }
.num-3 { color: var(--color-3); text-shadow: 0 0 8px rgba(57, 255, 20, 0.4); }
.num-4 { color: var(--color-4); text-shadow: 0 0 8px rgba(204, 255, 0, 0.4); }
.num-5 { color: var(--color-5); text-shadow: 0 0 8px rgba(255, 242, 0, 0.4); }
.num-6 { color: var(--color-6); text-shadow: 0 0 8px rgba(255, 165, 0, 0.4); }
.num-7 { color: var(--color-7); text-shadow: 0 0 8px rgba(255, 87, 34, 0.4); }
.num-8 { color: var(--color-8); text-shadow: 0 0 8px rgba(255, 0, 85, 0.4); }
.num-9 { color: var(--color-9); text-shadow: 0 0 8px rgba(176, 0, 255, 0.4); }

/* Popped / 0 cell style */
.num-0 {
    color: transparent;
    background: rgba(0, 0, 0, 0.4);
    border-style: dotted;
    border-color: rgba(255, 255, 255, 0.05);
}

.num-0::after {
    content: "•";
    color: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    position: absolute;
}

/* Selection Highlight States */
.cell.selected {
    background: rgba(0, 240, 240, 0.22);
    border-color: var(--neon-cyan);
    box-shadow: inset 0 0 10px rgba(0, 240, 240, 0.25);
    transform: scale(0.96);
}

/* Selected boundary borders to outline the selected box */
.cell.selected-top { border-top: 2px solid var(--neon-cyan); }
.cell.selected-bottom { border-bottom: 2px solid var(--neon-cyan); }
.cell.selected-left { border-left: 2px solid var(--neon-cyan); }
.cell.selected-right { border-right: 2px solid var(--neon-cyan); }

/* Pop and Clear animation */
.cell.pop-clear {
    animation: cellPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes cellPop {
    0% {
        transform: scale(1);
        background: rgba(57, 255, 20, 0.4);
        border-color: var(--neon-green);
        box-shadow: 0 0 15px var(--neon-green);
    }
    40% {
        transform: scale(1.15);
        background: rgba(57, 255, 20, 0.6);
        border-color: #fff;
    }
    100% {
        transform: scale(0);
        opacity: 0.3;
    }
}

/* Error Shake animation */
.cell.shake-error {
    animation: cellShake 0.4s ease-in-out;
}

@keyframes cellShake {
    0%, 100% { transform: translateX(0); border-color: rgba(255, 255, 255, 0.04); background: rgba(255, 255, 255, 0.02); }
    15%, 45%, 75% { transform: translateX(-4px); border-color: var(--neon-magenta); background: rgba(255, 0, 85, 0.15); }
    30%, 60%, 90% { transform: translateX(4px); border-color: var(--neon-magenta); background: rgba(255, 0, 85, 0.15); }
}

/* Hint pulse animation */
.cell.hint-pulse {
    animation: hintPulseAnim 1.2s infinite alternate;
}

@keyframes hintPulseAnim {
    0% {
        box-shadow: 0 0 4px var(--neon-yellow);
        border-color: rgba(255, 242, 0, 0.3);
        background: rgba(255, 242, 0, 0.05);
    }
    100% {
        box-shadow: 0 0 14px var(--neon-yellow);
        border-color: var(--neon-yellow);
        background: rgba(255, 242, 0, 0.2);
    }
}

/* Floating Sum Bubble */
.sum-bubble {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(12, 12, 28, 0.9);
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(0, 240, 240, 0.25);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.sum-bubble.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sum-bubble.valid {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px rgba(57, 255, 20, 0.35);
}

.sum-bubble.invalid {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 0, 85, 0.35);
}

/* Overlays inside Board Wrapper */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 3, 8, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 2rem;
    text-align: center;
    border-radius: 14px;
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-title {
    font-family: var(--font-header);
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 1.25rem;
    letter-spacing: 2px;
}

#start-screen .overlay-title {
    background: linear-gradient(45deg, var(--neon-cyan), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 240, 240, 0.2);
}

#gameover-screen .overlay-title {
    background: linear-gradient(45deg, var(--neon-magenta), var(--neon-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 0, 127, 0.2);
}

.overlay-stats {
    margin-bottom: 1.75rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 1rem 2rem;
}

.overlay-stats span {
    color: #fff;
    font-weight: bold;
    font-family: var(--font-header);
    margin-left: 0.25rem;
}

/* Neon buttons */
.btn-neon {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 0.8rem 1.75rem;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 240, 240, 0.15);
    outline: none;
}

.btn-neon:hover {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 240, 240, 0.7);
}

.btn-neon-magenta {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.15);
}

.btn-neon-magenta:hover {
    background: var(--neon-magenta);
    color: #000;
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.7);
}

/* Sidebar Action Buttons */
.btn-neon-action {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: var(--font-header);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    outline: none;
}

.btn-neon-action:hover:not(:disabled) {
    background: rgba(0, 240, 240, 0.1);
    box-shadow: 0 0 10px rgba(0, 240, 240, 0.3);
}

.btn-neon-action:disabled {
    border-color: rgba(131, 149, 176, 0.3);
    color: rgba(131, 149, 176, 0.4);
    cursor: not-allowed;
}

.btn-magenta-action {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
}

.btn-magenta-action:hover:not(:disabled) {
    background: rgba(255, 0, 127, 0.1);
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
}

.action-icon {
    font-size: 1rem;
}

/* Settings Controls & Toggles */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #242533;
    transition: .3s;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #8395b0;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: rgba(0, 240, 240, 0.2);
    border-color: var(--neon-cyan);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--neon-cyan);
    box-shadow: 0 0 8px var(--neon-cyan);
}

/* Desktop Help Section */
.instructions-panel {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    width: 100%;
}

.instruction-group {
    background: rgba(12, 12, 28, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 1.25rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.instruction-group h3 {
    font-family: var(--font-header);
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    color: var(--neon-cyan);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.key-list {
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.key-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    line-height: 1.4;
}

.key-list li:last-child {
    border: none;
}

.key-list span:last-child {
    color: #ffffff;
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: auto;
}

/* Animations */
@keyframes titleGlow {
    from {
        text-shadow: 0 0 10px rgba(0, 240, 240, 0.25), 0 0 20px rgba(255, 0, 127, 0.15);
    }
    to {
        text-shadow: 0 0 22px rgba(0, 240, 240, 0.55), 0 0 35px rgba(255, 0, 127, 0.45);
    }
}

/* Screen Shake effect for incorrect match */
.shake {
    animation: shakeAnim 0.15s ease-in-out 2;
}

@keyframes shakeAnim {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 3px); }
    50% { transform: translate(4px, -2px); }
    75% { transform: translate(-3px, -3px); }
    100% { transform: translate(0, 0); }
}

/* Responsive Rules */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        align-items: center;
        padding: 0.75rem;
        gap: 1.25rem;
    }

    .side-panel {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .panel-card {
        flex: 1;
        min-width: 160px;
        padding: 1rem;
    }

    .panel-card h2 {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
    
    #card-actions {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    
    #btn-reset-board {
        margin-top: 0 !important;
    }

    .board-wrapper {
        max-width: 480px;
        aspect-ratio: 1 / 1;
    }
    
    .cell {
        font-size: 1.3rem;
    }
}

@media (max-width: 500px) {
    .logo {
        font-size: 2.2rem;
    }
    
    .side-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    #card-actions {
        flex-direction: column;
    }
    
    #btn-reset-board {
        margin-top: 0.75rem !important;
    }
    
    .board-wrapper {
        border-radius: 12px;
        padding: 5px;
    }
    
    .grid-board {
        gap: 3px;
    }
    
    .cell {
        font-size: 1.1rem;
        border-radius: 4px;
    }
    
    .instructions-panel {
        display: none; /* Save space on mobile */
    }
}


/* Embedded in the Skorven game player (iframe): hide standalone-page chrome
   so the game board fits the player frame. Direct/standalone view is unchanged. */
.embedded header,
.embedded footer,
.embedded .instructions-panel { display: none !important; }
.embedded .game-container { padding-top: 0.75rem; padding-bottom: 0.75rem; }
