:root {
    --bg-dark: #0f0c1b;
    --primary: #ff3366;
    --primary-glow: rgba(255, 51, 102, 0.4);
    --secondary: #ffb800;
    --accent: #00f2fe;
    --accent-purple: #9d4edd;
    --card-bg: rgba(26, 21, 48, 0.75);
    --card-border: rgba(255, 255, 255, 0.12);
    --text-main: #ffffff;
    --text-muted: #a09cb5;
}

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

body {
    font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(255, 51, 102, 0.18) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(157, 78, 221, 0.2) 0%, transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(0, 242, 254, 0.15) 0%, transparent 50%),
        linear-gradient(180deg, #0b0816 0%, #17112c 100%);
    background-attachment: fixed;
}

/* Background floating balloons */
.floating-balloons {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.balloon {
    position: absolute;
    bottom: -100px;
    font-size: 2.5rem;
    animation: floatUp 14s linear infinite;
    opacity: 0.6;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
    }
    90% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(-120vh) rotate(25deg);
        opacity: 0;
    }
}

/* App Container */
.app-container {
    position: relative;
    z-index: 2;
    max-width: 1300px;
    margin: 0 auto;
    padding: 15px 20px 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    margin-bottom: 20px;
    animation: fadeInDown 0.8s ease-out;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 2.4rem;
    filter: drop-shadow(0 0 12px var(--primary));
    animation: bounce 2s infinite ease-in-out;
}

.logo-title {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 50%, #fbc531 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.logo-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    border: none;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff4b2b 0%, #ff416c 100%);
    box-shadow: 0 6px 20px rgba(255, 75, 43, 0.6);
}

/* Main Layout Grid */
.game-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    flex: 1;
}

/* Game Arena */
.game-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Status Bar */
.game-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 20px;
    margin-bottom: 16px;
}

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

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.stat-value.score {
    color: #fbc531;
    text-shadow: 0 0 12px rgba(251, 197, 49, 0.6);
}

.stat-value.combo {
    color: #ff3366;
    animation: pulseCombo 0.3s ease-in-out;
}

@keyframes pulseCombo {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Arena Stage */
.stage-wrapper {
    position: relative;
    flex: 1;
    min-height: 480px;
    background: radial-gradient(circle at center, #241947 0%, #120b24 100%);
    border-radius: 20px;
    overflow: hidden;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
    cursor: crosshair;
}

/* Dynamic Fireworks & Overlay Canvas */
#fireworksCanvas, #effectsCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#effectsCanvas {
    z-index: 15;
}

/* Target Area */
.target-character {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 190px;
    height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: transform 0.08s linear;
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.5));
}

.target-img-wrap {
    position: relative;
    width: 170px;
    height: 210px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.target-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 20px;
    transition: all 0.2s ease;
}

/* Birthday party hat on character */
.party-hat {
    position: absolute;
    top: -38px;
    left: 48%;
    transform: translateX(-50%) rotate(10deg);
    font-size: 3rem;
    z-index: 8;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
    animation: hatWiggle 3s ease-in-out infinite;
}

@keyframes hatWiggle {
    0%, 100% { transform: translateX(-50%) rotate(10deg); }
    50% { transform: translateX(-50%) rotate(-10deg); }
}

.target-badge {
    position: absolute;
    bottom: -10px;
    background: linear-gradient(135deg, #ff416c, #8a2387);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.3);
}

/* Splat Overlay Container on Character */
.splat-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 7;
}

.splat-mark {
    position: absolute;
    width: 120px;
    height: 120px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: translate(-50%, -50%) scale(0);
    animation: splatPop 0.25s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

@keyframes splatPop {
    0% { transform: translate(-50%, -50%) scale(0.2) rotate(0deg); opacity: 0.8; }
    80% { transform: translate(-50%, -50%) scale(1.15) rotate(15deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1) rotate(10deg); opacity: 0.95; }
}

/* Shake when hit */
.target-character.hit-shake {
    animation: hitVibration 0.4s ease-in-out;
}

@keyframes hitVibration {
    0% { transform: translate(-50%, -50%) rotate(0deg) scale(1.05); }
    20% { transform: translate(-55%, -48%) rotate(-8deg) scale(0.95); }
    40% { transform: translate(-45%, -52%) rotate(8deg) scale(1.02); }
    60% { transform: translate(-52%, -49%) rotate(-4deg); }
    80% { transform: translate(-48%, -51%) rotate(4deg); }
    100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}

/* Stars circling when stunned */
.stars-stun {
    position: absolute;
    top: -20px;
    font-size: 1.4rem;
    animation: spinStars 1.5s linear infinite;
    display: none;
}

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

/* Throwing Sling / Cannon Area */
.launcher-zone {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
    pointer-events: none;
}

.cake-ammo-display {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 20px var(--primary-glow);
    cursor: grab;
    pointer-events: auto;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cake-ammo-display:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(255, 51, 102, 0.6);
}

.cake-ammo-display:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.aim-hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Grand Hit Celebration Banner */
.grand-celebration {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 30;
    pointer-events: none;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
    opacity: 0;
}

.grand-celebration.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.celebration-title {
    font-size: 2.8rem;
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffe259 0%, #ffa751 50%, #ff5252 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 5px 20px rgba(255, 215, 0, 0.8));
    letter-spacing: 2px;
    white-space: nowrap;
    animation: textGlow 1.5s ease-in-out infinite alternate;
}

.celebration-sub {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8), 0 0 15px #ff4081;
    margin-top: 5px;
}

