@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Outfit:wght@400;600;800&display=swap');

:root {
    --bg-gradient: radial-gradient(circle at center, #231022 0%, #0c050b 100%);
    --pink-primary: #ff70a6;
    --pink-accent: #ffb2c6;
    --pink-border: rgba(255, 112, 166, 0.2);
    --pink-glow: rgba(255, 112, 166, 0.4);
    --panel-bg: rgba(255, 112, 166, 0.04);
    --glass-border: 1px solid rgba(255, 112, 166, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(255, 112, 166, 0.06);
    --font-heading: 'Fredoka One', cursive, sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden !important;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: #fff;
    font-family: var(--font-body);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden !important;
    padding: 6px 12px;
}

/* Base Layout Container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    max-width: 1000px;
    width: 100%;
    height: 100vh;
    padding: 8px 12px;
    position: relative;
    box-sizing: border-box;
}

/* Transparent Full-Viewport Sakura Overlay Canvas (Zero DOM Flow Space) */
#fx-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    display: block !important;
}

/* Inner Game Board Shake Animation (Shakes only board, zero layout shift) */
@keyframes boardShake {
    0% { transform: translate(0, 0) rotate(0deg); }
    15% { transform: translate(-6px, 4px) rotate(-0.5deg); }
    30% { transform: translate(6px, -4px) rotate(0.5deg); }
    45% { transform: translate(-4px, -3px) rotate(-0.3deg); }
    60% { transform: translate(4px, 3px) rotate(0.3deg); }
    75% { transform: translate(-2px, 1px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

#board-canvas.shake-effect {
    animation: boardShake 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Outer Border Neon Pulse Glow */
@keyframes outerBorderGlow {
    0% { filter: drop-shadow(0 0 5px rgba(255, 112, 166, 0.2)); }
    50% { filter: drop-shadow(0 0 35px rgba(255, 112, 166, 0.9)) drop-shadow(0 0 60px rgba(255, 158, 187, 0.6)); }
    100% { filter: drop-shadow(0 0 5px rgba(255, 112, 166, 0.2)); }
}

.tetris-glow-effect {
    animation: outerBorderGlow 1.2s ease-in-out;
}

/* Header Aesthetics with Pulsing Neon Glowing */
header {
    text-align: center;
    margin-bottom: 4px;
    margin-top: 0;
    flex-shrink: 0;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: #fff;
    letter-spacing: 2px;
    text-shadow: 0 0 7px #fff, 0 0 14px var(--pink-primary), 0 0 28px var(--pink-primary);
    animation: neonPulse 2.5s ease-in-out infinite alternate;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

h1 span {
    font-size: 1.8rem;
    animation: floatingHeart 2s ease-in-out infinite alternate;
}

/* Main Playing Frame */
.game-layout {
    display: flex;
    flex-direction: row;
    gap: 25px;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Sidebar Containers (Hold, Next, Stats) */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 150px;
    height: calc(100vh - 120px);
    max-height: 860px;
    justify-content: space-between;
}

/* Glassmorphism Panel styles */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 12px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
}

.panel:hover {
    border-color: rgba(255, 112, 166, 0.35);
    box-shadow: 0 12px 40px 0 rgba(255, 112, 166, 0.12);
}

.panel h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--pink-accent);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Canvas styling - Large dynamic scaling filling vertical height */
.canvas-wrapper {
    background: #090308;
    border-radius: 16px;
    border: 1px solid rgba(255, 112, 166, 0.1);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    height: calc(100vh - 120px);
    max-height: 860px;
    aspect-ratio: 1 / 2;
}

#board-canvas {
    display: block;
    border-radius: 16px;
    border: 3px solid rgba(255, 112, 166, 0.25);
    box-shadow: 0 0 25px rgba(255, 112, 166, 0.15);
    background: #110710;
    height: 100%;
    width: 100%;
    object-fit: contain;
}

/* Next / Hold Previews */
#next-canvas, #hold-canvas {
    display: block;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Score Panel Specifics */
.stats {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.stat-item {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.stat-value.highlight {
    color: var(--pink-primary);
    text-shadow: 0 0 8px var(--pink-glow);
}

/* Game settings / Audio panels */
.controls-footer {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-top: 8px;
    margin-bottom: 4px;
    justify-content: center;
    width: 100%;
    flex-shrink: 0;
}

.btn-icon {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    background: rgba(255, 112, 166, 0.1);
    border: 1px solid rgba(255, 112, 166, 0.25);
    border-radius: 35px;
    color: #fff;
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-icon:hover {
    background: rgba(255, 112, 166, 0.2);
    border-color: var(--pink-primary);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 15px var(--pink-glow);
}

.btn-icon:active {
    transform: scale(0.98) translateY(0);
}

.btn-icon.off {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
}

.btn-icon.off:hover {
    box-shadow: none;
    transform: none;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Center Play Area Screen Overlay styling */
.play-area {
    position: relative;
}

.overlay {
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    background: rgba(16, 7, 15, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
    animation: fadeIn 0.3s ease-out;
    border: 1px solid rgba(255, 112, 166, 0.15);
}

.overlay h3 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--pink-primary);
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--pink-glow);
}

.overlay p {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 25px;
    text-align: center;
    line-height: 1.6;
}

.overlay .btn-action {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--pink-primary), #ff99c8);
    color: white;
    border: none;
    border-radius: 40px;
    padding: 12px 35px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 112, 166, 0.4);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay .btn-action:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 12px 30px rgba(255, 112, 166, 0.6);
}

.overlay .btn-action:active {
    transform: scale(0.96) translateY(0);
}

.overlay .btn-outline {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    background: transparent;
    border: 2px solid var(--pink-primary);
    color: var(--pink-accent);
    border-radius: 40px;
    padding: 12px 35px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay .btn-outline:hover {
    background: rgba(255, 112, 166, 0.12);
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 112, 166, 0.25);
    color: #fff;
}

.overlay .btn-outline:active {
    transform: scale(0.96) translateY(0);
}

.overlay-stats {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.overlay-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.overlay-val {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Instructions card overlay styling */
.controls-guide {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    width: 80%;
    margin-bottom: 25px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    padding: 12px 15px;
}

.guide-row {
    display: flex;
    justify-content: space-between;
}

.guide-key {
    color: var(--pink-accent);
    font-weight: 600;
}

/* Mobile Virtual controls panel styling */
.mobile-controls {
    display: none; /* hidden on desktop */
    grid-template-columns: repeat(12, 1fr);
    gap: 10px;
    margin-top: 25px;
    width: 100%;
    max-width: 420px;
}

.ctrl-btn {
    background: rgba(255, 112, 166, 0.07);
    border: 1px solid rgba(255, 112, 166, 0.2);
    border-radius: 15px;
    color: white;
    font-size: clamp(0.95rem, 3.5vw, 1.2rem);
    height: 54px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.1s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 0 4px;
    white-space: nowrap;
}

.ctrl-btn:active {
    background: rgba(255, 112, 166, 0.35);
    border-color: var(--pink-primary);
    transform: scale(0.92);
}

.ctrl-btn.col-3 {
    grid-column: span 3;
}

.ctrl-btn.col-4 {
    grid-column: span 4;
}

/* Floating animation details */
@keyframes neonPulse {
    from {
        text-shadow: 0 0 5px #fff, 0 0 10px var(--pink-primary), 0 0 20px var(--pink-primary), 0 0 35px var(--pink-primary);
    }
    to {
        text-shadow: 0 0 8px #fff, 0 0 18px var(--pink-primary), 0 0 35px var(--pink-primary), 0 0 55px var(--pink-primary), 0 0 70px var(--pink-primary);
    }
}

@keyframes floatingHeart {
    0% {
        transform: translateY(0) scale(1);
    }
    100% {
        transform: translateY(-6px) scale(1.1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Scaling Queries - narrow vertical screens (mobile phones) */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 2.2rem;
        margin-top: 10px;
    }

    h1 span {
        font-size: 1.6rem;
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .sidebar {
        flex-direction: row;
        width: 100%;
        max-width: 420px;
        justify-content: space-between;
        gap: 10px;
    }

    .panel {
        flex: 1;
        padding: 8px;
        border-radius: 12px;
    }

    .panel h2 {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }

    /* Fixed aspect ratio sizing on mobile for the next/hold canvases to prevent stretching */
    #next-canvas {
        width: 60px;
        height: 160px;
    }

    #hold-canvas {
        width: 60px;
        height: 60px;
    }

    #board-canvas {
        max-width: 100%;
        height: auto;
        max-height: 52vh;
    }

    .controls-footer {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 15px;
    }

    .btn-icon {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* Touch Input Devices - Force display D-pad controls on iPads and all tablet screens */
@media (hover: none), (pointer: coarse) {
    .mobile-controls {
        display: grid !important;
    }
}

/* Settings Rebinding Button Styling additions */
.rebind-knob:hover {
    background: rgba(255, 112, 166, 0.2) !important;
    border-color: var(--pink-primary) !important;
}

.rebind-knob.binding {
    background: rgba(255, 112, 166, 0.45) !important;
    border-color: var(--pink-primary) !important;
    animation: rebindPulse 0.8s ease-in-out infinite alternate;
}

@keyframes rebindPulse {
    from {
        opacity: 0.65;
        box-shadow: 0 0 4px var(--pink-glow);
    }
    to {
        opacity: 1.0;
        box-shadow: 0 0 12px var(--pink-primary);
    }
}

/* 🌸 Sakura Burst Special Effect Styles */
h1 span.burst-active {
    animation: mainSakuraBurst 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes mainSakuraBurst {
    0% {
        transform: translateY(-6px) scale(1.1);
    }
    15% {
        transform: translateY(0) scale(0.3) rotate(-25deg);
    }
    30% {
        transform: translateY(-15px) scale(1.6) rotate(15deg);
    }
    100% {
        transform: translateY(-6px) scale(1.1) rotate(0deg);
    }
}

.sakura-particle {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    font-size: 1.1rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(255, 112, 166, 0.2));
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
}

h1 span.animation-paused {
    animation: none !important;
}

