:root {
  --bg: #fff6ea;
  --ink: #3b2416;
  --muted: #8a684c;
  --wood-light: #e8b56a;
  --wood: #d4923f;
  --wood-dark: #b5742c;
  --char-light: #4a433c;
  --char: #241f1c;
  --head: #d33b2c;
  --head-dark: #9e1f16;
  --btn: #ff5a1f;
  --btn-ink: #fffdf8;
  --best: #7a5233;
  --human: #c39216;
  --radius-btn: 22px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans",
    "Yu Gothic", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

.app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 18px
    calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  position: relative;
}

.top {
  position: relative;
  min-height: 3.4rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.best {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--best);
  letter-spacing: 0.04em;
}

.best.is-new {
  animation: bestPulse 0.7s ease;
}

.title {
  margin-top: 1.15rem;
  font-size: clamp(1.35rem, 5.6vw, 1.7rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.3;
}

.copy {
  min-height: 8.8rem;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.28rem;
}

.lead {
  font-size: clamp(0.95rem, 3.8vw, 1.12rem);
  font-weight: 700;
  color: var(--muted);
  line-height: 1.5;
}

.lead.is-wait {
  color: var(--ink);
  font-size: clamp(1.05rem, 4.4vw, 1.28rem);
}

.lead.is-ouch {
  display: none;
}

.distance {
  font-size: clamp(3.2rem, 16vw, 4.6rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.distance.is-in {
  animation: popIn 0.38s cubic-bezier(0.18, 1.4, 0.32, 1);
}

.distance.is-human {
  color: var(--human);
  text-shadow: 0 0 18px rgba(232, 186, 64, 0.45);
}

.judge {
  margin-top: 0.35rem;
  font-size: clamp(1.2rem, 5.2vw, 1.55rem);
  font-weight: 900;
  line-height: 1.35;
}

.judge.is-close {
  color: #d44512;
}

.judge.is-insane {
  color: #b42318;
}

.judge.is-human {
  margin-top: 0.5rem;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  color: var(--human);
  animation: humanIn 0.55s cubic-bezier(0.18, 1.45, 0.28, 1);
}

.sub {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 160px;
  overflow: hidden;
  isolation: isolate;
}

.stage::before {
  content: "";
  position: absolute;
  width: 120%;
  height: 70%;
  left: -10%;
  top: 18%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 214, 150, 0.55),
    rgba(255, 246, 234, 0) 68%
  );
  pointer-events: none;
}

.match-row {
  width: 100%;
  display: flex;
  align-items: center;
  transform-origin: 70% 60%;
  will-change: transform, opacity;
}

.match-row.is-dropping {
  animation: dropMatch 0.72s cubic-bezier(0.55, 0.06, 0.78, 0.19) forwards;
}

.match-body {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 86px;
}

.match-head {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 34%, #f26a55 0%, var(--head) 46%, var(--head-dark) 100%);
  box-shadow: 0 1px 0 rgba(90, 20, 12, 0.28);
  z-index: 2;
}

.match-head.is-lit,
.match-head.is-out {
  background: radial-gradient(circle at 35% 35%, #5a5048, #2a2420 70%);
}

.shaft {
  position: relative;
  flex: 1;
  height: 16px;
  margin-left: -6px;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 48%, var(--wood-dark) 100%);
  box-shadow: 0 2px 0 rgba(120, 70, 20, 0.18);
  overflow: hidden;
  z-index: 1;
}

.shaft-char {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(180deg, var(--char-light) 0%, var(--char) 52%, #1a1614 100%);
  transform-origin: left center;
  pointer-events: none;
}

.shaft-char.is-burning::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  bottom: -1px;
  width: 10px;
  background: linear-gradient(90deg, transparent, rgba(255, 140, 30, 0.85));
}

.flame-anchor {
  position: absolute;
  top: 43px;
  left: 11px;
  width: 0;
  height: 0;
  z-index: 4;
}

.flame {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 52px;
  transform: translate(-50%, -100%);
  animation: sway 0.16s ease-in-out infinite alternate;
}

.flame-glow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 46px;
  height: 46px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 170, 40, 0.55), rgba(255, 170, 40, 0) 70%);
}

.flame-outer,
.flame-mid,
.flame-core {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
}

.flame-outer {
  width: 26px;
  height: 44px;
  background: linear-gradient(to top, #ff4d00 10%, #ff9a1a 58%, #ffd54a 100%);
}

.flame-mid {
  width: 16px;
  height: 32px;
  bottom: 3px;
  background: linear-gradient(to top, #ff8a00, #ffe36b 70%, #fff6c8);
}

.flame-core {
  width: 8px;
  height: 16px;
  bottom: 4px;
  background: #fff8dc;
  filter: blur(0.2px);
}

.hand {
  flex: 0 0 108px;
  width: 108px;
  margin-left: -28px;
  z-index: 3;
}

.hand-svg {
  display: block;
  width: 124px;
  height: auto;
  overflow: visible;
}

.ouch[hidden] {
  display: none !important;
}

.ouch {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.1rem, 9vw, 2.9rem);
  font-weight: 900;
  color: #d61f0f;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 8;
  animation: ouchIn 0.18s ease-out;
}

.actions {
  position: relative;
  z-index: 9;
  padding-top: 8px;
  background: var(--bg);
}

.btn {
  width: 100%;
  min-height: 74px;
  border: 0;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--btn-ink);
  background: var(--btn);
  box-shadow: 0 6px 0 #d34112, 0 10px 18px rgba(211, 65, 18, 0.18);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #d34112, 0 6px 10px rgba(211, 65, 18, 0.16);
}

.btn-extinguish {
  background: #ff2d2d;
  box-shadow: 0 6px 0 #c11616, 0 10px 18px rgba(193, 22, 22, 0.2);
}

.btn-extinguish:active {
  box-shadow: 0 3px 0 #c11616, 0 6px 10px rgba(193, 22, 22, 0.16);
}

.btn-retry {
  background: #5c3b28;
  box-shadow: 0 6px 0 #3b2418, 0 10px 18px rgba(59, 36, 24, 0.16);
  font-size: 1.35rem;
}

.btn-retry:active {
  box-shadow: 0 3px 0 #3b2418, 0 6px 10px rgba(59, 36, 24, 0.14);
}

.btn[hidden] {
  display: none;
}

.app.is-human-rare {
  background: radial-gradient(circle at 50% 28%, #fff3c4 0%, var(--bg) 58%);
}

@keyframes sway {
  from {
    transform: translate(-50%, -100%) rotate(-9deg) scale(0.96, 1.04);
  }
  to {
    transform: translate(-50%, -100%) rotate(8deg) scale(1.05, 0.94);
  }
}

@keyframes popIn {
  from {
    transform: scale(0.62);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes humanIn {
  0% {
    transform: scale(0.4) rotate(-8deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.12) rotate(3deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes dropMatch {
  0% {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }
  100% {
    transform: translateY(240px) rotate(34deg);
    opacity: 0;
  }
}

@keyframes ouchIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bestPulse {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
    color: #d44512;
  }
}

@media (min-width: 760px) {
  body {
    background: #f3e6d4;
  }

  .app {
    background: var(--bg);
    box-shadow: 0 0 0 1px rgba(90, 50, 20, 0.06), 0 18px 40px rgba(90, 50, 20, 0.08);
  }
}

@media (max-height: 640px) {
  .copy {
    min-height: 6.6rem;
  }

  .title {
    margin-top: 0.85rem;
  }

  .btn {
    min-height: 64px;
    font-size: 1.35rem;
  }
}
