/* Wildbound: Open Valley — responsive presentation and touch controls */

:root {
  --cream: #fff9e9;
  --cream-deep: #f4ead2;
  --forest: #183f34;
  --forest-soft: #315f4b;
  --sage: #8fb69a;
  --emerald: #397a56;
  --amber: #e5a43b;
  --amber-light: #ffd77d;
  --berry: #b9525b;
  --water: #3c9ea4;
  --glass: rgba(255, 249, 233, 0.9);
  --glass-soft: rgba(255, 249, 233, 0.76);
  --line: rgba(34, 75, 57, 0.17);
  --shadow: 0 10px 32px rgba(17, 48, 39, 0.2);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #b9dcd2;
}

.profile-options {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1rem;
  text-align: left;
}

#player-name {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid #a9b9aa;
  border-radius: 8px;
  background: #fff;
  color: #24382d;
}

.character-choice {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.character-choice legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.character-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.character-options label {
  position: relative;
  display: flex;
  min-width: 0;
  cursor: pointer;
}

.character-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.character-options span {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: 2px solid #a9b9aa;
  border-radius: 10px;
  background: #fff;
  color: #24382d;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease,
    box-shadow 140ms ease;
}

.character-options input:checked + span {
  border-color: var(--amber);
  background: var(--amber-light);
  color: var(--forest);
  box-shadow: inset 0 0 0 1px var(--amber);
}

.character-options input:focus-visible + span {
  outline: 3px solid var(--forest);
  outline-offset: 3px;
}

@media (hover: hover) {
  .character-options label:hover span {
    border-color: var(--amber);
  }
}

#player-label {
  margin-left: 0.4rem;
  font-size: 0.8em;
  font-weight: 500;
}
body {
  position: fixed;
  inset: 0;
  color: var(--forest);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--amber-light);
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
  filter: grayscale(0.35);
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

/* Full-viewport Three.js host */

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, #a9d8dd 0%, #dce9ce 58%, #789b69 100%);
  touch-action: none;
}

#game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  touch-action: none;
}

/* Shared glass and overlays */

.hud-card {
  position: relative;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 15px;
  background: var(--glass);
  box-shadow:
    0 5px 18px rgba(21, 55, 44, 0.14),
    inset 0 0 0 1px var(--line);
  backdrop-filter: blur(12px) saturate(1.12);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
  color: var(--forest);
  font-size: 12px;
  line-height: 1.25;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(22px + var(--safe-top))
    calc(22px + var(--safe-right))
    calc(22px + var(--safe-bottom))
    calc(22px + var(--safe-left));
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 245, 196, 0.14), transparent 42%),
    linear-gradient(180deg, rgba(15, 47, 42, 0.18), rgba(12, 39, 31, 0.67));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.overlay > div,
.overlay > section,
.title-card,
.end-card,
.sheet {
  width: min(540px, 100%);
  max-height: calc(100vh - 44px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 44px - var(--safe-top) - var(--safe-bottom));
  padding: clamp(22px, 4vw, 38px);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 252, 239, 0.97), rgba(246, 237, 211, 0.94));
  box-shadow:
    0 28px 80px rgba(9, 35, 28, 0.32),
    inset 0 0 0 1px rgba(58, 94, 65, 0.11);
  color: var(--forest);
  animation: card-arrive 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.overlay h1,
.overlay h2,
.overlay h3,
.overlay p {
  margin-top: 0;
}

