:root {
  color-scheme: light;
  --ink: #172c35;
  --cream: #fff4d7;
  --gold: #ffd276;
  --rose: #d96b67;
  --green: #4e8769;
  --paper: #fffaf0;
  font-family: "Nunito Sans", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  background: #dce8c8;
  color: var(--ink);
}
button,
input {
  font: inherit;
}
button {
  touch-action: manipulation;
}
canvas#world {
  position: fixed;
  inset: 0;
}
.gate,
.start-card {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 50% 35%,
      rgba(255, 210, 118, 0.24),
      transparent 34%
    ),
    #172c35;
}
.gate[hidden],
.start-card[hidden] {
  display: none;
}
.gate-card,
.start-card {
  color: var(--cream);
  text-align: center;
}
.gate-card {
  width: min(460px, 100%);
  padding: 36px;
  border: 1px solid rgba(255, 244, 215, 0.3);
  background: #1d3540;
  box-shadow: 0 24px 80px #09161c;
}
.gate h1,
.start-card h1,
.story h2,
.map h2 {
  font:
    600 clamp(2.3rem, 7vw, 4.8rem)/0.95 Fraunces,
    serif;
  margin: 10px 0 14px;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  font-weight: 800;
}
.gate label {
  display: block;
  margin: 26px 0 8px;
}
.gate input {
  width: 100%;
  min-height: 50px;
  border: 1px solid #9bb3ad;
  background: #f9f0d8;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 1.1rem;
}
.gate-message {
  min-height: 22px;
  color: #ffd276;
}
.warm-button {
  min-height: 50px;
  border: 0;
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  padding: 0 22px;
  box-shadow: 0 5px 0 #bb783e;
  cursor: pointer;
}
.warm-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #bb783e;
}
.start-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.start-card > p {
  max-width: 480px;
}
.key-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 14px 0 28px;
}
.key-row span {
  border: 1px solid rgba(255, 244, 215, 0.35);
  padding: 7px 11px;
  border-radius: 5px;
}
.hud {
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  padding:
    calc(12px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    12px
    calc(14px + env(safe-area-inset-left));
  display: grid;
  grid-template-columns: auto 48px 48px;
  justify-content: end;
  align-items: center;
  gap: 10px;
  background: linear-gradient(#172c35dd, transparent);
  color: #fff;
}
.hud[hidden] {
  display: none;
}
.reset-progress-button {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(23, 44, 53, 0.3);
  border-radius: 6px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(23, 44, 53, 0.35);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.reset-progress-button:hover,
.reset-progress-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.reset-progress-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(23, 44, 53, 0.35);
}
.petal-meter {
  display: flex;
  align-items: baseline;
  gap: 3px;
  background: #fff4d7;
  color: var(--ink);
  padding: 8px 11px;
  border-radius: 5px;
  font-weight: 800;
}
.petal-meter small {
  font-size: 0.65rem;
}
.round-button {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: #172c35;
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
}
.music-player {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: min(300px, calc(100vw - 28px));
  max-width: 300px;
  justify-self: end;
  padding: 7px 8px 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  background: rgba(23, 44, 53, 0.92);
}
.music-volume {
  display: grid;
  gap: 2px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  text-align: center;
}
.music-volume input {
  width: 72px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}
.music-player[hidden] {
  display: none;
}
@media (max-width: 620px) {
  .reset-progress-button {
    min-height: 38px;
    max-width: 74px;
    padding: 0 9px;
    font-size: 0.62rem;
    line-height: 1.05;
  }
}
.song-copy {
  display: grid;
  min-width: 0;
}
.song-copy small {
  color: var(--gold);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.song-copy span {
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
#next-song {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.64rem;
  font-weight: 800;
}
.interact {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-height: 52px;
  border: 0;
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  padding: 0 26px;
  box-shadow: 0 5px 0 #a96537;
}
.interact[hidden] {
  display: none;
}
.story,
.map {
  width: min(600px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 28px;
  box-shadow: 12px 12px 0 #172c35;
  overflow: auto;
}
.story::backdrop,
.map::backdrop {
  background: rgba(9, 22, 28, 0.72);
  backdrop-filter: blur(4px);
}
.story-close {
  float: right;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid var(--ink);
  background: transparent;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
}
.story h2,
.map h2 {
  font-size: clamp(2rem, 8vw, 4rem);
  clear: both;
}
.story > p:not(.kicker, .story-gift),
.map > p {
  font-size: 1.05rem;
  line-height: 1.6;
}
.story-media[hidden] {
  display: none;
}
.story-media {
  display: grid;
  place-items: center;
  margin: 18px 0;
}
.story-media img,
.story-media video {
  display: block;
  width: 100%;
  max-height: min(58vh, 520px);
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: #111;
  object-fit: contain;
}
.memory-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 20px 0;
}
.memory-tags span {
  padding: 7px 10px;
  background: #e1ead1;
  border: 1px solid #789179;
  border-radius: 4px;
  font-size: 0.8rem;
}
.story-gift {
  margin: 22px 0;
  padding: 16px;
  border-left: 5px solid var(--gold);
  background: #fff1c8;
  font-weight: 800;
}
#mini-map {
  width: 100%;
  height: auto;
  border: 1px solid var(--ink);
  background: #e4ebce;
}
.touch-controls {
  position: fixed;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: calc(32px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding:
    0 calc(18px + env(safe-area-inset-right))
    0 calc(18px + env(safe-area-inset-left));
  pointer-events: none;
}
.touch-controls[hidden] {
  display: none;
}
.drive-pad,
.jump-button {
  pointer-events: auto;
  user-select: none;
}
.drive-pad {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(23, 44, 53, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.7);
  touch-action: none;
}
.drive-pad span {
  position: absolute;
  width: 58px;
  height: 58px;
  left: 39px;
  top: 39px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 4px 0 #a96537;
}
.drive-pad small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -20px;
  text-align: center;
  color: #fff;
  font-weight: 800;
}
.jump-button {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--rose);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 5px 0 #8e3f42;
}
@media (max-width: 620px) {
  .hud {
    gap: 6px;
  }
  .music-player {
    width: min(230px, calc(100vw - 28px));
    max-width: 230px;
    grid-template-columns: minmax(0, 1fr) 48px auto;
  }
  .music-volume input {
    width: 48px;
  }
  .petal-meter small {
    display: inline;
  }
  .story,
  .map {
    padding: 20px;
  }
  .interact {
    bottom: calc(174px + env(safe-area-inset-bottom));
  }
  .start-card {
    padding: 28px;
  }
  .key-row {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .warm-button:active {
    transform: none;
  }
}
