/* Let the scene take the remaining viewport, with natural overflow on small screens. */
:root {
  --font-sans: "Noto Sans", "Noto Sans SC", sans-serif;
  --font-serif: "Noto Serif", "Noto Serif SC", serif;
  font-family: var(--font-sans);
  --header-height: clamp(64px, 9dvh, 88px);
  --page-gap: clamp(12px, 2dvh, 24px);
  --scene-min-height: 340px;
}
body { height: 100dvh; display: flex; flex-direction: column; }
*,*::before,*::after { -webkit-user-select: none; user-select: none; }
.brand { align-items: center; min-width: 0; }
.brand-name { display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 3px; font-size: 22px; line-height: 1.2; }
.brand-name b { display: block; font-family: var(--font-serif); font-weight: 600; font-style: normal; line-height: 1.2; white-space: nowrap; }
.brand-symbol { display: inline-flex; flex: 0 0 36px; width: 36px; height: 36px; align-items: center; justify-content: center; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 36px; line-height: 1; }
.intro h1 { font-family: var(--font-serif); font-weight: 600; }
.intro .title-dot { color: inherit; }
.speed-control output { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.header-actions { flex-shrink: 0; }
.header-actions .sound-button { width: auto; height: 40px; padding: 0 12px; gap: 6px; justify-content: center; }
.header-actions #sound-label { display: inline; }
.sound-button[aria-pressed=true] { background: var(--selection); color: var(--accent); }
.intro-actions .ride-button:active,.intro-actions .shuffle-button:active { transform: scale(.97); }
.header { flex: 0 0 var(--header-height); height: var(--header-height); width: 100%; margin: 0 auto; }
.brand-name > span { font-size: 9px; font-weight: 400; letter-spacing: .6px; line-height: 1.4; margin-top: 0; white-space: nowrap; }
main {
  flex: 1;
  min-height: min-content;
  width: 100%;
  margin: 0 auto;
  padding: var(--page-gap) 3.15%;
  display: grid;
  grid-template-rows: minmax(var(--scene-min-height), 1fr) auto;
  gap: var(--page-gap);
}
.ride-scene { height: auto; min-height: 0; container-type: size; }
.controls { margin: 0; padding: 0 8px; align-items: start; }
.control-group { min-width: 0; }
.brand-name > span { color: var(--muted); transition: color .65s ease; }

/* A shallow desktop window keeps the same layout with tighter vertical spacing. */
@media (min-width: 768px) and (max-height: 720px) {
  :root { --header-height: 60px; --page-gap: 12px; }
  .brand-name { font-size: 22px; }
  .brand-name > span { font-size: 9px; margin-top: 0; }
  .intro { top: 7%; }
  .intro .eyebrow { margin-bottom: 10px; font-size: 10px; }
  .intro h1 { font-size: clamp(30px, 3vw, 46px); }
  .intro-copy { margin: 10px 0 12px; font-size: 11px; }
  .intro-actions { gap: 7px; }
  .intro-actions .ride-button { padding: 10px 17px; }
  .intro-actions .shuffle-button { padding: 7px 13px; }
  .control-heading { margin-bottom: 8px; }
  .speed-control .control-heading { margin-bottom: 18px; }
  .speed-captions { margin-top: 12px; }
  .dog-option,.vehicle-option { padding-block: 4px; }
}

@media (max-width: 767px) {
  :root { --header-height: 60px; --page-gap: 12px; --scene-min-height: 350px; }
  .header { padding-inline: 4%; gap: 10px; }
  .brand { gap: 8px; }
  .brand-name { font-size: 22px; letter-spacing: 3px; }
  .brand-name > span { font-size: 9px; letter-spacing: 0; margin-top: 0; white-space: normal; }
  .header-actions { gap: 6px; }
  .header-actions .sound-button { width: 36px; height: 36px; padding: 0; gap: 0; }
  .header-actions #sound-label { display: none; }
  main { padding: 10px 4% max(10px, env(safe-area-inset-bottom)); gap: 12px; }
  .intro { top: 58px; left: 18px; right: 14px; }
  .intro .eyebrow { display: flex; font-size: 10px; line-height: 1.4; letter-spacing: .3px; margin-bottom: 7px; gap: 5px; }
  .intro .tiny-sun { width: 15px; height: 15px; }
  .intro h1 { font-size: 28px; line-height: 1.25; letter-spacing: .5px; }
  .intro-copy { font-size: 10px; line-height: 1.6; margin: 9px 0 12px; max-width: 27em; }
  .intro-actions { gap: 6px; }
  .intro-actions .ride-button { padding: 9px 13px; font-size: 10px; }
  .intro-actions .shuffle-button { padding: 6px 12px; font-size: 10px; }
  .time-switcher { top: 12px; left: 16px; right: auto; }
  .time-switcher button { padding: 7px 10px; }
  .scene-switcher { left: 12px; right: auto; bottom: 12px; gap: 5px; max-width: calc(100% - 60px); }
  .scene-option { flex: 0 0 auto; gap: 4px; padding: 4px 6px 4px 4px; font-size: 9px; }
  .landscape-mini { width: 20px; height: 23px; }
  .scene-option .selection-dot { display: none; }
  .scene-actions { right: 12px; bottom: 12px; gap: 7px; }
  .round-button { width: 34px; height: 34px; }
  .scene-meta { right: 12px; bottom: 140px; font-size: 9px; }
  .controls { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px 12px; padding: 0 2px; }
  .control-group + .control-group { padding-left: 12px; }
  .control-heading { margin-bottom: 6px; gap: 5px; }
  .control-heading h2 { font-size: 10px; }
  .control-heading > span { display: none; }
  .option-row { gap: 2px; }
  .dog-option,.vehicle-option { padding: 3px 0; font-size: 9px; gap: 3px; }
  .dog-portrait { transform: scale(.78); height: 32px; margin: -2px -5px; }
  .vehicle-option [data-icon] { width: 29px; height: 27px; }
  .control-group.speed-control { padding: 0; }
  .speed-control .control-heading { margin-bottom: 10px; }
  .speed-control .control-heading h2 { font-size: 11px; }
  .speed-control output { font-size: 21px; }
  .speed-captions { margin-top: 9px; font-size: 9px; }
}

@media (max-width: 767px) and (max-height: 640px) {
  :root { --header-height: 56px; --scene-min-height: 340px; }
  main { padding-block: 8px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
}

/* At the narrowest widths, use horizontal option rows instead of tiny columns. */
@media (max-width: 360px) {
  :root { --header-height: 56px; --scene-min-height: 340px; }
  main { padding-block: 8px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
  .brand-name { font-size: 22px; }
  .brand-name > span { font-size: 8px; }
  .brand { min-width: 0; gap: 6px; }
  .brand-name { min-width: 0; gap: 2px; }
  .brand-name b { line-height: 1; }
  .brand-name > span { white-space: normal; font-size: 7.5px; line-height: 1.2; margin-top: 0; }
  .header-actions { gap: 4px; }
  .header-actions .sound-button { width: 32px; }
  .theme-button { width: 32px; }
  .intro { left: 15px; }
  .time-switcher { left: 13px; }
  .time-switcher button { padding-inline: 12px; }
  .scene-switcher { left: 10px; gap: 4px; }
  .scene-option { font-size: 8px; padding-right: 5px; }
  .landscape-mini { width: 18px; height: 22px; }
  .controls { grid-template-columns: minmax(0,1fr); gap: 5px; }
  .control-group,.control-group.speed-control { display: grid; grid-template-columns: 84px minmax(0,1fr); column-gap: 8px; align-items: center; }
  .control-group + .control-group { padding-left: 0; border-left: 0; }
  .control-heading { margin: 0; }
  .control-heading h2 { font-size: 9px; line-height: 1.6; }
  .dog-option,.vehicle-option { font-size: 9px; padding-block: 2px; }
  .dog-portrait { height: 28px; }
  .vehicle-option [data-icon] { height: 24px; }
  .speed-control .control-heading { grid-row: 1 / 3; flex-direction: column; align-items: flex-start; gap: 1px; margin: 0; }
  .speed-control .control-heading h2 { font-size: 9px; }
  .speed-control output { font-size: 18px; }
  .speed-control input { align-self: end; }
  .speed-captions { margin-top: 6px; font-size: 8px; }
  .speed-captions #speed-mood { display: none; }
}

/* Preserve the main controls when a short scene needs a more compact introduction. */
@container (max-width: 700px) and (max-height: 480px) {
  .intro { top: 55px; }
  .intro h1 { font-size: 24px; line-height: 1.2; }
  .intro-copy { display: none; }
  .intro-actions { margin-top: 10px; gap: 5px; }
  .intro-actions .ride-button { padding-block: 8px; }
  .intro-actions .shuffle-button { padding-block: 5px; }
  .scene-meta { display: none; }
}

.immersive-mode .ride-scene { height: 100dvh; min-height: 100dvh; }
@media (prefers-reduced-motion: reduce) { .brand-name > span { transition: color .35s ease!important; } }

.scene-actions { z-index: 2; }
.control-tip-wrap { position: relative; display: inline-flex; }
.control-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 1;
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 8px 11px;
  border: 1px solid var(--scene-control-border, #a4b28b);
  border-radius: 9px;
  background: var(--scene-control-bg, #fffaf0);
  color: var(--scene-control-ink, #4d583d);
  box-shadow: 0 4px 16px #17251d20;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  pointer-events: none;
}
.control-tooltip::after { content: ''; position: absolute; top: 100%; left: 0; width: 100%; height: 11px; }
.tooltip-open .control-tooltip { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.control-tooltip small { display: block; font-size: 9px; opacity: .75; }
.control-tooltip kbd { font: inherit; font-size: 9px; margin-left: 6px; padding: 1px 4px; border: 1px solid currentColor; border-radius: 4px; opacity: .8; }
@media (max-width: 767px) {
  .control-tooltip { top: 50%; right: calc(100% + 10px); bottom: auto; transform: translate(4px, -50%); }
  .tooltip-open .control-tooltip { transform: translate(0, -50%); }
  .control-tooltip::after { top: 0; left: 100%; width: 11px; height: 100%; }
}

.language-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 30px; background: transparent; font-size: 12px; }
.language-button [data-icon] { width: 17px; height: 17px; }
.language-button:hover { background: var(--selection); }
:root:lang(en) .brand-name { letter-spacing: .3px; }
:root:lang(en) .brand-name > span { letter-spacing: 0; }
:root:lang(en) .intro h1 { letter-spacing: -.03em; line-height: 1.24; }
:root:lang(en) #title-first,:root:lang(en) #title-second { white-space: nowrap; }
:root:lang(en) .eyebrow { font-size: 10px; letter-spacing: .9px; }
:root:lang(en) .intro-copy { letter-spacing: .2px; }
@media (max-width: 767px) {
  .language-button { min-width: 60px; height: 36px; padding: 0 8px; gap: 5px; font-size: 11px; }
  :root:lang(en) .intro h1 { font-size: 26px; }
  :root:lang(en) .dog-option { font-size: 8px; }
  :root:lang(en) .time-switcher button { padding-inline: 8px; gap: 3px; }
}
@media (max-width: 360px) {
  .header { gap: 6px; }
  .language-button { min-width: 50px; padding-inline: 5px; font-size: 10px; gap: 4px; }
  .language-button [data-icon] { width: 14px; height: 14px; }
  :root:lang(en) .brand-name > span { font-size: 7.8px; }
}
@container (max-width: 700px) and (max-height: 480px) {
  .intro { top: 52px; }
  .intro .eyebrow { display: flex; margin-bottom: 4px; font-size: 9px; line-height: 14px; }
  .intro .tiny-sun { width: 14px; height: 14px; }
  .intro h1 { font-size: 22px; line-height: 1.2; }
  :root:lang(en) .intro h1 { font-size: 20px; line-height: 1.2; }
  .intro-actions { margin-top: 6px; gap: 4px; }
  .intro-actions .ride-button { padding-block: 7px; }
  .intro-actions .shuffle-button { padding-block: 4px; }
}
