:root {
  --ink: #0f1419;
  --amber: #e8a317;
  --vermilion: #c43c2a;
  --teal: #1a8a7a;
  --cream: #f2e6c9;
  --glow: #ffe566;
  --panel: rgba(15, 20, 25, 0.94);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(232, 163, 23, 0.14), transparent 55%),
    linear-gradient(180deg, #1a1210 0%, var(--ink) 45%, #06080c 100%);
  line-height: 1.55;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(232, 163, 23, 0.22);
}

.masthead a {
  color: var(--glow);
  text-decoration: none;
  font-size: 0.92rem;
}

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

#sound {
  border: 1px solid rgba(232, 163, 23, 0.45);
  background: rgba(30, 22, 18, 0.85);
  color: var(--cream);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

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

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

.eyebrow {
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--amber);
  margin: 0 0 0.35rem;
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  line-height: 1.25;
}

.intro h1 span {
  display: block;
  color: var(--glow);
}

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

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

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

.hud div {
  background: var(--panel);
  border: 1px solid rgba(232, 163, 23, 0.25);
  border-radius: 0.65rem;
  padding: 0.4rem 0.55rem;
  text-align: center;
}

.hud span {
  display: block;
  opacity: 0.75;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
}

.hud strong {
  font-size: 1.15rem;
  color: var(--glow);
}

.game-shell {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  border: 2px solid rgba(196, 60, 42, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0c10;
  vertical-align: top;
}

.hook {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  color: var(--glow);
  text-shadow: 0 0 12px rgba(255, 229, 102, 0.6);
  pointer-events: none;
  z-index: 2;
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.55rem;
  padding: 1.2rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(15, 20, 25, 0.55), rgba(15, 20, 25, 0.92));
  z-index: 3;
}

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

.start-burapi {
  margin: 0 auto;
  background: transparent;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

.start-kicker {
  margin: 0;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  color: var(--teal);
}

.start-panel h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.35;
}

.start-panel p {
  margin: 0;
  max-width: 28ch;
  margin-inline: auto;
  font-size: 0.88rem;
  opacity: 0.92;
}

#start,
.share {
  margin-top: 0.35rem;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, var(--glow), var(--amber));
  box-shadow: 0 4px 0 #8a5a08;
}

.share {
  background: linear-gradient(180deg, #fff, #ddd);
  box-shadow: 0 4px 0 #666;
  color: #111;
}

.live {
  position: absolute;
  left: 50%;
  bottom: 0.65rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  background: rgba(15, 20, 25, 0.82);
  border-radius: 999px;
  border: 1px solid rgba(232, 163, 23, 0.3);
  max-width: 92%;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.mission {
  background: var(--panel);
  border: 1px solid rgba(26, 138, 122, 0.35);
  border-radius: 1rem;
  padding: 1rem 1.1rem 1.2rem;
}

.mission-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--teal);
}

.mission h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.mission ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.mission li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.5rem;
  align-items: start;
}

.mission li span {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(196, 60, 42, 0.35);
  font-size: 0.75rem;
  color: var(--glow);
}

.mission strong {
  display: block;
  margin-bottom: 0.15rem;
}

.mission p {
  margin: 0;
  font-size: 0.86rem;
  opacity: 0.9;
}

.keyboard {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  opacity: 0.85;
}

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

.records dt {
  opacity: 0.75;
  font-size: 0.72rem;
}

.records dd {
  margin: 0.15rem 0 0;
  font-weight: 700;
  color: var(--glow);
}

.reset {
  width: 100%;
  border: 1px dashed rgba(232, 163, 23, 0.45);
  background: transparent;
  color: var(--cream);
  border-radius: 0.5rem;
  padding: 0.45rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}

.save-note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  opacity: 0.8;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.82rem;
  opacity: 0.75;
}

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 {
  background: #06080c;
}

html[data-capture="1"] main {
  padding: 0;
  width: 100%;
  max-width: none;
}

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

html[data-capture="1"] .game-shell {
  border: none;
  border-radius: 0;
  max-width: 100vw;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  max-height: 100vh;
  height: 100vh;
  width: auto;
}

html[data-capture="1"] canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

html[data-capture="1"] .hud {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  margin: 0;
}

html[data-capture="1"] .live {
  bottom: max(0.65rem, env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (max-width: 919px) {
  .hud strong {
    font-size: 1rem;
  }
}
