* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Popup Overlay */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-overlay.active {
    display: flex;
}

/* Popup Content */
.popup-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Popup Header */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.popup-header h2 {
    font-size: 24px;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.close-btn:hover {
    background-color: #e0e0e0;
    color: #333;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.image-item {
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.image-item:hover {
    transform: scale(1.05);
    border-color: #4ECDC4;
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Back Button */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    z-index: 100;
    text-decoration: none;
    color: #333;
}

.back-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background-color: #f8f9fa;
}

.back-button:active {
    transform: scale(0.95);
}

.back-button svg {
    width: 28px;
    height: 28px;
    transition: color 0.2s;
}

.back-button:hover svg {
    color: #4ECDC4;
}

/* Mode Toggle Button */
.mode-toggle {
    position: fixed;
    top: 20px;
    left: 90px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 100;
}

.mode-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mode-toggle:active {
    transform: scale(0.95);
}

.mode-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Row Toggle Button */
.row-toggle {
    position: fixed;
    top: 20px;
    left: 160px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 100;
}

.row-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.row-toggle:active {
    transform: scale(0.95);
}

.row-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Metronome Controls */
.metronome-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
}

.metronome-play {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    padding: 0;
}

.metronome-play:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.metronome-play:active {
    transform: scale(0.95);
}

.metronome-play svg {
    width: 24px;
    height: 24px;
    fill: #333;
    transition: fill 0.2s;
}

.metronome-play.playing {
    background-color: #4ECDC4;
}

.metronome-play.playing svg {
    fill: white;
}

.metronome-play.playing svg path {
    d: path('M6 19h4V5H6v14zm8-14v14h4V5h-4z');
}

.tempo-buttons {
    display: flex;
    gap: 5px;
}

.tempo-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    background-color: white;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tempo-btn:hover {
    border-color: #4ECDC4;
    box-shadow: 0 4px 8px rgba(78, 205, 196, 0.3);
}

.tempo-btn.active {
    background-color: #4ECDC4;
    border-color: #4ECDC4;
    color: white;
    box-shadow: 0 4px 8px rgba(78, 205, 196, 0.4);
}

.tempo-btn:active {
    transform: scale(0.95);
}
