/* ══ CSS Custom Properties ══ */
:root {
    --bg: #141419;
    --surface: rgba(255, 255, 255, 0.08);
    --surface2: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.15);
    --accent: #8b7bf8;
    --accent2: #b8acfc;
    --text: #e2e2ec;
    --muted: rgba(226, 226, 236, 0.55);
    --green: #34d399;
    --radius: 16px;
    --diagram-bg: rgba(255, 255, 255, .04);
    --diagram-line: rgba(255, 255, 255, .15);
}

body.light-mode {
    --bg: #f2f2f7;
    --surface: rgba(0, 0, 0, .045);
    --surface2: rgba(0, 0, 0, .07);
    --border: rgba(0, 0, 0, .10);
    --text: #1c1c1e;
    --muted: rgba(28, 28, 30, .5);
    --diagram-bg: rgba(0, 0, 0, .04);
    --diagram-line: rgba(0, 0, 0, .15);
}

/* ══ Reset & Base ══ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html {
    height: 100%;
    height: -webkit-fill-available;
    overflow-x: hidden;
}

body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, 'SF Pro Display', 'Inter', BlinkMacSystemFont, sans-serif;
    color: var(--text);
    min-height: 100vh;
    min-height: 100svh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    position: relative;
}

#main-wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 14px 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 1;
    position: relative;
}

/* ══ Background & Decorative ══ */
#app-bg-grid {
    position: fixed;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M0 39.5h40M39.5 0v40' stroke='rgba(255,255,255,0.1)' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 40px 40px;
    transition: background-color 0.3s, opacity 0.3s;
}

body.light-mode #app-bg-grid {
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M0 39.5h40M39.5 0v40' stroke='rgba(0,0,0,0.05)' stroke-width='1'/%3E%3C/svg%3E");
}

/* Vignette overlay for grid */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at center, transparent 30%, var(--bg) 98%);
    z-index: -1;
    opacity: 1;
}

body.light-mode::before {
    background: radial-gradient(circle at center, transparent 30%, #ffffff 98%);
}

/* Blur Background Orbs */
.bg-orb1,
.bg-orb2 {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: -2;
}

.bg-orb1 {
    width: 800px;
    height: 800px;
    top: -200px;
    left: -200px;
    background: radial-gradient(circle, rgba(108, 99, 255, .15) 0%, rgba(108, 99, 255, 0.05) 40%, transparent 70%);
}

.bg-orb2 {
    width: 700px;
    height: 700px;
    bottom: -200px;
    right: -200px;
    background: radial-gradient(circle, rgba(52, 211, 153, .12) 0%, rgba(52, 211, 153, 0.04) 40%, transparent 70%);
}

body.light-mode .bg-orb1 {
    background: radial-gradient(circle, rgba(108, 99, 255, .12) 0%, rgba(108, 99, 255, 0.04) 40%, transparent 70%);
}

body.light-mode .bg-orb2 {
    background: radial-gradient(circle, rgba(52, 211, 153, .09) 0%, rgba(52, 211, 153, 0.03) 40%, transparent 70%);
}

/* Particle canvas */
#particle-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* ══ Typography ══ */
h1 {
    font-size: clamp(1.7rem, 5vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -.04em;
    background: linear-gradient(135deg, #fff 30%, var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 3px;
    z-index: 1;
}

body.light-mode h1 {
    background: linear-gradient(135deg, #1c1c1e 20%, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--muted);
    font-size: clamp(.75rem, 2.5vw, .88rem);
    margin-bottom: 20px;
    z-index: 1;
    text-align: center;
}

.lbl-small {
    font-size: .68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}

.mode-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    background: rgba(108, 99, 255, .1);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(108, 99, 255, .2);
    box-shadow: 0 0 6px rgba(108, 99, 255, .1);
    margin-bottom: 24px;
    align-self: flex-start;
}

/* ══ Glass Panels ══ */
.glass {
    background: #1e1e24;
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-radius: var(--radius);
    position: relative;
    z-index: 10;
}

.glass:hover {
    box-shadow: 0 8px 32px rgba(108, 99, 255, 0.15);
}

body.light-mode .glass {
    background: rgba(255, 255, 255, .65);
    border-color: rgba(0, 0, 0, .09);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

body.light-mode .glass:hover {
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.35);
}

.glass-strong {
    background: #23232a;
    border: 1px solid rgba(255, 255, 255, .10);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius);
    position: relative;
    z-index: 1;
}

.glass-strong:hover {
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.25);
}

body.light-mode .glass-strong {
    background: rgba(255, 255, 255, .85);
    border-color: rgba(0, 0, 0, .12);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

body.light-mode .glass-strong:hover {
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.45);
}

/* ══ Settings Panel ══ */
#settings-main {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    background: rgba(255, 255, 255, 0.06) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05),
        inset 0 0 40px 4px rgba(255, 255, 255, 0.03) !important;
    overflow: hidden;
}

