/* How the page looks: the full-window 3D view, the hearts and power bar,
   messages, the screens, and the thumb pad for phones. */

:root {
  --ochre: #c98d4a;
  --red-earth: #b4532c;
  --night: rgba(25, 18, 12, 0.82);
  --cream: #fff6e4;
  --teal: #5ff2e0;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--cream);
  font-family: system-ui, sans-serif;
  /* Stop phones scrolling, zooming or selecting text while playing. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

button {
  font: inherit;
  font-weight: 700;
  color: #2a160b;
  background: var(--ochre);
  border: 3px solid #2a160b;
  border-radius: 10px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a160b;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2a160b;
}

button.quiet {
  background: transparent;
  color: var(--cream);
  border-color: var(--cream);
  box-shadow: none;
}

/* The hearts, power bar and field guide button along the top. */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

#hud button {
  margin-left: auto;
  pointer-events: auto;
  padding: 6px 14px;
}

#hearts {
  font-size: 28px;
  color: #e8433a;
  text-shadow: 0 2px 0 #000;
  letter-spacing: 2px;
}

#power {
  flex: 0 1 240px;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

#power .bar {
  height: 12px;
  margin-top: 3px;
  border: 2px solid #2a160b;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

#powerFill {
  height: 100%;
  width: 100%;
  background: var(--teal);
}

#powerFill.low {
  background: #e8433a;
}

#score {
  white-space: nowrap;
  font-weight: 700;
  font-size: 18px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* The label over an animal that's been in the crosshair for a moment. */
#label {
  position: fixed;
  transform: translate(-50%, -100%);
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--night);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

#label strong {
  display: block;
  font-size: 15px;
}

#label span {
  display: block;
  font-size: 12px;
  color: var(--teal);
}

/* The map in the top right corner, under the Field guide button. */
#map {
  position: fixed;
  top: 64px;
  right: 12px;
  width: 150px;
  pointer-events: none;
  text-align: center;
}

#mapCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid var(--night);
  border-radius: 10px;
  opacity: 0.92;
}

#mapLabel {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

body.touch #map {
  top: 70px;
  width: 110px;
}

body.touch #mapLabel {
  white-space: nowrap;
  font-size: 12px;
}

/* On phones, messages sit to the left of the map instead of over it. */
body.touch #toast {
  left: 12px;
  transform: none;
  max-width: calc(100% - 176px);
}

#photoButton {
  position: fixed;
  right: 24px;
  bottom: 28px;
}

#homeButton {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--teal);
}

#toast {
  position: fixed;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--night);
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
}

/* The red flash at the edges of the screen when the player is hurt. */
#hurt {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, transparent 45%, rgba(220, 30, 20, 0.75));
  opacity: 0;
  pointer-events: none;
}

#hurt.on {
  animation: flash 0.7s ease-out;
}

/* A small dot in the middle of the screen, where the traveller is looking. */
#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 246, 228, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

#flash.on {
  animation: flash 0.9s ease-out;
}

/* A quick, softer flash for the camera. */
#flash.snap {
  animation: flash 0.25s ease-out;
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* The title, field guide and end-of-trip screens. */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 16px;
  box-sizing: border-box;
  text-align: center;
  background: radial-gradient(circle at center, rgba(25, 18, 12, 0.35), rgba(25, 18, 12, 0.8));
  overflow-y: auto;
  touch-action: pan-y;
}

.screen h1 {
  margin: 0;
  font-size: clamp(36px, 9vw, 72px);
  line-height: 1;
  color: var(--ochre);
  text-shadow: 0 4px 0 #2a160b;
}

.screen h1 span {
  display: block;
  font-size: 0.5em;
  color: var(--cream);
}

.screen h2 {
  margin: 0;
  font-size: 32px;
  color: var(--ochre);
}

.screen p {
  max-width: 520px;
  margin: 0;
  line-height: 1.45;
}

.small,
.keys {
  font-size: 13px;
  opacity: 0.85;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  width: min(560px, 100%);
  text-align: left;
}

.cards li {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--night);
  border-left: 6px solid var(--red-earth);
}

.cards li.unknown {
  opacity: 0.6;
  border-left-color: #666;
}

.cards p {
  margin: 4px 0 0;
  font-size: 14px;
}

.cards p.record {
  font-weight: 700;
  color: var(--teal);
}

/* The thumb pad, shown only on touch screens. */
#pad {
  display: none;
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 246, 228, 0.18);
  border: 3px solid rgba(255, 246, 228, 0.5);
  touch-action: none;
}

#knob {
  position: absolute;
  left: 40px;
  top: 40px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 246, 228, 0.7);
}

body.touch #hud:not([hidden]) ~ #pad {
  display: block;
}

body.touch .keys,
body.touch #homeButton .key,
body.touch #photoButton .key {
  display: none;
}

/* The Jump button is only for phones; Space jumps on a keyboard. */
#jumpButton {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 140px;
  padding: 18px 22px;
}

body.touch #jumpButton:not([hidden]) {
  display: block;
}

body.touch #photoButton {
  bottom: 60px;
  padding: 18px 22px;
}

body.touch #homeButton {
  left: auto;
  right: 24px;
  bottom: 220px;
  transform: none;
}
