/* ============================================================
   Tracksy - Spotle-style Design
   ============================================================ */

:root {
    /* Colors */
    --bg-primary: #121212;
    --bg-card: #1E1E1E;
    --bg-card-border: #333333;
    
    --color-correct: #22C55E;
    --color-close: #EAB308;
    --color-wrong: #6B7280;
    --color-unknown: #4B5563;
    
    --color-higher: #EF4444;
    --color-lower: #3B82F6;
    
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --accent: #1DB954;
    --accent-gold: #F59E0B;
    
    /* Sizing */
    --max-width: 420px;
    --header-height: 60px;
    --bottom-height: 100px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
}

/* ============================================================
   App Container (Mobile Frame)
   ============================================================ */

.app-container {
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.screen-hidden {
    display: none !important;
}

/* ============================================================
   Home Screen
   ============================================================ */

.home-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
}

.home-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 48px;
    padding-bottom: 40px;
}

.home-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.home-logo-img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.home-modes {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.home-mode-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    border: 1px solid var(--bg-card-border);
    transition: opacity 0.2s;
}

.home-mode-btn.primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
}

.home-mode-btn.primary:hover {
    opacity: 0.95;
}

.home-mode-btn.disabled {
    cursor: pointer;
    opacity: 0.95;
}

.home-mode-btn.disabled:hover {
    opacity: 1;
}

.home-mode-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(51, 51, 51, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.home-mode-btn.primary .home-mode-icon {
    background: rgba(0, 0, 0, 0.15);
}

.home-mode-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.home-mode-text strong {
    font-size: 17px;
    font-weight: 600;
}

.home-mode-btn.disabled .home-mode-text strong {
    color: var(--text-muted);
}

.home-mode-text em {
    font-size: 13px;
    font-weight: 400;
    font-style: normal;
    color: var(--text-muted);
}

.home-mode-arrow {
    font-size: 18px;
    font-weight: 600;
    color: var(--bg-primary);
}

.home-mode-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card-border);
    padding: 4px 8px;
    border-radius: 6px;
}

.home-secondary {
    margin-top: auto;
    padding-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.home-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.home-link:hover {
    color: var(--text-primary);
}

/* Coming Soon modal */
.coming-soon-modal {
    max-height: 50vh;
}

.coming-soon-message {
    padding: 16px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

/* Game screen wrapper */
.game-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ============================================================
   Header
   ============================================================ */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    height: var(--header-height);
    border-bottom: 1px solid var(--bg-card-border);
}

.title-container {
    text-align: center;
}

.title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.subtitle {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--bg-card);
}

.icon-info-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 14px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
}

/* ============================================================
   Guess Counter (Dots)
   ============================================================ */

.guess-counter {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dots {
    display: flex;
    gap: 6px;
}

.countdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 20px;
    font-size: 13px;
}

.countdown-label {
    color: var(--text-muted);
}

.countdown-time {
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--accent);
    font-size: 14px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-card-border);
    transition: background 0.3s;
}

.dot.used {
    background: var(--text-secondary);
}

.dot.correct {
    background: var(--color-correct);
}

/* ============================================================
   Debug Answer (for testing)
   ============================================================ */

.debug-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px 16px;
    padding: 8px 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px dashed var(--accent-gold);
    border-radius: 8px;
}

.debug-answer {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--accent-gold);
}

.debug-reset-btn {
    padding: 6px 12px;
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.debug-reset-btn:hover {
    opacity: 0.9;
}

/* ============================================================
   Guesses Container
   ============================================================ */

.guesses-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ============================================================
   Guess Card
   ============================================================ */

.guess-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 16px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.guess-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.guess-artist-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-card-border);
}

.guess-artist-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.guess-artist-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-secondary);
}

.artist-name {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
}

.check-icon {
    color: var(--color-correct);
    font-size: 20px;
}

/* ============================================================
   Hint Grid (3x2)
   ============================================================ */

.hint-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.hint-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hint-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hint-value {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 36px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: white;
    padding: 0 6px;
    text-align: center;
}

.hint-value.correct { background: var(--color-correct); }
.hint-value.close { background: var(--color-close); }
.hint-value.wrong { background: var(--color-wrong); }
.hint-value.higher { background: var(--color-higher); }
.hint-value.lower { background: var(--color-lower); }
.hint-value.unknown { background: var(--color-unknown); }

