@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: #04040a;
    --grid-bg: #080914;
    --panel-bg: rgba(14, 14, 32, 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;
    --neon-blue: #3b82f6;
    --text-primary: #ffffff;
    --text-muted: #8295af;
    --font-header: 'Orbitron', sans-serif;
    --font-body: 'Outfit', sans-serif;
    
    /* Dice Value Colors */
    --dice-1: #00f0f0; /* Cyan */
    --dice-2: #39ff14; /* Green */
    --dice-3: #3b82f6; /* Blue */
    --dice-4: #fff200; /* Yellow */
    --dice-5: #ff7b00; /* Orange */
    --dice-6: #ff0055; /* Pink/Red */
}

* {
    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-purple));
    -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;
    position: relative;
}

.panel-card:hover {
    border-color: rgba(0, 240, 240, 0.35);
    box-shadow: 0 0 18px rgba(0, 240, 240, 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 visual */
.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-purple));
    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: 10px;
    max-width: 440px;
    width: 100%;
    aspect-ratio: 1 / 1;
}

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

/* Grid Cells / Dice Slots */
.cell {
    background: rgba(255, 255, 255, 0.02);
    border: 1.5px solid rgba(0, 240, 240, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
}

/* Highlight state for cells where the active block can be placed */
.cell.placement-possible {
    background: rgba(0, 240, 240, 0.04);
    border-color: rgba(0, 240, 240, 0.35);
    box-shadow: 0 0 6px rgba(0, 240, 240, 0.15);
    cursor: pointer;
    animation: cellPulseHighlight 1.5s infinite ease-in-out;
}

@keyframes cellPulseHighlight {
    0% {
        border-color: rgba(0, 240, 240, 0.25);
        box-shadow: 0 0 4px rgba(0, 240, 240, 0.1);
        background: rgba(0, 240, 240, 0.03);
    }
    50% {
        border-color: rgba(0, 240, 240, 0.55);
        box-shadow: 0 0 12px rgba(0, 240, 240, 0.3);
        background: rgba(0, 240, 240, 0.08);
    }
    100% {
        border-color: rgba(0, 240, 240, 0.25);
        box-shadow: 0 0 4px rgba(0, 240, 240, 0.1);
        background: rgba(0, 240, 240, 0.03);
    }
}

/* Inside cell dice visual representation */
.dice {
    width: 82%;
    height: 82%;
    border-radius: 8px;
    background: rgba(10, 10, 25, 0.75);
    border: 2.5px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-header);
    font-size: 1.6rem;
    font-weight: 900;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-sizing: border-box;
}

/* Neon Glows for values 1-6 */
.dice-1 { color: var(--dice-1); background: rgba(0, 240, 240, 0.08); filter: drop-shadow(0 0 5px rgba(0, 240, 240, 0.4)); }
.dice-2 { color: var(--dice-2); background: rgba(57, 255, 20, 0.08); filter: drop-shadow(0 0 5px rgba(57, 255, 20, 0.4)); }
.dice-3 { color: var(--dice-3); background: rgba(59, 130, 246, 0.08); filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.4)); }
.dice-4 { color: var(--dice-4); background: rgba(255, 242, 0, 0.08); filter: drop-shadow(0 0 5px rgba(255, 242, 0, 0.4)); }
.dice-5 { color: var(--dice-5); background: rgba(255, 123, 0, 0.08); filter: drop-shadow(0 0 5px rgba(255, 123, 0, 0.4)); }
.dice-6 { color: var(--dice-6); background: rgba(255, 0, 85, 0.08); filter: drop-shadow(0 0 5px rgba(255, 0, 85, 0.4)); }