.overlay h1 {
  margin-bottom: 10px;
  color: var(--forest);
  font-size: clamp(38px, 8vw, 68px);
  font-weight: 850;
  line-height: 0.98;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.overlay h2 {
  margin-bottom: 12px;
  font-size: clamp(27px, 5vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.overlay h3 {
  margin-bottom: 7px;
  color: var(--forest-soft);
  font-size: 15px;
}

.overlay p {
  margin-bottom: 18px;
  color: #416352;
  font-size: clamp(14px, 2.2vw, 17px);
  line-height: 1.55;
}

.overlay small {
  color: #617768;
  line-height: 1.45;
}

.overlay ul,
.overlay ol {
  margin: 12px 0 20px;
  padding-left: 22px;
  text-align: left;
  color: #365a48;
  line-height: 1.65;
}

.overlay kbd,
#help-panel kbd {
  display: inline-block;
  min-width: 25px;
  margin: 1px 2px;
  padding: 2px 7px;
  border: 1px solid rgba(32, 73, 56, 0.2);
  border-bottom-width: 3px;
  border-radius: 7px;
  background: #fffdf4;
  color: var(--forest);
  font-family: inherit;
  font-size: 0.82em;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

#start-screen,
#end-screen,
#help-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(22px + var(--safe-top))
    calc(22px + var(--safe-right))
    calc(22px + var(--safe-bottom))
    calc(22px + var(--safe-left));
}

#start-screen {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 225, 143, 0.2), transparent 46%),
    linear-gradient(180deg, rgba(14, 50, 45, 0.08), rgba(11, 42, 32, 0.58));
}

#start-btn,
#restart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 190px;
  min-height: 54px;
  margin: 5px auto 10px;
  padding: 14px 26px;
  border: 1px solid rgba(118, 73, 14, 0.2);
  border-radius: 999px;
  background: linear-gradient(180deg, #f8c65f, var(--amber));
  box-shadow:
    0 7px 0 #a56d25,
    0 13px 24px rgba(118, 79, 29, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.66);
  color: #263e2d;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0.015em;
  text-shadow: 0 1px rgba(255, 255, 255, 0.35);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

#start-btn:hover,
#restart-btn:hover {
  filter: brightness(1.05) saturate(1.05);
  transform: translateY(-2px);
  box-shadow:
    0 9px 0 #a56d25,
    0 16px 28px rgba(118, 79, 29, 0.27),
    inset 0 1px 0 rgba(255, 255, 255, 0.66);
}

#start-btn:active,
#restart-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 2px 0 #a56d25,
    0 6px 13px rgba(118, 79, 29, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* Expedition ending and help */

#end-screen {
  z-index: 65;
  background:
    radial-gradient(circle at 50% 25%, rgba(255, 220, 132, 0.23), transparent 45%),
    rgba(14, 45, 36, 0.67);
}

#end-title {
  margin: 0 0 12px;
  color: var(--forest);
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 850;
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

#end-copy {
  margin: 0 auto 20px;
  max-width: 410px;
  color: #3e604e;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-line;
}

#help-panel {
  z-index: 75;
  background: rgba(11, 39, 31, 0.68);
}

#help-panel > div,
#help-panel > section {
  text-align: left;
}

#help-panel h2,
#help-panel h3 {
  text-align: left;
}

#close-help {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 43px;
  margin: 8px auto 0;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--forest);
  box-shadow: 0 4px 0 #0c2a21;
  color: var(--cream);
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease;
}

#close-help:hover {
  background: #285b47;
}

#close-help:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0c2a21;
}

/* Top HUD */

#hud {
  position: fixed;
  z-index: 20;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(58px + var(--safe-right));
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 7px;
  max-width: 970px;
  margin: 0 auto;
  pointer-events: none;
}

#hud > * {
  pointer-events: none;
}

#hud button {
  pointer-events: auto;
}

#hud .hud-card {
  flex: 0 1 auto;
}

#health-text,
#hunger-text,
#thirst-text,
#time,
#wood,
#stone,
#berries {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

#health-text,
#hunger-text,
#thirst-text {
  display: inline-block;
  min-width: 27px;
  text-align: right;
}

#wood,
#stone,
#berries {
  display: inline-block;
  min-width: 14px;
  color: var(--forest);
  text-align: center;
}

#wood {
  color: #75532d;
}

#stone {
  color: #53646a;
}

#berries {
  color: var(--berry);
}

#time {
  color: var(--forest-soft);
  letter-spacing: 0.045em;
  white-space: nowrap;
}

.bar {
  position: relative;
  display: inline-block;
  width: 94px;
  height: 9px;
  overflow: hidden;
  vertical-align: middle;
  border: 1px solid rgba(30, 65, 52, 0.14);
  border-radius: 999px;
  background: rgba(30, 66, 51, 0.13);
  box-shadow: inset 0 1px 3px rgba(25, 53, 43, 0.16);
}

.bar > div,
.bar > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
}

