@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap");

:root {
  color-scheme: dark;
  --forest-950: #0c1009;
  --forest-900: #12180e;
  --forest-800: #1b2515;
  --forest-700: #2f4022;
  --moss: #839762;
  --moss-bright: #b8ca8c;
  --cream: #f4e8cf;
  --cream-muted: #c8bca5;
  --ember: #d77c31;
  --ember-bright: #ffab55;
  --apple: #d74a34;
  --glass: rgba(18, 24, 14, 0.72);
  --glass-strong: rgba(14, 19, 11, 0.91);
  --line: rgba(244, 232, 207, 0.16);
  --shadow: rgba(0, 0, 0, 0.34);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--forest-950);
  color: var(--cream);
}

body {
  user-select: none;
  -webkit-user-select: none;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
summary:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  isolation: isolate;
  background: radial-gradient(circle at 68% 28%, #3e3a22 0, var(--forest-950) 58%);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene.is-dragging {
  cursor: grabbing;
}

#scene.can-hit {
  cursor: crosshair;
}

.atmosphere,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.atmosphere {
  background:
    linear-gradient(180deg, rgba(255, 182, 91, 0.09), transparent 34%),
    radial-gradient(circle at 50% 85%, transparent 0 42%, rgba(11, 15, 8, 0.22) 75%);
  mix-blend-mode: screen;
  opacity: 0.75;
}

.vignette {
  box-shadow: inset 0 0 180px 38px rgba(4, 7, 3, 0.62);
  background: linear-gradient(180deg, rgba(4, 7, 3, 0.2), transparent 25% 70%, rgba(4, 7, 3, 0.35));
}

.glass-panel {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 16px 42px var(--shadow);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}

.hud-top {
  position: absolute;
  z-index: 5;
  top: 22px;
  left: 24px;
  right: 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 8px 15px 8px 9px;
  border-radius: 16px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--forest-950);
  background: linear-gradient(145deg, var(--ember-bright), var(--ember));
  box-shadow: 0 6px 18px rgba(215, 124, 49, 0.3);
}

.brand__mark svg {
  width: 28px;
  fill: currentColor;
}

.brand__copy {
  display: grid;
  line-height: 1.05;
}

.brand__copy strong {
  font-size: 12px;
  letter-spacing: 0.14em;
}

.brand__copy small {
  margin-top: 5px;
  color: var(--cream-muted);
  font-size: 10px;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 54px;
  padding: 8px 20px;
  border-radius: 17px;
}

.score {
  display: flex;
  align-items: center;
  gap: 9px;
}

.score > span:last-child {
  display: grid;
  line-height: 1;
}

.score strong {
  font-family: "Fraunces", Georgia, serif;
  font-size: 21px;
  color: var(--cream);
}