#settings-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.5),
            transparent);
    pointer-events: none;
    z-index: 1;
}

#settings-main::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.4),
            transparent,
            rgba(255, 255, 255, 0.15));
    pointer-events: none;
    z-index: 1;
}

body.light-mode #settings-main {
    background: rgba(255, 255, 255, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(255, 255, 255, 0.2),
        inset 0 0 20px 4px rgba(255, 255, 255, 0.4) !important;
}

.settings-row {
    width: 100%;
    max-width: 960px;
    padding: 14px 18px;
    margin-bottom: 0px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: flex-end;
}

.settings-glass-container {
    width: 100%;
    max-width: 960px;
    background: var(--surface2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 10px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 0 12px rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.settings-glass-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    pointer-events: none;
}

body.light-mode .settings-glass-container {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ══ Form Controls ══ */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 120px;
    min-width: 100px;
}

.field label {
    font-size: .67rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .10em;
    text-transform: uppercase;
}

body.light-mode label {
    color: rgba(0, 0, 0, .45);
}

body.light-mode .field label[style*='text-align:center'],
body.light-mode .field label {
    text-align: center;
}

select,
input[type="number"],
input[type="text"] {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 11px;
    color: var(--text);
    font-family: inherit;
    font-size: .88rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color .2s, background .2s;
    -webkit-user-select: auto;
    user-select: auto;
    pointer-events: auto;
}

select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(240,240,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

select:hover,
select:focus {
    border-color: var(--accent);
    background-color: rgba(108, 99, 255, .1);
}

select option {
    background: #1a1a2e;
}

select:disabled {
    opacity: .35;
    cursor: not-allowed;
}

body.light-mode select,
body.light-mode input[type="number"] {
    background-color: rgba(255, 255, 255, .75);
    border-color: rgba(0, 0, 0, .13);
    color: var(--text);
}

body.light-mode select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(0,0,0,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* Sliders */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    border: none;
    padding: 0;
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, #937adb 0%, #937adb var(--pct, 50%), rgba(147, 122, 219, 0.1) var(--pct, 50%));
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1),
        0 3px 6px rgba(0, 0, 0, 0.25),
        0 4px 10px rgba(0, 0, 0, 0.15);
    margin-top: -6px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type=range]:active::-webkit-slider-thumb,
input[type=range]:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.35),
        0 6px 14px rgba(0, 0, 0, 0.2);
}

body.light-mode input[type=range]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 50%), rgba(0, 0, 0, .12) var(--pct, 50%));
}

body.light-mode input[type=range]::-webkit-slider-thumb {
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(108, 99, 255, .35);
}

.bpm-val {
    font-size: 0.65rem;
    font-weight: 800;
    color: #937adb;
    text-transform: uppercase;
    min-width: 32px;
    display: inline-block;
    text-align: right;
    letter-spacing: 0.05em;
}

body.light-mode .bpm-val {
    color: var(--accent);
}

