/**
 * tetris.css - Tetris game styles
 */

/* ======== Keyframes ======== */
@keyframes levelUpPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1.3); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

@keyframes lineClearPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

@keyframes dancePop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

@keyframes flashFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes shimmer {
    0% { filter: hue-rotate(0deg) brightness(1); }
    50% { filter: hue-rotate(180deg) brightness(1.3); }
    100% { filter: hue-rotate(360deg) brightness(1); }
}

@keyframes electricPulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #00ffff; }
    50% { opacity: 0.8; text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff; }
}

@keyframes flameBorder {
    0%, 100% { box-shadow: 0 0 10px #ff6600, 0 0 20px #ff3300; }
    50% { box-shadow: 0 0 20px #ff6600, 0 0 40px #ff3300, 0 0 60px #ff0000; }
}

@keyframes rainbowWave {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes dangerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

@keyframes dangerShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* ======== Danger Zone Styles ======== */
.game-container.danger-yellow {
    box-shadow: 0 0 20px rgba(255, 200, 0, 0.6),
                inset 0 0 10px rgba(255, 200, 0, 0.2);
    animation: dangerPulse 1s ease-in-out infinite;
}

.game-container.danger-red {
    box-shadow: 0 0 30px rgba(255, 50, 50, 0.8),
                inset 0 0 15px rgba(255, 50, 50, 0.3);
    animation: dangerPulse 0.5s ease-in-out infinite,
               dangerShake 0.15s ease-in-out infinite;
}

/* ======== Base Styles ======== */
body {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    overflow-x: hidden;
}

/* ======== Header ======== */
.header {
    width: 100%;
    max-width: 400px;
    margin-bottom: 10px;
}

.header h1 {
    font-size: 1.8rem;
}

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

.back-btn {
    border: none;
    font-size: 1rem;
    border-radius: 20px;
    transition: background 0.2s, transform 0.2s;
}

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

/* ======== Stats Row ======== */
.stats-row {
    gap: 10px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 400px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    min-width: 80px;
}

.stat-box .label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
    margin-bottom: 2px;
}

.stat-box .value {
    color: #ffd700;
}

.stat-box.level .value {
    color: #4ade80;
}

.stat-box.lines .value {
    color: #f472b6;
}

/* ======== Bonus Indicators ======== */
.bonus-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    justify-content: center;
    min-height: 35px;
}

.bonus-indicator {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 5px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s, transform 0.2s;
}

.bonus-indicator.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.combo-indicator {
    border: 2px solid #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.b2b-indicator {
    border: 2px solid #ff6600;
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.3);
}

.bonus-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

.bonus-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
}

/* ======== Game Area ======== */
.game-area {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.game-container {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    display: block;
    background: #1a1a2e;
    border-radius: 5px;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.next-container,
.hold-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 10px;
    text-align: center;
}

.next-container .label,
.hold-container .label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

#nextCanvas {
    display: block;
    background: #1a1a2e;
    border-radius: 5px;
    margin: 0 auto;
}

/* ======== Overlays ======== */
.overlay {
    background: rgba(0, 0, 0, 0.8);
}

.overlay h2 {
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.overlay p {
    margin-bottom: 10px;
}

.overlay .final-score {
    color: #ffd700;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 20px;
}

.overlay .high-score {
    color: #4ade80;
    font-size: 1.2rem;
    margin-bottom: 30px;
}

.play-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    padding: 15px 50px;
    font-size: 1.3rem;
    border-radius: 30px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 20px rgba(34, 197, 94, 0.4);
}

.play-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(34, 197, 94, 0.5);
}

.controls-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin-top: 20px;
    text-align: center;
    line-height: 1.6;
}

/* ======== Popups ======== */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 90;
    pointer-events: none;
}

.popup.level-up {
    color: #4ade80;
    animation: levelUpPop 1.5s ease forwards;
}

.popup.line-clear {
    font-size: 2rem;
    animation: lineClearPop 1s ease forwards;
}

.popup.tetris {
    color: #ffd700;
}

/* ======== Dancing Emoji ======== */
.dancing-emoji {
    position: fixed;
    font-size: 3rem;
    animation: dancePop 0.5s ease forwards;
    z-index: 200;
    pointer-events: none;
}

/* ======== Flash Screen ======== */
.flash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 250;
    pointer-events: none;
    animation: flashFade 0.5s ease forwards;
}

