.trainer-selectors { grid-template-columns: 1fr 1.4fr 0.8fr 0.9fr 1fr; gap: 0.6rem; padding: 0.45rem 0.85rem; }
.masthead { padding-block: 0; }
.brand img { width: 56px; }
.intro { padding-block: 0.35rem; }
.intro h1 { font-size: 1.5rem; }
.intro .subtitle { font-size: 0.75rem; }
.game-settings .selectors { border-radius: 1.25rem 1.25rem 0 0; }
.trainer-selectors select { padding-block: 0.4rem; }
.trainer-selectors .field > label { margin-bottom: 0.15rem; }
.trainer-content { padding: 0.5rem 0.85rem; }
.round-heading { display: flex; align-items: center; gap: 0.75rem; min-height: 52px; border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; }
.round-heading .eyebrow { margin: 0; }
.game-stats { display: flex; gap: 1rem; margin-left: auto; font-size: 0.8rem; }
.game-stats strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; color: var(--green); margin-left: 0.25rem; }
.game-stats > span { white-space: nowrap; }
.game-stats #timer { display: inline-block; min-width: 4ch; }
.game-stats #score { display: inline-block; min-width: 3ch; }
.intro { display: flex; align-items: baseline; gap: 1rem; padding-block: 0.5rem; }
#levelDescription, #instruction { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }
.question-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 1rem; height: 68px; }
.trainer-content h2 { margin-top: 0.15rem; font-size: clamp(1.1rem, 2.5vw, 1.35rem); }
#feedback { margin-block: 0.25rem; font-size: 0.85rem; }
#audioStatus:empty, #foundCount:empty { display: none; }
.instructions { padding-block: 0.75rem; max-width: none; }
.sound-option { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; font-size: 0.8rem; }
.trainer-content h2 { font-size: clamp(1.1rem, 2.5vw, 1.35rem); letter-spacing: -0.025em; }
#instruction { color: var(--muted); line-height: 1.4; font-size: 0.8rem; }
.game-heading { height: 136px; padding-bottom: 0; }
.answer-panel { height: 56px; padding-top: 0; }
#trainer:not([data-exercise="name"]) .answer-panel { display: none; }
.round-actions { display: flex; gap: 0.5rem; }
button:disabled { opacity: 0.5; }
#trainer { overflow-anchor: none; }
.answer-controls { display: flex; align-items: start; flex-wrap: wrap; gap: 0.4rem 1rem; }
.answer-controls .answers { flex: 1 1 480px; }
.answer-feedback { min-width: 0; font-size: 0.8rem; }
.answer-feedback:has(#audioStatus.error:not(:empty)) > :not(#audioStatus) { display: none; }
.answer-controls button { height: 44px; line-height: 1.25; }
.game-heading #prompt { min-height: 1.25em; line-height: 1.2; }
.round-heading .eyebrow { min-width: 150px; }
#audioStatus:not(.error) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button { min-height: 44px; padding: 0.6rem 1rem; border: 1px solid #bdc3b5; border-radius: 0.55rem; background: #fff; color: var(--ink); cursor: pointer; touch-action: manipulation; }
button:hover:not(:disabled) { background: #f3f5ee; border-color: var(--green); }
button.primary { color: #fff; background: var(--green); border-color: var(--green); font-weight: 650; }
button.primary:hover { background: #304b38; }
button:disabled { cursor: default; }
.actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
#resetConfirm { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.answers { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.answers button { min-width: 44px; padding-inline: 0.65rem; font-weight: 650; border-width: 2px; }
.answers button.correct { background: #e2efdf; border: 2px solid #42604b; }
.answers button.wrong { background: #fae8df; border: 2px dashed #aa421a; }
#feedback { min-height: 1.4em; line-height: 1.4; margin: 0.2rem 0; }
.trainer-board-scroll { overflow-x: auto; overscroll-behavior-x: contain; background: #fcfbf7; border-block: 1px solid var(--line); padding: 0.5rem; }
.fretboard-pane { position: relative; padding-top: 44px; background: #fcfbf7; border-top: 1px solid var(--line); }
.view-field { position: absolute; top: 0; right: 12px; z-index: 3; display: flex; align-items: center; gap: 0.5rem; min-height: 44px; padding-inline: 0.5rem; border-radius: 0.5rem; background: #fcfbf7ed; font-size: 0.8rem; cursor: pointer; }
.view-field input { appearance: none; width: 32px; height: 20px; border: 1px solid #8b9587; border-radius: 12px; background: #e4e5dc; position: relative; cursor: pointer; }
.view-field input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #25282040; }
.view-field input:checked { background: var(--green); }
.view-field input:checked::before { left: 14px; }
.board-stage { width: 100%; }
.trainer-board { position: relative; display: grid; grid-template-rows: 24px repeat(6, 44px); gap: 0; width: 100%; min-width: 440px; padding: 0.25rem; margin-inline: auto; }
.trainer-neck { width: 100%; height: 264px; min-width: 0; pointer-events: none; overflow: visible; }
.neck-wood { fill: #62432f; }
.neck-side { display: none; fill: #38281f; stroke: #b58b5c; stroke-width: 1; vector-effect: non-scaling-stroke; }
.headstock-face { fill: #dfb77a; stroke: #99703f; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.headstock-side { fill: #694526; }
.headstock-scoop { fill: #dfb77a; stroke: #99703f; stroke-width: 1; vector-effect: non-scaling-stroke; }
.headstock-grain { fill: none; stroke: #e5ba7d; stroke-width: 1; opacity: 0.35; vector-effect: non-scaling-stroke; }
.tuner-shaft { stroke: #737778; stroke-width: 5; vector-effect: non-scaling-stroke; }
.tuner-key, .tuner-washer { fill: #d6d9d5; stroke: #737778; stroke-width: 1; vector-effect: non-scaling-stroke; }
.tuner-post { fill: #666b6b; stroke: #f4f1df; stroke-width: 1; vector-effect: non-scaling-stroke; }
.tuner-barrel, .tuner-key-edge { fill: #737778; }
.tuner-riser { stroke: #737778; stroke-width: 3; }
.tuner-highlight { fill: none; stroke: #fff; stroke-width: 1; }
.headstock-string { stroke: #f9edcc; vector-effect: non-scaling-stroke; filter: drop-shadow(0 1px 1px #513620); }
.side-inlay { display: none; pointer-events: none; }
.board-stage[data-view="player"] { position: relative; overflow: clip; }
.board-stage[data-view="player"] .trainer-board { position: absolute; inset: 0 auto auto 0; transform-origin: top left; margin: 0; }
.board-stage[data-view="player"] .neck-side { display: block; }
.board-stage[data-view="player"] .open-heading, .board-stage[data-view="player"] .trainer-position[data-fret="0"] { position: relative; background: transparent; }
.board-stage[data-view="player"] .side-inlay { display: block; place-self: end center; z-index: 1; height: 12px; line-height: 12px; font-size: 18px; letter-spacing: 4px; color: #f5ead4; transform: translateY(var(--side-offset)); }
.board-stage[data-view="player"] .marker { min-width: 25px; height: 25px; font-size: 0.72rem; }
.board-stage[data-view="player"] .trainer-position[data-fret="0"] .marker { min-width: 18px; height: 18px; padding: 0; font-size: 0.6rem; }
.fret-caption { display: inline-block; }
.wood-grain { fill: none; stroke: #b88b5e; stroke-width: 1; opacity: 0.16; vector-effect: non-scaling-stroke; }
.neck-binding { fill: none; stroke: #d6bf90; stroke-width: 3; vector-effect: non-scaling-stroke; }
.neck-fret { stroke: #d6d4cb; stroke-width: 3; vector-effect: non-scaling-stroke; }
.neck-nut { stroke: #f2e9ce; stroke-width: 7; vector-effect: non-scaling-stroke; }
.neck-inlay { fill: #e9e1c7; background: #e9e1c7; border: 1px solid #c7b896; border-radius: 50%; height: 32%; max-height: 28px; aspect-ratio: 1; place-self: center; pointer-events: none; z-index: 1; }
.neck-continuation-dot { fill: #e9e1c7; }
.neck-string { stroke: #fff0ce; vector-effect: non-scaling-stroke; filter: drop-shadow(0 1px 1px #21160f); }
.trainer-board[data-wood="maple"] .neck-wood { fill: #e9c48a; }
.trainer-board[data-wood="maple"] .neck-side { fill: #c39960; stroke: #9d7746; }
.trainer-board[data-wood="maple"] .side-inlay { color: #332c26; }
.trainer-board[data-wood="maple"] .wood-grain { stroke: #936136; opacity: 0.22; }
.trainer-board[data-wood="maple"] .neck-binding { stroke: #ad7c40; }
.trainer-board[data-wood="maple"] .neck-fret { stroke: #777b7d; }
.trainer-board[data-wood="maple"] .neck-inlay { fill: #332c26; background: #332c26; border-color: #514132; }
.trainer-board[data-wood="maple"] .neck-continuation-dot { fill: #332c26; }
.trainer-board[data-wood="maple"] .neck-string { stroke: #494740; filter: drop-shadow(0 1px 0 #fff9); }
.trainer-fret { display: grid; place-items: center; min-height: 24px; font-size: 0.75rem; color: var(--muted); }
.open-heading { position: sticky; left: 0; z-index: 2; background: #fcfbf7; }
.trainer-position { position: relative; min-width: 0; min-height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.trainer-position:hover:not(:disabled) { background: #ffffff16; }
.trainer-position[data-fret="0"] { position: sticky; left: 0; z-index: 2; background: #fcfbf7; }
.trainer-position[data-fret="0"]:hover { background: #f3f5ee; }
.trainer-position .marker { display: inline-grid; place-items: center; height: 32px; min-width: 32px; padding: 0 2px; border-radius: 50%; background: #fff; border: 1px solid #b6b8aa; font-size: 0.8rem; font-weight: 700; color: #626353; transform: translateY(var(--string-offset)); }
.trainer-position:not([data-fret="0"]):not(.target):not(.correct):not(.wrong):not(.revealed) .marker { opacity: 0; }
.trainer-position:hover .marker, .trainer-position:focus-visible .marker { opacity: 1 !important; }
.trainer-position.target .marker { background: var(--orange); border: 2px solid #fff; color: #fff; border-radius: 6px; }
.trainer-position.correct .marker { background: var(--green); border: 2px solid #fff; color: #fff; }
.trainer-position.wrong .marker { background: #fff0e8; border: 2px dashed var(--orange); color: var(--orange); }
.trainer-position.revealed .marker { border: 2px dashed var(--green); color: var(--green); background: #fff; }
.trainer-position:focus-visible { outline-offset: -4px; position: relative; z-index: 1; }
/* One full-screen layout for every device: settings, toolbar, fretboard, then answer keys. */
html, body { height: 100%; }
body { height: 100dvh; overflow: hidden; }
main.container { display: flex; flex-direction: column; justify-content: center; width: min(100%, 1240px); height: 100dvh; margin-inline: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#trainer { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; max-height: 760px; overflow: hidden; border-block: 0; border-radius: 0; box-shadow: none; }
@media (min-height: 800px) and (min-width: 1000px) {
  #trainer { border: 1px solid var(--line); border-radius: 1rem; }
  .game-settings .selectors { border-radius: 1rem 1rem 0 0; }
}
.game-settings { flex: 0 0 auto; }
.game-settings .selectors { border-radius: 0; }
.trainer-selectors { grid-template-columns: 0.8fr 1.35fr 1fr 1fr 1.15fr auto; align-items: end; gap: 0.35rem; padding: 0.25rem 0.4rem; }
.trainer-selectors .field { grid-column: auto !important; }
.trainer-selectors .field > label { margin-bottom: 0; font-size: 0.62rem; }
.trainer-selectors select { min-height: 32px; padding: 0.1rem 1.4rem 0.1rem 0.4rem; font-size: 0.75rem; }
.trainer-menu { display: flex; align-items: center; gap: 0.35rem; }
.trainer-menu button { min-height: 32px; padding: 0.2rem 0.65rem; font-size: 0.75rem; }
.home-link { display: block; border-radius: 0.4rem; }
.home-link img { display: block; width: auto; height: 32px; mix-blend-mode: multiply; }
.game-heading { position: relative; display: flex; flex: 0 0 auto; flex-direction: column; height: auto; padding: 0 0.4rem; }
.game-heading #levelDescription, .game-heading #instruction { top: 0; left: 0; }
.round-heading { flex: 0 0 44px; min-height: 44px; height: 44px; gap: 0.4rem; padding: 0; }
.round-heading .eyebrow { min-width: 0; overflow: hidden; font-size: 0.6rem; white-space: nowrap; text-overflow: ellipsis; }
.game-stats { gap: 0.6rem; margin-left: auto; font-size: 0.7rem; }
.game-stats strong { font-size: 1rem; }
.sound-option { min-height: 44px; gap: 0.3rem; font-size: 0.7rem; white-space: nowrap; }
.sound-option input { width: 16px; height: 16px; }
.round-actions { gap: 0.25rem; }
.round-actions button { min-height: 44px; padding: 0.2rem 0.75rem; font-size: 0.75rem; }
.question-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0.4rem; height: 34px; min-height: 34px; }
.trainer-content h2 { margin: 0; font-size: 0.9rem; }
.answer-feedback { display: flex; gap: 0.4rem; align-items: center; justify-content: flex-end; font-size: 0.7rem; line-height: 1.2; text-align: right; }
.answer-feedback p { margin: 0; }
.answer-feedback #audioStatus { padding: 0; font-size: inherit; line-height: inherit; }
#foundCount { flex: none; white-space: nowrap; }
#feedback { min-height: 0; margin: 0; font-size: 0.7rem; line-height: 1.2; }
.answer-panel { order: 3; flex: 0 0 72px; height: 72px; min-height: 0; padding: 0.2rem 0.4rem 0.3rem; }
.answer-controls, .answer-controls .answers { width: 100%; height: 100%; }
.answer-controls .answers { display: grid; grid-template-columns: repeat(var(--answer-count, 7), minmax(0, 1fr)); grid-template-rows: 1fr; gap: 0.3rem; flex: none; max-width: 900px; margin-inline: auto; }
.answer-controls .answers button { min-width: 0; min-height: 44px; padding: 0.2rem; border-radius: 0.4rem; font-size: 0.9rem; }
.fretboard-pane { order: 2; display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; min-height: 0; padding-top: 26px; }
.view-field { top: 0; right: 0.4rem; min-height: 26px; padding-inline: 0.25rem; font-size: 0.7rem; }
.view-field input { width: 28px; height: 18px; }
.view-field input::before { width: 12px; height: 12px; }
.view-field input:checked::before { left: 12px; }
.trainer-board-scroll { display: grid; place-items: center; container-type: size; flex: 1 1 auto; min-height: 0; overflow: hidden; padding: 0; }
/* Preserve a 4:1 neck, excluding the 40px open-string labels and 14px heading. */
.board-stage { width: min(100cqw, calc((100cqh - 14px) * 4 + 40px)); height: min(100cqh, calc((100cqw - 40px) / 4 + 14px)); }
.trainer-board { width: 100%; height: 100%; min-width: 0; grid-template-rows: 14px repeat(6, minmax(0, 1fr)); padding: 0; }
.trainer-fret { min-height: 0; font-size: 0.65rem; line-height: 14px; }
.trainer-neck { height: 100%; }
.trainer-position { min-height: 0; }
.trainer-position .marker { height: 26px; min-width: 26px; font-size: 0.7rem; }
.board-stage[data-view="player"] .trainer-position .marker { height: 22px; min-width: 22px; }
.help-dialog { width: min(calc(100% - 2rem), 760px); max-height: calc(100dvh - 2rem); padding: 0 1.25rem 1.25rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; color: var(--ink); }
.help-dialog::backdrop { background: #25282066; }
.help-heading { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 0.75rem; background: #fff; border-bottom: 1px solid var(--line); }
.help-heading h2 { margin: 0; font-size: 1.1rem; }
.help-links { display: flex; flex-wrap: wrap; gap: 0 1rem; font-size: 0.8rem; }
@media (max-width: 700px) {
  .trainer-selectors { gap: 0.25rem; }
  .trainer-selectors select { padding-right: 1rem; font-size: 0.68rem; }
  .home-link { display: none; }
  .round-heading .eyebrow { display: none; }
  .game-stats { margin-left: 0; }
  .sound-option { margin-left: auto; }
}
@media (max-width: 640px), (max-height: 379px) {
  .fretboard-pane { padding-top: 0; }
  .view-field { display: none; }
}
@media (max-height: 420px) {
  .board-stage[data-view="player"] .trainer-position .marker { height: 16px; min-width: 16px; font-size: 0.6rem; }
}
@media (max-height: 340px) {
  .trainer-selectors .field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .question-row { height: 28px; min-height: 28px; }
  .trainer-content h2 { font-size: 0.8rem; }
  .answer-panel { flex-basis: 60px; height: 60px; }
}
@media (pointer: coarse) and (orientation: portrait) {
  .orientation-notice { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: #faf9f6; text-align: center;
    padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left)); }
  .orientation-notice[hidden] { display: none; }
  .orientation-card { max-width: 24rem; }
  .orientation-icon { width: 4rem; height: 4rem; color: var(--green); margin-bottom: 1rem; }
  .orientation-card h2 { font-size: 1.35rem; }
  .orientation-card p { color: var(--muted); line-height: 1.5; }
}
@media (forced-colors: active) {
  .headstock-face, .headstock-side, .headstock-scoop, .tuner-key, .tuner-washer, .tuner-post { fill: Canvas; stroke: CanvasText; }
  .headstock-string, .tuner-shaft { stroke: CanvasText; }
  .tuner-barrel, .tuner-key-edge { fill: CanvasText; }
  .tuner-riser, .tuner-highlight { stroke: CanvasText; }
  .trainer-board .neck-wood { fill: Canvas !important; }
  .trainer-board .neck-fret, .trainer-board .neck-string, .trainer-board .neck-nut, .trainer-board .neck-binding { stroke: CanvasText !important; }
  .trainer-board .neck-inlay { fill: CanvasText !important; background: CanvasText !important; }
  .trainer-board .neck-side { fill: Canvas !important; stroke: CanvasText !important; }
  .trainer-board .side-inlay { color: CanvasText !important; }
  .trainer-position { border: 1px solid CanvasText; }
  .trainer-position.target .marker { outline: 3px solid Highlight; }
  .trainer-position.correct .marker { border: 3px solid CanvasText; }
}