body.light-mode .slider {
    background-color: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.15);
}

/* ══ Toggle Switches ══ */
.toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.toggle-lbl-left {
    width: 44px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.toggle-lbl-right {
    width: 44px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.toggle-label {
    font-size: .8rem;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s;
    user-select: none;
}

.toggle-label.on {
    color: var(--text);
}

body.light-mode .toggle-label {
    color: rgba(0, 0, 0, .35);
}

body.light-mode .toggle-label.on {
    color: var(--accent);
}

/* Apple-like Switch Toggles */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: background-color .2s ease;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: transform .2s ease;
    border-radius: 50%;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

input:checked+.slider {
    background-color: var(--accent);
    border-color: rgba(255, 255, 255, 0.45);
}

body.light-mode input:checked+.slider {
    border-color: rgba(0, 0, 0, 0.25);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* 3-Way Toggle for Chord Symbols */
.three-way-toggle {
    display: flex;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 4px;
}

body.light-mode .three-way-toggle {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.three-way-toggle .tw-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 9px 8px;
    cursor: pointer;
    transition: background .2s, color .2s;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

body.light-mode .three-way-toggle .tw-btn {
    border-right-color: rgba(0, 0, 0, 0.06);
}

.three-way-toggle .tw-btn:last-child {
    border-right: none;
}

.three-way-toggle .tw-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.3);
}

.three-way-toggle .tw-btn:not(.active):hover {
    background: rgba(108, 99, 255, 0.12);
    color: var(--text);
}

/* ══ Cards ══ */
.card {
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.15);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.4s ease, filter 0.4s ease, box-shadow 0.4s ease;
}

#card-area {
    width: 100%;
    max-width: 960px;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 0px;
    z-index: 1;
}

.chord-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 20px;
    border-radius: 24px;
}

/* MERGED: #cur-card from lines ~74 and ~1029 */
#cur-card {
    position: relative;
    flex: 1.6;
    min-width: 0;
    box-shadow: 0 12px 48px rgba(108, 99, 255, 0.15);
    cursor: grab;
    transition: box-shadow 0.3s ease;
}

#cur-card:hover {
    box-shadow: 0 0 50px rgba(108, 99, 255, 0.15), 0 0 100px rgba(108, 99, 255, 0.08);
}

body.light-mode #cur-card:hover {
    box-shadow: 0 0 50px rgba(108, 99, 255, 0.15), 0 0 100px rgba(108, 99, 255, 0.08);
}

#cur-card:active {
    box-shadow: 0 0 30px rgba(108, 99, 255, 0.15), 0 0 60px rgba(108, 99, 255, 0.1);
    transform: translateY(2px) scale(0.98);
    cursor: grabbing;
}

#cur-card.flip-in {
    animation: cardFlipIn .38s cubic-bezier(.22, 1, .36, 1) forwards;
}

/* MERGED: .chord-card--next from lines ~644 and ~1039 */
.chord-card--next {
    flex: 1;
    min-width: 0;
    background: #111113 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    opacity: .78;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body.light-mode .chord-card--next {
    background: #f0f0f5 !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Next card: milky / frosted (always) */
#next-card {
    opacity: 0.52;
    filter: blur(1.5px) saturate(80%);
    pointer-events: none;
    transition: opacity .3s, filter .3s;
}

body.light-mode #next-card {
    filter: blur(1.5px) saturate(60%) brightness(1.04);
}

#card-beat-display {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text);
    opacity: 0;
    transition: opacity .2s, text-shadow .15s;
    z-index: 10;
}

#card-beat-num {
    display: inline-block;
}

#cur-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

#active-timer {
    margin-top: 6px;
    align-self: flex-start;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 20;
}

/* MERGED: .card-lbl — later value .65rem wins */
.card-lbl {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--muted);
    text-transform: uppercase;
}

