/* Facet Core — flat tokens only. Depth = mix toward Bone or Ink. */
:root {
  --ink: #1a1b26;
  --bone: #f4efe6;
  --ember: #ff9e64;
  --moss: #9ece6a;
  --sky: #7aa2f7;
  --lilac: #bb9af7;
  --coral: #f7768e;
  --mist: #a9b1d6;

  --moss-ink: color-mix(in srgb, var(--moss) 68%, var(--ink));
  --moss-bone: color-mix(in srgb, var(--moss) 72%, var(--bone));
  --sky-ink: color-mix(in srgb, var(--sky) 68%, var(--ink));
  --ember-bone: color-mix(in srgb, var(--ember) 72%, var(--bone));
  --ink-bone: color-mix(in srgb, var(--ink) 82%, var(--bone));

  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--bone);
  font-family: var(--font-body);
  background-color: var(--ink);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--ink);
}

.mesh {
  position: absolute;
  inset: 0;
  background-color: var(--ink);
  background-image: url("./assets/facet/mesh.svg");
  background-repeat: repeat;
  background-size: 128px 128px;
  opacity: 0.12;
}

.terrain {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(26vh, 220px);
  background-image: url("./assets/facet/terrain.svg");
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: cover;
}

#motion-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hud {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  max-width: 36rem;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: 0.04em;
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--bone);
}

.brand-mark {
  display: block;
  width: clamp(2.4rem, 7vw, 3.4rem);
  height: clamp(2.4rem, 7vw, 3.4rem);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ember);
}

.lede {
  margin: 0;
  max-width: 34rem;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  line-height: 1.55;
  color: var(--mist);
}

.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.2rem 0 0;
}

.scoreboard[hidden],
.btn[hidden] {
  display: none;
}

.score-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.score-mark {
  display: block;
  width: 2.4rem;
  height: 2.4rem;
}

.btn {
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 0;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.75rem 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.btn-icon {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
}

.btn.primary {
  background: var(--ember);
  color: var(--ink);
  border-color: var(--ink);
}

.btn.primary:hover {
  background: var(--ember-bone);
}

.btn.primary:disabled {
  cursor: default;
  opacity: 0.72;
}

.btn.ghost {
  background: var(--ink);
  color: var(--bone);
  border-color: var(--mist);
}

.btn.ghost:hover {
  background: var(--ink-bone);
  border-color: var(--bone);
}

.scoreline {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  color: var(--bone);
}

.score-kicker {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mist);
}

.score-value {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 11vw, 5.4rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 0.82;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}

.scoreline.is-fail .score-value,
.scoreline.is-fail .score-kicker,
.roundline.is-fail {
  color: var(--coral);
}

.scoreline.is-pop .score-value {
  animation: score-pop 280ms ease-out;
}

.roundline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 0.15rem 0 0.35rem;
  min-height: 1.25rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--moss);
}

.status.is-fail {
  color: var(--coral);
}

h1.is-fail {
  color: var(--coral);
}

.camera-invite {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  padding: 0.95rem 1.05rem 1.05rem;
  border: 2px solid var(--mist);
  border-radius: 0;
  background: var(--ink-bone);
}

.camera-kicker {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ember);
}

.kicker-mark {
  display: block;
  width: 1rem;
  height: 1rem;
}

.camera-copy {
  margin: 0;
  max-width: 32rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--bone);
}

body.is-camera-prompt.is-start .camera-invite {
  border-color: var(--ember);
}

body.is-camera-prompt.is-start #start-camera.primary {
  animation: pulse-btn 1.6s steps(2, end) infinite;
}

body.is-camera-denied .camera-invite {
  border-color: var(--coral);
}

body.is-camera-denied .camera-kicker {
  color: var(--coral);
}

body.is-camera-ready .camera-invite {
  padding: 0.7rem 0 0;
  border: none;
  background: transparent;
}

body.is-playing .camera-invite,
body.is-between .camera-invite {
  padding: 0.55rem 0 0;
  border: none;
  background: transparent;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.camera-feeds {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  pointer-events: none;
}

.camera-feed {
  display: none;
  width: min(28vw, 220px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--ink);
  border: 2px solid var(--moss);
  border-radius: 0;
  transform: scaleX(-1);
}

.camera-feed.is-live {
  display: block;
}

.camera-feed-b.is-live {
  border-color: var(--sky);
}

@keyframes pulse-btn {
  0%,
  100% {
    background: var(--ember);
  }
  50% {
    background: var(--ember-bone);
  }
}

@keyframes score-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.16);
    color: var(--moss);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  .hud {
    max-width: none;
  }

  .btn {
    text-align: center;
  }

  .camera-feeds {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .camera-feed {
    width: min(42vw, 160px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
