:root {
    --primary: #00A6ED; /* Cold blue */
    --accent: #E32636; /* Blackhawks red accent */
    --text: #ffffff;
    --glass-bg: rgba(10, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.15);
}

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

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    background-color: #111;
    overflow: hidden;
    touch-action: none; /* Crucial for swipe controls */
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: absolute;
    top: 5vh;
    left: 5vw;
    width: 90vw;
    height: 90vh;
    z-index: 1;
    background: 
        url('assets/download.png') center/min(250px, 45%) no-repeat,
        radial-gradient(circle at center, transparent min(15vw, 15vh), #E32636 min(15vw, 15vh), #E32636 calc(min(15vw, 15vh) + 5px), transparent calc(min(15vw, 15vh) + 6px)),
        linear-gradient(to bottom, transparent calc(50% - 3px), #E32636 calc(50% - 3px), #E32636 calc(50% + 3px), transparent calc(50% + 3px)),
        linear-gradient(to bottom, transparent calc(30% - 4px), #00A6ED calc(30% - 4px), #00A6ED calc(30% + 4px), transparent calc(30% + 4px)),
        linear-gradient(to bottom, transparent calc(70% - 4px), #00A6ED calc(70% - 4px), #00A6ED calc(70% + 4px), transparent calc(70% + 4px)),
        url('assets/ice_texture.png') center/cover;
    border: 12px solid #fff;
    border-radius: min(10vw, 10vh); /* perfectly responsive rounded corners */
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 0 0 8px var(--accent), 0 10px 40px rgba(0,0,0,0.8);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none; /* Let touches pass through to canvas when safe */
    display: flex;
    flex-direction: column;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Scoreboard */
#scoreboard {
    width: 90%;
    max-width: 400px;
    margin: 16px auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

#scoreboard.move-away {
    transform: translateY(-120%);
    opacity: 0.1;
}

.score-logo img {
    height: 48px;
    object-fit: contain;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat span {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.stat strong {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Screens */
.screen {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 380px;
    padding: 32px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.screen h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
    text-transform: uppercase;
    background: linear-gradient(to right, #fff, #b3d4ff);
    -webkit-background-clip: text;
    color: transparent;
}

.screen h2 {
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 16px;
}

.screen p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 24px;
}

/* Controls selection */
.controls-selector {
    margin-bottom: 24px;
    text-align: left;
}

.controls-selector p {
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.control-btn {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 166, 237, 0.4);
    transition: transform 0.1s, filter 0.2s;
}

.primary-btn:active {
    transform: scale(0.96);
}

.primary-btn:hover {
    filter: brightness(1.1);
}

.results {
    margin-bottom: 24px;
    text-align: left;
    background: rgba(0,0,0,0.3);
    padding: 16px;
    border-radius: 8px;
}

.results p {
    margin: 8px 0;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
}

.results span {
    font-weight: 800;
}

/* D-PAD Controls */
#dpad-controls {
    pointer-events: auto;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.dpad-row {
    display: flex;
    gap: 4px;
}

.dpad-center {
    width: 60px;
    height: 60px;
}

.dir-btn {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
}

.dir-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ════════════════════════════════════════════════════════════
   WIN SCREEN & RAFFLE
   ════════════════════════════════════════════════════════════ */

#win-screen {
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 28px 20px;
    animation: winSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes winSlideIn {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Trophy Badge */
.win-badge {
    margin: 0 auto 8px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5), 0 0 60px rgba(255, 165, 0, 0.2);
    animation: trophyPulse 2s ease-in-out infinite;
}

.trophy {
    font-size: 2rem;
}

@keyframes trophyPulse {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.5), 0 0 60px rgba(255, 165, 0, 0.2); transform: scale(1); }
    50%      { box-shadow: 0 0 40px rgba(255, 215, 0, 0.7), 0 0 80px rgba(255, 165, 0, 0.35); transform: scale(1.05); }
}

.win-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(to right, #FFD700, #FFA500, #FFD700);
    background-size: 200% auto;
    -webkit-background-clip: text;
    color: transparent;
    animation: goldShimmer 3s linear infinite;
    margin-bottom: 12px;
}

@keyframes goldShimmer {
    0%   { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* Raffle Section */
#raffle-section {
    margin: 16px 0;
    padding: 20px;
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
}

.raffle-header {
    text-align: center;
    margin-bottom: 16px;
}

.raffle-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 4px;
}

.raffle-header h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #FFD700;
    margin-bottom: 6px;
}

.raffle-sub {
    font-size: 0.85rem !important;
    opacity: 0.8;
    margin-bottom: 0 !important;
    line-height: 1.4;
}

/* Form */
#raffle-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#raffle-form input {
    width: 100%;
    padding: 12px 16px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#raffle-form input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#raffle-form input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(0, 166, 237, 0.2);
}

.raffle-btn {
    margin-top: 4px;
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: #1a1a1a !important;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3) !important;
    font-weight: 800;
    position: relative;
}

.raffle-btn:hover {
    filter: brightness(1.15);
}

.raffle-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Raffle Messages */
.raffle-msg {
    text-align: center;
    font-size: 0.9rem;
    margin-top: 10px !important;
    margin-bottom: 0 !important;
    min-height: 1.3em;
    transition: opacity 0.3s;
}

.raffle-msg.success {
    color: #4ade80;
}

.raffle-msg.error {
    color: #f87171;
}

.raffle-msg.info {
    color: #FFD700;
}

/* Secondary Button */
.secondary-btn {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.secondary-btn:active {
    transform: scale(0.96);
}

/* Confetti Burst */
.confetti-burst {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: 16px;
    z-index: 0;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0%   { opacity: 1; transform: translateY(-20px) rotate(0deg) scale(1); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(400px) rotate(720deg) scale(0.3); }
}

/* Hide scrollbar for win screen */
#win-screen::-webkit-scrollbar {
    width: 4px;
}
#win-screen::-webkit-scrollbar-track {
    background: transparent;
}
#win-screen::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