/* MERGED: .card-name — later value 2.8rem wins */
.card-name {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
    background: linear-gradient(135deg, #fff 20%, var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-mode .card-name {
    background: linear-gradient(135deg, #1c1c1e 20%, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-name sup {
    font-size: 0.55em;
    font-weight: 700;
    letter-spacing: 0;
    vertical-align: super;
    line-height: 0;
}

body.light-mode .card-name sup {
    background: linear-gradient(135deg, #1c1c1e 20%, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-name--next sup {
    font-size: 0.6em;
    font-weight: 700;
    letter-spacing: 0;
    vertical-align: super;
    line-height: 0;
}

/* MERGED: .card-name--next — later value 1.8rem wins */
.card-name--next {
    font-size: 1.8rem;
    background: none;
    -webkit-text-fill-color: unset;
    color: var(--accent2);
}

/* MERGED: .card-sub — later value .9rem wins */
.card-sub {
    font-size: .9rem;
    color: var(--muted);
    margin-top: -4px;
}

/* .card-inv — identical duplicates, kept once */
.card-inv {
    font-size: .78rem;
    color: var(--muted);
}

/* MERGED: .card-ivals — later font-size .82rem, first font-family preserved */
.card-ivals {
    font-size: .82rem;
    color: var(--muted);
    font-family: 'SF Mono', 'Menlo', monospace;
    letter-spacing: .04em;
}

.card-bass {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.bass-lbl {
    font-size: .68rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .08em;
}

#bass-note {
    font-size: 2rem;
    font-weight: 700;
    color: var(--green);
}

/* ══ Chord Diagram ══ */
/* diagram-wrap — identical duplicates, kept once */
#diagram-wrap,
#next-diagram-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* MERGED: .diag-lbl — later value .65rem wins */
.diag-lbl {
    font-size: .65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

#chord-diagram,
#next-diagram {
    display: block;
    overflow: visible;
}

.diagram-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.3);
    align-self: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

body.light-mode .diagram-box {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.05);
}

.pulse-anim {
    animation: diagramPulse 0.35s ease-out;
}

.shadow-pulse {
    animation: shadowPulse 2s infinite ease-in-out;
    transform-origin: center;
}

/* ══ Metronome ══ */
#metro-card {
    width: 100%;
    max-width: 960px;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#beat-row {
    display: flex;
    align-items: center;
    border-radius: 50px;
    padding: 8px 16px;
    gap: 12px;
}

.beat-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    position: relative;
}

.beat-num {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--muted);
    transition: color .08s, transform .08s;
    line-height: 1;
    z-index: 2;
}

body.light-mode .beat-dot {
    background: rgba(0, 0, 0, .10);
    border-color: rgba(0, 0, 0, .18);
}

body.light-mode .beat-sep,
body.light-mode .beat-and,
body.light-mode .beat-num {
    color: rgba(0, 0, 0, .45);
}

/* Pulse circle behind the number */
.beat-cell::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(108, 99, 255, 0.4);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease-out;
    z-index: 1;
}

.beat-cell.active::before {
    animation: pulseBeat 0.4s ease-out forwards;
}

.beat-cell.beat1.active::before {
    animation: pulseBeat1 0.4s ease-out forwards;
}

.beat-cell.active .beat-num {
    color: var(--text);
    text-shadow: 0 0 12px var(--accent);
    transform: scale(1.15);
}

.beat-cell.beat1.active .beat-num {
    color: var(--accent2);
    transform: scale(1.25);
}

.beat-and-inline {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--muted);
    margin-top: -2px;
    line-height: 1;
    transition: all 0.1s ease-out;
    opacity: 0.5;
    display: flex;
    align-items: center;
}

body.light-mode .beat-and-inline {
    color: rgba(108, 99, 255, .45);
}

.beat-and-inline.active-and {
    color: var(--accent);
    opacity: 1;
    transform: scale(1.4);
    text-shadow: 0 0 12px var(--accent);
}