.score small {
  margin-top: 4px;
  color: var(--cream-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.apple-icon {
  position: relative;
  width: 22px;
  height: 21px;
  border-radius: 48% 52% 48% 48%;
  background: var(--apple);
  box-shadow: inset -4px -3px rgba(87, 20, 13, 0.24);
  transform: rotate(-4deg);
}

.apple-icon::before {
  content: "";
  position: absolute;
  left: 11px;
  top: -7px;
  width: 3px;
  height: 9px;
  border-radius: 4px;
  background: #684427;
  transform: rotate(18deg);
}

.apple-icon::after {
  content: "";
  position: absolute;
  left: 12px;
  top: -4px;
  width: 9px;
  height: 5px;
  border-radius: 100% 0 100% 0;
  background: var(--moss);
  transform: rotate(-24deg);
}

.score__tree {
  width: 25px;
  fill: var(--moss-bright);
}

.scoreboard__rule {
  width: 1px;
  height: 29px;
  background: var(--line);
}

.icon-button {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 16px;
  color: var(--cream);
  cursor: pointer;
  transition: transform 180ms var(--ease-out), border-color 180ms ease, background 180ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 171, 85, 0.5);
  background: rgba(29, 38, 22, 0.86);
}

.icon-button svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.controls-card {
  position: absolute;
  z-index: 4;
  left: 24px;
  bottom: 26px;
  width: min(300px, calc(100vw - 48px));
  padding: 22px;
  border-radius: 20px;
  transition: opacity 300ms ease, transform 300ms var(--ease-out);
}

.controls-card.is-dismissed {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.controls-card__close {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 30px;
  height: 30px;
  border: 0;
  color: var(--cream-muted);
  background: transparent;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ember-bright);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.controls-card h1,
.settings-panel h2,
.loading-screen h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.03;
}

.controls-card h1 {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 600;
}

.controls-card h1 em {
  color: var(--moss-bright);
  font-weight: inherit;
}

.control-list {
  display: grid;
  gap: 9px;
  margin-top: 19px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.control-list > div {
  display: grid;
  grid-template-columns: 98px 1fr;
  align-items: center;
  min-height: 26px;
  color: var(--cream-muted);
  font-size: 11px;
}

.key-pair {
  display: flex;
  gap: 3px;
}

kbd,
.mouse-key {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 23px;
  padding: 0 6px;
  border: 1px solid rgba(244, 232, 207, 0.22);
  border-bottom-color: rgba(244, 232, 207, 0.34);
  border-radius: 6px;
  background: rgba(244, 232, 207, 0.07);
  color: var(--cream);
  font-size: 8px;
  font-family: inherit;
  font-weight: 700;
}

.mouse-key {
  position: relative;
  width: 25px;
  padding: 0;
  border-radius: 9px 9px 7px 7px;
}

.mouse-key::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 10px;
  left: 50%;
  width: 1px;
  background: var(--line);
}

.mouse-key i {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 7px;
  height: 7px;
  border-radius: 4px 2px 2px;
  background: var(--ember-bright);
}

.mouse-key--right i {
  right: 4px;
  left: auto;
  border-radius: 2px 4px 2px 2px;
  background: var(--moss-bright);
}

.interaction-card {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 30px;
  width: min(330px, calc(100vw - 48px));
  padding: 15px 17px 13px;
  border-radius: 18px;
  opacity: 0;
  transform: translate(-50%, 18px) scale(0.97);
  pointer-events: none;
  transition: opacity 220ms ease, transform 320ms var(--ease-out), border-color 180ms ease;
}

.interaction-card.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.interaction-card.is-ready {
  border-color: rgba(255, 171, 85, 0.5);
}

.interaction-card__heading {
  display: flex;
  align-items: center;
  gap: 11px;
}

.interaction-card__heading > span:last-child {
  display: grid;
}

.interaction-card__heading small {
  color: var(--cream-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.interaction-card__heading strong {
  margin-top: 3px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
}

.interaction-card__tree {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(131, 151, 98, 0.15);
  color: var(--moss-bright);
}

.interaction-card__tree svg {
  width: 23px;
  fill: currentColor;
}

.hit-meter {
  margin-top: 12px;
}

.hit-meter__labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--cream-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.hit-pips {
  display: flex;
  gap: 5px;
}

.hit-pips span {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(244, 232, 207, 0.12);
  transition: background 160ms ease, transform 160ms var(--ease-out);
}

.hit-pips span.is-filled {
  background: linear-gradient(90deg, var(--ember), var(--ember-bright));
  transform: scaleY(1.3);
}

.interaction-card p {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--cream-muted);
  font-size: 10px;
}

.click-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ember-bright);
  box-shadow: 0 0 0 4px rgba(255, 171, 85, 0.13);
}

.world-status {
  position: absolute;
  z-index: 3;
  right: 25px;
  bottom: 27px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(244, 232, 207, 0.66);
  font-size: 9px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.world-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moss-bright);
  box-shadow: 0 0 12px var(--moss-bright);
}