/* ======== Dad Speech Bubble ======== */
.dad-speech {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 20px;
    padding: 15px 20px;
    font-size: 1.2rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    animation: dancePop 0.5s ease forwards;
    z-index: 200;
}

.dad-speech::after {
    content: '\1F468';
    position: absolute;
    bottom: -30px;
    right: 20px;
    font-size: 2rem;
}

/* ======== Screen Edge Glow ======== */
.screen-edge-glow {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 150;
    box-shadow: inset 0 0 100px var(--glow-color);
    animation: flashFade 1s ease forwards;
}

/* ======== Help Overlay ======== */
.help-content {
    max-width: 380px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
    padding: 0 10px;
}

.help-content h3 {
    color: #ffd700;
    font-size: 1.1rem;
    margin: 18px 0 8px;
}

.help-content h3:first-child {
    margin-top: 0;
}

.controls-table {
    width: 100%;
    border-collapse: collapse;
}

.controls-table td {
    padding: 5px 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}

.controls-table td:first-child {
    color: #4ade80;
    font-weight: bold;
    white-space: nowrap;
    width: 40%;
}

.hold-callout {
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    padding: 12px 15px;
    margin: 15px 0;
}

.hold-callout h3 {
    color: #ffd700 !important;
    margin: 0 0 6px !important;
    font-size: 1.1rem;
}

.hold-callout p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
}

.close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s, transform 0.2s;
}

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

/* ======== Pause Overlay ======== */
.pause-stats {
    display: flex;
    gap: 20px;
    margin: 15px 0 25px;
}

.pause-stat {
    text-align: center;
}

.pause-stat .pause-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
}

.pause-stat .pause-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #ffd700;
}

.pause-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    margin-top: 15px;
}

/* ======== Responsive ======== */
@media (max-width: 400px) {
    .header h1 {
        font-size: 1.4rem;
    }

    .back-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .stats-row {
        gap: 5px;
    }

    .stat-box {
        padding: 6px 10px;
        min-width: 60px;
    }

    .stat-box .value {
        font-size: 1.1rem;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .side-panel {
        flex-direction: row;
        justify-content: center;
    }

    .overlay h2 {
        font-size: 2rem;
    }

    .controls-hint {
        font-size: 0.8rem;
        padding: 0 20px;
    }
}

/* ======== Mode Selector ======== */
.mode-selector-title {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.mode-selector-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    margin-bottom: 25px;
}

.mode-cards {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.mode-card {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    text-align: center;
    width: 160px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
}

.mode-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.mode-card .mode-emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.mode-card .mode-title {
    font-size: 1.3rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.mode-card .mode-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    display: block;
}

/* ======== Power-Up Container ======== */
.powerup-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 10px;
    text-align: center;
}

.powerup-container .label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

.powerup-container.hidden {
    display: none;
}

.powerup-display {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.powerup-display:hover {
    transform: scale(1.05);
}

.powerup-display.has-powerup {
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    animation: powerupGlow 1.5s ease-in-out infinite;
}

@keyframes powerupGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); }
}

.powerup-emoji {
    font-size: 1.5rem;
}

.powerup-name {
    font-size: 0.65rem;
    color: #ffd700;
    margin-top: 2px;
}

.powerup-empty {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
}

/* ======== Multiplier Indicator ======== */
.multiplier-indicator {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 5px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    justify-content: center;
}

.multiplier-indicator.hidden {
    display: none;
}

.multiplier-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffd700;
}

.multiplier-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

/* ======== Complex Mode Particles ======== */
.complex-particle {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 200;
    animation: complexParticle 0.6s ease-out forwards;
}

@keyframes complexParticle {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ======== Screen Shake ======== */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-4px, 2px); }
    20% { transform: translate(4px, -2px); }
    30% { transform: translate(-3px, -3px); }
    40% { transform: translate(3px, 3px); }
    50% { transform: translate(-2px, 2px); }
    60% { transform: translate(2px, -1px); }
    70% { transform: translate(-1px, 1px); }
    80% { transform: translate(1px, -1px); }
}

.screen-shake {
    animation: screenShake 0.3s ease-out;
}

/* ======== Milestone Flash ======== */
.milestone-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4);
    z-index: 250;
    pointer-events: none;
    animation: milestoneFlash 1.5s ease-out forwards;
}