/* ══ Control Buttons ══ */
/* MERGED: #ctrl-row — later grid layout wins, unique properties from first kept */
#ctrl-row {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    gap: 24px;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: 14px;
    font-weight: 600;
    font-size: .93rem;
    transition: all .18s;
}

/* MERGED: #btn-play, #btn-next — later combined definition wins */
#btn-play,
#btn-next {
    flex: 1;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: #fff;
    transition: transform .2s, filter .2s;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 4px 15px rgba(108, 99, 255, .3);
}

#btn-play:hover,
#btn-next:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

#btn-next {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #e5e5ea;
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .1);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
}

body.light-mode #btn-next {
    background: #d1d1d6;
    color: #000;
    border: none;
}

#btn-skip {
    padding: 13px 18px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--text);
}

#btn-skip:hover {
    background: rgba(255, 255, 255, .13);
}

#btn-skip:disabled {
    opacity: .3;
    cursor: not-allowed;
}

/* ══ Progression Display ══ */
#prog-display {
    width: 100%;
    max-width: 960px;
    z-index: 1;
}

.prog-step {
    padding: 5px 12px;
    border-radius: 30px;
    font-size: .78rem;
    font-weight: 500;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .09);
    color: var(--muted);
    white-space: nowrap;
}

.prog-step.current {
    background: rgba(108, 99, 255, .28);
    border-color: var(--accent2);
    color: var(--text);
}

#metro-box {
    margin-top: 20px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    width: 100%;
}

#stringset-row {
    margin-top: 20px;
    margin-bottom: 12px;
    padding: 12px 20px 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

/* ══ String Set Buttons ══ */
.btn-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

#sg-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    gap: 20px;
}

.sg-all-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

.sg-pair {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* String Set Lock (during practice) */
#stringset-row.locked {
    opacity: 0.35;
    pointer-events: none;
    transition: opacity .3s ease;
}

/* ══ Scale Panel ══ */
#scale-panel {
    width: 100%;
    max-width: 960px;
    margin-bottom: 10px;
    padding: 10px 18px;
    z-index: 1;
}

#scale-panel.hidden {
    display: none;
}

.scale-panel-title {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
    text-align: center;
}

#scale-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    align-items: center;
    justify-content: center;
}

.scale-chip {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: .80rem;
    font-weight: 500;
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    cursor: default;
    white-space: nowrap;
    user-select: none;
}

.scale-chip .chip-degree {
    font-size: .66rem;
    color: var(--muted);
    margin-left: 4px;
    font-weight: 400;
}

.scale-chip.current-chip {
    font-weight: 700;
    color: var(--accent2);
}

.scale-chip.current-chip .chip-degree {
    color: var(--accent2);
    opacity: .8;
}

body.light-mode .scale-chip {
    background: rgba(0, 0, 0, .04);
    color: var(--text);
}

body.light-mode .scale-chip.current-chip {
    color: var(--accent);
}

/* ══ Action Bar ══ */
#action-bar {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

/* Bar-phase indicator */
#bar-phase-wrap {
    width: 100%;
    max-width: 960px;
    z-index: 1;
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 6px;
}

.bar-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    transition: background .15s;
}

.bar-pip.bar-pip-active {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.bar-pip.bar-pip-root {
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
}

/* ══ Overlays ══ */
/* Session end overlay */
#end-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s
}

#end-overlay.visible {
    opacity: 1;
    pointer-events: all
}

#end-card {
    padding: 44px 52px;
    text-align: center;
    max-width: 420px;
    width: 90%
}

#end-emoji {
    font-size: 3.5rem;
    margin-bottom: 12px
}

#end-card h2 {
    font-size: 1.8rem;
    margin: 0 0 14px;
    background: linear-gradient(135deg, #fff, var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent
}

#end-score {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--accent2);
    margin-bottom: 6px
}

#end-hs {
    font-size: 1rem;
    color: #34d399;
    margin-bottom: 28px
}

#btn-again {
    padding: 13px 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 20px rgba(108, 99, 255, .4)
}