#health,
#hunger,
#thirst {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 5px;
  border-radius: 999px;
  transition: width 180ms linear, background-color 180ms ease;
}

#health {
  background: linear-gradient(90deg, #c9574f, #e88765);
  box-shadow: 0 0 8px rgba(204, 91, 75, 0.22);
}

#hunger {
  background: linear-gradient(90deg, #d59432, #efc259);
  box-shadow: 0 0 8px rgba(222, 164, 55, 0.2);
}

#thirst {
  background: linear-gradient(90deg, #318e9c, #62c1bd);
  box-shadow: 0 0 8px rgba(54, 153, 161, 0.22);
}

#health.low,
#hunger.low,
#thirst.low,
.bar.low,
.hud-card.low,
#health-text.low,
#hunger-text.low,
#thirst-text.low {
  animation: vital-pulse 850ms ease-in-out infinite;
}

/* Compass and current objective sit below the vitals */

#compass {
  position: fixed;
  z-index: 21;
  top: calc(105px + var(--safe-top));
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 28px);
  min-height: 31px;
  padding: 6px 13px;
  overflow: hidden;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.82);
  box-shadow: 0 4px 16px rgba(23, 56, 43, 0.13);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: var(--forest-soft);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: 0.025em;
  white-space: nowrap;
  pointer-events: none;
}

#compass span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#compass strong {
  color: var(--forest);
}

#objective {
  position: fixed;
  z-index: 21;
  top: calc(143px + var(--safe-top));
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 4px 10px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: rgba(23, 57, 44, 0.55);
  color: #fff9e9;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* When these are markup children of the HUD, keep everything in one flow. */

#hud #compass,
#hud #objective {
  position: relative;
  top: auto;
  left: auto;
  flex: 1 0 100%;
  width: auto;
  margin: 0;
  transform: none;
}

#hud #compass {
  min-height: 28px;
  padding-top: 5px;
  padding-bottom: 5px;
}

#hud #objective {
  justify-self: center;
  width: max-content;
  max-width: 100%;
  flex-grow: 0;
}

/* Context interaction prompt and toast */

#prompt {
  position: fixed;
  z-index: 28;
  bottom: calc(82px + var(--safe-bottom));
  left: 50%;
  max-width: min(440px, calc(100vw - 34px));
  padding: 10px 17px;
  transform: translate(-50%, 10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 249, 233, 0.94);
  box-shadow: 0 8px 25px rgba(18, 50, 39, 0.22);
  color: var(--forest);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}

#prompt.prompt-show,
.prompt-show#prompt {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

#prompt kbd {
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--forest);
  color: var(--cream);
  font-size: 11px;
}

#toast {
  position: fixed;
  z-index: 48;
  top: 30%;
  left: 50%;
  max-width: min(430px, calc(100vw - 40px));
  padding: 11px 20px;
  transform: translate(-50%, 12px) scale(0.96);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 15px;
  background: rgba(24, 63, 52, 0.92);
  box-shadow: 0 10px 30px rgba(11, 39, 30, 0.25);
  color: var(--cream);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#toast.toast-show,
.toast-show#toast {
  visibility: visible;
  animation: toast-arrive 240ms ease-out both;
}

/* Small utility buttons */

#eat-btn,
#help-btn,
#mute-btn,
#action-btn,
#sprint-btn {
  position: fixed;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.68);
  background: var(--glass);
  box-shadow:
    0 5px 0 rgba(26, 64, 49, 0.52),
    0 9px 20px rgba(14, 44, 34, 0.2),
    inset 0 0 0 1px rgba(34, 74, 56, 0.12);
  color: var(--forest);
  font-weight: 850;
  letter-spacing: 0.045em;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 90ms ease, box-shadow 90ms ease, background 120ms ease;
  touch-action: none;
}

#eat-btn:active,
#help-btn:active,
#mute-btn:active,
#action-btn:active,
#sprint-btn:active,
#action-btn.active,
#sprint-btn.active {
  transform: translateY(4px) scale(0.98);
  box-shadow:
    0 1px 0 rgba(26, 64, 49, 0.55),
    0 4px 10px rgba(14, 44, 34, 0.18),
    inset 0 0 0 1px rgba(34, 74, 56, 0.12);
}