@keyframes milestoneFlash {
    0% { opacity: 0; transform: scale(0.5); background: rgba(255, 215, 0, 0.3); }
    15% { opacity: 1; transform: scale(1.2); background: rgba(255, 215, 0, 0.15); }
    30% { transform: scale(1); }
    100% { opacity: 0; background: transparent; }
}

/* ======== Power-Up Popup ======== */
.power-up-popup {
    color: #ffd700;
    font-size: 2rem;
    animation: lineClearPop 1s ease forwards;
}

/* ======== Score Breakdown ======== */
.score-breakdown {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 15px;
    text-align: left;
    min-width: 220px;
}

.score-breakdown.hidden {
    display: none;
}

.score-breakdown div {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
}

.score-breakdown span {
    color: #ffd700;
    font-weight: bold;
}

/* ======== Change Mode Button ======== */
.change-mode-btn {
    background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
    border: none;
    padding: 12px 35px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 20px rgba(239, 68, 68, 0.4);
    margin-top: 10px;
}

.change-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.5);
}

/* ======== Complex Mode Visual Effects ======== */
body.complex-color-shift {
    background: linear-gradient(135deg, #7b2ff7 0%, #0072ff 50%, #00c6ff 100%) !important;
}

body.complex-fever .game-container {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
}

body.complex-ultra .game-container {
    border: 2px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5), 0 0 40px rgba(59, 130, 246, 0.3);
    animation: rainbowBorderGlow 3s linear infinite;
}

@keyframes rainbowBorderGlow {
    0% { box-shadow: 0 0 20px #ff0000, 0 0 40px rgba(255, 0, 0, 0.3); }
    17% { box-shadow: 0 0 20px #ff7f00, 0 0 40px rgba(255, 127, 0, 0.3); }
    33% { box-shadow: 0 0 20px #ffd700, 0 0 40px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 20px #00ff00, 0 0 40px rgba(0, 255, 0, 0.3); }
    67% { box-shadow: 0 0 20px #0000ff, 0 0 40px rgba(0, 0, 255, 0.3); }
    83% { box-shadow: 0 0 20px #8b00ff, 0 0 40px rgba(139, 0, 255, 0.3); }
    100% { box-shadow: 0 0 20px #ff0000, 0 0 40px rgba(255, 0, 0, 0.3); }
}

body.complex-legendary .game-container {
    animation: legendaryGlow 1s ease-in-out infinite;
}

@keyframes legendaryGlow {
    0%, 100% { box-shadow: 0 0 30px #ff0000, 0 0 60px #ff7f00, 0 0 90px #ffd700; }
    50% { box-shadow: 0 0 50px #ff0000, 0 0 80px #ff7f00, 0 0 120px #ffd700; }
}

/* ======== Complex Combo Float ======== */
.complex-combo-float {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    pointer-events: none;
    z-index: 90;
    animation: comboFloat 1s ease-out forwards;
}

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

/* ======== Pulse on Clear ======== */
@keyframes pulseGlow {
    0% { box-shadow: 0 0 20px rgba(0, 245, 255, 0.6); }
    50% { box-shadow: 0 0 40px rgba(0, 245, 255, 0.9), 0 0 60px rgba(0, 245, 255, 0.3); }
    100% { box-shadow: 0 0 20px rgba(0, 245, 255, 0.6); }
}

.pulse-clear {
    animation: pulseGlow 0.4s ease-out;
}

/* ======== Laser Line ======== */
.laser-beam {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #ff0000, #ff4444, #ff0000, transparent);
    box-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000;
    pointer-events: none;
    z-index: 10;
    animation: laserFlash 0.3s ease-out forwards;
}

@keyframes laserFlash {
    0% { opacity: 1; height: 3px; }
    50% { opacity: 1; height: 8px; }
    100% { opacity: 0; height: 1px; }
}

/* ======== Freeze Indicator ======== */
.freeze-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid rgba(0, 200, 255, 0.5);
    border-radius: 5px;
    pointer-events: none;
    animation: freezeBorder 1s ease-in-out infinite;
}

@keyframes freezeBorder {
    0%, 100% { border-color: rgba(0, 200, 255, 0.3); }
    50% { border-color: rgba(0, 200, 255, 0.8); }
}

@media (max-width: 400px) {
    .mode-cards {
        flex-direction: column;
        align-items: center;
    }

    .mode-card {
        width: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .complex-particle,
    .screen-shake,
    .milestone-flash,
    .powerup-display.has-powerup,
    .laser-beam,
    .freeze-indicator {
        animation: none;
    }
}
