:root {
  color-scheme: light;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  --ink: #19120f;
  --paper: #fffaf0;
  --gold: #f7c400;
  --red: #ef3030;
  --green: #00a96b;
  --blue: #2667ff;
  --wood: #6a341d;
  --shadow: 0 22px 58px rgba(31, 14, 8, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #160c08;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.5), transparent 18rem),
    radial-gradient(circle at 88% 12%, rgba(247, 196, 0, 0.58), transparent 18rem),
    linear-gradient(135deg, #ff4d35 0%, #f7c400 42%, #21120d 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app {
  min-height: 100svh;
  padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, transparent, black 16%, black 84%, transparent);
  z-index: -2;
}

.reversal-cutin {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.92), rgba(239, 48, 48, 0.76) 34%, rgba(25, 18, 15, 0.96) 72%),
    repeating-linear-gradient(-18deg, rgba(255, 255, 255, 0.18) 0 14px, transparent 14px 28px);
  color: white;
  text-align: center;
  opacity: 0;
  transform: scale(1.18);
  pointer-events: none;
  visibility: hidden;
}

.reversal-cutin span,
.reversal-cutin strong,
.reversal-cutin em {
  display: block;
  width: fit-content;
  max-width: 100%;
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.32);
}

.reversal-cutin span {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: clamp(1rem, 5vw, 1.5rem);
  font-weight: 1000;
  transform: rotate(-5deg);
}

.reversal-cutin strong {
  padding: 8px 18px;
  border-radius: 16px;
  background: var(--red);
  font-size: clamp(2.5rem, 16vw, 5.2rem);
  font-weight: 1000;
  line-height: 0.92;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(2deg);
}

.reversal-cutin em {
  padding: 6px 12px;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: clamp(0.8rem, 3.8vw, 1rem);
  font-style: normal;
  font-weight: 1000;
  transform: rotate(-2deg);
}

.reversal-cutin.show {
  visibility: visible;
  animation: reversal-cutin 980ms cubic-bezier(0.17, 0.84, 0.44, 1) forwards;
}

.court {
  width: min(100%, 520px);
  min-height: calc(100svh - 24px);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 10px;
  padding: clamp(14px, 4vw, 22px);
  border: 4px solid var(--ink);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 244, 208, 0.95)),
    repeating-linear-gradient(90deg, rgba(106, 52, 29, 0.14) 0 18px, transparent 18px 36px);
  box-shadow: var(--shadow), inset 0 0 0 6px rgba(255, 255, 255, 0.4);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.court::before {
  content: "";
  position: absolute;
  inset: auto -20% -76px;
  height: 210px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(44, 20, 10, 0.36)),
    repeating-linear-gradient(90deg, #6a341d 0 26px, #7d4026 26px 52px);
  z-index: -1;
}

.court::after {
  content: "JUSTICE  JANKEN  JUSTICE  JANKEN";
  position: absolute;
  left: 50%;
  top: 47%;
  z-index: -1;
  width: 140%;
  transform: translate(-50%, -50%) rotate(-12deg);
  color: rgba(25, 18, 15, 0.06);
  font-size: clamp(2.7rem, 16vw, 6rem);
  font-weight: 1000;
  line-height: 0.9;
  text-align: center;
}

.court__header {
  text-align: center;
}

.eyebrow {
  width: fit-content;
  margin: 0 auto 6px;
  padding: 5px 11px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 8.2vw, 2.65rem);
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow:
    2px 2px 0 #fff,
    5px 5px 0 rgba(239, 48, 48, 0.3),
    -3px 4px 0 rgba(38, 103, 255, 0.18);
}

.lead {
  margin: 8px auto 0;
  max-width: 29rem;
  font-size: clamp(0.86rem, 3.5vw, 1rem);
  font-weight: 800;
  line-height: 1.42;
}

.showdown {
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: center;
  position: relative;
}

.phase-banner {
  width: fit-content;
  min-width: 9em;
  margin: 0 auto;
  padding: 7px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  text-align: center;
  font-size: clamp(0.9rem, 4vw, 1.08rem);
  font-weight: 1000;
  letter-spacing: 0.06em;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.versus-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 0.85fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.side-card {
  min-width: 0;
  min-height: 170px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 239, 178, 0.92)),
    repeating-linear-gradient(-8deg, rgba(25, 18, 15, 0.05) 0 8px, transparent 8px 16px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2);
}

.side-card--onikin {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 218, 126, 0.94)),
    repeating-linear-gradient(8deg, rgba(25, 18, 15, 0.05) 0 8px, transparent 8px 16px);
}

.side-label {
  padding: 4px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
  font-size: 0.76rem;
  font-weight: 1000;
}

