:root {
  --cream: #f4e8d4;
  --crimson: #8b2635;
  --teal: #1f6f78;
  --gold: #d4a017;
  --plum: #5c2d4a;
  --sky: #7ec8e3;
  --ink: #2a1215;
  --panel: rgba(42, 18, 21, 0.92);
}

*,
*::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 90% 60% at 50% 0%, rgba(212, 160, 23, 0.12), transparent 55%),
    linear-gradient(180deg, #4a1820 0%, var(--ink) 42%, #120608 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(212, 160, 23, 0.22);
}

.masthead a {
  color: #fbbf24;
  text-decoration: none;
  font-size: 0.92rem;
}

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

#sound {
  border: 1px solid rgba(212, 160, 23, 0.45);
  background: rgba(60, 24, 32, 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(--gold);
  margin: 0 0 0.35rem;
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.85rem, 6vw, 2.55rem);
  font-weight: 800;
}

.intro h1 span {
  color: #fca5a5;
}

.intro > p:last-child {
  margin: 0.5rem 0 0;
  opacity: 0.9;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 1.25rem;
  align-items: start;
}

.game-column {
  display: grid;
  gap: 0.75rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.hud div {
  background: var(--panel);
  border: 1px solid rgba(212, 160, 23, 0.25);
  border-radius: 0.65rem;
  padding: 0.45rem 0.55rem;
}

.hud span {
  display: block;
  opacity: 0.72;
  font-size: 0.65rem;
}

.hud strong {
  display: block;
  font-size: 1.05rem;
  margin-top: 0.15rem;
}

.game-shell {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  border: 2px solid rgba(212, 160, 23, 0.35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  background: #1a0a0e;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: pointer;
}

.hook {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 248, 235, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 2;
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.55rem;
  padding: 1.5rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(42, 18, 21, 0.55), rgba(18, 6, 8, 0.88));
  z-index: 5;
}

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

.start-burapi {
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
}

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

.start-panel h2 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 1.85rem);
  line-height: 1.25;
}

#panel-copy {
  margin: 0;
  max-width: 22rem;
  font-size: 0.92rem;
  opacity: 0.92;
}

#start,
.share {
  margin-top: 0.35rem;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.6rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #fbbf24, #b45309);
  color: #2a1215;
}

.share {
  background: linear-gradient(180deg, #e5e7eb, #9ca3af);
}

.live {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  background: rgba(42, 18, 21, 0.75);
  border-top: 1px solid rgba(212, 160, 23, 0.2);
}

.mission {
  background: var(--panel);
  border: 1px solid rgba(212, 160, 23, 0.22);
  border-radius: 1rem;
  padding: 1.1rem 1.15rem;
}

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

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

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

.mission li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.55rem;
}

.mission li span {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(212, 160, 23, 0.18);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.78rem;
}

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

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

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

.records {
  margin: 1rem 0 0;
  display: grid;
  gap: 0.45rem;
}

.records div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.86rem;
  border-bottom: 1px dashed rgba(244, 232, 212, 0.15);
  padding-bottom: 0.25rem;
}

.records dt {
  opacity: 0.75;
}

.reset {
  margin-top: 0.85rem;
  width: 100%;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: transparent;
  color: #fecaca;
  border-radius: 0.65rem;
  padding: 0.45rem;
  cursor: pointer;
  font: inherit;
}

.save-note {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  opacity: 0.72;
}

footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

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

html[data-capture="1"] body {
  background: #1a0a0e;
}

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

html[data-capture="1"] .game-layout {
  grid-template-columns: 1fr;
  gap: 0;
}

html[data-capture="1"] .hud {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top));
  left: 0.75rem;
  right: 18%;
  z-index: 4;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  pointer-events: none;
}

html[data-capture="1"] .game-shell {
  border: none;
  border-radius: 0;
  min-height: 100dvh;
}

html[data-capture="1"] #game {
  min-height: 100dvh;
  object-fit: cover;
}

html[data-capture="1"] .live {
  position: absolute;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 0.75rem;
  right: 18%;
  z-index: 4;
  background: rgba(42, 18, 21, 0.55);
  border-radius: 0.65rem;
}

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

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .hud {
    grid-template-columns: repeat(2, 1fr);
  }
}

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