.toast {
  position: absolute;
  z-index: 9;
  top: 92px;
  left: 50%;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 16px;
  border: 1px solid rgba(255, 171, 85, 0.28);
  border-radius: 999px;
  background: rgba(14, 19, 11, 0.88);
  color: var(--cream);
  box-shadow: 0 14px 34px var(--shadow);
  font-size: 11px;
  opacity: 0;
  transform: translate(-50%, -10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 260ms var(--ease-out);
}

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

.credits {
  position: absolute;
  z-index: 5;
  right: 24px;
  bottom: 49px;
  border-radius: 11px;
  color: var(--cream-muted);
  font-size: 9px;
}

.credits summary {
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
}

.credits summary::-webkit-details-marker {
  display: none;
}

.credits__body {
  display: grid;
  gap: 6px;
  width: 245px;
  padding: 2px 12px 12px;
}

.credits a {
  color: var(--moss-bright);
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

.mobile-controls {
  display: none;
}

.settings-dialog {
  width: min(470px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid rgba(244, 232, 207, 0.18);
  border-radius: 24px;
  background: var(--glass-strong);
  color: var(--cream);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(24px) saturate(130%);
}

.settings-dialog::backdrop {
  background: rgba(5, 8, 4, 0.62);
  backdrop-filter: blur(5px);
}

.settings-panel {
  padding: 25px;
}

.settings-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
}

.settings-panel h2 {
  font-size: 30px;
}

.dialog-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--cream-muted);
  background: rgba(244, 232, 207, 0.06);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
}

.setting-row > span {
  display: grid;
  gap: 4px;
}

.setting-row strong {
  font-size: 13px;
}

.setting-row small {
  color: var(--cream-muted);
  font-size: 10px;
}

.setting-row output {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 171, 85, 0.12);
  color: var(--ember-bright);
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 15px 0 3px;
  border-radius: 99px;
  appearance: none;
  background: rgba(244, 232, 207, 0.13);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  border: 3px solid var(--forest-900);
  border-radius: 50%;
  appearance: none;
  background: var(--ember-bright);
  box-shadow: 0 0 0 1px rgba(255, 171, 85, 0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 3px solid var(--forest-900);
  border-radius: 50%;
  background: var(--ember-bright);
}

.settings-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 25px 0 18px;
  padding: 11px 13px;
  border: 1px solid rgba(131, 151, 98, 0.2);
  border-radius: 12px;
  background: rgba(131, 151, 98, 0.08);
  color: var(--cream-muted);
}

.settings-note > span {
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--moss);
  color: var(--forest-950);
  font-size: 11px;
  font-weight: 700;
}

.settings-note p {
  margin: 0;
  font-size: 10px;
}

.reset-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 45px;
  border: 1px solid rgba(255, 171, 85, 0.32);
  border-radius: 13px;
  background: rgba(215, 124, 49, 0.12);
  color: var(--cream);
  cursor: pointer;
  transition: background 180ms ease, transform 180ms var(--ease-out);
}

.reset-button:hover {
  background: rgba(215, 124, 49, 0.2);
  transform: translateY(-1px);
}

.reset-button svg {
  width: 18px;
  fill: none;
  stroke: var(--ember-bright);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loading-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(215, 124, 49, 0.18), transparent 34%),
    var(--forest-950);
  transition: opacity 650ms ease, visibility 650ms ease;
}

.game-shell[data-state="ready"] .loading-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-screen__scene {
  position: relative;
  width: 180px;
  height: 105px;
  margin-bottom: 26px;
  overflow: hidden;
  border-bottom: 1px solid rgba(244, 232, 207, 0.16);
}

.loading-screen__sun {
  position: absolute;
  top: 7px;
  left: 72px;
  width: 39px;
  height: 39px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 35px rgba(215, 124, 49, 0.42);
}

.loading-screen__tree {
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
  border-right: 28px solid transparent;
  border-bottom: 75px solid var(--forest-700);
  border-left: 28px solid transparent;
}

.loading-screen__tree::after {
  content: "";
  position: absolute;
  top: 38px;
  left: -5px;
  width: 10px;
  height: 38px;
  background: #5f3f24;
}

.loading-screen__tree--one {
  left: 16px;
}

.loading-screen__tree--two {
  right: 8px;
  transform: scale(0.82);
  transform-origin: bottom;
}