#help-btn {
  bottom: calc(17px + var(--safe-bottom));
  left: calc(17px + var(--safe-left));
  min-width: 76px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 11px;
}

#mute-btn {
  right: calc(13px + var(--safe-right));
  bottom: calc(17px + var(--safe-bottom));
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  letter-spacing: 0;
}

#eat-btn {
  bottom: calc(17px + var(--safe-bottom));
  left: 50%;
  min-width: 86px;
  min-height: 40px;
  padding: 8px 15px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: #753c42;
  font-size: 11px;
}

#eat-btn:active {
  transform: translate(-50%, 4px) scale(0.98);
}

/* Touch controls are enabled below for coarse pointers and compact screens. */

#joystick,
#action-btn,
#sprint-btn {
  display: none;
}

#joystick {
  position: fixed;
  z-index: 38;
  bottom: calc(20px + var(--safe-bottom));
  left: calc(18px + var(--safe-left));
  width: 118px;
  height: 118px;
  border: 2px solid rgba(255, 255, 255, 0.53);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 251, 235, 0.2) 0 31%, transparent 32%),
    rgba(26, 66, 51, 0.25);
  box-shadow:
    inset 0 0 0 8px rgba(255, 249, 233, 0.09),
    0 6px 22px rgba(16, 47, 37, 0.18);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  pointer-events: auto;
  touch-action: none;
}

#joystick::before,
#joystick::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#joystick::before {
  width: 64px;
  height: 1px;
}

#joystick::after {
  width: 1px;
  height: 64px;
}

#stick {
  position: absolute;
  top: 35px;
  left: 35px;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 252, 239, 0.96), rgba(211, 224, 191, 0.92));
  box-shadow:
    0 5px 12px rgba(15, 45, 35, 0.28),
    inset 0 0 0 2px rgba(48, 91, 65, 0.11);
  pointer-events: none;
  will-change: transform;
}

#action-btn {
  right: calc(18px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  width: 82px;
  height: 82px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(155deg, #ffd77d, #dfa03b);
  box-shadow:
    0 6px 0 #9c6928,
    0 12px 24px rgba(32, 54, 35, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.64);
  color: #2e4933;
  font-size: 12px;
}

#sprint-btn {
  right: calc(108px + var(--safe-right));
  bottom: calc(42px + var(--safe-bottom));
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  color: var(--forest);
  font-size: 10px;
}

/* Phone layout: 412 × 732 is the primary target. */

@media (pointer: coarse), (max-width: 760px) {
  #joystick {
    display: block;
  }

  #action-btn,
  #sprint-btn {
    display: inline-flex;
  }

  #help-btn {
    right: calc(90px + var(--safe-right));
    bottom: calc(128px + var(--safe-bottom));
    left: auto;
    min-width: 52px;
    min-height: 42px;
    padding: 7px 10px;
    font-size: 9px;
  }

  #mute-btn {
    top: calc(8px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    bottom: auto;
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  #eat-btn {
    right: calc(23px + var(--safe-right));
    bottom: calc(120px + var(--safe-bottom));
    left: auto;
    min-width: 57px;
    min-height: 51px;
    padding: 7px 9px;
    transform: none;
    border-radius: 18px;
    font-size: 10px;
  }

  #eat-btn:active {
    transform: translateY(4px) scale(0.98);
  }

  #prompt {
    bottom: calc(184px + var(--safe-bottom));
    font-size: 12px;
  }
}

