:root {
  color-scheme: dark;
  --ink: #160c0d;
  --wine: #2b1013;
  --wine-light: #4d171c;
  --crimson: #991f27;
  --ivory: #f5ecdf;
  --ivory-muted: #cdbdaf;
  --gold: #d7ae67;
  --gold-light: #f0d598;
  --gold-dark: #85632d;
  --sage: #8faf8b;
  --panel: rgba(22, 12, 13, 0.86);
  --app-height: 100svh;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  min-width: 320px;
  height: var(--app-height);
  min-height: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ivory);
  background:
    radial-gradient(circle at 50% 42%, rgba(116, 45, 41, 0.28), transparent 32rem),
    radial-gradient(circle at 8% 14%, rgba(215, 174, 103, 0.08), transparent 24rem),
    linear-gradient(145deg, #0d0808 0%, #271012 48%, #100909 100%);
  font-family: var(--sans);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.2;
  background:
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(255, 255, 255, 0.018) 3px 4px),
    repeating-linear-gradient(0deg, transparent 0 5px, rgba(0, 0, 0, 0.04) 5px 6px);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
.portrait-frame:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 4px;
}

.ambient-glow {
  position: fixed;
  top: 28%;
  left: 50%;
  width: min(62vw, 55rem);
  aspect-ratio: 1;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.25;
  filter: blur(80px);
  transform: translate(-50%, -50%);
  background: #7a2b2c;
}

.game-shell {
  width: min(100%, 1500px);
  height: var(--app-height);
  min-height: 0;
  margin: 0 auto;
  padding: 22px clamp(18px, 3vw, 48px) 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.royal-mark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--gold-light);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.royal-mark__crown {
  color: var(--gold);
  font-size: 1.2rem;
  line-height: 1;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(215, 174, 103, 0.35);
  border-radius: 999px;
  color: var(--ivory-muted);
  background: rgba(17, 8, 9, 0.55);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.icon-button:hover {
  color: var(--ivory);
  border-color: var(--gold);
  background: rgba(52, 18, 21, 0.8);
}

.portfolio-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  text-decoration: none;
  border-color: rgba(215, 174, 103, 0.6);
}

.portfolio-button::before {
  margin-right: 6px;
  content: "←";
  font-size: 0.85em;
}

#soundIcon {
  display: inline-block;
  width: 1em;
  margin-right: 4px;
  color: var(--gold);
}

.game-board {
  flex: 1;
  min-height: 0;
  margin: 18px 0 12px;
  padding: clamp(17px, 2vw, 30px);
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(300px, 1.22fr) minmax(230px, 0.72fr);
  align-items: center;
  gap: clamp(20px, 3vw, 48px);
  overflow: hidden;
  border: 1px solid rgba(215, 174, 103, 0.45);
  border-radius: 28px;
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.025), transparent 35%),
    var(--panel);
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.36),
    inset 0 0 0 1px rgba(255, 255, 255, 0.018);
}

.intro-copy {
  align-self: center;
}

.eyebrow,
.verdict-label {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.21em;
  text-transform: uppercase;
}

.intro-copy h1 {
  max-width: 11ch;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 4.1vw, 5.2rem);
  font-weight: 400;
  line-height: 0.93;
  letter-spacing: -0.05em;
  text-wrap: balance;
}

.intro-copy h1 em {
  color: var(--gold-light);
  font-weight: 400;
}

.lede {
  max-width: 34ch;
  margin: 22px 0 0;
  color: var(--ivory-muted);
  font-family: var(--serif);
  font-size: clamp(0.95rem, 1.3vw, 1.15rem);
  line-height: 1.55;
}

.royal-rules {
  margin: clamp(26px, 4vh, 48px) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(215, 174, 103, 0.2);
}

.royal-rules li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(215, 174, 103, 0.14);
}

.royal-rules span {
  color: var(--gold-dark);
  font-family: var(--serif);
  font-size: 0.7rem;
  font-weight: 700;
}

.royal-rules p {
  margin: 0;
  color: #d8ccc0;
  font-size: 0.78rem;
  line-height: 1.45;
}

.impossible-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 20px 0 0;
  color: #9e8f82;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.impossible-note span {
  color: var(--gold);
  font-family: var(--serif);
  font-size: 1.35rem;
}