#btn-again:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(108, 99, 255, .55)
}

/* Countdown overlay */
#countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}

#countdown-overlay.visible {
    pointer-events: all;
    opacity: 1;
}

#countdown-num {
    font-size: 10rem;
    font-weight: 900;
    letter-spacing: -.05em;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: countPulse .8s cubic-bezier(.22, 1, .36, 1);
}

/* Fireworks canvas */
#fw-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 199;
    display: none
}

/* ══ Advanced Options Popup ══ */
#adv-popup {
    background: #1e1e26;
    border: 1px solid rgba(108, 99, 255, 0.35);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    scrollbar-width: thin;
    scrollbar-color: rgba(108, 99, 255, 0.4) transparent;
    contain: layout style paint;
}

#adv-popup * {
    will-change: auto;
}

body.light-mode #adv-popup {
    background: #f5f5fa;
    border: 1px solid rgba(108, 99, 255, 0.25);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

body.light-mode #adv-overlay {
    background: rgba(0, 0, 0, 0.25);
}

#adv-popup h3 {
    margin: 0 0 20px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: #6c63ff;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.light-mode #adv-popup h3 {
    color: #5a52d5;
}

#adv-popup .adv-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    margin: 18px 0 10px;
}

body.light-mode #adv-popup .adv-section-label {
    color: rgba(0, 0, 0, 0.4);
}

#adv-popup .adv-section-label:first-of-type {
    margin-top: 0;
}

#adv-popup .chord-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

#adv-popup .ct-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

body.light-mode #adv-popup .ct-row {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.05);
}

#adv-popup .ct-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.toggle-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

body.light-mode .toggle-box {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05);
}

.toggle-box:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.toggle-field-box {
    padding: 12px 14px;
}

#sel-instrument {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    color: inherit;
    border: 1px solid rgba(108, 99, 255, 0.3);
    outline: none;
    cursor: pointer;
    padding-right: 32px;
}

#btn-ct-all {
    background: rgba(108, 99, 255, 0.12);
    border: 1px solid rgba(108, 99, 255, 0.3);
    color: #6c63ff;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .05em;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 20px;
    transition: background .15s;
    text-transform: uppercase;
}

#adv-popup .ct-label {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

body.light-mode #adv-popup .ct-label {
    color: rgba(0, 0, 0, 0.8);
}

#adv-popup .ct-sub {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.38);
    font-weight: 400;
    margin-left: 4px;
}

body.light-mode #adv-popup .ct-sub {
    color: rgba(0, 0, 0, 0.4);
}

#adv-popup .switch {
    transform: scale(0.85);
    transform-origin: right center;
}

#adv-popup .adv-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 18px 0 16px;
}

body.light-mode #adv-popup .adv-divider {
    background: rgba(0, 0, 0, 0.08);
}

#adv-popup .adv-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 18px 0 10px;
}

#adv-popup .adv-section-header .adv-section-label {
    margin: 0;
}

#sg-grid-popup .sg-popup-item .ct-label {
    font-size: 0.85rem;
    font-weight: 500;
}

body.light-mode .sg-popup-item {
    background: rgba(0,0,0,0.03) !important;
    border-color: rgba(0,0,0,0.05) !important;
}

#adv-popup .adv-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    line-height: 1;
    transition: color .15s;
    padding: 4px 6px;
    border-radius: 6px;
}

body.light-mode #adv-popup .adv-close {
    color: rgba(0, 0, 0, 0.35);
}

#adv-popup .adv-close:hover {
    color: #6c63ff;
    background: rgba(108, 99, 255, 0.1);
}

#btn-adv-options {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 9px;
    color: var(--muted, #888);
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 10px;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}

/* Gear button hover states */
#btn-adv-options:hover {
    color: #6c63ff !important;
    background: rgba(108, 99, 255, 0.12) !important;
}

#btn-adv-options.active {
    color: #6c63ff !important;
}

