

:root {
    --tile-size: clampclamp(30px, 5vw, 4vw);
    --primary-blue: #368dc7;
    --primary-orange: #f8a04b;
    --bg-light: #f0f5fa;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --text-dark: #1e2b3a;
    --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 20px 30px -10px rgba(0, 0, 0, 0.2);
    --border-radius: 32px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


.tile,
.icon-overlay,
#game-board,
#game-board-container {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

body {
    font-family: 'Montserrat', 'Inter', sans-serif;
    background: linear-gradient(45deg,
            #ffd966,
            #ffb347,
            #ff8c69,
            #6eb5ff,
            #b983ff,
            #ff99c8);
    background-size: 400% 400%;
    animation: vibrantFlow 12s ease infinite;
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 105, 180, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(54, 141, 199, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 70% 20%, rgba(248, 160, 75, 0.3) 0%, transparent 40%),
        repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.03) 0px,
            rgba(255, 255, 255, 0.03) 20px,
            rgba(255, 255, 255, 0.06) 20px,
            rgba(255, 255, 255, 0.06) 40px);
    animation:
        lightPulse 8s ease-in-out infinite,
        subtleShift 15s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.8) 4px, transparent 8px),
        radial-gradient(circle at 30% 60%, rgba(0, 255, 255, 0.5) 6px, transparent 12px),
        radial-gradient(circle at 50% 30%, rgba(255, 0, 255, 0.5) 8px, transparent 16px),
        radial-gradient(circle at 70% 80%, rgba(255, 255, 0, 0.5) 5px, transparent 10px),
        radial-gradient(circle at 90% 40%, rgba(0, 255, 0, 0.5) 7px, transparent 14px),
        radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.8) 6px, transparent 12px),
        radial-gradient(circle at 45% 15%, rgba(0, 255, 255, 0.5) 8px, transparent 16px),
        radial-gradient(circle at 85% 95%, rgba(255, 0, 255, 0.5) 7px, transparent 14px);
    background-size: 400px 400px;
    animation: floatParticles 25s linear infinite;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

@keyframes vibrantFlow {
    0% { background-position: 0% 0%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 0%; }
}

@keyframes lightPulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.7; }
    100% { opacity: 0.3; }
}

@keyframes subtleShift {
    0% { background-position: 0% 0%; }
    50% { background-position: 5% 5%; }
    100% { background-position: 0% 0%; }
}

@keyframes floatParticles {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.main-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    padding: 16px;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.logo-column {
    flex: 0 0 25%;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.9);
    padding: 20px;
}

.vertical-logo {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    border-radius: 40px;
    display: block;
}

.victory-msg {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-radius: 60px;
    border: 4px solid var(--primary-orange);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-dark);
    box-shadow: var(--shadow-md);
    z-index: 30;
    padding: 36px 28px;
}

.victory-msg h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 12px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.victory-msg p {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #334155;
}

.prize-line {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 16px 0 24px;
    color: var(--primary-blue);
    background: rgba(248, 160, 75, 0.1);
    padding: 10px 24px;
    border-radius: 40px;
    border: 1px dashed var(--primary-orange);
}

#prize-value {
    color: var(--primary-orange);
    font-weight: 800;
    text-transform: uppercase;
}

.victory-msg .btn {
    font-size: 1.2rem;
    padding: 14px 32px;
}

.game-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    height: 100%;
}

.header-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.game-title {
    font-size: 1.9rem;
    font-weight: 800;
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, var(--primary-blue), #1e4f72);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    max-width: 600px;
}

.stats {
    display: flex;
    gap: 20px;
    background: #e2eaf2;
    padding: 8px 22px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.stats span span {
    background: white;
    color: var(--primary-orange);
    padding: 4px 12px;
    border-radius: 30px;
    margin-left: 8px;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}

#game-board-container {
    backdrop-filter: blur(8px);
    border-radius: 36px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#game-board {
    display: grid;
    gap: 6px;
    width: fit-content;
    height: fit-content;
    margin: auto;
}


.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    background-color: #ff69b4;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: neonBg 4s ease infinite;
}