.arrow {
    font-size: 12px;
    font-weight: 700;
}

/* ============================================================
   Bottom Action
   ============================================================ */

.bottom-action {
    padding: 16px;
    padding-bottom: 32px;
    border-top: 1px solid var(--bg-card-border);
}

.bottom-action-sticky {
    flex-shrink: 0;
    border-top: none;
    border-bottom: 1px solid var(--bg-card-border);
}

.action-btn {
    width: 100%;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 27px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.action-btn:hover {
    opacity: 0.9;
}

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

.action-btn.gold {
    background: var(--accent-gold);
}

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

/* ============================================================
   Modals
   ============================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: var(--max-width);
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--bg-card-border);
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px;
}

/* ============================================================
   Search Modal
   ============================================================ */

.search-modal {
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.search-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px;
    padding: 0 16px;
    height: 50px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.search-input-container:focus-within {
    border-color: var(--accent);
}

.search-input-container svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-input-container input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 17px;
    font-family: inherit;
}

.search-input-container input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-muted);
    color: var(--bg-card);
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.clear-btn.visible {
    opacity: 1;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    gap: 12px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--bg-card-border);
}

.search-result-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.artist-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-secondary);
    overflow: hidden;
    flex-shrink: 0;
}

.artist-avatar .artist-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.artist-info {
    flex: 1;
}

.artist-info .name {
    font-size: 16px;
    font-weight: 500;
}

.artist-info .nationality {
    font-size: 13px;
    color: var(--text-muted);
}

.guessed-badge {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card-border);
    padding: 4px 8px;
    border-radius: 4px;
}

/* ============================================================
   Create Puzzle Modal
   ============================================================ */

.create-modal {
    max-width: 480px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.create-modal-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 20px 12px;
}

.create-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
}

.create-result-item {
    cursor: pointer;
}

.create-link-section {
    padding: 16px 20px 24px;
    border-top: 1px solid var(--bg-card-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.create-selected-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.create-link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 8px 12px;
}

.create-link-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
}

.create-copy-btn {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

.create-play-btn {
    width: 100%;
}

/* ============================================================
   Result Modal
   ============================================================ */

.result-modal {
    padding: 24px;
    text-align: center;
    border-radius: 20px 20px 0 0;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.result-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
}

.result-icon.win {
    background: rgba(34, 197, 94, 0.2);
}

.result-icon.lose {
    background: rgba(245, 158, 11, 0.2);
}

.result-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.correct-artist-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.correct-artist-card .label {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
}

.correct-artist-card .artist-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.correct-artist-card .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(29, 185, 84, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
    flex-shrink: 0;
}

.correct-artist-card .avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.correct-artist-card .details {
    flex: 1;
}

.correct-artist-card .name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.correct-artist-card .meta {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Result: play preview + Spotify link */
.result-audio {
    margin-bottom: 24px;
}

.result-preview {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.result-preview-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.result-audio-player {
    width: 100%;
    max-width: 320px;
    height: 40px;
}

.result-spotify-embed,
.result-spotify-embed-container iframe {
    max-width: 100%;
    border-radius: 12px;
    margin: 0 auto;
    display: block;
}

.result-spotify-embed-container {
    width: 100%;
    max-width: 320px;
    min-height: 152px;
}

.result-spotify-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.result-spotify-link:hover {
    text-decoration: underline;
}

.result-spotify-btn {
    display: inline-flex;
    width: auto;
    padding: 0 24px;
}

.stats-row {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-bottom: 24px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.share-btn {
    margin-top: 8px;
}

/* ============================================================
   Help Modal
   ============================================================ */

.help-modal {
    max-height: 80vh;
}

.help-content {
    padding: 16px;
    overflow-y: auto;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.help-section ol {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 15px;
}

.help-section p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 8px;
}

.hint-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hint-box {
    width: 40px;
    height: 28px;
    border-radius: 6px;
}

.hint-box.correct { background: var(--color-correct); }
.hint-box.close { background: var(--color-close); }
.hint-box.wrong { background: var(--color-wrong); }
.hint-box.unknown { background: var(--color-unknown); }

/* ============================================================
   Responsive
   ============================================================ */

@media (min-width: 500px) {
    .modal-content {
        border-radius: 20px;
        margin: auto;
        max-height: 80vh;
    }
    
    .result-modal,
    .help-modal {
        border-radius: 20px;
    }
}
