/* Riff Catcher — page-local styles. Does not change the rest of the site. */
.riff-catcher {
  --game-bg: #1b2a24;
  --game-bg-2: #24352e;
  --game-line: #3d5145;
  --game-string: #8a9a86;
  --game-fret: #dfbda4;
  --game-note: #a44f30;
  --game-note-2: #d27a58;
  --game-good: #d7c4a3;
  --game-text: #f6f2e9;
  --game-muted: #c5c1b4;
  max-width: 760px;
  margin-inline: auto;
}
.riff-catcher[data-theme="5754"] {
  --game-bg: #0a0a0a;
  --game-bg-2: #161616;
  --game-line: #2b2b2b;
  --game-string: #8a8378;
  --game-fret: #ece8e1;
  --game-note: #c45c3e;
  --game-note-2: #e08968;
  --game-good: #ece8e1;
  --game-text: #ece8e1;
  --game-muted: #9a958c;
}
.game-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px 28px;
  margin-bottom: 16px;
}
.hud-stat { min-width: 72px; }
.hud-label {
  display: block;
  font-size: 10px;
  letter-spacing: .16em;
  font-weight: 600;
  color: var(--accent, #a44f30);
  margin-bottom: 4px;
}
.hud-value {
  font-family: var(--serif, Georgia, serif);
  font-size: 28px;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink, var(--paper, #24352e));
  letter-spacing: -.03em;
}
.riff-catcher[data-theme="5754"] .hud-value {
  font-family: var(--display, "Barlow Condensed", Impact, sans-serif);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--paper);
}
.mute-toggle {
  margin-left: auto;
  background: transparent;
  color: inherit;
  border: 1px solid var(--line, #dcd9cd);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  min-height: 44px;
}
.mute-toggle:hover { background: var(--white, var(--bg-alt, #fcfaf5)); }
.riff-catcher[data-theme="5754"] .mute-toggle:hover { background: #1a1a1a; }
.game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: min(80vh, 760px);
  height: min(80vh, 760px);
  background: var(--game-bg);
  border: 1px solid var(--line, #dcd9cd);
  overflow: hidden;
  overscroll-behavior: none;
}
#riff-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: none;
  cursor: pointer;
  vertical-align: middle;
}
.lane-hit {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px 14px;
  background: color-mix(in srgb, var(--game-bg) 88%, black);
}
.lane-hit button {
  min-height: 52px;
  border: 1px solid var(--game-line);
  background: var(--game-bg-2);
  color: var(--game-text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  cursor: pointer;
}
.lane-hit button:hover,
.lane-hit button.is-hot { border-color: var(--game-note); color: var(--game-note-2, var(--game-note)); }
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background: color-mix(in srgb, var(--game-bg) 78%, transparent);
  z-index: 2;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.game-overlay[hidden] { display: none !important; }
.overlay-card {
  width: min(520px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--white, var(--bg-alt, #fcfaf5));
  border: 1px solid var(--line, #dcd9cd);
  padding: 0;
  color: var(--text, var(--paper, #3c443e));
}
.overlay-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 22px 12px;
}
.overlay-actions {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 22px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line, #2b2b2b);
  background: inherit;
}
.overlay-actions .btn,
.overlay-actions #play-btn {
  width: 100%;
  min-height: 52px;
  justify-content: center;
}
.riff-catcher[data-theme="redbeardz"] .overlay-card { background: #fcfaf5; color: #3c443e; }
.riff-catcher[data-theme="5754"] .overlay-card {
  background: #141414;
  color: var(--paper);
  border-color: var(--line);
}
.overlay-card h2 {
  font-size: clamp(32px, 6vw, 48px);
  margin: 0 0 14px;
}
.overlay-card p { margin: 0; }
.overlay-card .eyebrow { margin-bottom: 12px; }
.best-line { margin-top: 16px !important; font-size: 14px; color: var(--muted); }
.now-playing {
  margin-top: 22px;
  font-size: 14px;
}
.now-playing a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.game-help { margin-top: 12px; max-width: 62ch; }
.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}
@media (max-width: 760px) {
  .hud-value { font-size: 22px; }
  .lane-hit button { min-height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .lane-hit button, .mute-toggle, .button { transition: none; }
}

.riff-catcher[data-theme="5754"] .overlay-card h2 {
  font-family: var(--display, "Barlow Condensed", Impact, sans-serif);
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  font-size: clamp(28px, 6vw, 44px);
}
.riff-catcher[data-theme="5754"] #play-btn.btn svg {
  width: 18px;
  height: 18px;
}
.riff-catcher[data-theme="5754"] .game-stage {
  border-color: var(--line, #2b2b2b);
}

.track-picker {
  margin: 16px 0 0;
  border: 1px solid var(--line, #2b2b2b);
  padding: 8px 8px 6px;
  min-width: 0;
}
.track-picker legend {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent, #c45c3e);
  padding: 0 6px;
}
.track-list { display: flex; flex-direction: column; }
.track-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
}
.track-option input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent, #c45c3e);
  margin: 0;
}
.track-option:hover { background: color-mix(in srgb, var(--accent, #c45c3e) 12%, transparent); }
.track-option:has(input:checked) { background: color-mix(in srgb, var(--accent, #c45c3e) 18%, transparent); }
.track-option:has(input:focus-visible) { outline: 2px solid var(--accent, #c45c3e); outline-offset: 2px; }
.riff-catcher[data-theme="redbeardz"] .track-picker { border-color: var(--line, #dcd9cd); }

.ampleague-embed {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
}

/* Viewport-first playfield. Game page only (body.game-page). */
.game-playfield {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hud-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.fs-toggle {
  background: transparent;
  color: inherit;
  border: 1px solid var(--line, #dcd9cd);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  min-height: 44px;
}
.fs-toggle:hover { background: var(--white, var(--bg-alt, #fcfaf5)); }
.riff-catcher[data-theme="5754"] .fs-toggle:hover { background: #1a1a1a; }
.mute-toggle { margin-left: 0; }
.game-below { padding: 32px 0 48px; }
.game-below .now-playing { margin-top: 18px; }
.game-playfield:fullscreen,
.game-playfield:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--game-bg, #0a0a0a);
  padding: 8px 12px 0;
  box-sizing: border-box;
}
.game-playfield:fullscreen .game-stage,
.game-playfield:-webkit-full-screen .game-stage {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
}

body.game-page.game-playing {
  overflow: hidden;
  overscroll-behavior: none;
}
body.game-page.game-playing .game-playfield,
body.game-page.game-playing .game-stage,
body.game-page.game-playing #riff-canvas {
  overscroll-behavior: none;
  touch-action: none;
}

@media (max-width: 760px) {
  body.game-page .page-main,
  body.game-page .game-main { padding: 0; min-height: 0; }
  body.game-page .site-header { padding-top: env(safe-area-inset-top, 0px); }
  body.game-page .header-inner { min-height: 56px; }
  body.game-page .riff-catcher { max-width: none; }
  .game-playfield {
    height: calc(100svh - 56px - env(safe-area-inset-top, 0px));
    min-height: calc(100svh - 56px - env(safe-area-inset-top, 0px));
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @supports (height: 100dvh) {
    .game-playfield {
      height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
      min-height: calc(100dvh - 56px - env(safe-area-inset-top, 0px));
    }
  }
  .game-stage {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .game-hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 6px 8px;
    align-items: end;
    margin: 0;
    padding: 6px 10px 8px;
  }
  .hud-stat { min-width: 0; }
  .hud-actions { margin-left: 0; grid-column: 5; }
  .mute-toggle,
  .fs-toggle {
    width: auto;
    margin: 0;
    padding: 6px 10px;
    min-height: 40px;
    font-size: 11px;
  }
  .overlay-scroll { padding: 16px 14px 8px; }
  .overlay-actions { padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .overlay-card { width: 100%; border-left: 0; border-right: 0; border-top: 0; }
  .game-below { padding: 28px 0 80px; }
}

@media (max-width: 760px) and (orientation: landscape) {
  .game-playfield { height: 100dvh; min-height: 0; }
  body.game-page .site-header { display: none; }
}

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: color-mix(in srgb, var(--game-bg, #0a0a0a) 82%, transparent);
  color: var(--game-text, #ece8e1);
}
.pause-overlay[hidden] { display: none !important; }
.pause-overlay .btn { min-height: 52px; min-width: 10rem; justify-content: center; }

html.game-embed-html,
body.game-embed {
  margin: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0a0a0a;
  min-height: 0;
}
body.game-embed .page-main,
body.game-embed .riff-catcher,
body.game-embed .game-playfield {
  height: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}
body.game-embed .game-playfield {
  box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.game-embed .game-stage {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  border: 0;
}
body.game-embed .game-overlay {
  touch-action: auto;
}
body.game-embed .overlay-card {
  width: 100%;
  height: 100%;
  max-height: 100%;
  border: 0;
}
body.game-embed .overlay-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
body.game-embed .overlay-card h2 {
  font-size: clamp(22px, 5.2vh, 34px);
  margin: 0 0 4px;
}
body.game-embed .overlay-card .eyebrow { margin-bottom: 2px; }
body.game-embed #overlay-body { font-size: 13px; line-height: 1.35; }
body.game-embed .track-picker {
  margin: 4px 0 0;
  padding: 4px 8px 6px;
}
body.game-embed .now-playing { margin: 4px 0 0; font-size: 12px; }
body.game-embed .best-line { margin-top: 4px !important; }
body.game-embed .overlay-actions { padding: 8px 12px; }
body.game-embed .game-hud { padding: 4px 8px 4px; }
body.game-embed .hud-value { font-size: 20px; }
body.game-embed .lane-hit { padding: 6px 8px 8px; }
body.game-embed .lane-hit button { min-height: 44px; }

.track-select-wrap { display: block; margin: 4px 0; }
.track-select-wrap select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line, #2b2b2b);
  background: var(--game-bg-2, #161616);
  color: inherit;
  font: inherit;
}
@media (max-width: 760px) {
  body.game-embed .game-playfield {
    height: 100%;
    min-height: 0;
  }
}

body.game-over #play-btn {
  min-height: 56px;
  width: 100%;
  justify-content: center;
  font-size: 1.05rem;
}

.daily-best,
.daily-best-song {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted, #9a958c);
}
.daily-best-flourish {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent, #c45c3e);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.daily-best-flourish.is-on {
  animation: daily-best-pop 0.45s ease-out;
}
@keyframes daily-best-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .daily-best-flourish.is-on { animation: none; }
}
body.game-embed .daily-best,
body.game-embed .daily-best-song { margin-top: 4px; font-size: 13px; }
body.game-embed .daily-best-flourish { margin-top: 6px; font-size: 14px; }