.big-hand {
  width: 100%;
  min-height: 76px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(1.7rem, 10vw, 3rem);
}

.big-hand.is-hidden {
  color: rgba(25, 18, 15, 0.44);
}

.center-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.character-frame {
  width: min(31vw, 170px);
  aspect-ratio: 1 / 1.1;
  display: grid;
  place-items: end center;
  border: 5px solid var(--ink);
  border-radius: 30px 30px 16px 16px;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.96), rgba(255, 235, 143, 0.68) 46%, transparent 47%),
    linear-gradient(180deg, #ffe56c, #eb7f2e 70%, #5f2c19 70%);
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.55),
    9px 9px 0 rgba(0, 0, 0, 0.26),
    0 0 34px rgba(247, 196, 0, 0.8);
  overflow: hidden;
  position: relative;
}

.character-frame::after {
  content: "ONIKIN";
  position: absolute;
  left: 10px;
  top: 10px;
  transform: rotate(-7deg);
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 0.68rem;
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.spotlight {
  position: absolute;
  inset: -30% 18% 18%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.7), transparent 58%);
  transform: rotate(8deg);
}

.onikin {
  width: 90%;
  height: 95%;
  object-fit: contain;
  object-position: bottom center;
  filter:
    saturate(1.34)
    contrast(1.18)
    drop-shadow(0 0 0 #fff)
    drop-shadow(0 0 12px rgba(255, 255, 255, 0.8))
    drop-shadow(7px 7px 0 rgba(0, 0, 0, 0.32));
  mix-blend-mode: multiply;
  transform-origin: 50% 82%;
  position: relative;
  z-index: 1;
}

.image-fallback {
  display: none;
  width: 78%;
  aspect-ratio: 1;
  margin-bottom: 20px;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(90deg, #111 0 50%, #f7c400 50%);
  color: #fff;
  font-weight: 1000;
}

.character-frame.image-missing .onikin {
  display: none;
}

.character-frame.image-missing .image-fallback {
  display: grid;
}

.opponent-label {
  margin: 0;
  padding: 5px 11px;
  border: 2px solid rgba(25, 18, 15, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 1000;
  font-size: 0.82rem;
}

.countdown {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: clamp(1.2rem, 6vw, 1.9rem);
  font-weight: 1000;
  box-shadow:
    0 7px 0 rgba(0, 0, 0, 0.2),
    0 0 24px rgba(239, 48, 48, 0.65);
}

.verdict-board {
  min-height: 124px;
  padding: 12px;
  border: 5px solid var(--ink);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 240, 0.94)),
    repeating-linear-gradient(-8deg, rgba(25, 18, 15, 0.04) 0 8px, transparent 8px 16px);
  text-align: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.22);
  position: relative;
}

.verdict-board::before {
  content: "速報";
  position: absolute;
  left: 10px;
  top: -13px;
  padding: 3px 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 1000;
  transform: rotate(-5deg);
}

.verdict-kicker {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
}

.verdict {
  width: fit-content;
  min-width: 5.5em;
  margin: 7px auto;
  padding: 7px 16px;
  border: 4px solid var(--ink);
  border-radius: 12px;
  background: #e9e0cf;
  color: var(--ink);
  font-size: clamp(1.9rem, 10vw, 3.2rem);
  font-weight: 1000;
  line-height: 1;
  transform: rotate(-2deg);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.18);
}

.message {
  margin: 0 auto;
  max-width: 25rem;
  font-weight: 900;
  font-size: clamp(0.92rem, 3.7vw, 1.05rem);
  line-height: 1.44;
}

.result-hand {
  display: grid;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 3px;
  max-width: 100%;
}

.result-hand img {
  width: min(76px, 20vw);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.18));
}

.result-hand span {
  font-size: clamp(2rem, 11vw, 3.4rem);
}

.result-hand b {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(0.9rem, 4vw, 1.12rem);
}

.versus {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-weight: 1000;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.choice,
.reset {
  min-height: 52px;
  border: 3px solid var(--ink);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  font-weight: 1000;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.choice:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: translateY(2px);
}

.choice {
  padding: 8px 4px;
  display: grid;
  gap: 2px;
  place-items: center;
  font-size: clamp(0.86rem, 3.5vw, 1rem);
  background: linear-gradient(180deg, #fff, #ffedaf);
}

.choice b {
  font-size: clamp(0.82rem, 3.4vw, 1rem);
}

.choice__image {
  width: min(54px, 15vw);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.18));
}

.choice:active,
.reset:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.26);
}

.status {
  display: grid;
  gap: 8px;
}

.score {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 1000;
}

