/* Numberblocks Restructuring Adventure stylesheet */
:root {
    --bg-dark: #0f111a;
    --card-bg: rgba(25, 28, 47, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #b3b9d1;
    
    /* Numberblocks Colors (HSL for vibrancy) */
    --color-one: hsl(0, 100%, 55%);      /* Red */
    --color-two: hsl(30, 100%, 55%);     /* Orange */
    --color-three: hsl(50, 100%, 55%);   /* Yellow */
    --color-four: hsl(120, 75%, 45%);    /* Green */
    --color-five: hsl(205, 95%, 55%);    /* Blue */
    --color-gray: hsl(220, 10%, 60%);    /* Single Uncollected block */
    
    --accent: hsl(45, 100%, 50%);        /* Gold for magic mirror */
}

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

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1b1e36 0%, #0a0b12 100%);
}

#game-container {
    position: relative;
    width: 960px;
    height: 540px;
    background-color: #111;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7),
                0 0 40px rgba(74, 85, 218, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.05);
}

/* Canvas Styles */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1d203f 0%, #111224 100%);
}

/* Screens overlays */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(10, 11, 20, 0.7);
    backdrop-filter: blur(8px);
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 0;
    visibility: hidden;
}

.overlay-screen.active {
    opacity: 1;
    visibility: visible;
}

.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Modern glassmorphic cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2.5rem 3.5rem;
    border-radius: 24px;
    text-align: center;
    max-width: 540px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Logo Animation in Start Screen */
.title-logo {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.logo-block {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1.4rem;
    color: #000;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    animation: floatLogo 2s infinite ease-in-out alternate;
    animation-delay: var(--delay);
}

.logo-block.red { background-color: var(--color-one); }
.logo-block.orange { background-color: var(--color-two); }
.logo-block.yellow { background-color: var(--color-three); }
.logo-block.green { background-color: var(--color-four); }
.logo-block.blue { background-color: var(--color-five); }

@keyframes floatLogo {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-10px) rotate(8deg); }
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
}

.highlight {
    background: linear-gradient(135deg, var(--color-three) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Controls panel in menu */
.controls-guide {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.2rem;
    margin-bottom: 2rem;
    text-align: left;
}

.controls-guide h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.4rem;
}

.control-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.6rem;
}

.control-row:last-child {
    margin-bottom: 0;
}

.key {
    background: #2e324c;
    border: 1px solid #4a5078;
    border-bottom: 3px solid #1a1c2c;
    border-radius: 6px;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 28px;
    text-align: center;
    display: inline-block;
}

.key.space {
    min-width: 90px;
}

.desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Button systems */
.btn-group {
    display: flex;
    justify-content: center;
    gap: 12px;
}

button {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, #4d5efc 0%, #2b39b3 100%);
    color: #fff;
    padding: 0.9rem 2rem;
    font-size: 1.1rem;
    border-radius: 14px;
    box-shadow: 0 8px 16px rgba(77, 94, 252, 0.3),
                inset 0 1px 0 rgba(255,255,255,0.2);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(77, 94, 252, 0.4);
}

.primary-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
    border-radius: 14px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.pulse {
    animation: pulsing 1.8s infinite alternate;
}

@keyframes pulsing {
    0% { box-shadow: 0 8px 16px rgba(77, 94, 252, 0.3); }
    100% { box-shadow: 0 8px 24px rgba(77, 94, 252, 0.6), 0 0 12px rgba(77, 94, 252, 0.3); }
}

/* HUD System overlaying canvas */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Let canvas drag/click work, but buttons handle overlay */
    transition: opacity 0.3s ease;
}

