:root {
  --cream: #f2e6c9;
  --jade: #1a8a7a;
  --coral: #d4574a;
  --indigo: #3d5a80;
  --mustard: #d4a017;
  --ink: #2a2420;
  --panel: rgba(42, 36, 32, 0.92);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #e8dcc8 0%, #d4c4a8 40%, #c8b898 100%);
  line-height: 1.55;
}

.masthead {
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(61, 90, 128, 0.2);
}

.masthead a {
  color: var(--indigo);
  text-decoration: none;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.intro {
  text-align: center;
  margin-bottom: 1rem;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--jade);
}

.intro h1 span {
  color: var(--coral);
}

.game-layout {
  display: grid;
  gap: 1.2rem;
}

@media (min-width: 920px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
    gap: 0.85rem;
  }

  main {
    padding: 0.55rem 1rem 1rem;
  }

  .intro {
    margin-bottom: 0.4rem;
  }

  .intro h1 {
    margin: 0.1em 0;
    font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  }

  .intro p {
    margin: 0;
    font-size: 0.88rem;
  }

  .masthead {
    padding: 0.5rem 1rem;
  }

  canvas {
    max-height: min(50vh, 500px);
  }

  .game-shell {
    max-width: calc(min(50vh, 500px) * 540 / 760);
  }

  .mission {
    max-height: calc(100vh - 4.5rem);
    overflow-y: auto;
  }
}

@media (min-width: 920px) and (max-height: 820px) {
  canvas {
    max-height: min(44vh, 420px);
  }

  .game-shell {
    max-width: calc(min(44vh, 420px) * 540 / 760);
  }

  .intro {
    display: none;
  }

  main {
    padding-top: 0.35rem;
  }
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
}

.hud div {
  background: var(--panel);
  color: var(--cream);
  border-radius: 0.5rem;
  padding: 0.35rem 0.5rem;
  text-align: center;
}

.hud strong {
  color: var(--mustard);
  font-size: 1.1rem;
}

.game-column {
  min-width: 0;
}

.game-shell {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  border: 2px solid rgba(61, 90, 128, 0.35);
  touch-action: manipulation;
  width: min(100%, 420px);
  max-width: calc(min(56vh, 580px) * 540 / 760);
  margin-inline: auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 540 / 760;
  max-height: min(56vh, 580px);
  background: #c9d8e8;
}

.burapi-conductor {
  position: absolute;
  right: 0.4rem;
  bottom: 3.35rem;
  width: clamp(68px, 19vw, 92px);
  height: auto;
  pointer-events: none;
  z-index: 2;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  transform-origin: center bottom;
  transition: opacity 0.15s ease;
}

.burapi-conductor.is-wave {
  animation: burapi-wave 0.45s ease;
}

@keyframes burapi-wave {
  50% {
    transform: rotate(-6deg) translateY(-2px);
  }
}

.burapi-conductor[hidden] {
  display: none !important;
}

.switch-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(42, 36, 32, 0.85);
}

.switch-btn {
  border: 2px solid rgba(212, 160, 23, 0.45);
  background: rgba(30, 26, 22, 0.9);
  color: var(--cream);
  border-radius: 0.65rem;
  padding: 0.5rem;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.switch-btn.pulse {
  animation: pulse-a 0.9s ease infinite;
}

.switch-btn:focus-visible {
  outline: 2px solid var(--mustard);
  outline-offset: 2px;
}

.switch-label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
}

.switch-state {
  font-size: 0.72rem;
  opacity: 0.85;
}

@keyframes pulse-a {
  50% {
    box-shadow: 0 0 0 3px rgba(255, 229, 102, 0.45);
  }
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
  background: rgba(232, 220, 200, 0.88);
  z-index: 3;
}

.start-panel[hidden] {
  display: none !important;
}

#start,
.share {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.3rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe566, var(--mustard));
}

.live {
  margin: 0 0 0.45rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  background: rgba(42, 36, 32, 0.88);
  color: var(--cream);
  border-radius: 0.55rem;
  max-width: 100%;
  text-align: center;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.live.is-tutorial {
  font-size: 0.86rem;
  box-shadow: inset 0 0 0 2px rgba(255, 229, 102, 0.45);
}

.mission {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid rgba(26, 138, 122, 0.25);
}

.routes {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.routes li {
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
}

.dest {
  display: inline-block;
  width: 1.6rem;
  text-align: center;
  border-radius: 0.25rem;
  font-weight: 700;
  margin-right: 0.35rem;
}

.dest.moon {
  background: #b8c4e8;
}
.dest.star {
  background: #ffe566;
}
.dest.sun {
  background: #ffb347;
}

.records {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  font-size: 0.82rem;
}

.reset {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  border: 1px dashed var(--jade);
  background: transparent;
  border-radius: 0.4rem;
  cursor: pointer;
  font: inherit;
}

.hook {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  color: var(--indigo);
  font-weight: 700;
  pointer-events: none;
}

html[data-capture="1"] .capture-hide {
  display: none !important;
}

html[data-capture="1"] .capture-only {
  display: block;
}

html:not([data-capture="1"]) .capture-only {
  display: none;
}

html[data-capture="1"] body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #e8dcc8 0%, #d4c4a8 100%);
}

html[data-capture="1"] main {
  padding: 0.35rem 0 max(0.35rem, env(safe-area-inset-bottom));
  max-width: none;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

html[data-capture="1"] .game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0.35rem;
}

html[data-capture="1"] .game-column {
  width: min(84vw, calc((100dvh - 9.5rem) * 540 / 760));
  max-width: 920px;
}

html[data-capture="1"] .game-shell {
  border: 2px solid rgba(61, 90, 128, 0.28);
  border-radius: 0.85rem;
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: 540 / 760;
  margin: 0 auto;
}

html[data-capture="1"] canvas {
  max-height: none;
  height: auto;
  width: 100%;
}

html[data-capture="1"] .switch-bar {
  position: relative;
  border-radius: 0 0 0.75rem 0.75rem;
}

html[data-capture="1"] .burapi-conductor {
  bottom: 3.55rem;
  right: 0.45rem;
  width: clamp(92px, 24vw, 118px);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.22));
}

html[data-capture="1"] .burapi-conductor::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -4px;
  height: 8px;
  background: rgba(42, 36, 32, 0.2);
  border-radius: 50%;
  z-index: -1;
}

html[data-capture="1"] .hud {
  margin-bottom: 0.35rem;
}

html[data-capture="1"] .live {
  margin-bottom: 0.3rem;
  font-size: clamp(0.78rem, 2.8vw, 0.86rem);
  min-height: 2.2em;
}

@media (prefers-reduced-motion: reduce) {
  .switch-btn.pulse {
    animation: none;
    box-shadow: 0 0 0 2px var(--mustard);
  }
  .burapi-conductor.is-wave {
    animation: none;
  }
}
