/* ═══════════════════════════════════════
   Shared UI Components
   ═══════════════════════════════════════ */

/* ── Game Header ── */
.game-header {
    text-align: center;
    padding: 32px 0 20px;
}

.game-badge {
    display: inline-block;
    padding: 6px 18px;
    border-radius: 999px;
    background: rgba(212, 160, 160, 0.10);
    color: var(--rose);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    border: 1px solid rgba(212, 160, 160, 0.16);
    margin-bottom: 14px;
}

.game-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.2rem, 6vw, 3.2rem);
    line-height: 1.1;
    font-weight: 500;
    margin-bottom: 6px;
}

.game-header h1 em {
    font-family: 'Great Vibes', cursive;
    font-style: normal;
    color: var(--accent);
    font-size: 1.2em;
}

.game-header .sub {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

/* ── Back Link ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(201, 169, 110, 0.08);
    border: 1px solid rgba(201, 169, 110, 0.14);
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.back-link:hover {
    background: rgba(201, 169, 110, 0.16);
    border-color: rgba(201, 169, 110, 0.3);
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 28px;
    padding: 20px 0 28px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    min-width: 80px;
}

.stat-value {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Difficulty Row ── */
.difficulty-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 10px 22px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    transition: all 0.3s ease;
}

.diff-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.diff-btn.active {
    background: rgba(201, 169, 110, 0.14);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--accent);
    color: #1a1a1a;
}

.btn-primary:hover {
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(201, 169, 110, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost-sm {
    padding: 10px 22px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.btn-ghost-sm:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Win Overlay ── */
.win-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.win-overlay.show {
    opacity: 1;
    visibility: visible;
}

.win-card {
    text-align: center;
    padding: 40px 32px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(28, 28, 28, 0.96), rgba(16, 16, 16, 0.96));
    border: 1px solid rgba(201, 169, 110, 0.2);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    max-width: 420px;
    width: 90%;
}

.win-icon {
    font-size: 3.5rem;
    color: var(--accent);
    margin-bottom: 12px;
    animation: bounce 0.6s ease infinite alternate;
}

.win-card h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.win-card .win-stats {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 24px;
}

.win-card .win-stats strong {
    color: var(--accent);
}

/* ── Result Card ── */
.result-card {
    text-align: center;
    padding: 40px 32px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(28, 28, 28, 0.96), rgba(16, 16, 16, 0.96));
    border: 1px solid rgba(201, 169, 110, 0.2);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.result-card h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.result-score {
    font-size: 3.5rem;
    font-family: 'Cormorant Garamond', serif;
    color: var(--accent);
    font-weight: 600;
    margin: 10px 0 4px;
}

.result-grade {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.result-breakdown {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.8;
    margin-bottom: 20px;
}

/* ── Music Toggle ── */
.music-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.music-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.music-toggle.playing {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(201, 169, 110, 0.1);
}

/* ── Progress Bar ── */
.progress-wrap {
    padding: 10px 0 24px;
}

.progress-bar-outer {
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.progress-bar-inner {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.progress-label {
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 6px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: 0.35s;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: min(100%, 500px);
    max-height: 85vh;
    background: linear-gradient(180deg, rgba(24, 24, 24, 0.98), rgba(12, 12, 12, 0.99));
    border: 1px solid rgba(201, 169, 110, 0.18);
    border-radius: 24px;
    padding: 24px;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    margin-bottom: 12px;
    font-weight: 500;
}

.modal-close {
    position: sticky;
    top: 0;
    float: right;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.25s;
    font-size: 0.9rem;
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface-3);
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-actions button {
    flex: 1;
    min-width: 90px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.03em;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #d9be88, var(--accent-soft));
    color: #1a1a1a;
    border: none;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(201, 169, 110, 0.25);
}

.btn-secondary {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(201, 169, 110, 0.35);
    color: var(--accent);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(232, 93, 93, 0.2);
    color: #e85d5d;
}

.btn-danger:hover {
    background: rgba(232, 93, 93, 0.08);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 24px;
    border-radius: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    white-space: nowrap;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ── Responsive ── */
@media (max-width: 600px) {
    .container {
        padding: 12px 10px 30px;
    }
    .stats-bar {
        gap: 16px;
    }
    .stat-value {
        font-size: 1.5rem;
    }
    .result-card {
        padding: 28px 20px;
    }
    .result-score {
        font-size: 2.8rem;
    }
}