.hud-item {
    background: rgba(18, 20, 38, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    pointer-events: auto;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.hud-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.hud-value {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #c4cbef 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Active configuration shape HUD grid */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(5, 7px);
    grid-template-rows: repeat(5, 7px);
    gap: 2px;
    width: 45px;
    height: 45px;
    background: rgba(0,0,0,0.3);
    padding: 3px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
}

.shape-cell {
    width: 6px;
    height: 6px;
    border-radius: 1px;
    background-color: transparent;
}

.shape-cell.active-cell {
    background-color: var(--color-one);
    box-shadow: 0 0 3px var(--color-one);
}

.hud-buttons {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.icon-btn {
    background: rgba(18, 20, 38, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

/* Victory Screen Details */
.victory-card {
    border-color: rgba(252, 211, 77, 0.3);
    box-shadow: 0 20px 40px rgba(252, 211, 77, 0.1),
                inset 0 1px 0 rgba(252, 211, 77, 0.2);
}

.victory-crown {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: crownFloat 2s infinite ease-in-out alternate;
}

@keyframes crownFloat {
    0% { transform: translateY(0px) scale(1); }
    100% { transform: translateY(-8px) scale(1.05); }
}

.victory-stats {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.stat-box {
    background: rgba(252, 211, 77, 0.08);
    border: 1px solid rgba(252, 211, 77, 0.2);
    padding: 0.8rem 2.5rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fcd34d;
    text-shadow: 0 0 10px rgba(252, 211, 77, 0.4);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Game Over Screen Details */
.gameover-emoji {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.gameover-card {
    border-color: rgba(239, 68, 68, 0.2);
}

/* Custom Overrides for Floating, Non-Masking Victory Screen */
#victory-screen {
    background-color: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none !important;
}

#victory-screen .victory-card {
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-sizing: border-box !important;
    padding-top: 40px !important;
    padding-bottom: 40px !important;
    pointer-events: none !important; /* Let clicks pass through the card layout... */
}

/* Hide the crown icon, subtitle description, and stats blocks count as requested */
#victory-screen .victory-crown,
#victory-screen .subtitle,
#victory-screen .victory-stats {
    display: none !important;
}

/* Float a giant gorgeous title at the top of the viewport */
#victory-screen h1 {
    font-size: 3.2rem !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    color: #ffffff !important;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.8), 
                 0 0 30px rgba(252, 211, 77, 0.6) !important;
    margin: 0 !important;
    text-align: center !important;
    pointer-events: none !important;
    animation: slideUpVictory 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Enable pointer events ONLY on the play again button floating at the bottom center */
#victory-screen #play-again-btn {
    margin-bottom: 20px !important;
    pointer-events: auto !important;
    animation: slideUpVictory 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpVictory {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Premium Easy Mode Checkbox Styling */
.easy-mode-container {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.easy-mode-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #4ade80; /* bright green */
    cursor: pointer;
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.easy-mode-label:hover {
    background: rgba(74, 222, 128, 0.15);
    transform: scale(1.02);
}

.easy-mode-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #22c55e;
}

/* Hard-code touch suppression on interactive layers */
#game-container, #gameCanvas, .touch-btn, #touch-controls {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* Touch controls overlay layout */
#touch-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 8;
    display: flex;
    justify-content: space-between;
    pointer-events: none; /* Let clicks pass through empty spaces to canvas */
    user-select: none;
}

.touch-left-group, .touch-right-group {
    display: flex;
    gap: 15px;
    pointer-events: auto; /* Buttons capture touches */
}

.touch-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(18, 20, 38, 0.65);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 2.2rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 0.05s ease, background 0.05s ease;
    touch-action: none;
}

/* Green Jump button with JUMP text */
.touch-btn.jump-btn {
    background: rgba(34, 197, 94, 0.7);
    border-color: rgba(74, 222, 128, 0.45);
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.25);
    font-size: 1.05rem; /* Smaller text size for JUMP text */
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Blue Star button */
.touch-btn.star-btn {
    background: rgba(59, 130, 246, 0.7);
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
    color: #fcd34d; /* Golden star */
}

.touch-btn:active {
    transform: scale(0.85);
    background: rgba(255, 255, 255, 0.25);
}

.touch-btn.jump-btn:active {
    background: rgba(34, 197, 94, 0.9);
}

.touch-btn.star-btn:active {
    background: rgba(59, 130, 246, 0.9);
}
