/* ═══════════════════════════════════════════════════════════════
   Dictado Melódico v2 — styles
   Uses design tokens from variables.css
═══════════════════════════════════════════════════════════════ */

/* ── Layout ─────────────────────────────────────────────────── */
.game-wrapper {
    max-width: 820px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────── */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.back-btn {
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1rem;
    transition: transform 0.2s;
    white-space: nowrap;
}
.back-btn:hover { transform: translateX(-4px); }

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.diff-badge {
    background: var(--color-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-pill);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.round-badge {
    color: var(--color-text-light);
    font-size: 0.8rem;
    font-weight: 600;
}

.score-display {
    background: white;
    font-weight: 800;
    font-size: 1.1rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    color: var(--color-primary);
    white-space: nowrap;
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    animation: screenIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    flex: 1;
}
.screen.active { display: flex; }

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

h1 {
    font-size: 2.2rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}
h2 {
    font-size: 1.5rem;
    color: var(--color-text);
    margin-bottom: 1.2rem;
}

.subtitle {
    color: var(--color-text-light);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

/* ── Start screen ────────────────────────────────────────────── */
.start-icon {
    font-size: 4rem;
    margin-bottom: 0.75rem;
}

.setup-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.setup-label {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.diff-selection {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.2rem 1rem;
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.15s;
    width: 175px;
    box-shadow: var(--shadow-sm);
    opacity: 0.88;
}
.diff-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    opacity: 1;
}
.diff-btn.selected {
    border-color: white;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.35), var(--shadow-lg);
    transform: translateY(-5px);
    opacity: 1;
}
.diff-emoji { font-size: 2rem; }
.diff-btn strong { font-size: 1rem; color: white; }
.diff-btn small  { font-size: 0.75rem; color: rgba(255,255,255,0.82); text-align: center; }

.diff-green  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.diff-orange { background: linear-gradient(135deg, #f97316, #ea580c); }
.diff-red    { background: linear-gradient(135deg, #ef4444, #b91c1c); }

/* Round count selector */
.count-selection {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.count-btn {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    border: 2.5px solid #e2e8f0;
    background: white;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text-light);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s;
    box-shadow: var(--shadow-sm);
}
.count-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-2px);
}
.count-btn.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
    transform: translateY(-3px);
}

/* Start button */
.btn-start {
    font-size: 1.2rem;
    padding: 1rem 3rem;
    margin-top: 0.5rem;
}
.btn-start:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ── Play button ────────────────────────────────────────────── */
.play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-secondary);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
    margin-bottom: 1.5rem;
    font-family: inherit;
}
.play-btn:hover { transform: scale(1.05); background: var(--color-secondary-hover); }
.play-btn:active { transform: scale(0.97); }
.play-icon { font-size: 1rem; }

/* ── Direction screen ────────────────────────────────────────── */
.qmark-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.qmark-circle {
    width: 140px;
    height: 140px;
    background: linear-gradient(135deg, #f3e8ff, #ddd6fe);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6rem;
    font-weight: 900;
    color: var(--color-primary);
    margin-bottom: 1.2rem;
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
    animation: qpulse 2s infinite;
}

@keyframes qpulse {
    0%  { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
    70% { box-shadow: 0 0 0 20px rgba(124, 58, 237, 0); }
    100%{ box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.dir-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.dir-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 1.8rem;
    border: 2.5px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: white;
    color: var(--color-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
}
.dir-option:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}
.dir-arrow { font-size: 1.8rem; }

/* ── Staff options (Level 2) ─────────────────────────────────── */
.staff-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 500px;
}

.staff-card {
    border: 2.5px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.5rem;
    overflow: hidden;
}
.staff-card:hover {
    border-color: var(--color-secondary);
    background: white;
    transform: translateX(6px);
    box-shadow: var(--shadow-sm);
}
.staff-card.card-correct {
    border-color: #22c55e;
    background: #f0fdf4;
}
.staff-card.card-wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

/* ── Dictation ───────────────────────────────────────────────── */
.hint-text {
    color: var(--color-text-light);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.dictation-controls-top {
    margin-bottom: 0.5rem;
}

.interactive-staff-wrap {
    width: 100%;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 1.2rem;
    transition: border-color 0.2s;
}
.interactive-staff-wrap:hover {
    border-color: var(--color-primary);
}

.dictation-controls-bottom {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Generic Buttons ─────────────────────────────────────────── */
.btn {
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.5);
}
.btn-secondary {
    background: #e2e8f0;
    color: var(--color-text);
}
.btn-secondary:hover { background: #cbd5e1; }

.btn-outline {
    background: white;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}
.btn-outline:hover {
    background: var(--color-primary);
    color: white;
}

/* ── SVG Staff elements ──────────────────────────────────────── */
.staff-line {
    stroke: #475569;
    stroke-width: 1.5;
}
.ledger-line {
    stroke: #475569;
    stroke-width: 1.5;
}
.notehead {
    fill: #1e293b;
}
.notehead-placed {
    fill: var(--color-primary);
}
.note-stem {
    stroke: #1e293b;
    stroke-width: 1.8;
    stroke-linecap: round;
}
.treble-clef {
    fill: none;
    stroke: #1e293b;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
/* Treble clef rendered as Unicode SVG text — reliable and accurate */
.treble-clef-text {
    fill: #1e293b;
    dominant-baseline: auto;
    user-select: none;
}
.hit-zone {
    fill: transparent;
    cursor: pointer;
}
.hit-zone:hover {
    fill: rgba(124, 58, 237, 0.08);
    rx: 4;
}

/* ── Result screen ───────────────────────────────────────────── */
.result-emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.result-score-card {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.5rem 2rem;
    width: 100%;
    max-width: 360px;
    margin: 1.5rem 0;
    border: 1.5px solid #e2e8f0;
}
.result-score-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.05rem;
    margin-bottom: 1rem;
}
.result-pct-bar {
    background: #e2e8f0;
    border-radius: var(--radius-pill);
    height: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.result-pct-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-pill);
    width: 0%;
    transition: width 1s ease;
}
.result-pct-label {
    color: var(--color-text-light);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ── Feedback Overlay ────────────────────────────────────────── */
.feedback-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.feedback-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.feedback-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.feedback-icon {
    font-size: 7rem;
    line-height: 1;
}
.feedback-msg {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
}

@keyframes popIn {
    from { transform: scale(0.3); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Shake animation (validation) ───────────────────────────── */
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    75%      { transform: translateX(8px); }
}
.shake { animation: shake 0.4s ease; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .screen { padding: 1.5rem 1rem; }
    .diff-selection { flex-direction: column; align-items: center; }
    .diff-btn { width: 100%; max-width: 280px; }
    .dir-options { flex-direction: column; align-items: center; }
    .dir-option { width: 100%; max-width: 260px; }
    .dictation-controls-bottom { flex-direction: column; align-items: center; }
}

.hidden {
    display: none !important;
}
