body {
    margin: 0;
    overflow: hidden;
    background-color: #111;
    color: white;
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    touch-action: manipulation; /* Important for mobile responsiveness */
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10;
    pointer-events: all;
}

#menu-screen {
    padding: 20px;
    background: #222;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
}

#pause-menu {
    padding: 20px;
    background: #222;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#pause-menu button {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    font-size: 1em;
    cursor: pointer;
    background: #3498db;
    color: white;
}

#song-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

#song-file, #manual-bpm, #note-speed, #start-button {
    padding: 10px;
    border-radius: 4px;
    border: none;
    font-size: 1em;
}

#start-button {
    background: #3498db;
    color: white;
    cursor: pointer;
}

#start-button:disabled {
    background: #444;
    cursor: not-allowed;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* DDR Arrows / Targets */
#targets {
    position: absolute;
    top: 10vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 5;
    width: 90vw; /* Adjust for mobile width */
    max-width: 400px; /* Max size for desktop view */
    justify-content: space-around;
}

.arrow-target {
    width: 70px;
    height: 70px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 4px solid #fff;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.1s, transform 0.1s, box-shadow 0.1s;
    flex-grow: 1;
}

.arrow-target.active {
    opacity: 1;
    transform: scale(1.05);
    background-color: rgba(255, 255, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 255, 0, 1);
}

.arrow-target::after {
    /* General style for Unicode arrows */
    font-size: 40px; 
    font-weight: bold;
    display: block;
    /* Remove previous border/shape styles */
}

/* Arrow Shapes */
/* Note: Target color definitions match note colors for consistency */
.arrow-target.left::after { content: '←'; color: red; transform: none; }
.arrow-target.down::after { content: '↓'; color: lime; transform: none; }
.arrow-target.up::after { content: '↑'; color: blue; transform: none; }
.arrow-target.right::after { content: '→'; color: yellow; transform: none; }


/* Notes */
#notes-container {
    position: absolute;
    bottom: 0;
    /* We define the top boundary relative to the targets position */
    top: 10vh; 
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    max-width: 400px;
    overflow: hidden;
    z-index: 5; /* Ensure notes are above the background video (z-index: 1) */
}

.note {
    position: absolute;
    top: 0;
    width: 25%; /* To align with targets */
    height: 15px;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    transition: box-shadow 0.05s;
}

.note.left { left: 0%; background-color: red; }
.note.down { left: 25%; background-color: lime; }
.note.up { left: 50%; background-color: blue; }
.note.right { left: 75%; background-color: yellow; }

/* Hit feedback */
.feedback {
    position: absolute;
    top: 18vh;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 2em;
    opacity: 0;
    animation: fadeout 0.8s forwards;
    z-index: 20;
    user-select: none;
}

.feedback.perfect { background: cyan; color: black; }
.feedback.great { background: yellow; color: black; }
.feedback.good { background: orange; color: black; }
.feedback.miss { background: red; color: white; }

@keyframes fadeout {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -50px); }
}

#score-display {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    z-index: 10;
}

/* Loading Spinner */
#loading-spinner {
    margin: 20px auto;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Community panel styles */
#community-panel {
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.06);
}
.community-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.04);
    padding: 10px;
    border-radius: 6px;
    gap: 12px;
}
.community-info {
    flex: 1;
    min-width: 0;
}
.community-title {
    color: #fff;
    display: block;
    margin-bottom: 4px;
}
.community-author {
    color: #bbb;
}
.community-actions {
    display: flex;
    gap: 8px;
}
.community-empty, .community-loading, .community-error {
    padding: 12px;
    color: #ddd;
    text-align: center;
}

/* Buttons */
button {
    padding: 8px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    background: #2b2b2b;
    color: #fff;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.btn.primary {
    background: linear-gradient(180deg,#3aa0ff,#2b85d6);
    box-shadow: 0 6px 14px rgba(43,133,214,0.25);
    color: white;
}
button.btn {
    background: #333;
    color: #fff;
}

/* Menu tweaks */
#menu-screen {
    padding: 22px;
    background: linear-gradient(180deg,#1b1b1b,#111);
    border: 1px solid rgba(255,255,255,0.04);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    border-radius: 10px;
    text-align: center;
    max-width: 92%;
}
#song-form input[type="file"] {
    background: rgba(255,255,255,0.03);
    padding: 8px;
    border-radius: 6px;
}
#start-button {
    background: linear-gradient(180deg,#3aa0ff,#2b85d6);
    box-shadow: 0 6px 14px rgba(43,133,214,0.25);
}

/* Smaller improvements for community panel responsiveness */
#community-panel {
    max-height: 72vh;
    overflow-y: auto;
    padding-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Controls (Touch friendly area) */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20vh; /* Dedicated touch area */
    justify-content: space-around;
    align-items: center;
    z-index: 9;
    padding-bottom: 5px;
    pointer-events: none; /* Initially non-interactive */
}

.mobile-arrow {
    width: 25%;
    height: 100%;
    background: rgba(255, 255, 255, 0); /* Invisible touch targets */
    pointer-events: all; /* Make them interactive */
    touch-action: none; /* Prevent scrolling when tapping */
}

@media (max-width: 600px) {
    /* Targets are now positioned from the top, mobile controls remain at the bottom */
    #mobile-controls {
        display: flex;
    }
}