@keyframes neonBg {
    0% { background-color: #00ff7f; }
    25% { background-color: #00ccff; }
    50% { background-color: #ff00ff; }
    75% { background-color: #ffaa00; }
    100% { background-color: #00ff7f; }
}

.tile:hover {
    transform: scale(1.02);
}

.tile.connected {
    filter: brightness(1.1);
    animation: connectedNeonBg 3s ease infinite;
}

@keyframes connectedNeonBg {
    0% { background-color: #87ff41; }
    25% { background-color: #14ffb8; }
    50% { background-color: #00ffff; }
    75% { background-color: #ffd700; }
    100% { background-color: #87ff41; }
}

.icon-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-size: 65%;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)) drop-shadow(0 0 3px white);
    transition: transform 0.2s ease;
}

.controls {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-radius: 40px;
    padding: 16px 24px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.controls .row {
    margin: 8px 0;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 28px;
    background: white;
    color: var(--primary-blue);
    border: 1px solid rgba(54, 141, 199, 0.2);
    border-radius: 60px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.3px;
}

.btn:hover {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 12px 20px -10px rgba(54, 141, 199, 0.5);
}

.btn:active {
    transform: translateY(1px);
}

.action-btn {
    background: var(--primary-orange);
    color: white;
    border: none;
    box-shadow: 0 8px 16px -6px rgba(248, 160, 75, 0.4);
}

.action-btn:hover {
    background: #e08b3a;
    color: white;
}

.row .btn:not(.action-btn) {
    background: #eef2f6;
    color: var(--primary-blue);
    border: 1px solid transparent;
}

.row .btn:not(.action-btn):hover {
    background: var(--primary-blue);
    color: white;
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}


.timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 
        0 0 10px var(--primary-orange),
        0 0 20px var(--primary-orange),
        0 0 40px var(--primary-orange),
        0 0 80px var(--primary-orange);
    z-index: 20;
    transition: all 0.3s ease;
    pointer-events: none;
    animation: timerPulse 1s ease-in-out infinite;
    opacity: 0.95;
    white-space: nowrap;
}

@keyframes timerPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 0 10px var(--primary-orange), 0 0 20px var(--primary-orange);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        text-shadow: 0 0 20px var(--primary-orange), 0 0 40px var(--primary-orange), 0 0 60px #ff0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 0 10px var(--primary-orange), 0 0 20px var(--primary-orange);
    }
}

.timer.critical {
    color: #ff4444;
    animation: timerCritical 0.5s ease-in-out infinite;
    font-size: 18rem;
    text-shadow: 
        0 0 20px #ff0000,
        0 0 40px #ff0000,
        0 0 80px #ff0000,
        0 0 120px #ff0000;
}

@keyframes timerCritical {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.timer.warning {
    color: #ffaa00;
    animation: timerWarning 0.8s ease-in-out infinite;
    font-size: 16rem;
    text-shadow: 
        0 0 15px #ffaa00,
        0 0 30px #ffaa00,
        0 0 60px #ffaa00;
}

@keyframes timerWarning {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.timeout-msg {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    border-radius: 60px;
    border: 4px solid #ff4444;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    box-shadow: 0 0 50px rgba(255, 68, 68, 0.5);
    z-index: 40;
    padding: 36px 28px;
}

.timeout-msg h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 12px;
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

.timeout-msg p {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #fff;
}

.timeout-msg .btn {
    font-size: 1.2rem;
    padding: 14px 32px;
    background: #ff4444;
    color: white;
    border: none;
}

.timeout-msg .btn:hover {
    background: #ff6666;
    box-shadow: 0 0 30px #ff4444;
}


body.light-mode {
    animation: none !important;
}

body.light-mode::before,
body.light-mode::after {
    animation: none !important;
    opacity: 0.2 !important;
}

body.light-mode .tile {
    animation: none !important;
    background-color: #87CEEB !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
}

body.light-mode .tile.connected {
    animation: none !important;
    background-color: #90EE90 !important;
}

body.light-mode .timer {
    animation: none !important;
    font-size: 12rem !important;
}

body.light-mode .timer.warning,
body.light-mode .timer.critical {
    animation: none !important;
}

body.light-mode #game-board-container {
    animation: none !important;
    backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.5) !important;
}

body.light-mode .icon-overlay {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)) !important;
}

@media (max-height: 700px) {
    :root {
        --tile-size: clamp(50px, 5vh, 8vw);
    }
}

@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
    }

    .logo-column {
        flex: 0 0 auto;
        width: 100%;
        height: 20vh;
    }

    .vertical-logo {
        max-width: 150px;
    }

    .game-title {
        font-size: 1.4rem;
    }

    .victory-msg {
        max-width: 90%;
        padding: 24px 16px;
    }

    .victory-msg h2 {
        font-size: 1.8rem;
    }

    .prize-line {
        font-size: 1.2rem;
    }
    
    .timer {
        font-size: 8rem;
    }
    
    .timer.warning {
        font-size: 9rem;
    }
    
    .timer.critical {
        font-size: 10rem;
    }
}




@media (max-width: 900px) {
    .victory-msg,
    .timeout-msg {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 400px;
        z-index: 10000;
    }
    
    .prize-stock {
        font-size: 1rem;
        color: #666;
        margin-top: 8px;
        padding: 4px 12px;
        background: rgba(0,0,0,0.05);
        border-radius: 20px;
    }
}

.prize-stock {
    font-size: 1rem;
    color: var(--primary-blue);
    margin: 8px 0 16px;
    padding: 4px 16px;
    background: rgba(54, 141, 199, 0.1);
    border-radius: 30px;
    display: inline-block;
}

#stock-count {
    font-weight: 800;
    color: var(--primary-orange);
}




.prize-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 16px;
    z-index: 10001;
    max-width: 300px;
    border-left: 5px solid var(--primary-orange);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


.prize-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 16px;
    z-index: 10001;
    max-width: 300px;
    border-left: 5px solid var(--primary-orange);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.prize-notification .notification-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prize-notification p {
    margin: 0;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.prize-notification .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
}

#download-prizes-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(54,141,199,0.3);
}

#download-prizes-btn:hover {
    background: #2a6792;
}

#upload-prizes-btn {
    background: var(--primary-orange);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(248,160,75,0.3);
}

#upload-prizes-btn:hover {
    background: #e08b3a;
}