@media (max-width: 600px) {
  .overlay {
    padding:
      calc(13px + var(--safe-top))
      calc(13px + var(--safe-right))
      calc(13px + var(--safe-bottom))
      calc(13px + var(--safe-left));
  }

  #start-screen,
  #end-screen,
  #help-panel {
    padding:
      calc(13px + var(--safe-top))
      calc(13px + var(--safe-right))
      calc(13px + var(--safe-bottom))
      calc(13px + var(--safe-left));
  }

  .overlay > div,
  .overlay > section,
  .title-card,
  .end-card,
  .sheet {
    max-height: calc(100dvh - 26px - var(--safe-top) - var(--safe-bottom));
    padding: 23px 20px;
    border-radius: 23px;
  }

  .overlay h1 {
    font-size: clamp(39px, 13vw, 56px);
  }

  .overlay p {
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.48;
  }

  #start-btn,
  #restart-btn {
    min-width: 178px;
    min-height: 50px;
    padding: 12px 22px;
    font-size: 15px;
  }

  #hud {
    top: calc(6px + var(--safe-top));
    left: calc(6px + var(--safe-left));
    right: calc(112px + var(--safe-right));
    justify-content: flex-start;
    gap: 4px;
  }

  .hud-card {
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.22;
  }

  #hud .hud-card {
    flex: 1 1 auto;
  }

  .bar {
    width: clamp(46px, 15vw, 65px);
    height: 7px;
  }

  #health-text,
  #hunger-text,
  #thirst-text {
    min-width: 22px;
  }

  #compass {
    top: calc(106px + var(--safe-top));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 14px;
    width: auto;
    max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    min-height: 27px;
    padding: 6px 12px;
    font-size: 12px;
  }

  #objective {
    top: calc(178px + var(--safe-top));
    max-width: calc(100vw - 22px);
    padding: 5px 9px;
    font-size: 12px;
  }

  #hud #compass,
  #hud #objective {
    top: auto;
    max-width: 100%;
  }

  #hud #compass {
    justify-content: space-around;
    gap: 4px;
    padding: 5px 8px;
  }

  #hud #objective {
    width: auto;
    align-self: center;
    flex-basis: auto;
    max-width: 96%;
  }

  #mute-btn {
    right: calc(10px + var(--safe-right));
    width: auto;
    min-width: 86px;
    max-width: calc(100vw - 20px - var(--safe-left) - var(--safe-right));
    padding: 7px 10px;
    font-size: 13px;
  }

  #prompt {
    max-width: calc(100vw - 48px);
    padding: 9px 13px;
    border-radius: 15px;
  }

  #toast {
    top: 34%;
    padding: 10px 15px;
    font-size: 13px;
  }

  #end-copy {
    font-size: 14px;
  }
}

/* Short landscape screens keep the central view clear. */

@media (max-height: 540px) and (orientation: landscape) {
  #hud {
    top: calc(5px + var(--safe-top));
    right: calc(52px + var(--safe-right));
    max-width: 760px;
    gap: 4px;
  }

  .hud-card {
    padding: 5px 8px;
    border-radius: 11px;
    font-size: 10px;
  }

  #compass {
    top: calc(65px + var(--safe-top));
  }

  #objective {
    top: calc(99px + var(--safe-top));
  }

  #hud #compass,
  #hud #objective {
    top: auto;
  }

  #hud #objective {
    display: none;
  }

  #joystick {
    bottom: calc(12px + var(--safe-bottom));
    width: 96px;
    height: 96px;
  }

  #stick {
    top: 27px;
    left: 27px;
    width: 42px;
    height: 42px;
  }

  #action-btn {
    bottom: calc(15px + var(--safe-bottom));
    width: 68px;
    height: 68px;
  }

  #sprint-btn {
    right: calc(94px + var(--safe-right));
    bottom: calc(24px + var(--safe-bottom));
    width: 55px;
    height: 55px;
  }

  #eat-btn {
    bottom: calc(91px + var(--safe-bottom));
  }

  #help-btn {
    bottom: calc(100px + var(--safe-bottom));
  }

  #prompt {
    bottom: calc(102px + var(--safe-bottom));
  }

  .overlay > div,
  .overlay > section,
  .title-card,
  .end-card,
  .sheet {
    padding: 17px 24px;
  }

  .overlay h1 {
    font-size: 39px;
  }

  .overlay h2 {
    font-size: 28px;
  }

  .overlay p {
    margin-bottom: 10px;
    font-size: 13px;
  }

  #start-btn,
  #restart-btn {
    min-height: 43px;
    padding: 9px 22px;
  }
}

@keyframes card-arrive {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-arrive {
  from {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes vital-pulse {
  0%,
  100% {
    filter: brightness(1);
    opacity: 1;
  }
  50% {
    filter: brightness(1.28) saturate(1.25);
    opacity: 0.66;
  }
}

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