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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 20px;
}

#login-screen h1 {
    font-size: 2rem;
    color: #1db954;
}

#login-screen p {
    color: #888;
}

.hint {
    font-size: 0.85rem;
    color: #666;
}

/* Settings Screen */
#settings-screen {
    align-items: center;
    text-align: center;
}

#settings-screen h1 {
    font-size: 2rem;
    color: #1db954;
    margin-bottom: 30px;
}

.settings-card {
    position: relative;
    background: #16213e;
    border-radius: 16px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
}

.settings-card h2 {
    color: #1db954;
    margin-bottom: 25px;
    font-size: 1.3rem;
}

#version-display {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.75rem;
    color: #555;
}

#update-banner {
    margin-top: 15px;
    padding: 10px;
    background: #1db954;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

#update-btn {
    margin-left: 10px;
    padding: 5px 15px;
    background: #fff;
    color: #1a1a2e;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
}

#update-btn .icon {
    width: 1em;
    height: 1em;
}

/* Buttons */
/* Icons */
.icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    margin-right: 0.4em;
}

.btn-icon .icon {
    width: 1.5em;
    height: 1.5em;
    margin-right: 0;
}

.btn-primary {
    background: #1db954;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background: #1ed760;
}

.btn-secondary {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 12px 30px;
    font-size: 1rem;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 8px;
    font-size: 0.9rem;
}

.btn-control {
    background: #333;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Screen */
#main-screen header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#main-screen h1 {
    font-size: 1.4rem;
    color: #1db954;
}

/* Scanner */
#scanner-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    max-height: 400px;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid #1db954;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

/* Player */
#player-container {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

#now-playing {
    text-align: center;
    margin-bottom: 20px;
}

#track-info {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Timer circle */
#timer-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 15px auto;
}

#timer-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: #333;
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: #1db954;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
}

.timer-progress.countdown {
    stroke: #e74c3c;
}

.timer-progress.post-countdown {
    stroke: #3498db;
}

#time-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
}

/* Countdown effect for last 10 seconds */
#player-container.countdown {
    animation: pulse 1s ease-in-out infinite;
}

#player-container.countdown #time-display {
    color: #e74c3c;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
    50% {
        box-shadow: 0 0 20px 5px rgba(231, 76, 60, 0.5);
    }
}

body.flash {
    animation: flash-screen 0.6s ease-in-out;
}

@keyframes flash-screen {
    0%, 100% { background-color: inherit; }
    25%, 75% { background-color: #fff; }
    50% { background-color: #e74c3c; }
}

#time-display {
    font-size: 0.9rem;
    color: #888;
}

#controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Status */
#status-message {
    text-align: center;
    padding: 15px;
    font-size: 0.95rem;
    color: #1db954;
    min-height: 50px;
}

#status-message.error {
    color: #e74c3c;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-content {
    background: #16213e;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #1db954;
}

.setting {
    margin-bottom: 20px;
}

.setting label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
}

.setting select {
    width: 100%;
    padding: 12px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #1a1a2e;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.checkbox-setting label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-setting input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.settings-card .btn-primary {
    width: 100%;
    margin-top: 10px;
}

.settings-card .btn-secondary {
    width: 100%;
}

/* Card flip */
#card-container {
    perspective: 1000px;
    margin-top: 20px;
}

#edition-display {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 10px;
}

#card {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: default;
}

#card.flippable {
    cursor: pointer;
}

#card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.card-back-face {
    background: url('card-back.png') center/cover no-repeat;
    border: 3px solid #1db954;
}

.card-logo {
    display: none;
}

.card-front {
    background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
    border: 3px solid #1db954;
    transform: rotateY(180deg);
    text-align: center;
}

.card-artist {
    font-size: 1rem;
    color: #888;
    margin-bottom: 10px;
}

.card-year {
    font-size: 2.5rem;
    font-weight: bold;
    color: #1db954;
    margin-bottom: 10px;
}

.card-title {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 600;
}

/* PWA Install Prompt */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}
