@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Playfair+Display:wght@700&display=swap');

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    font-family: 'Orbitron', monospace;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

canvas {
    display: block;
    touch-action: none;
}

#result-display {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 140, 0, 0.1));
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 12px 25px;
    color: #ffd700;
    font-size: 0.85rem;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow:
        0 0 20px rgba(255, 215, 0, 0.3),
        inset 0 0 15px rgba(255, 215, 0, 0.1);
    opacity: 0;
    transition: all 0.5s ease;
    z-index: 100;
    max-width: 90vw;
}

#result-display.visible {
    opacity: 1;
}

#result-display h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#result-display .results-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

#result-display .result-item {
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
}

#result-display .label {
    color: #aaa;
    font-size: 0.7rem;
}

#result-display .value {
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
}

.now-playing {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 0.75rem;
    color: #00ff88;
}

.now-playing .playing-icon {
    animation: pulse-icon 1s ease-in-out infinite;
    display: inline-block;
    margin-right: 5px;
}

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

.hidden {
    display: none !important;
}

#instructions {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 215, 0, 0.9);
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    background: rgba(0,0,0,0.5);
    padding: 8px 20px;
    border-radius: 20px;
    z-index: 100;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

#controls-hint {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.75);
    color: #000;
    font-size: 0.65rem;
    text-align: right;
    z-index: 100;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 8px;
}

.neon-border {
    position: fixed;
    pointer-events: none;
    z-index: 50;
}

.neon-border.top {
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    box-shadow: 0 0 15px #ffd700;
}

.neon-border.bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ff6b35, transparent);
    box-shadow: 0 0 15px #ff6b35;
}

#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffd700;
    font-size: 1.2rem;
    z-index: 1000;
}

#audio-controls {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #ffd700;
    border-radius: 25px;
    padding: 8px 15px;
    z-index: 100;
}

#audio-controls button {
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s, color 0.2s;
}

#audio-controls button:hover {
    transform: scale(1.2);
    color: #fff;
}

#progress-container {
    width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffd700, #ff6b35);
    border-radius: 3px;
    transition: width 0.1s linear;
}

#time-display {
    color: #aaa;
    font-size: 0.7rem;
    min-width: 80px;
}

#played-count {
    color: #00ff88;
    font-size: 0.75rem;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

#lang-selector {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 200;
}

#lang-select {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #ffd700;
    border-radius: 5px;
    color: #ffd700;
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    padding: 5px 10px;
    cursor: pointer;
    outline: none;
}

#lang-select:hover {
    background: rgba(255, 215, 0, 0.2);
}

#lang-select option {
    background: #1a1a2e;
    color: #ffd700;
}

/* Power saving mode */
#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 300;
    transition: opacity 2s ease;
}

/* Keep UI elements visible during fade */
#result-display {
    z-index: 350;
}

#audio-controls {
    z-index: 350;
}

#instructions {
    z-index: 350;
}

#fade-overlay.fade-out {
    opacity: 1;
}

#fade-overlay.fade-in {
    opacity: 0;
}

#power-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 400;
}

#power-overlay.hidden {
    display: none;
}

/* Show audio controls above power overlay */
body.power-saving #audio-controls {
    z-index: 450;
}

body.power-saving #result-display {
    z-index: 450;
}

body.power-saving #instructions {
    z-index: 450;
}

#power-wake-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: rgba(30, 30, 40, 0.8);
    border: 2px solid #666;
    border-radius: 50%;
    width: 150px;
    height: 150px;
    color: #999;
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    cursor: pointer;
}

#power-wake-btn:hover {
    border-color: #ffd700;
    color: #ffd700;
}

#power-wake-btn .power-icon {
    font-size: 3rem;
    margin-top: 20px;
}

@media (max-height: 500px) and (orientation: landscape) {
    #instructions {
        top: 5px;
        font-size: 0.7rem;
        padding: 5px 15px;
    }

    #result-display {
        bottom: 55px;
        padding: 8px 15px;
        font-size: 0.75rem;
    }

    #result-display h3 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }

    #controls-hint {
        font-size: 0.55rem;
        bottom: 5px;
    }

    #audio-controls {
        padding: 5px 10px;
    }
}

/* Explosion overlay */
#explosion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 500;
    opacity: 0;
    transition: opacity 1s ease, background 2s ease;
    pointer-events: none;
}

#explosion-overlay.hidden {
    display: none;
}

#explosion-overlay.visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

.explosion-content {
    text-align: center;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.8s ease, opacity 0.8s ease;
    transition-delay: 1s;
}

#explosion-overlay.visible .explosion-content {
    transform: translateY(0);
    opacity: 1;
}

.silence-message {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    color: #fff;
    letter-spacing: 3px;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    animation: gentle-glow 3s ease-in-out infinite;
}

.zen-quote {
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 2px;
    margin-bottom: 40px;
    font-style: italic;
}

@keyframes gentle-glow {
    0%, 100% { text-shadow: 0 0 30px rgba(255, 255, 255, 0.3); }
    50% { text-shadow: 0 0 50px rgba(255, 255, 255, 0.6); }
}

#party-again-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #ff6b35 0%, #ff0844 50%, #ffb347 100%);
    border: none;
    border-radius: 50%;
    width: 140px;
    height: 140px;
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow:
        0 0 30px rgba(255, 107, 53, 0.5),
        0 0 60px rgba(255, 8, 68, 0.3),
        inset 0 -5px 20px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#party-again-btn:hover {
    transform: scale(1.1);
    box-shadow:
        0 0 50px rgba(255, 107, 53, 0.7),
        0 0 100px rgba(255, 8, 68, 0.5),
        inset 0 -5px 20px rgba(0, 0, 0, 0.3);
}

#party-again-btn:active {
    transform: scale(0.95);
}

#party-again-btn .party-icon {
    font-size: 2.5rem;
    margin-top: 15px;
    animation: party-bounce 0.6s ease-in-out infinite;
}

@keyframes party-bounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}