.loading-screen__fox {
  position: absolute;
  bottom: 7px;
  left: 73px;
  width: 42px;
  height: 23px;
  border-radius: 55% 55% 38% 38%;
  background: var(--ember);
  animation: loading-fox 1.4s ease-in-out infinite;
}

.loading-screen__fox::before {
  content: "";
  position: absolute;
  right: -10px;
  top: -8px;
  width: 21px;
  height: 21px;
  border-radius: 45%;
  background: var(--ember-bright);
}

.loading-screen__fox::after {
  content: "";
  position: absolute;
  left: -22px;
  top: 3px;
  width: 30px;
  height: 14px;
  border-radius: 100% 20% 20% 100%;
  background: var(--ember);
  transform: rotate(23deg);
}

.loading-screen h2 {
  font-size: 32px;
}

.loading-bar {
  width: 240px;
  height: 4px;
  margin-top: 21px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(244, 232, 207, 0.1);
}

.loading-bar span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ember), var(--ember-bright));
  transition: width 280ms var(--ease-out);
}

.loading-screen > small {
  margin-top: 9px;
  color: var(--cream-muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.loading-screen.is-error h2 {
  color: var(--apple);
}

@keyframes loading-fox {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(2deg); }
}

@media (max-width: 780px) {
  .hud-top {
    top: 14px;
    left: 14px;
    right: 14px;
    grid-template-columns: 1fr auto;
  }

  .brand {
    min-height: 48px;
    padding: 6px 11px 6px 7px;
  }

  .brand__mark {
    width: 34px;
    height: 34px;
  }

  .brand__copy small {
    display: none;
  }

  .scoreboard {
    position: absolute;
    top: 58px;
    left: 0;
    min-height: 45px;
    padding: 6px 13px;
  }

  .score strong {
    font-size: 17px;
  }

  .icon-button {
    position: absolute;
    top: 0;
    right: 0;
    grid-column: auto;
    width: 48px;
    height: 48px;
  }

  .controls-card {
    top: 126px;
    bottom: auto;
    left: 14px;
    width: 245px;
    padding: 17px;
  }

  .controls-card h1 {
    font-size: 26px;
  }

  .control-list {
    display: none;
  }

  .interaction-card {
    bottom: 25px;
    width: min(310px, calc(100vw - 140px));
  }

  .world-status,
  .credits {
    display: none;
  }
}

@media (hover: none), (pointer: coarse), (max-width: 780px) {
  #scene {
    cursor: default;
  }

  .mobile-controls {
    position: absolute;
    z-index: 6;
    right: 18px;
    bottom: 23px;
    left: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    pointer-events: none;
  }

  .joystick,
  .action-button {
    pointer-events: auto;
  }

  .joystick {
    position: relative;
    width: 98px;
    height: 98px;
    touch-action: none;
  }

  .joystick__ring {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(244, 232, 207, 0.23);
    border-radius: 50%;
    background: rgba(14, 19, 11, 0.43);
    backdrop-filter: blur(8px);
  }

  .joystick__knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px;
    border: 1px solid rgba(255, 171, 85, 0.55);
    border-radius: 50%;
    background: rgba(215, 124, 49, 0.72);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
    transform: translate(0, 0);
  }

  .action-button {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    padding: 0;
    border: 1px solid rgba(255, 171, 85, 0.5);
    border-radius: 50%;
    background: rgba(215, 124, 49, 0.76);
    color: var(--cream);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(8px);
  }

  .action-button svg {
    width: 26px;
    fill: currentColor;
  }

  .action-button span {
    margin-top: -12px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.12em;
  }

  .interaction-card {
    bottom: 31px;
  }
}

@media (max-width: 520px) {
  .interaction-card {
    bottom: 130px;
    width: min(310px, calc(100vw - 28px));
  }

  .controls-card {
    width: 210px;
  }

  .controls-card h1 {
    font-size: 22px;
  }
}

@media (max-height: 620px) {
  .controls-card {
    display: none;
  }

  .interaction-card {
    bottom: 17px;
  }

  .credits,
  .world-status {
    display: none;
  }
}

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