:root {
  --turquoise: #5eb8a8;
  --clay: #c9785a;
  --sand: #d4b483;
  --ivory: #f2e6c9;
  --salmon: #d4574a;
  --ink: #2a2420;
  --panel: rgba(42, 36, 32, 0.9);
}

*,
*::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 100%);
  line-height: 1.55;
}

.masthead {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(94, 184, 168, 0.25);
}

.masthead a {
  color: #3d5a80;
  text-decoration: none;
}

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

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

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

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

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

.game-column {
  width: 100%;
  max-width: min(100vw - 2rem, 560px);
  margin-inline: auto;
}

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

  .game-column {
    max-width: none;
  }

  canvas {
    max-height: min(68vh, 680px);
  }

  .game-shell {
    width: 100%;
    max-width: calc(min(68vh, 680px) * 540 / 760);
  }

  .intro {
    margin-bottom: 0.45rem;
  }

  .intro h1 {
    font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  }
}

@media (max-width: 919px) {
  main {
    padding: 0.65rem 0.75rem 1.5rem;
  }

  .intro {
    margin-bottom: 0.5rem;
  }

  .intro p {
    font-size: 0.9rem;
  }

  .game-shell {
    width: min(100%, calc(100vw - 1.25rem));
    max-width: 560px;
  }
}

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

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

.hud strong {
  color: #ffe566;
  font-size: 1.05rem;
}

.game-shell {
  position: relative;
  margin-inline: auto;
  width: min(100%, 560px);
  border-radius: 1rem;
  overflow: hidden;
  border: 2px solid rgba(94, 184, 168, 0.35);
  touch-action: manipulation;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 540 / 760;
  background: #c9d8e8;
}

.burapi-digger {
  position: absolute;
  left: 50%;
  bottom: 0.2rem;
  width: clamp(80px, 22vw, 104px);
  translate: -50% 0;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
  transform-origin: center bottom;
}

.burapi-digger.is-brush {
  animation: brush-scrub 0.35s ease infinite;
}

.burapi-digger.is-salute {
  transform: translateY(-4px) scale(1.04);
}

@keyframes brush-scrub {
  50% {
    rotate: -4deg;
  }
}

html[data-capture="1"] body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

html[data-capture="1"] .game-column {
  width: min(88vw, calc((100dvh - 8.5rem) * 540 / 760));
  margin-inline: auto;
}

html[data-capture="1"] .game-shell {
  width: 100%;
  max-width: none;
}

html[data-capture="1"] .burapi-digger {
  width: clamp(92px, 24vw, 118px);
}

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

html[data-capture="1"] .live {
  font-size: clamp(0.78rem, 2.8vw, 0.86rem);
}

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

.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.9);
  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, #d4a017);
}

.live {
  margin: 0 0 0.4rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--panel);
  color: var(--ivory);
  border-radius: 0.55rem;
  text-align: center;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mission {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid rgba(94, 184, 168, 0.25);
}

.tips {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.88rem;
}

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

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

.hook {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  color: #3d5a80;
  pointer-events: none;
  z-index: 1;
}

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;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