@keyframes textGlow {
    0% { filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6)); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 82, 82, 0.9)); }
}

/* Floating Points text */
.floating-text {
    position: absolute;
    font-weight: 900;
    font-size: 1.6rem;
    pointer-events: none;
    z-index: 25;
    animation: floatUpFade 1s forwards ease-out;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

@keyframes floatUpFade {
    0% { transform: translateY(0) scale(0.8); opacity: 1; }
    50% { transform: translateY(-30px) scale(1.3); opacity: 1; }
    100% { transform: translateY(-70px) scale(1); opacity: 0; }
}

/* Cake Selection Bar */
.cake-selector-card {
    margin-top: 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 12px 16px;
}

.cake-selector-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cake-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cake-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 8px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.cake-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.cake-btn.active {
    background: linear-gradient(135deg, rgba(255, 51, 102, 0.3), rgba(157, 78, 221, 0.3));
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.cake-btn .c-icon {
    font-size: 1.8rem;
}

.cake-btn .c-name {
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.cake-btn .c-pts {
    font-size: 0.68rem;
    color: var(--secondary);
    font-weight: 800;
}

/* Sidebar Components */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.side-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.side-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

/* Leaderboard List */
.rank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.rank-list::-webkit-scrollbar {
    width: 4px;
}
.rank-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.rank-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.88rem;
    transition: transform 0.2s ease;
}

.rank-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(3px);
}

.rank-item.top-1 {
    border-color: rgba(251, 197, 49, 0.4);
    background: linear-gradient(90deg, rgba(251, 197, 49, 0.15), transparent);
}

.rank-badge {
    font-weight: 800;
    width: 24px;
    color: var(--text-muted);
}

.rank-item.top-1 .rank-badge { color: #fbc531; font-size: 1.1rem; }
.rank-item.top-2 .rank-badge { color: #dcdde1; font-size: 1.05rem; }
.rank-item.top-3 .rank-badge { color: #e1b12c; font-size: 1rem; }

.rank-name {
    flex: 1;
    font-weight: 600;
    margin-left: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-score {
    font-weight: 800;
    color: var(--secondary);
}

/* Wishes Wall */
.wishes-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 12px;
}

.wish-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.82rem;
}

.wish-sender {
    font-weight: 700;
    color: #ff758c;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
}

.wish-text {
    color: #ddd;
    line-height: 1.35;
}

/* Input & Form Elements */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.input-field {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    color: #fff;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

textarea.input-field {
    resize: none;
    min-height: 60px;
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-card {
    background: #19142b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    padding: 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Game Over Card */
.game-over-summary {
    text-align: center;
    margin-bottom: 20px;
}

.final-score {
    font-size: 3.5rem;
    font-weight: 900;
    color: #fbc531;
    text-shadow: 0 0 20px rgba(251, 197, 49, 0.5);
    margin: 10px 0;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ==========================================================================
   Mobile & Responsive Optimization
   ========================================================================== */

/* Prevent pinch-zoom & accidental scroll on game stage */
.stage-wrapper {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 960px) {
    .app-container {
        padding: 10px 12px 30px;
    }

    .game-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .game-card {
        padding: 14px;
        border-radius: 20px;
    }

    .stage-wrapper {
        min-height: 420px;
        height: 52vh;
    }
}

@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 16px;
    }

    .logo-area {
        justify-content: center;
        text-align: center;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .logo-title {
        font-size: 1.25rem;
    }

    .logo-sub {
        font-size: 0.75rem;
    }

    .header-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .header-controls .icon-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        justify-content: center;
        border-radius: 10px;
    }

    .header-controls .btn-primary {
        grid-column: span 2;
    }

    /* Status Bar on mobile */
    .game-stats-bar {
        padding: 8px 10px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    /* Stage & Target on mobile */
    .stage-wrapper {
        min-height: 360px;
        height: 48vh;
        border-radius: 16px;
    }

    .target-character {
        width: 130px;
        height: 180px;
    }

    .target-img-wrap {
        width: 120px;
        height: 155px;
    }

    .party-hat {
        font-size: 2.2rem;
        top: -28px;
    }

    .target-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
        bottom: -8px;
    }

    .splat-mark {
        width: 80px;
        height: 80px;
    }

    .cake-ammo-display {
        width: 70px;
        height: 70px;
        font-size: 2.4rem;
    }

    .aim-hint {
        font-size: 0.72rem;
        padding: 2px 8px;
    }

    .celebration-title {
        font-size: 1.6rem;
        letter-spacing: 1px;
    }

    .celebration-sub {
        font-size: 0.95rem;
    }

    /* Cake Selector on mobile: 2x2 grid */
    .cake-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .cake-btn {
        padding: 6px 4px;
    }

    .cake-btn .c-icon {
        font-size: 1.5rem;
    }

    .cake-btn .c-name {
        font-size: 0.68rem;
    }

    .cake-btn .c-pts {
        font-size: 0.65rem;
    }

    /* Modals on mobile */
    .modal-card {
        padding: 20px 16px;
        border-radius: 18px;
        width: 94%;
    }

    .modal-title {
        font-size: 1.15rem;
    }

    .final-score {
        font-size: 2.6rem;
    }
}

@media (max-width: 380px) {
    .stage-wrapper {
        min-height: 320px;
        height: 44vh;
    }

    .target-character {
        width: 110px;
        height: 150px;
    }

    .target-img-wrap {
        width: 100px;
        height: 130px;
    }

    .celebration-title {
        font-size: 1.3rem;
    }
}

