* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #1a1a2e;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #e0e0e0;
    touch-action: none; /* Prevent scroll on mobile */
    overflow: hidden;
}

.game-container {
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #16213e;
    /* Responsive sizing keeping 800x400 ratio */
    width: 100vw;
    max-width: 800px;
    height: auto;
    aspect-ratio: 2 / 1;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10;
    backdrop-filter: blur(3px);
    transition: opacity 0.3s;
}

.ui-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#title {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #e94560;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    text-align: center;
}

#instruction {
    font-size: 1.2rem;
    color: #0f3460;
    background-color: #e0e0e0;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    animation: pulse 1.5s infinite;
    text-align: center;
}

.mode-btn-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.mode-btn {
    padding: 8px 15px;
    font-size: 1.1rem;
    font-weight: bold;
    background-color: #0f3460;
    color: white;
    border: 2px solid #e94560;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    pointer-events: auto;
}

.mode-btn.active.party {
    background-color: #d11141;
    box-shadow: 0 0 15px #d11141;
    border-color: #fff;
}

.mode-btn.active.nightmare {
    background-color: #111;
    color: #ff3333;
    box-shadow: 0 0 15px #000;
    border-color: #660000;
}

.mode-btn.active.hard {
    background-color: #e94560;
    box-shadow: 0 0 15px #e94560;
}

.mode-btn:active {
    transform: scale(0.95);
}

.action-btn {
    margin-top: 25px;
    padding: 20px 60px;
    font-size: 2rem;
    font-weight: bold;
    background-color: #00c6ff;
    color: #111;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,255,204,0.5);
    pointer-events: auto;
    transition: transform 0.1s;
}

.action-btn:active {
    transform: scale(0.95);
}

.current-score-display {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px #000;
}

#scoreDisplay {
    margin-top: 20px;
    font-size: 1.5rem;
    color: #ffd700;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.energy-container {
    position: absolute;
    top: 55px; 
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.energy-container span {
    font-size: 0.9rem;
    font-weight: bold;
    color: #00ffcc;
    text-shadow: 1px 1px 2px #000;
}

.energy-bar-bg {
    width: 150px;
    height: 15px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    border: 1px solid #000;
    overflow: hidden;
}

.energy-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00c6ff, #00ffcc);
    transition: width 0.1s linear;
}

/* Tutorial UI */
.tutorial-overlay {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #00c6ff;
    width: 260px;
    transition: opacity 1s, visibility 1s;
    pointer-events: none;
    z-index: 5;
}

.tutorial-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.tutorial-overlay p {
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #eee;
}
.tutorial-overlay strong {
    color: #00ffcc;
}

.tutorial-animation {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 50px;
    margin-bottom: 10px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.tut-key {
    background: #e0e0e0;
    color: #111;
    padding: 5px 15px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 4px #888;
    animation: keyAnim 3.5s infinite;
}

.tut-char {
    width: 25px;
    height: 25px;
    background: linear-gradient(#00c6ff, #0072ff);
    box-shadow: 0 0 10px rgba(0,198,255,0.8);
    animation: charAnim 3.5s infinite;
}

@keyframes keyAnim {
    0% { transform: translateY(0); box-shadow: 0 4px #888; }
    5% { transform: translateY(4px); box-shadow: 0 0px #888; }
    15% { transform: translateY(0); box-shadow: 0 4px #888; }
    35% { transform: translateY(0); box-shadow: 0 4px #888; }
    40% { transform: translateY(4px); box-shadow: 0 0px #888; }
    45% { transform: translateY(0); box-shadow: 0 4px #888; }
    50% { transform: translateY(4px); box-shadow: 0 0px #888; }
    55% { transform: translateY(0); box-shadow: 0 4px #888; }
    65% { transform: translateY(0); box-shadow: 0 4px #888; }
    70% { transform: translateY(4px); box-shadow: 0 0px #888; background: #00ffcc; }
    90% { transform: translateY(4px); box-shadow: 0 0px #888; background: #00ffcc;}
    95% { transform: translateY(0); box-shadow: 0 4px #888; background: #e0e0e0; }
    100% { transform: translateY(0); }
}

@keyframes charAnim {
    0% { transform: translateY(0); }
    5% { transform: translateY(-30px); }
    15% { transform: translateY(0); }
    35% { transform: translateY(0); }
    40% { transform: translateY(-30px); }
    50% { transform: translateY(-60px); }
    60% { transform: translateY(0); }
    65% { transform: translateY(0); }
    70% { transform: translateY(-40px); }
    85% { transform: translateY(-40px); box-shadow: 0 0 20px #00ffcc;}
    95% { transform: translateY(0); box-shadow: 0 0 10px rgba(0,198,255,0.8); }
    100% { transform: translateY(0); }
}

.party-effect-list {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #d11141;
    font-size: 0.9rem;
    text-align: left;
    box-shadow: 0 0 10px rgba(209, 17, 65, 0.5);
    pointer-events: none;
    z-index: 50;
}

.party-effect-list h3 { 
    margin-top: 0; 
    margin-bottom: 8px; 
    color: #ffeb3b; 
    font-size: 1.1rem;
}

.party-effect-list ul { 
    padding-left: 0; 
    margin: 0; 
    line-height: 1.5;
    list-style: none;
}

/* Media query for smaller mobile screens */
@media (max-width: 600px) {
    #title { font-size: 2rem; }
    #instruction { font-size: 0.9rem; }
    .tutorial-overlay {
        transform: scale(0.7);
        transform-origin: top right;
    }
}
