:root {
  color-scheme: dark;
  --ink: #080713;
  --moon: #f2edcf;
  --violet: #7e74ca;
  --glow: #b9d9ff;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(105, 101, 177, 0.26), transparent 34%),
    linear-gradient(#0d0b1f, #05050c);
  color: var(--moon);
  font-family: "Nunito", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.28;
  background-image:
    radial-gradient(circle at 12% 25%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 16%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 88% 64%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 35% 75%, #fff 0 1px, transparent 1.5px);
  background-size: 170px 170px, 230px 230px, 190px 190px, 260px 260px;
}

.game-shell {
  position: relative;
  width: min(100vw, 1120px);
  padding: 54px 18px 20px;
}

.home-btn {
  position: absolute;
  top: 12px;
  left: 18px;
  z-index: 20;
  padding: 9px 13px;
  border: 1px solid rgba(242, 237, 207, 0.38);
  border-radius: 999px;
  background: rgba(8, 7, 19, 0.72);
  color: var(--moon);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.home-btn:hover {
  border-color: var(--glow);
  box-shadow: 0 0 18px rgba(185, 217, 255, 0.22);
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid rgba(226, 225, 255, 0.55);
  background: var(--ink);
  box-shadow:
    0 0 0 7px rgba(8, 7, 19, 0.8),
    0 18px 70px rgba(0, 0, 0, 0.68),
    0 0 60px rgba(111, 104, 190, 0.18);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #080713;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(102, 96, 176, 0.25), transparent 38%),
    rgba(5, 5, 13, 0.76);
  backdrop-filter: blur(2px);
}

.screen.hidden,
.message.hidden {
  display: none;
}

.moon-mark {
  width: clamp(50px, 8vw, 86px);
  aspect-ratio: 1;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--moon);
  box-shadow: 0 0 36px rgba(226, 235, 255, 0.46);
}

.moon-mark::after {
  display: block;
  width: 88%;
  height: 88%;
  margin: -5% 0 0 31%;
  border-radius: 50%;
  background: #15132b;
  content: "";
}

.eyebrow {
  margin: 4px 0;
  color: #aaa6d7;
  font-size: clamp(0.5rem, 1.4vw, 0.7rem);
  font-weight: 800;
  letter-spacing: 0.42em;
}

h1,
h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  letter-spacing: 0.14em;
  text-shadow: 0 0 25px rgba(185, 217, 255, 0.34);
}

h1 {
  font-size: clamp(2.1rem, 7vw, 5.5rem);
}

h2 {
  font-size: clamp(1.6rem, 5vw, 3.7rem);
}

.story,
#end-copy {
  margin: 8px 0 14px;
  color: #c6c3d9;
  font-size: clamp(0.7rem, 1.7vw, 1rem);
  line-height: 1.5;
}

.screen button {
  padding: 11px 20px;
  border: 1px solid #e7e3c4;
  background: rgba(8, 7, 19, 0.84);
  color: var(--moon);
  font: 800 clamp(0.62rem, 1.5vw, 0.78rem) "Nunito", sans-serif;
  letter-spacing: 0.16em;
  cursor: pointer;
}

.screen button:hover {
  background: var(--moon);
  color: var(--ink);
  box-shadow: 0 0 24px rgba(242, 237, 207, 0.28);
}

.controls-hint {
  margin: 12px 0 0;
  color: #77738e;
  font-size: clamp(0.48rem, 1.4vw, 0.65rem);
}

#end-screen a {
  margin-top: 11px;
  color: #aaa6d7;
  font-size: 0.72rem;
}

.message {
  position: absolute;
  left: 50%;
  bottom: 18%;
  z-index: 8;
  transform: translateX(-50%);
  width: min(88%, 510px);
  padding: 11px 16px;
  border: 1px solid rgba(226, 225, 255, 0.42);
  background: rgba(7, 7, 16, 0.88);
  color: #e9e6d4;
  font: 800 clamp(0.6rem, 1.6vw, 0.78rem) "Nunito", sans-serif;
  letter-spacing: 0.05em;
  text-align: center;
  pointer-events: none;
}

.game-note {
  margin: 14px 0 0;
  color: #9995af;
  font-size: 0.78rem;
  text-align: center;
}

.touch-controls {
  position: absolute;
  inset: auto 0 8px;
  z-index: 7;
  display: none;
  justify-content: space-between;
  padding: 0 10px;
  pointer-events: none;
}

.touch-left,
.touch-right {
  display: flex;
  gap: 8px;
}

.touch-controls button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  background: rgba(8, 7, 19, 0.56);
  color: #fff;
  font-size: 1rem;
  pointer-events: auto;
  touch-action: none;
}

.touch-controls button.active {
  background: rgba(185, 217, 255, 0.48);
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls {
    display: flex;
  }

  .game-note {
    display: none;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding-inline: 0;
  }

  .game-frame {
    border-inline: 0;
  }

  .home-btn {
    left: 10px;
  }
}