/* ══ Animations ══ */
@keyframes diagramPulse {
    0% {
        transform: scale(0.96);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shadowPulse {
    0% {
        r: 12px;
        opacity: 0.8;
        fill: rgba(108, 99, 255, 0.15);
    }

    50% {
        r: 16px;
        opacity: 1;
        fill: rgba(108, 99, 255, 0.4);
    }

    100% {
        r: 12px;
        opacity: 0.8;
        fill: rgba(108, 99, 255, 0.15);
    }
}

@keyframes pulseBeat {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }

    40% {
        opacity: 1;
        transform: scale(1.1);
        box-shadow: 0 0 10px rgba(108, 99, 255, 0.7);
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes pulseBeat1 {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }

    40% {
        opacity: 1;
        background: rgba(244, 63, 94, 0.4);
        transform: scale(1.1);
        box-shadow: 0 0 12px rgba(244, 63, 94, 0.7);
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes countPulse {
    from {
        transform: scale(1.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes cardFlipIn {
    0% {
        transform: perspective(900px) rotateY(-90deg) scale(0.92);
        opacity: 0;
    }

    60% {
        transform: perspective(900px) rotateY(6deg) scale(1.01);
        opacity: 1;
    }

    100% {
        transform: perspective(900px) rotateY(0deg) scale(1);
        opacity: 1;
    }
}

/* ══ Utility Classes (from inline styles) ══ */

.settings-key-row {
    display: flex;
    gap: 24px;
    width: 100%;
}

.field--centered {
    flex: 1;
    align-items: center;
}

.label--centered {
    text-align: center;
    width: 100%;
}

.select--centered {
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.settings-controls-row {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
}

.field--slider {
    margin: 0;
    min-width: 100px;
    flex: 1;
    align-items: center;
    justify-content: flex-start;
}

.label--slider {
    font-size: 0.65rem;
    text-align: center;
    margin-bottom: 4px;
}

.field--toggle {
    margin: 0;
    flex: 1;
    align-items: center;
    justify-content: flex-start;
    min-width: 90px;
}

.label--toggle {
    text-align: center;
    margin-bottom: 4px;
}

.label--toggle-upper {
    text-align: center;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.field--metro-sound {
    flex: 1;
    min-width: 0;
    max-width: 150px;
}

.label--metro-sound {
    text-align: left;
    font-size: 0.6rem;
    margin-bottom: 4px;
    padding-left: 8px;
}

.field--metro-vol {
    margin: 0;
    min-width: 120px;
    flex: 1.5;
    align-items: center;
    justify-content: center;
}

.label--no-margin {
    margin-bottom: 0;
}

.sg-toggle {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stringset-label {
    font-size: .67rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .10em;
    text-transform: uppercase;
    text-align: center;
}

.ct-row--spaced {
    justify-content: flex-start;
    gap: 12px;
}

.ct-row--padded {
    padding: 2px 0 8px 0;
}

.adv-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.adv-section-header .adv-section-label {
    margin: 0;
}

.icon-flex {
    display: flex;
    align-items: center;
}

.toggle-row {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* ══ Responsive: Tablet (768px) ══ */
@media (max-width: 480px) and (orientation: portrait) {
    .hide-on-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {

    /* Safe-Area Padding for Notch and Home Indicator */
    #main-wrap {
        padding: 12px max(8px, env(safe-area-inset-left)) calc(120px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
        gap: 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    /* Prevent zoom on input focus */
    select,
    input[type="number"],
    input[type="range"],
    #inp-timer,
    #inp-bpm {
        font-size: 16px !important;
    }

    .settings-row {
        padding: 14px 16px;
        gap: 10px 12px;
    }

    #settings-main>div:first-child {
        flex-direction: column;
        gap: 12px !important;
    }

    /* Second row: 2x3 Grid */
    #settings-main>div:nth-child(2) {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 16px 8px !important;
    }

    #settings-main>div:nth-child(2)>.field {
        flex: 0 0 calc(50% - 4px) !important;
        min-width: 0 !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Larger touch targets for toggle switches */
    .switch {
        width: 48px;
        height: 28px;
    }

    .slider:before {
        height: 22px;
        width: 22px;
    }

    input:checked+.slider:before {
        transform: translateX(20px);
    }

    .toggle-wrap {
        transform: scale(1.0);
        justify-content: center !important;
        gap: 10px;
    }

    .settings-row .field {
        justify-content: center !important;
        align-items: center !important;
    }

    /* Selects – better tap targets */
    select {
        padding: 11px 30px 11px 12px;
        min-height: 44px;
    }

    input[type="number"] {
        min-height: 44px;
        padding: 11px;
    }

    /* Card Layout: only Current Card */
    #card-area {
        flex-direction: column;
        gap: 16px;
    }

    #cur-card,
    #next-card {
        flex: none;
        width: 100%;
        min-height: auto;
        padding: 20px 16px 16px;
    }

    /* Chord name larger on iPhone */
    .card-name {
        font-size: 2.8rem !important;
    }

    .card-sub {
        font-size: 1rem;
    }

    .card-inv,
    .card-ivals {
        font-size: 0.88rem;
    }

    /* Buttons: FIXED BAR AT BOTTOM */
    #action-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        z-index: 100 !important;
        padding: 12px 16px clamp(20px, env(safe-area-inset-bottom), 30px) 16px !important;
        background: rgba(20, 20, 25, 0.94) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4) !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
    }

    body.light-mode #action-bar {
        background: rgba(242, 242, 247, 0.92) !important;
        border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1) !important;
    }

    #ctrl-row {
        display: flex !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }

    #btn-play,
    #btn-next {
        flex: 1;
        min-height: 52px !important;
        font-size: 1rem !important;
        border-radius: 14px !important;
        padding: 14px 16px !important;
    }

    /* Metronome */
    #metro-box {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px 12px !important;
        padding: 14px 16px !important;
    }

    #metro-box>.field {
        flex: 1;
        max-width: 48% !important;
        min-width: 0 !important;
    }

    #beat-row {
        gap: 8px;
        padding: 8px 12px;
    }

    .beat-cell {
        width: 30px;
        height: 30px;
    }

    .beat-num {
        font-size: 1.1rem;
    }

    .beat-and-inline {
        font-size: 1.2rem;
    }

    /* Stringset – paired columns layout */
    #sg-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 16px 20px !important;
    }

    #sg-buttons .sg-toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 0 !important;
    }

    /* Advanced Popup – adjusted for iPhone */
    #adv-popup {
        width: min(94vw, 440px) !important;
        max-height: 80vh !important;
        padding: 24px 20px 18px !important;
    }

    /* Countdown overlay */
    #countdown-num {
        font-size: 8rem;
    }

    /* Header more compact */
    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.78rem;
        margin-bottom: 12px;
    }

    /* Volume slider larger touch target */
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    /* Label text slightly larger */
    .field label,
    .lbl-small {
        font-size: 0.72rem;
    }
}

/* ══ Responsive: Small Phone (375px) ══ */
@media (max-width: 375px) {
    .card-name {
        font-size: 2.4rem !important;
    }

    #sg-buttons {
        gap: 12px 16px !important;
    }

    .beat-num {
        font-size: 0.95rem;
    }
}

/* ══ Responsive: Landscape ══ */
@media (max-height: 500px) and (orientation: landscape) {
    #main-wrap {
        padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }

    #action-bar {
        padding: 8px max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom, 8px) max(16px, env(safe-area-inset-left)) !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
    }

    #btn-play,
    #btn-next {
        min-height: 44px !important;
        padding: 10px 16px !important;
    }

    .card-name {
        font-size: 1.8rem !important;
    }

    #card-area {
        flex-direction: row !important;
        align-items: stretch !important;
    }

    #cur-card,
    #next-card {
        min-height: 480px;
        padding: 24px;
    }
}