.portrait-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.portrait-frame {
  position: relative;
  width: min(100%, 440px, 46dvh);
  aspect-ratio: 0.625;
  flex: 0 1 auto;
  isolation: isolate;
  overflow: hidden;
  border: clamp(6px, 0.7vw, 10px) solid #b98d47;
  border-radius: 46% 46% 22px 22px / 9% 9% 22px 22px;
  outline: 1px solid var(--gold-light);
  outline-offset: 4px;
  background: #3a2417;
  box-shadow:
    0 34px 54px rgba(0, 0, 0, 0.48),
    0 0 0 6px #4b2c18,
    0 0 0 7px rgba(239, 205, 137, 0.55),
    inset 0 0 46px rgba(0, 0, 0, 0.5);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.portrait-frame * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.portrait-frame.is-petting {
  cursor: grabbing;
}

.portrait-frame.is-annoyed {
  animation: short-shake 220ms ease-in-out;
}

.portrait-frame.is-furious {
  animation: royal-fury 90ms linear 8;
}

.monkey-portrait {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  -webkit-user-drag: none;
  filter: saturate(0.9) contrast(1.03) brightness(0.94);
  transition: opacity 190ms ease, filter 300ms ease, transform 500ms ease;
}

.portrait-frame.is-warning .monkey-portrait {
  filter: saturate(0.78) contrast(1.08) brightness(0.82) sepia(0.08);
  transform: scale(1.012);
}

.portrait-frame.is-danger .monkey-portrait {
  filter: saturate(0.82) contrast(1.12) brightness(0.72) sepia(0.14);
  transform: scale(1.025);
}

.portrait-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow:
    inset 0 0 70px rgba(18, 7, 5, 0.52),
    inset 0 -42px 60px rgba(13, 6, 6, 0.45),
    inset 0 16px 24px rgba(244, 203, 126, 0.1);
}

.anger-wash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: var(--anger, 0);
  mix-blend-mode: multiply;
  background: radial-gradient(circle at 50% 30%, transparent 24%, rgba(131, 4, 12, 0.72) 100%);
  transition: opacity 180ms linear;
}

.frame-ornament {
  position: absolute;
  left: 50%;
  z-index: 8;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold-light);
  color: var(--gold-light);
  background: #5d3b1f;
  box-shadow: 0 0 0 3px #2e170d;
  font-size: 0.6rem;
  transform: translateX(-50%) rotate(45deg);
}

.frame-ornament--top {
  top: 7px;
}

.frame-ornament--bottom {
  bottom: 7px;
}

.frame-ornament::first-letter {
  transform: rotate(-45deg);
}

.pet-hint {
  position: absolute;
  left: 50%;
  top: 61%;
  z-index: 6;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 240ms ease, transform 240ms ease;
}

.pet-hint span {
  width: 106px;
  height: 146px;
  border: 1px solid rgba(245, 236, 223, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(245, 236, 223, 0.08), 0 0 40px rgba(245, 236, 223, 0.22);
  animation: hint-pulse 1.8s ease-in-out infinite;
}

.pet-hint p {
  position: absolute;
  top: calc(100% + 8px);
  margin: 0;
  color: #fff9ef;
  text-shadow: 0 2px 8px #000;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pet-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.9);
}

.effects-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  pointer-events: none;
}