.score span {
  min-width: 0;
  padding: 7px 5px;
  border: 2px solid rgba(25, 18, 15, 0.66);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.reset {
  min-height: 44px;
  background: #211817;
  color: #fff7df;
}

.app[data-outcome="win"] .verdict {
  background: var(--green);
  color: white;
}

.app[data-outcome="lose"] .verdict {
  background: var(--red);
  color: white;
}

.app[data-outcome="draw"] .verdict {
  background: var(--gold);
}

.app[data-outcome="win"] {
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.58), transparent 12rem),
    linear-gradient(135deg, #00c481, #f7c400 50%, #21120d);
}

.app[data-outcome="lose"] {
  background:
    radial-gradient(circle at 78% 12%, rgba(255, 255, 255, 0.46), transparent 12rem),
    linear-gradient(135deg, #ff725a, #ef3030 50%, #21120d);
}

.app[data-outcome="draw"] {
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.56), transparent 12rem),
    linear-gradient(135deg, #fff2a7, #f7c400 50%, #21120d);
}

.app.reversal-hit .court {
  animation: court-shock 700ms ease-out;
}

.app.reversal-hit .side-card--onikin {
  animation: reversal-glow 900ms ease-out;
}

.app.reversal-hit .countdown {
  background: var(--ink);
  color: var(--gold);
  animation: alarm-pop 760ms ease-out;
}

.shake .onikin {
  animation: gavel-shake 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pop .verdict {
  animation: verdict-pop 560ms cubic-bezier(0.17, 0.84, 0.44, 1);
}

.flashbang {
  animation: screen-flash 460ms ease-out;
}

.confetti::before,
.confetti::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #fff 0 2px, transparent 3px),
    radial-gradient(circle, #19120f 0 2px, transparent 3px),
    radial-gradient(circle, #f7c400 0 3px, transparent 4px),
    linear-gradient(45deg, transparent 42%, #ef3030 43% 56%, transparent 57%);
  background-size: 42px 42px, 54px 54px, 68px 68px, 74px 74px;
  animation: confetti 900ms ease-out forwards;
  z-index: 3;
}

@keyframes gavel-shake {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  20% {
    transform: rotate(-5deg) scale(1.04);
  }
  45% {
    transform: rotate(6deg) scale(1.06);
  }
  70% {
    transform: rotate(-3deg) scale(1.03);
  }
}

@keyframes verdict-pop {
  0% {
    opacity: 0;
    transform: rotate(-9deg) scale(0.68);
  }
  72% {
    opacity: 1;
    transform: rotate(3deg) scale(1.11);
  }
  100% {
    transform: rotate(-2deg) scale(1);
  }
}

@keyframes screen-flash {
  0% {
    filter: brightness(1);
  }
  32% {
    filter: brightness(1.45) saturate(1.35);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes reversal-cutin {
  0% {
    opacity: 0;
    transform: scale(1.28) rotate(-2deg);
  }
  16% {
    opacity: 1;
    transform: scale(0.96) rotate(1deg);
  }
  72% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.08) rotate(1deg);
  }
}

@keyframes court-shock {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  18% {
    transform: translateX(-8px) rotate(-1deg);
  }
  34% {
    transform: translateX(9px) rotate(1deg);
  }
  52% {
    transform: translateX(-5px) rotate(-0.6deg);
  }
  70% {
    transform: translateX(4px) rotate(0.4deg);
  }
}

@keyframes reversal-glow {
  0%,
  100% {
    box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2);
  }
  35% {
    box-shadow:
      0 7px 0 rgba(0, 0, 0, 0.2),
      0 0 0 8px rgba(239, 48, 48, 0.34),
      0 0 36px rgba(239, 48, 48, 0.8);
  }
}

@keyframes alarm-pop {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18) rotate(-8deg);
  }
  68% {
    transform: scale(0.96) rotate(4deg);
  }
}

@keyframes confetti {
  0% {
    opacity: 0;
    transform: translateY(-24px) scale(1.04);
  }
  18% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateY(112px) scale(1);
  }
}

@media (min-width: 780px) {
  .app {
    padding: 28px;
  }

  .court {
    min-height: min(900px, calc(100vh - 56px));
  }
}

@media (max-width: 350px) {
  .court {
    padding: 12px 9px;
    gap: 8px;
    border-radius: 18px;
  }

  .character-frame {
    width: min(29vw, 120px);
  }

  .versus-stage {
    gap: 5px;
    grid-template-columns: minmax(0, 1fr) minmax(96px, 0.76fr) minmax(0, 1fr);
  }

  .side-card {
    min-height: 150px;
    padding-inline: 4px;
  }

  .verdict-board {
    min-height: 112px;
    padding: 10px 8px;
  }

  .choice {
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
