:root {
  color-scheme: dark;
  --page: #151713;
  --panel: #1d201a;
  --inset: #141711;
  --line: #363b30;
  --text: #f1f3e9;
  --muted: #b1b7a6;
  --green: #d6fa70;
  --green-dark: #27331a;
  --cyan: #8fe0d0;
  --red: #ffb4a5;
  --display: "Barlow Condensed", "Arial Narrow", "DM Sans", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--page);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding-bottom: max(36px, env(safe-area-inset-bottom)); }
button, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button:disabled, select:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
a { color: inherit; }
h1, h2, p { margin: 0; }

.shell { width: min(1100px, calc(100% - 56px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line); background: #181a16; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font: 800 30px/.9 var(--display); letter-spacing: .04em; }
.brand-period { color: var(--green); }
.brand-mark { width: 33px; height: 33px; border-radius: 8px; background: var(--green); display: flex; justify-content: center; align-items: center; gap: 3px; }
.brand-mark i { height: 13px; width: 4px; background: #293715; transform: skew(-13deg); border-radius: 1px; }
.brand-mark i:nth-child(1) { transform: translateY(-4px) skew(-13deg); }
.brand-mark i:nth-child(3) { transform: translateY(4px) skew(-13deg); }
.button { min-height: 42px; padding: 7px 14px; border-radius: 8px; font-weight: 700; font-size: .88rem; white-space: nowrap; }
.button-outline { border: 1px solid #4a5240; background: #24281f; }
.button-outline:hover { background: #30372a; }
.tuner-button span { display: inline-block; color: var(--green); margin-right: 4px; font-size: 1.25em; line-height: 1; }
.button-primary { color: #17200d; background: var(--green); border: 1px solid var(--green); padding-inline: 17px; }
.button-primary:hover { background: #e1ff91; }
.button-primary span { margin-left: 9px; font-size: 1.05em; }
.button-quiet { border: 1px solid transparent; background: transparent; color: var(--muted); padding-inline: 9px; }
.button-quiet:hover:not(:disabled), .button-quiet[aria-pressed="true"] { background: #2b3223; color: var(--green); }

.intro { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 28px 0 23px; }
.intro h1 { font: 800 clamp(2.7rem, 5.5vw, 4.2rem)/.97 var(--display); letter-spacing: -.012em; }
.intro p { margin-top: 10px; font-size: .99rem; color: var(--muted); }
.mobile-setup { display: none; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 293px; align-items: start; gap: 19px; }
.game { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.game-card { padding: 14px 17px 7px; }
.game-head, .game-foot, .board-head, .board-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mode-picker, .input-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; background: #141711; border: 1px solid #353b2f; border-radius: 9px; }
.mode-picker button, .input-picker button { border: 1px solid transparent; background: transparent; min-height: 38px; padding: 5px 11px; border-radius: 6px; font-size: .88rem; color: var(--muted); font-weight: 700; }
.mode-picker button:hover, .input-picker button:hover { color: var(--text); }
.mode-picker button[aria-pressed="true"], .input-picker button[aria-pressed="true"] { background: #303922; color: var(--green); border-color: #465334; }
.round-label { color: var(--muted); font: 500 .76rem var(--mono); white-space: nowrap; padding-right: 3px; }
.round-progress { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.level { color: var(--green); font: 600 .67rem var(--mono); }
.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.scoreboard div { border: 1px solid #353b2e; background: #23281e; border-radius: 7px; padding: 6px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.scoreboard span { color: var(--muted); text-transform: uppercase; letter-spacing: .075em; font: 500 .68rem var(--mono); }
.scoreboard strong { font: 700 1.55rem/1 var(--display); font-variant-numeric: tabular-nums; color: var(--text); }
.scoreboard div:last-child strong { color: var(--green); }

.track { position: relative; height: clamp(182px, 29vh, 280px); overflow: hidden; isolation: isolate; border-radius: 9px; border: 1px solid #3c4434; background: #151a12; }
.lanes { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); background-image: linear-gradient(0deg, transparent 95%, #a5b99a10 96%); background-size: 100% 28px; }
.lanes i { border-right: 1px solid #adb6a221; background: linear-gradient(90deg, transparent 49%, #a7b29a15 50%, transparent 51%); }
.lanes i:nth-child(even) { background-color: #bfeb9c06; }
.lanes i:last-child { border: 0; }
.hit-line { position: absolute; inset: 72% 0 auto; height: 2px; background: #b9df6a; box-shadow: 0 0 19px #b7e15f73; }
.falling { position: absolute; inset: 0; }
.note-chip { position: absolute; top: var(--fall); left: calc((var(--lane) + .5) * 100% / 6); transform: translate(-50%, -50%); min-width: min(80%, 43px); max-width: calc(100% / 6 - 5px); padding: 3px 5px; border: 1px solid #758753; background: #2d3921; color: #e2f4bd; text-align: center; border-radius: 6px; display: grid; line-height: 1; box-shadow: 0 3px 8px #0009; }
.note-chip.current { border-color: var(--green); color: #1b270d; background: var(--green); z-index: 1; }
.free-match .note-chip { left: 50%; min-width: 55px; max-width: none; }
.free-match .lane-labels { visibility: hidden; }
.note-chip strong { font: 800 1.42rem/1 var(--display); white-space: nowrap; }
.note-chip small { font: 600 .58rem/1.3 var(--mono); white-space: nowrap; margin-top: 1px; }
.track[data-result]::after { content: attr(data-result); position: absolute; top: 9px; right: 10px; z-index: 2; padding: 4px 8px; border: 1px solid #738460; border-radius: 5px; background: #283421; color: var(--green); font: 600 .69rem var(--mono); pointer-events: none; }
.overlay { position: absolute; inset: 0; z-index: 3; background: radial-gradient(ellipse at center, #1a2116 10%, #171c13cc 57%, #171c1344 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px; }
.overlay h2 { font: 800 clamp(1.95rem, 4vw, 2.7rem)/1 var(--display); }
.overlay p { color: var(--muted); font-size: .85rem; margin: 5px 0 12px; }
.play-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #303b22; border: 1px solid #536440; color: var(--green); font-size: .95rem; margin-bottom: 6px; }
.lane-labels { display: grid; grid-template-columns: repeat(6, 1fr); font: 600 .8rem var(--mono); text-align: center; color: #cbd2bf; margin-top: 5px; }
.lane-labels small { font-size: .68em; color: var(--muted); }
.game-foot { min-height: 42px; margin-top: 2px; }
.readout { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .83rem; }
.status-dot { flex: 0 0 6px; height: 6px; border-radius: 50%; background: #99b36c; }
#feedback[data-tone="good"] { color: var(--cyan); }

.board-card { padding: 12px 16px 11px; }
.board-head h2, .settings h2, .tuner h2 { font: 700 1.85rem/1 var(--display); }
.board-head p, .tuner-head p { color: var(--muted); font-size: .77rem; margin-top: 4px; }
.board-instruction { color: var(--muted); font-size: .74rem; margin-top: 8px; }
.board-scroll { border: 1px solid #424b38; border-radius: 8px; overflow: auto; margin-top: 10px; scrollbar-color: #778761 #252b20; overscroll-behavior-x: contain; }
.board { --string-column: 32px; --fret-height: 41px; width: 100%; background: #282c23; }
.board.wide { min-width: calc(var(--string-column) + var(--columns) * 46px); }
.fret-row { display: grid; grid-template-columns: var(--string-column) repeat(var(--columns), minmax(0, 1fr)); }
.fret-row:nth-child(odd) { background: #ffffff05; }
.fret-row.fret-header { background: #191e15; color: #c5cbb9; font: 500 .72rem var(--mono); text-align: center; }
.fret-header span { padding: 5px 0; }
.fret-header span:first-child, .string-name { position: sticky; left: 0; z-index: 2; }
.fret-header span:first-child { background: #191e15; }
.fret-header .marked { color: var(--green); }
.string-name { display: grid; place-items: center; color: #d8e1cb; background: #242b1e; border-bottom: 1px solid #ffffff10; font: 600 .83rem var(--mono); }
.fret { position: relative; display: grid; place-items: center; min-height: var(--fret-height); touch-action: manipulation; border: 0; border-bottom: 1px solid #ffffff0d; border-right: 1px solid #69745c; background: transparent; padding: 0; }
.fret.open { background: #141b12; border-right: 2px solid #8a9876; }
.fret:last-child { border-right: 0; }
.fret::before { content: ""; position: absolute; height: var(--gauge); inset: 50% 0 auto; transform: translateY(-50%); background: #949b80; opacity: .66; }
.fret:focus-visible { outline-offset: -3px; z-index: 1; }
.fret-note { position: relative; z-index: 1; opacity: 0; padding: 3px 5px; border-radius: 3px; background: #171e15; color: #f2f3ec; font: 600 .68rem/1 var(--mono); }
.with-notes .fret-note, .fret.hint .fret-note, .fret.correct .fret-note, .fret.wrong .fret-note { opacity: 1; }
@media (hover: hover) { .fret:hover { background: #414b34; } }
.fret.hint { background: #687d3f; box-shadow: inset 0 0 0 2px var(--green); }
.fret.correct { background: #79bd8b; }
.fret.wrong { background: #a65144; }
.board-foot { margin-top: 7px; font-size: .74rem; color: var(--muted); }
.board-foot label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.board-foot select { min-height: 36px; padding: 3px 5px; }

.settings { padding: 16px; }
.settings h2 { margin-bottom: 17px; }
fieldset { min-width: 0; padding: 0; border: 0; margin: 0 0 16px; }
legend, .select-field { color: #e8ebdd; font-size: .81rem; font-weight: 700; }
legend { margin-bottom: 7px; padding: 0; }
.input-picker button { padding-inline: 4px; white-space: nowrap; }
.input-picker span { color: var(--green); margin-right: 2px; }
.field-help, .settings-note, .tuner-note { color: var(--muted); font-size: .74rem; line-height: 1.4; }
.field-help { margin-top: 6px; }
.range-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.range-picker button, .tuner-targets button { min-height: 41px; border: 1px solid #444e3b; border-radius: 6px; background: #262d21; color: #d3d8ca; font-size: .8rem; font-weight: 700; }
.range-picker button:hover, .tuner-targets button:hover { background: #343f2b; }
.range-picker button[aria-pressed="true"], .tuner-targets button[aria-pressed="true"] { background: var(--green-dark); border-color: #9bb65f; color: var(--green); }
.scale-controls { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px; }
.select-field { display: grid; gap: 5px; }
.select-field.compact { margin-top: 8px; }
select { background: #171b15; border: 1px solid #46503e; color: var(--text); border-radius: 6px; min-height: 42px; padding: 6px; width: 100%; font-size: .82rem; }
.tempo-field { margin-bottom: 10px; }
.matching-help { margin-bottom: 10px; }
.switch-field { position: relative; display: flex; justify-content: space-between; align-items: center; min-height: 43px; border-top: 1px solid #353b30; color: #dfe4d4; font-size: .82rem; font-weight: 600; cursor: pointer; }
.switch-field input { position: absolute; right: 0; width: 36px; height: 22px; opacity: 0; }
.switch { pointer-events: none; width: 35px; height: 20px; border: 1px solid #646e59; border-radius: 999px; background: #2b3226; padding: 3px; }
.switch::after { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: #aeb7a1; transition: transform .16s; }
.switch-field input:checked + .switch { background: #4d6130; border-color: #96ab64; }
.switch-field input:checked + .switch::after { transform: translateX(14px); background: var(--green); }
.switch-field input:focus-visible + .switch { outline: 2px solid var(--cyan); outline-offset: 3px; }
.switch-field input:disabled + .switch { opacity: .55; }
.settings-note { border-top: 1px solid #353b30; padding-top: 9px; }

.tuner { width: min(440px, calc(100% - 28px)); max-height: calc(100% - 28px); color: var(--text); background: var(--panel); border: 1px solid #667355; border-radius: 16px; padding: 19px; box-shadow: 0 18px 70px #000a; }
.tuner::backdrop { background: #0a0d09c9; }
.tuner-head { display: flex; justify-content: space-between; align-items: start; }
.tuner-targets { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 16px; }
.tuner-targets button { padding: 0 2px; font-size: .75rem; }
.pitch-display { display: grid; text-align: center; gap: 2px; padding: 16px 0 13px; }
.pitch-display strong { font: 800 4rem/.94 var(--display); color: var(--green); }
.pitch-display span, .meter-labels { color: var(--muted); font: 500 .73rem var(--mono); }
.tuner-meter { height: 29px; position: relative; border: 1px solid #535e49; border-radius: 6px; background: repeating-linear-gradient(90deg, #2a3324 0 9.6%, #616d55 9.6% 10%); }
.meter-centre { position: absolute; left: 45%; right: 45%; inset-block: 0; background: #526537; }
.needle { position: absolute; width: 4px; height: 35px; top: -4px; transform: translateX(-50%); border-radius: 2px; background: #f2cb92; }
.in-tune .needle { background: var(--green); box-shadow: 0 0 8px var(--green); }
.meter-labels { display: flex; justify-content: space-between; margin-top: 5px; }
#tuner-status { min-height: 43px; margin: 11px 0 4px; font-size: .86rem; }
.tuner-note { margin-top: 9px; }

@media (max-width: 840px) {
  .shell { width: min(720px, calc(100% - 32px)); }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .settings { scroll-margin-top: 10px; }
  .mobile-setup { display: inline; flex: 0 0 auto; color: var(--green); font-size: .79rem; text-underline-offset: 3px; padding-block: 8px; }
  .back-to-game { display: inline-block; margin-top: 6px; }
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 20px); }
  .topbar-inner { min-height: 52px; }
  .brand { font-size: 25px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  .intro { padding: 13px 2px 10px; align-items: start; flex-wrap: wrap; gap: 1px; }
  .intro h1 { font-size: 2.43rem; }
  .intro p { font-size: .79rem; margin-top: 4px; }
  .mobile-setup { padding: 5px 0; font-size: .74rem; }
  .game { gap: 10px; }
  .game-card { padding: 7px 8px 2px; }
  .mode-picker button { min-height: 35px; }
  .track { height: clamp(150px, 24svh, 218px); }
  .round-active .intro { display: none; }
  .round-active .layout { padding-top: 8px; }
  .round-active .track { height: clamp(108px, calc(100svh - 535px), 172px); }
  .round-active .board-head .button { min-height: 34px; }
  .round-active .play-mark { display: none; }
  .scoreboard { margin: 6px 0; }
  .scoreboard div { padding: 4px 6px; }
  .scoreboard strong { font-size: 1.36rem; }
  .overlay p { margin: 3px 0 8px; }
  .overlay .button { min-height: 38px; }
  .play-mark { width: 26px; height: 26px; margin-bottom: 3px; }
  .game-foot { min-height: 34px; }
  .game-foot .button { min-height: 36px; }
  .board-card { padding: 7px 8px 8px; }
  .board-head h2 { font-size: 1.58rem; }
  .board-head p { margin-top: 2px; }
  .board-scroll { margin-top: 6px; }
  .board { --fret-height: clamp(36px, 5.2svh, 44px); }
  .round-active .board { --fret-height: clamp(36px, 5.2svh, 42px); }
  .board-foot { font-size: .71rem; }
  .tuner-targets button { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
