:root {
  --bg: #0a0e16;
  --panel: #121a28;
  --line: #23304a;
  --ink: #e7edf6;
  --muted: #8593aa;
  --gold: #ffd566;
  --gold-dim: #f4b740;
}

* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.wrap {
  max-width: 572px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
}

h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 2px;
  letter-spacing: .4px
}

.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px
}

.hud {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 10px;
  flex-wrap: wrap
}

.stat {
  font-size: 13px;
  color: var(--muted)
}

.stat b {
  color: var(--ink);
  font-weight: 500;
  font-size: 16px
}

.cost {
  color: var(--gold)
}

.status {
  font-size: 14px;
  color: var(--gold);
  min-height: 20px;
  font-weight: 500;
  margin-left: auto
}

.meter {
  height: 8px;
  background: #16202f;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin: 0 0 12px;
  max-width: 540px
}

.meter>i {
  display: block;
  height: 100%;
  background: var(--gold-dim);
  transition: width .25s
}

canvas {
  display: block;
  width: 100%;
  max-width: 540px;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0e16;
  touch-action: none
}

.tray {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 14px auto 0;
  max-width: 540px
}

.tool {
  flex: 1 1 0;
  min-width: 96px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .12s
}

.tool:hover {
  border-color: #3a4a66
}

.tool.active {
  border-color: var(--gold-dim);
  background: #1a2236
}

.tool small {
  color: var(--muted);
  font-size: 11px
}

.glyph {
  width: 26px;
  height: 26px
}

.row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap
}

.btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 18px;
  cursor: pointer;
  font-size: 14px
}

.btn:hover {
  border-color: #3a4a66
}

.btn.primary {
  border-color: var(--gold-dim);
  background: #1a2236;
  color: var(--gold)
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed
}

.hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 14px;
  line-height: 1.6
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  min-height: 100vh;
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 16%, #0e1626 0%, #06080f 72%)
}

/* serif only on the third intro slide (the spoken quote) */
#dialogue {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif
}

#dialogue h1 {
  font-size: 44px;
  letter-spacing: .5px
}

.screen>*:not(.stars):not(.scene):not(.planets):not(.shootlayer) {
  position: relative;
  z-index: 2
}

.screen .scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden
}

.screen .scene svg {
  width: 100%;
  height: 100%;
  display: block
}

#ending {
  justify-content: space-between;
  padding: 7vh 24px
}

#ending .endtop,
#ending .endbot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px
}

#ending h2,
#ending p {
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6)
}

.screen h1 {
  font-size: 34px
}

.screen h2 {
  font-size: 22px;
  font-weight: 500;
  color: #e7edf6;
  margin: 0 0 4px
}

.screen p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
  max-width: 520px;
  margin: 0
}

.dialogue {
  font-style: italic;
  color: #dde5f2;
  line-height: 2.1;
  font-size: 17px
}

.kicker {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted)
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -16px);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease
}

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

.toast .ttext {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  text-align: left
}

.toast .ttext b {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink)
}

.toast .ttext span {
  font-size: 12px;
  color: var(--muted)
}

.sundisc {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--gold);
  margin: 0 auto
}

.hide {
  display: none !important
}

.stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden
}

.stars span {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: tw 3s infinite ease-in-out
}

.planets {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none
}

.planet {
  position: absolute;
  border-radius: 50%
}

.p-ringed {
  width: 120px;
  height: 120px;
  top: 13%;
  right: 10%;
  background: radial-gradient(circle at 34% 32%, #e6c79a 0%, #b9925a 45%, #6e5230 100%);
  box-shadow: 0 0 26px rgba(230, 199, 154, .16)
}

.p-ringed .ring {
  position: absolute;
  left: -28%;
  top: 42%;
  width: 156%;
  height: 18%;
  border-radius: 50%;
  border: 2px solid rgba(226, 202, 152, .55);
  transform: rotate(-18deg)
}

.p-red {
  width: 58px;
  height: 58px;
  top: 26%;
  left: 12%;
  background: radial-gradient(circle at 36% 32%, #d98a6a 0%, #9c4a33 55%, #5a2417 100%)
}

.p-blue {
  width: 38px;
  height: 38px;
  bottom: 22%;
  right: 26%;
  background: radial-gradient(circle at 36% 32%, #bcd6f0 0%, #6f9fd0 55%, #2f4f78 100%)
}

.shootlayer {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none
}

.shoot {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  opacity: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .95));
  box-shadow: 0 0 6px rgba(255, 255, 255, .7)
}

@keyframes shoot {
  0% {
    opacity: 0;
    transform: translate(-60px, -30px) rotate(20deg)
  }

  8% {
    opacity: 1
  }

  55% {
    opacity: 1
  }

  100% {
    opacity: 0;
    transform: translate(440px, 160px) rotate(20deg)
  }
}

@keyframes tw {

  0%,
  100% {
    opacity: .12
  }

  50% {
    opacity: .9
  }
}

.mute {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center
}

.mute:hover {
  border-color: #3a4a66
}