.stroke-glint {
  position: absolute;
  width: var(--size, 7px);
  height: var(--size, 7px);
  border-radius: 50%;
  background: var(--glint, #f7e2b0);
  box-shadow: 0 0 12px rgba(247, 226, 176, 0.95);
  animation: glint-float var(--duration, 720ms) ease-out forwards;
}

.fur-fleck {
  position: absolute;
  width: var(--width, 6px);
  height: 2px;
  border-radius: 999px;
  background: var(--fur, #f3eee7);
  transform: rotate(var(--rotation, 0deg));
  animation: fur-float var(--duration, 780ms) ease-out forwards;
}

.warning-toast {
  position: absolute;
  top: 20px;
  left: 50%;
  z-index: 20;
  max-width: min(90%, 330px);
  padding: 9px 14px;
  border: 1px solid rgba(240, 213, 152, 0.65);
  border-radius: 999px;
  color: var(--ivory);
  background: rgba(28, 10, 11, 0.92);
  box-shadow: 0 9px 26px rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  font-family: var(--serif);
  font-size: 0.82rem;
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, -9px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.warning-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.warning-toast.is-danger {
  border-color: rgba(218, 90, 91, 0.8);
  color: #ffe4e2;
  background: rgba(84, 10, 15, 0.95);
}

.stage-caption {
  min-height: 1.3em;
  margin: 17px 0 0;
  color: #a9998c;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
}

.royal-hud {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timer-card,
.mood-card,
.meter-card {
  padding: 16px;
  border: 1px solid rgba(215, 174, 103, 0.18);
  border-radius: 16px;
  background: rgba(7, 4, 4, 0.22);
}

.hud-label {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.timer {
  margin: 0;
  color: var(--ivory);
  font-family: var(--serif);
  font-size: clamp(2.2rem, 3.7vw, 4rem);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
}

.timer span {
  margin-left: 3px;
  color: var(--gold-dark);
  font-size: 0.34em;
  letter-spacing: 0;
}

.best-time {
  margin-top: 15px;
  padding-top: 11px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(215, 174, 103, 0.13);
  color: #9f9083;
  font-size: 0.66rem;
}

.best-time strong {
  color: var(--ivory-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.mood {
  margin: 0;
  color: var(--ivory);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.45vw, 1.32rem);
  line-height: 1.15;
}

.mood-detail {
  min-height: 2.5em;
  margin: 8px 0 0;
  color: #9e9084;
  font-size: 0.68rem;
  line-height: 1.45;
}

.meter-heading {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #c8b9ac;
  font-size: 0.68rem;
  font-weight: 700;
}

.meter-heading strong {
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 100ms linear;
}

.approval-fill {
  background: linear-gradient(90deg, #6f8f72, #bed0a8, #f0d598);
  box-shadow: 0 0 12px rgba(190, 208, 168, 0.32);
}

.irritation-fill {
  background: linear-gradient(90deg, #b06f34, #b72c32 68%, #ef293a);
  box-shadow: 0 0 12px rgba(183, 44, 50, 0.4);
}

.unreachable-mark {
  position: absolute;
  top: 0;
  right: 0.6%;
  width: 2px;
  height: 100%;
  background: #fff5d9;
  box-shadow: 0 0 7px #fff5d9;
}

.meter-note,
.temper-scale {
  margin: 7px 0 0;
  color: #74675e;
  font-size: 0.57rem;
  line-height: 1.3;
}

.temper-scale {
  display: flex;
  justify-content: space-between;
}

.purr-status {
  min-height: 40px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(215, 174, 103, 0.13);
  border-radius: 999px;
  color: #9e9084;
  background: rgba(7, 4, 4, 0.2);
  font-size: 0.65rem;
  font-weight: 700;
}

.purr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #665a52;
  box-shadow: none;
}

.purr-status.is-active {
  color: #cbdcbd;
}

.purr-status.is-active .purr-dot {
  background: #a9c8a4;
  box-shadow: 0 0 0 5px rgba(169, 200, 164, 0.1), 0 0 12px rgba(169, 200, 164, 0.7);
  animation: purr-pulse 1.25s ease-in-out infinite;
}

.footer-line {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #6f5f55;
  font-family: var(--serif);
  font-size: 0.65rem;
  font-style: italic;
  letter-spacing: 0.06em;
}

.footer-line span:nth-child(2) {
  color: var(--gold-dark);
  font-size: 0.52rem;
}

.overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--app-height);
  z-index: 100;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  visibility: hidden;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 40%, rgba(100, 32, 35, 0.32), transparent 32rem),
    rgba(9, 5, 5, 0.87);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  transition: opacity 280ms ease, visibility 280ms ease;
}

.overlay.is-visible {
  visibility: visible;
  opacity: 1;
}

.overlay-portfolio {
  position: fixed;
  top: 22px;
  left: 22px;
  z-index: 2;
  min-height: 38px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(215, 174, 103, 0.5);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(17, 8, 9, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  transition: border-color 150ms ease, background 150ms ease;
}

.overlay-portfolio:hover {
  border-color: var(--gold);
  background: rgba(52, 18, 21, 0.9);
}

.overlay-card {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(var(--app-height) - 40px);
  padding: clamp(30px, 5vh, 52px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(240, 213, 152, 0.56);
  border-radius: 26px;
  color: var(--ivory);
  background:
    radial-gradient(circle at 50% -10%, rgba(214, 171, 97, 0.14), transparent 17rem),
    linear-gradient(145deg, rgba(53, 17, 20, 0.98), rgba(17, 8, 9, 0.99));
  box-shadow: 0 45px 100px rgba(0, 0, 0, 0.62), inset 0 0 0 5px rgba(215, 174, 103, 0.045);
  text-align: center;
  transform: translateY(14px) scale(0.98);
  transition: transform 320ms ease;
}

.overlay.is-visible .overlay-card {
  transform: translateY(0) scale(1);
}

.overlay-card::before,
.overlay-card::after {
  position: absolute;
  left: 50%;
  width: 100px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: translateX(-50%);
}

.overlay-card::before { top: 18px; }
.overlay-card::after { bottom: 18px; }

.royal-seal {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-light);
  border-radius: 50%;
  color: var(--gold-light);
  background: radial-gradient(circle, #754726, #3c1d11);
  box-shadow: 0 0 0 5px rgba(215, 174, 103, 0.1), 0 13px 28px rgba(0, 0, 0, 0.38);
}

.royal-seal span {
  font-size: 2rem;
  transform: translateY(-2px);
}

.overlay-card h2 {
  margin: 0 auto;
  max-width: 12ch;
  color: var(--ivory);
  font-family: var(--serif);
  font-size: clamp(2.1rem, 6vw, 4rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.overlay-card > p:not(.eyebrow, .truth-line, .sound-note, .verdict-label, .run-title, .end-copy, .end-note) {
  max-width: 45ch;
  margin: 23px auto 0;
  color: var(--ivory-muted);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
}

.truth-line {
  margin: 20px 0 0;
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.volume-check {
  max-width: 390px;
  margin: 22px auto 0;
  padding: 14px;
  border: 1px solid rgba(215, 174, 103, 0.28);
  border-radius: 16px;
  background: rgba(7, 4, 4, 0.24);
}

.volume-check__instruction {
  margin: 0;
  color: var(--ivory);
  font-family: var(--serif);
  font-size: 0.88rem;
}

.volume-check__instruction span {
  margin-right: 7px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.music-test-button {
  width: 100%;
  min-height: 43px;
  margin-top: 11px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  border: 1px solid rgba(240, 213, 152, 0.56);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(91, 45, 25, 0.38);
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.music-test-button:hover {
  border-color: var(--gold-light);
  background: rgba(116, 65, 32, 0.48);
  transform: translateY(-1px);
}

.volume-bars {
  height: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.volume-bars i {
  width: 2px;
  height: 5px;
  display: block;
  border-radius: 999px;
  background: var(--gold-light);
}

.music-test-button.is-playing .volume-bars i {
  animation: volume-dance 700ms ease-in-out infinite alternate;
}

.music-test-button.is-playing .volume-bars i:nth-child(2) { animation-delay: -180ms; }
.music-test-button.is-playing .volume-bars i:nth-child(3) { animation-delay: -390ms; }
.music-test-button.is-playing .volume-bars i:nth-child(4) { animation-delay: -90ms; }

.volume-check__status {
  margin: 8px 0 0;
  color: #8f8176;
  font-size: 0.6rem;
  line-height: 1.35;
}

.volume-check__status.is-ready {
  color: #b9cfad;
}

.primary-button {
  min-height: 52px;
  margin-top: 28px;
  padding: 13px 24px;
  border: 1px solid #f4d995;
  border-radius: 999px;
  color: #1b0d0d;
  background: linear-gradient(180deg, #f1d696, #c79549);
  box-shadow: 0 13px 30px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.primary-button:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
  box-shadow: 0 17px 34px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.6);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  border-color: rgba(167, 136, 84, 0.34);
  color: rgba(27, 13, 13, 0.6);
  background: linear-gradient(180deg, #8f7a58, #695233);
  box-shadow: none;
  cursor: not-allowed;
  filter: saturate(0.5);
  opacity: 0.66;
  transform: none;
}

.sound-note,
.end-note {
  margin: 13px 0 0;
  color: #74675e;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-card--end {
  border-color: rgba(191, 59, 67, 0.7);
  background:
    radial-gradient(circle at 50% 12%, rgba(191, 59, 67, 0.3), transparent 18rem),
    linear-gradient(145deg, rgba(63, 13, 18, 0.99), rgba(16, 7, 8, 0.99));
}

.verdict-crown {
  margin-bottom: 16px;
  color: #d35e64;
  font-size: 2.3rem;
  filter: drop-shadow(0 4px 10px rgba(207, 49, 57, 0.35));
}

.run-title {
  margin: 16px 0 0;
  color: var(--gold-light);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
}

.end-copy {
  max-width: 42ch;
  margin: 20px auto 0;
  color: var(--ivory-muted);
  font-family: var(--serif);
  font-size: 0.96rem;
  line-height: 1.55;
}

.end-copy strong {
  color: var(--ivory);
}

.record-banner {
  width: max-content;
  margin: 18px auto 0;
  padding: 7px 12px;
  border: 1px solid rgba(240, 213, 152, 0.4);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(215, 174, 103, 0.08);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.primary-button--dark {
  color: var(--ivory);
  border-color: #bc474d;
  background: linear-gradient(180deg, #8c242b, #571319);
}

.portfolio-cta {
  width: min(100%, 360px);
  min-height: 46px;
  margin: 12px auto 0;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(215, 174, 103, 0.45);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(15, 6, 7, 0.42);
  text-decoration: none;
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.portfolio-cta:hover {
  border-color: var(--gold);
  background: rgba(70, 24, 27, 0.66);
  transform: translateY(-1px);
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.04); }
}

@keyframes volume-dance {
  from { height: 4px; opacity: 0.65; }
  to { height: 16px; opacity: 1; }
}

@keyframes purr-pulse {
  0%, 100% { transform: scale(0.85); }
  50% { transform: scale(1.15); }
}

@keyframes glint-float {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift-x, 8px)), calc(-50% + var(--drift-y, -34px))) scale(0.05); }
}

@keyframes fur-float {
  0% { opacity: 0.85; transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift-x, 20px)), calc(-50% + var(--drift-y, -42px))) rotate(calc(var(--rotation, 0deg) + 130deg)); }
}

@keyframes short-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-5px) rotate(-0.35deg); }
  50% { transform: translateX(4px) rotate(0.3deg); }
  75% { transform: translateX(-2px) rotate(-0.15deg); }
}

@keyframes royal-fury {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-8px, 2px) rotate(-0.7deg); }
  50% { transform: translate(7px, -1px) rotate(0.65deg); }
  75% { transform: translate(-4px, -2px) rotate(-0.3deg); }
}

@media (max-width: 1100px) {
  .game-board {
    grid-template-columns: minmax(190px, 0.65fr) minmax(300px, 1fr) minmax(210px, 0.62fr);
    gap: 24px;
  }

  .intro-copy h1 {
    font-size: clamp(2.2rem, 4.4vw, 3.6rem);
  }

  .royal-rules {
    margin-top: 24px;
  }

  .portrait-frame {
    width: min(100%, 390px);
  }
}

@media (max-width: 840px) {
  .game-shell {
    padding: 14px 14px 12px;
  }

  .royal-mark span:last-child {
    display: none;
  }

  .game-board {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(205px, 0.55fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "copy copy"
      "portrait hud";
    gap: 18px;
    padding: 18px;
    border-radius: 22px;
  }

  .intro-copy {
    grid-area: copy;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    align-items: end;
  }

  .intro-copy .eyebrow {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .intro-copy h1 {
    max-width: 12ch;
    font-size: clamp(2rem, 7vw, 3.4rem);
  }

  .lede {
    margin: 0;
  }

  .royal-rules,
  .impossible-note {
    display: none;
  }

  .portrait-stage {
    grid-area: portrait;
  }

  .royal-hud {
    grid-area: hud;
  }

  .portrait-frame {
    width: min(100%, 380px, 44dvh);
  }
}

@media (max-width: 600px) {
  body {
    background: linear-gradient(160deg, #100808, #2b1013 54%, #0f0808);
  }

  .game-shell {
    height: var(--app-height);
    min-height: 0;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 44px;
  }

  .topbar__actions {
    gap: 5px;
  }

  .icon-button {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 9px;
    font-size: 0.63rem;
  }

  .royal-mark {
    min-width: 44px;
    min-height: 44px;
  }

  .portfolio-button::before {
    margin-right: 4px;
  }

  #soundLabel {
    display: none;
  }

  #soundIcon {
    margin: 0;
  }

  .game-board {
    flex: 1;
    min-height: 0;
    margin: 9px 0 7px;
    padding: 13px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "copy"
      "portrait"
      "hud";
    gap: 9px;
    overflow: hidden;
    border-radius: 18px;
  }

  .intro-copy {
    width: 100%;
    display: block;
    text-align: center;
  }

  .intro-copy .eyebrow {
    margin-bottom: 7px;
  }

  .intro-copy h1 {
    max-width: none;
    font-size: clamp(1.55rem, 8vw, 2.35rem);
    line-height: 0.95;
  }

  .lede {
    display: none;
  }

  .portrait-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .portrait-frame {
    width: min(72vw, 34dvh, 330px);
    border-radius: 44% 44% 15px 15px / 8% 8% 15px 15px;
  }

  .warning-toast {
    top: 12px;
    font-size: 0.73rem;
  }

  .stage-caption {
    min-height: 1.15em;
    margin-top: 7px;
    font-size: 0.61rem;
  }

  .royal-hud {
    width: 100%;
    display: grid;
    grid-template-columns: 0.72fr 1.14fr 1.14fr;
    gap: 6px;
  }

  .timer-card,
  .mood-card,
  .meter-card {
    min-width: 0;
    padding: 8px;
    border-radius: 10px;
  }

  .timer {
    font-size: 1.55rem;
  }

  .best-time {
    display: none;
  }

  .mood-card,
  .purr-status {
    display: none;
  }

  .hud-label {
    margin-bottom: 5px;
    font-size: 0.52rem;
  }

  .meter-heading {
    min-height: 2.25em;
    margin-bottom: 6px;
    display: block;
    font-size: 0.55rem;
    line-height: 1.1;
  }

  .meter-heading strong {
    display: block;
    margin-top: 3px;
  }

  .meter-note,
  .temper-scale {
    display: none;
  }

  .footer-line {
    display: none;
  }

  .overlay {
    padding: 12px;
  }

  .overlay-portfolio {
    top: 12px;
    left: 12px;
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.6rem;
  }

  .overlay-card {
    max-height: calc(var(--app-height) - 24px);
    padding: 34px 22px;
    border-radius: 20px;
  }

  .royal-seal {
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
  }

  .overlay-card h2 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .overlay-card > p:not(.eyebrow, .truth-line, .sound-note, .verdict-label, .run-title, .end-copy, .end-note) {
    margin-top: 18px;
    font-size: 0.9rem;
  }

  .primary-button {
    width: 100%;
    margin-top: 22px;
  }

  .portfolio-cta {
    width: 100%;
  }
}

@media (max-height: 760px) and (min-width: 601px) {
  .game-shell {
    padding-top: 10px;
  }

  .topbar {
    min-height: 38px;
  }

  .game-board {
    margin-top: 9px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .portrait-frame {
    width: min(100%, 335px, 40dvh);
  }

  .royal-rules {
    margin-top: 18px;
  }

  .royal-rules li {
    padding: 8px 0;
  }

  .timer-card,
  .mood-card,
  .meter-card {
    padding: 12px;
  }
}

@media (max-height: 520px) and (min-width: 601px) {
  .game-board {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 0.72fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "portrait hud";
    gap: 14px;
  }

  .intro-copy {
    display: none;
  }

  .portrait-stage {
    grid-area: portrait;
  }

  .portrait-frame {
    width: min(100%, 38dvh);
  }

  .stage-caption {
    margin-top: 6px;
    font-size: 0.58rem;
  }

  .royal-hud {
    grid-area: hud;
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    align-content: center;
    gap: 6px;
  }

  .timer-card,
  .mood-card,
  .meter-card {
    min-width: 0;
    padding: 8px;
    border-radius: 10px;
  }

  .timer {
    font-size: 1.55rem;
  }

  .best-time,
  .mood-detail,
  .meter-note,
  .temper-scale {
    display: none;
  }

  .meter-heading {
    margin-bottom: 6px;
    font-size: 0.58rem;
  }

  .purr-status {
    grid-column: 1 / -1;
    min-height: 30px;
    padding: 6px;
  }
}

@media (max-height: 820px) {
  .overlay {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .overlay-card {
    max-height: calc(var(--app-height) - 20px);
    padding: 28px 20px;
  }

  .royal-seal {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
  }

  .royal-seal span {
    font-size: 1.45rem;
  }

  .overlay-card h2 {
    font-size: clamp(1.75rem, 7vh, 2.6rem);
  }

  .overlay-card > p:not(.eyebrow, .truth-line, .sound-note, .verdict-label, .run-title, .end-copy, .end-note) {
    margin-top: 13px;
    font-size: 0.82rem;
    line-height: 1.4;
  }

  .volume-check {
    margin-top: 13px;
    padding: 10px;
  }

  .truth-line {
    margin-top: 12px;
  }

  .primary-button {
    min-height: 46px;
    margin-top: 15px;
  }

  .sound-note,
  .end-note {
    margin-top: 8px;
  }
}

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