:root {
  color-scheme: light;
  --paper: #eee1c8;
  --paper-light: #f8efd9;
  --ink: #29251f;
  --muted: #746b5e;
  --rust: #a8492d;
  --rust-dark: #71301f;
  --cream: #f4dba8;
  --rule: rgba(59, 47, 34, .22);
  font-family: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 12%, rgba(255,255,255,.35) 0 1px, transparent 1.5px) 0 0 / 18px 18px,
    radial-gradient(circle at 70% 60%, rgba(79,53,29,.08) 0 .7px, transparent 1px) 0 0 / 23px 21px,
    var(--paper);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid #34706a; outline-offset: 3px; }

.home-link {
  position: fixed;
  z-index: 10;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  color: var(--muted);
  font: 700 .68rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .14em;
  text-decoration: none;
  text-transform: uppercase;
}
.home-link:hover { color: var(--rust-dark); }

.toy-shell {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  width: min(100%, 920px);
  min-height: calc(100vh - 42px);
  min-height: calc(100svh - 42px);
  margin: 0 auto;
  padding: clamp(54px, 8vh, 82px) 18px 14px;
}

.title-block { position: relative; z-index: 2; text-align: center; }
.kicker {
  margin: 0 0 4px;
  color: var(--rust-dark);
  font: 800 .65rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .19em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.7rem);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: .98;
}
h1 span { color: var(--rust); font-style: italic; }

.fox-stage {
  position: relative;
  align-self: center;
  width: 100%;
  aspect-ratio: 760 / 420;
  min-height: 205px;
  max-height: 48vh;
  margin: -8px auto -12px;
}
.fox {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 11px 8px rgba(68, 40, 20, .15));
}
.fox-layer, .head-assembly { position: absolute; inset: 0; width: 100%; height: 100%; }
.fox-layer { display: block; pointer-events: none; user-select: none; }
.tail { z-index: 1; }
.body { z-index: 2; }
.head-assembly {
  z-index: 3;
  transform-origin: 63.16% 57.14%;
  will-change: transform;
}
.mouth { z-index: 1; }
.jaw {
  z-index: 2;
  transform-origin: 63.16% 57.14%;
  will-change: transform;
}
.head { z-index: 3; }
.hinge { z-index: 4; }
.ground-shadow {
  position: absolute;
  z-index: 0;
  right: 6%;
  bottom: 12%;
  width: 44%;
  height: 7%;
  border-radius: 50%;
  background: rgba(80, 52, 30, .12);
  filter: blur(7px);
  transform: rotate(-1deg);
}

.control-panel {
  position: relative;
  z-index: 4;
  align-self: end;
  width: min(100%, 620px);
  min-height: 128px;
  margin: 0 auto;
  padding: 12px 0 0;
  border-top: 1px solid var(--rule);
}
.status-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  font: 700 .73rem/1.3 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .05em;
}
.status-row p { margin: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #958a78; box-shadow: 0 0 0 4px rgba(104, 92, 74, .09); }
body[data-state="recording"] .status-dot { background: #c63d2c; box-shadow: 0 0 0 4px rgba(198,61,44,.15); animation: pulse 1s ease-in-out infinite; }
body[data-state="playing"] .status-dot { background: #34706a; }
#timer { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 3px; margin: 7px 0 14px; overflow: hidden; background: rgba(76,58,40,.1); }
.progress span { display: block; width: 0; height: 100%; background: var(--rust); transition: width 80ms linear; }
.primary-controls { text-align: center; }
.talk-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-width: 210px;
  min-height: 58px;
  padding: 13px 28px;
  border: 2px solid var(--ink);
  border-radius: 4px 7px 5px 8px;
  background: var(--rust);
  box-shadow: 3px 4px 0 var(--ink);
  color: #fff9eb;
  cursor: pointer;
  font: 850 .82rem/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  touch-action: none;
  transform: rotate(-.3deg);
  transition: transform 100ms ease, box-shadow 100ms ease, background 160ms ease;
}
.talk-button:hover { background: #b95736; transform: translateY(-1px) rotate(-.3deg); }
.talk-button:active, .talk-button.is-held { box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 3px) rotate(-.3deg); }
.talk-button:disabled { cursor: wait; opacity: .7; }
.talk-icon { position: relative; width: 13px; height: 19px; border: 2px solid currentColor; border-radius: 9px; }
.talk-icon::before { content: ""; position: absolute; inset: 8px -6px -6px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 12px 12px; }
.talk-icon::after { content: ""; position: absolute; left: 50%; bottom: -10px; width: 9px; border-top: 2px solid currentColor; transform: translateX(-50%); }
.helper { margin: 9px 0 0; color: var(--muted); font-size: .8rem; font-style: italic; }

.result-controls, .shared-controls, .error-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.action, .link-fallback button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 3px 5px 4px 6px;
  background: rgba(255,248,231,.42);
  box-shadow: 2px 2px 0 rgba(41,37,31,.8);
  cursor: pointer;
  font: 800 .74rem/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.action:hover, .link-fallback button:hover { background: var(--paper-light); }
.action.primary { background: var(--rust); color: white; }
.action.primary:hover { background: #b95736; }
.action:active, .link-fallback button:active { box-shadow: none; transform: translate(2px, 2px); }

.link-fallback { margin-top: 14px; padding: 11px; border: 1px dashed var(--rule); background: rgba(255,255,255,.18); }
.link-fallback label { display: block; margin-bottom: 7px; font: 800 .68rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.link-fallback div { display: flex; gap: 6px; }
.link-fallback input { min-width: 0; flex: 1; padding: 9px; border: 1px solid var(--rule); background: #fff9eb; color: var(--ink); font: .72rem ui-monospace, monospace; }
.link-fallback button { min-height: 38px; padding: 8px 13px; }
.link-fallback p { margin: 7px 0 0; color: var(--muted); font-size: .72rem; }

footer { min-height: 42px; padding: 7px 20px max(9px, env(safe-area-inset-bottom)); color: var(--muted); text-align: center; font: .66rem/1.4 ui-sans-serif, system-ui, sans-serif; letter-spacing: .05em; }
audio { display: none; }
[hidden] { display: none !important; }

@keyframes pulse { 50% { transform: scale(.72); opacity: .55; } }

@media (max-width: 560px) {
  .toy-shell { grid-template-rows: auto minmax(180px, 1fr) auto; padding-top: 60px; }
  .fox-stage { width: 100%; margin-left: 0; }
  .fox { transform: translateX(-7%) scale(.7); transform-origin: 50% 55%; }
  .control-panel { min-height: 137px; }
  .action { flex: 1 1 30%; padding-inline: 10px; }
}

@media (max-height: 650px) {
  .toy-shell { padding-top: 42px; }
  .home-link { top: 13px; }
  .kicker { display: none; }
  h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
  .fox-stage { max-height: 42vh; margin-top: -15px; margin-bottom: -20px; }
  footer { display: none; }
  .toy-shell { min-height: 100vh; min-height: 100svh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