/* Flux (F) block - Rainbow Pulsing */
.dice-flux {
    background: linear-gradient(45deg, #020205, #080816);
    border: 2.5px solid transparent;
    background-image: linear-gradient(rgba(10, 10, 25, 0.85), rgba(10, 10, 25, 0.85)), 
                      linear-gradient(135deg, #ff007f, #00f0f0, #39ff14, #fff200, #ff007f);
    background-origin: border-box;
    background-clip: content-box, border-box;
    color: #ffffff;
    text-shadow: 0 0 10px #ff007f, 0 0 20px #00f0f0;
    animation: rainbowGlow 2.5s linear infinite;
    font-size: 1.7rem;
}

@keyframes rainbowGlow {
    0% { filter: drop-shadow(0 0 6px #ff007f); }
    33% { filter: drop-shadow(0 0 6px #00f0f0); }
    66% { filter: drop-shadow(0 0 6px #39ff14); }
    100% { filter: drop-shadow(0 0 6px #ff007f); }
}

/* Next Block Preview Box */
.preview-area {
    min-height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    position: relative;
}

/* Active block container containing dice items */
.preview-block-container {
    display: flex;
    gap: 6px;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    touch-action: none;
}

.preview-block-container:hover {
    transform: scale(1.08);
}

.preview-block-container:active {
    cursor: grabbing;
}

/* Next Block orientations */
.block-horizontal { flex-direction: row; }
.block-vertical { flex-direction: column; }

/* Drag and Drop ghost states */
.cell.ghost-hover {
    background: rgba(0, 240, 240, 0.15);
    border-color: var(--neon-cyan);
    box-shadow: inset 0 0 10px rgba(0, 240, 240, 0.25);
}

.cell.ghost-invalid {
    background: rgba(255, 0, 85, 0.15);
    border-color: var(--neon-magenta);
    box-shadow: inset 0 0 10px rgba(255, 0, 85, 0.25);
}

/* Selected state for click-to-place fallback */
.preview-block-container.active-select {
    outline: 2px solid var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan);
    background: rgba(0, 240, 240, 0.08);
}

/* Interactive Floating drag element */
.drag-element {
    position: fixed;
    pointer-events: none;
    z-index: 100;
    display: flex;
    gap: 6px;
    opacity: 0.85;
    transform: scale(0.9);
}

/* Drag and Drop ghost states */

/* Animations */
/* Success Merge scale down/in transition */
.cell.merge-out {
    animation: mergeOutAnim 0.35s ease-in forwards;
}

@keyframes mergeOutAnim {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

.cell.merge-in {
    animation: mergeInAnim 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes mergeInAnim {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.25); filter: brightness(1.5); }
    100% { transform: scale(1); opacity: 1; }
}

/* Flux blast wave shockwave overlay */
.cell.blast-shockwave {
    animation: blastShockwaveAnim 0.45s ease-out;
}

@keyframes blastShockwaveAnim {
    0% {
        transform: scale(1);
        background: rgba(255, 0, 127, 0.4);
        border-color: var(--neon-magenta);
        box-shadow: 0 0 20px var(--neon-magenta);
    }
    100% {
        transform: scale(1);
        background: rgba(255, 255, 255, 0.02);
        border-color: rgba(255, 255, 255, 0.04);
        box-shadow: none;
    }
}

/* Overlays inside Board Wrapper */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 4, 10, 0.9);
    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: 1.5rem;
    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;
    width: 80%;
}

.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-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(157, 78, 221, 0.15);
    }
    to {
        text-shadow: 0 0 22px rgba(0, 240, 240, 0.55), 0 0 35px rgba(157, 78, 221, 0.45);
    }
}

/* Shake screen animation */
.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;
    }
    
    #btn-reset-board {
        margin-top: 0 !important;
    }

    .board-wrapper {
        max-width: 380px;
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 500px) {
    .logo {
        font-size: 2.2rem;
    }
    
    .side-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .board-wrapper {
        border-radius: 12px;
        padding: 6px;
    }
    
    .grid-board {
        gap: 5px;
    }
    
    .instructions-panel {
        display: none; /* Save space on mobile */
    }
}

/* Ghost dice preview styling */
.ghost-dice-preview {
    opacity: 0.55;
    pointer-events: none;
    transform: scale(0.92);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
    animation: ghostPulse 1s infinite alternate ease-in-out;
}

@keyframes ghostPulse {
    from {
        opacity: 0.45;
        transform: scale(0.9);
    }
    to {
        opacity: 0.65;
        transform: scale(0.94);
    }
}


/* 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; }
