:root {
  color-scheme: light;
  --ink: #302522;
  --muted: #6f5346;
  --paper: #faedd7;
  --light: #fff7e7;
  --peach: #fbc38b;
  --pink: #fbd6ca;
  --accent: #a0462e;
  --stroke: #c6a789;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
button, a, summary { touch-action: manipulation; }
button { color: inherit; font: inherit; cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
img { display: block; max-width: 100%; object-fit: contain; height: auto; }
h1, h2, h3, p { margin: 0; }

.plaza {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.plaza::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background: radial-gradient(ellipse at 49% 39%, #fff6e3 0%, var(--paper) 75%);
}
.mast {
  width: min(100%, 1100px);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 2.2rem;
  border-bottom: 1px solid #9c8068;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
}
.crew { color: var(--ink); font: 900 .76rem var(--mono); letter-spacing: .075em; }
.street {
  position: absolute;
  z-index: -2;
  left: 50%;
  bottom: min(3rem, 7vh);
  translate: -50% 0;
  width: min(100%, 930px);
  height: min(70vh, 603px);
  background: url("assets/street.webp") center 55% / cover no-repeat;
  opacity: .78;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 68%, transparent 99%);
  mask-image: linear-gradient(transparent, #000 22%, #000 68%, transparent 99%);
}
.plaza-inner {
  width: min(100%, 540px);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding-top: clamp(18px, 4.6vh, 46px);
}
.title-block { text-align: center; }
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Arial Black", ui-sans-serif, system-ui, sans-serif;
  font-style: italic;
  font-weight: 1000;
  line-height: .9;
  letter-spacing: -.075em;
  rotate: -5deg;
  text-shadow: 2px 3px #e89564;
  padding-inline: .1em .22em;
}
.logo-first { font-size: clamp(2.9rem, 12vw, 4.9rem); }
.logo-first span {
  display: inline-block;
  font: 950 .43em var(--mono);
  letter-spacing: -.07em;
  vertical-align: 21%;
  border-block: .08em solid;
  padding: .06em .13em;
  rotate: 4deg;
}
.logo-last { position: relative; font-size: clamp(3.85rem, 18vw, 7.85rem); margin-top: .04em; }
.logo-last::after {
  content: "";
  position: absolute;
  left: 0;
  right: -2%;
  bottom: -.14em;
  height: .065em;
  rotate: -1deg;
  border-radius: 47% 20% 55% 33%;
  background: var(--ink);
  box-shadow: 1px 4px #ea9b6b;
}
.tagline {
  display: inline-block;
  margin-top: clamp(22px, 4.5vh, 35px);
  padding: .28em .55em;
  background: #fff0d9e8;
  font-size: clamp(.83rem, 3.7vw, 1.04rem);
  font-weight: 850;
  rotate: 1deg;
}
.crossing {
  position: relative;
  width: 100%;
  height: clamp(179px, 32svh, 292px);
}
.chick-button {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 37px;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: clamp(108px, 36vw, 186px);
  padding: 0;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.chick-button img { width: 100%; filter: drop-shadow(0 2px 1px #67452722); }
.chick-shadow {
  position: absolute;
  left: 50%;
  bottom: 33px;
  translate: -50% 0;
  width: clamp(90px, 32vw, 155px);
  height: 16px;
  background: #97613b58;
  border-radius: 49% 51% 53% 47%;
  filter: blur(1px);
}
.dropped-number {
  position: absolute;
  z-index: 4;
  left: calc(50% + clamp(36px, 13vw, 76px));
  bottom: 48%;
  font: 950 1.65rem var(--mono);
  color: var(--accent);
  text-shadow: 2px 2px var(--light), -1px -1px var(--light);
  pointer-events: none;
  opacity: 0;
}
.sign {
  position: absolute;
  z-index: 3;
  min-height: 47px;
  padding: .3em .62em;
  border: 1.5px solid var(--ink);
  border-radius: 3px 7px 4px 5px;
  box-shadow: 2px 3px #533d34;
  font-size: clamp(.8rem, 3.6vw, .98rem);
  font-weight: 850;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease;
}
.sign span { color: var(--accent); margin-left: .12em; }
.sign-rules { left: 0; bottom: 29px; rotate: -9deg; background: var(--light); }
.sign-tips { right: 0; bottom: 95px; rotate: 8deg; background: var(--pink); }
.sign:active, .ink-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px var(--ink); }
.plaza-actions {
  display: grid;
  justify-items: center;
  gap: .65rem;
  width: min(100%, 315px);
  padding-block: .2rem .35rem;
}
.ink-button {
  display: grid;
  place-items: center;
  text-decoration: none;
  width: 100%;
  min-height: 52px;
  padding: .55em .8em;
  border: 2px solid var(--ink);
  border-radius: 6px 8px 4px 8px;
  background: var(--peach);
  box-shadow: 3px 4px var(--ink);
  color: var(--ink);
  text-align: center;
  font-weight: 900;
  transition: transform .15s ease, box-shadow .15s ease;
}
.text-link {
  display: inline-grid;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .3em .6em;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .35em;
  font-size: .91rem;
  font-weight: 800;
}
.plaza .text-link { background: #faedd7cc; }
@media (min-width: 700px) {
  .street {
    -webkit-mask-image: radial-gradient(ellipse at center, #000 35%, transparent 76%);
    mask-image: radial-gradient(ellipse at center, #000 35%, transparent 76%);
  }
  .sign-rules { left: 28px; bottom: 46px; }
  .sign-tips { right: 32px; bottom: 128px; }
}

html:has(dialog[open]) { overflow: hidden; }
dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  overscroll-behavior: contain;
  max-width: none;
}
dialog::backdrop { background: #452c2785; }
.paper-dialog {
  width: min(calc(100% - 32px), 480px);
  max-height: calc(100% - 32px);
  overflow: auto;
  border: 1.5px solid var(--ink);
  border-radius: 9px 6px 12px 6px;
  background: var(--light);
  box-shadow: 5px 6px #3d2826;
}
.paper-dialog[open] { animation: unfold .23s cubic-bezier(.18,.84,.2,1) both; }
@keyframes unfold {
  from { opacity: .25; transform: translateY(15px) rotate(-3deg) scale(.94,.87); }
}
.paper {
  position: relative;
  display: flow-root;
  padding: clamp(16px, 5vw, 28px);
  font-size: 1rem;
  line-height: 1.65;
}
.paper::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  pointer-events: none;
  background: linear-gradient(45deg, #edc29b 47%, #7b5945 49%, #7b5945 53%, #e8cbaa 55%);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.paper > p { margin-bottom: .78rem; }
.tip-paper > p strong { white-space: nowrap; }
.paper-head, .trial-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: .6rem;
}
.paper-head h2 { font-size: clamp(1.65rem, 6vw, 2.35rem); line-height: 1.25; }
.paper-head h2:focus, .trial-head h2:focus, .trial-clear h3:focus { outline: 0; }
.close {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .28em;
  min-height: 44px;
  padding: .3em .45em;
  border: 0;
  background: none;
  font-size: .88rem;
  font-weight: 800;
  color: var(--muted);
}
.close span { font: 900 1.2em var(--mono); }
.paper-lead { font-weight: 850; }
.equation {
  display: flex;
  align-items: center;
  gap: clamp(5px, 2vw, 12px);
  font: 900 clamp(1.1rem, 5vw, 1.4rem) var(--mono);
  margin: .95rem 0 1.32rem;
}
.equation b {
  display: grid;
  place-items: center;
  min-width: 1.8em;
  height: 1.85em;
  padding-inline: .25em;
  background: var(--peach);
  border: 1px solid var(--ink);
  border-radius: 4px 3px 5px 3px;
}
.equation b:nth-child(2) { rotate: -3deg; }
.equation strong { color: var(--accent); padding-left: .17em; }
.mode { padding: .8rem 0; border-top: 1px solid var(--stroke); }
.mode h3 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: .2em;
  font-size: 1.1rem;
  font-weight: 900;
}
.mode h3 span { color: var(--accent); font-family: var(--mono); }
.paper-fold {
  border: 1px solid var(--ink);
  border-radius: 5px 7px 6px 4px;
  background: #fae1cf;
  margin-top: .5rem;
}
.paper-fold summary {
  display: flex;
  align-items: center;
  gap: .65em;
  min-height: 46px;
  padding: .45em .7em;
  list-style: none;
  cursor: pointer;
  font-weight: 800;
  font-size: .92rem;
}
.paper-fold summary::-webkit-details-marker { display: none; }
.paper-fold summary::before { content: "＋"; color: var(--accent); }
.paper-fold[open] summary::before { content: "−"; }
.fold-body { display: flow-root; padding: 0 .8rem .85rem; line-height: 1.6; }
.fold-body p + p, .fold-body p + h3 { margin-top: .8rem; }
.fold-body h3 { font-size: 1rem; margin-bottom: .25em; }
.paper-demo { margin-top: .55rem; padding-left: 0; }
.tip-paper .paper-head { margin-bottom: 1.05rem; }
.tip-headline { font-size: clamp(1.16rem, 5vw, 1.4rem); margin: .45rem 0 .6rem; }
.pink-quizer { width: clamp(82px, 28vw, 128px); float: right; margin: -.1rem 0 .25rem .55rem; rotate: 5deg; }
.paper-dialog[open] .pink-quizer { animation: peek .32s .12s both; }
@keyframes peek { from { opacity: 0; translate: 8px 10px; rotate: 13deg; } }
.tip-equation, .deep-tips { clear: both; }
.long-quizer { float: right; width: 57px; margin: 0 0 .45rem .55rem; }
.deep-tips[open] .long-quizer { animation: peek .24s both; }

.trial-dialog {
  width: min(calc(100% - 48px), 390px);
  max-height: calc(100% - 36px);
  max-height: calc(100dvh - max(18px, env(safe-area-inset-top)) - max(18px, env(safe-area-inset-bottom)));
  margin: auto;
  overflow: auto;
  background: var(--light);
  border: 1.5px solid var(--ink);
  border-radius: 12px 8px 13px 9px;
  box-shadow: 4px 5px var(--ink), 0 12px 35px #452c2733;
}
.trial-dialog::backdrop {
  background: #52332b30;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.trial-dialog[open] { animation: unfold .19s ease both; }
.trial-panel {
  padding: 3px clamp(11px, 3.8vw, 16px) 9px;
  display: flex;
  flex-direction: column;
}
.trial-head {
  border-bottom: 1px solid #9c8068;
  margin: 0 0 .4rem;
}
.trial-head h2 { font-size: .9rem; font-weight: 900; }
.trial-game {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.distance { padding: .15rem .4rem 0; }
.distance-label { display: flex; justify-content: space-between; align-items: baseline; }
.distance-label span:first-child { font: 950 clamp(1.3rem, 4vh, 1.6rem) var(--mono); }
.distance-label span:last-child { color: var(--muted); font-size: .85rem; font-weight: 800; }
.track {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 16px;
  margin: .2rem 0;
  --progress: 0%;
}
.track::before, .track-fill {
  position: absolute;
  content: "";
  left: 5px;
  right: 5px;
  top: calc(50% - 1px);
  height: 2px;
  background: #ad8a72;
}
.track-fill {
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--progress)) 0 0);
  background: var(--accent);
  transition: clip-path .18s ease;
}
.track-dot { z-index: 2; width: 10px; height: 10px; border: 1px solid var(--ink); background: var(--light); border-radius: 50%; }
.track-dot.active { border-color: var(--accent); background: var(--accent); }
.arena {
  position: relative;
  display: grid;
  grid-template-rows: auto 24px;
  justify-items: center;
  align-items: center;
  isolation: isolate;
  padding-top: 4px;
}
.floor-mark {
  position: absolute;
  bottom: 24px;
  left: 50%;
  translate: -50% 0;
  width: 108px;
  height: 12px;
  background: #cc9b7460;
  border-radius: 50%;
  z-index: -1;
}
.opponent {
  position: relative;
  align-self: center;
  width: clamp(104px, 16svh, 141px);
  transform-origin: center 82%;
}
.opponent img { width: 100%; }
.hit-marks { position: absolute; inset: 0; pointer-events: none; }
.hit-mark {
  position: absolute;
  width: 13%;
  height: 9%;
  transform: translate(-50%, -50%) rotate(var(--angle));
}
.hit-mark.bruise {
  background: radial-gradient(ellipse at 45% 50%, #82628ec4 12%, #a483a9b3 45%, #ab88ab65 68%, transparent 76%);
  border-radius: 53% 48% 47% 56%;
}
.hit-mark.scratches::before, .hit-mark.scratches::after {
  content: "";
  position: absolute;
  left: 9%;
  width: 83%;
  height: 30%;
  border-top: 1.25px solid #825353;
  border-radius: 60% 5% 0 0;
}
.hit-mark.scratches::before { top: 24%; rotate: -8deg; }
.hit-mark.scratches::after { top: 52%; left: 26%; width: 66%; rotate: -12deg; }
.hit-mark.dirt {
  opacity: .81;
  background:
    radial-gradient(ellipse at 30% 65%, #967249 14%, transparent 23%),
    radial-gradient(ellipse at 54% 48%, #a3825e 26%, transparent 40%),
    radial-gradient(ellipse at 77% 33%, #a08059 11%, transparent 22%),
    radial-gradient(ellipse at 83% 73%, #a3825e 8%, transparent 17%);
}
.hit-mark.bandage {
  width: 14%;
  height: 7%;
  border: 1px solid #855b44;
  border-radius: 27% 32% 20% 30%;
  background:
    linear-gradient(90deg, transparent 28%, #fff4dc 29% 71%, transparent 72%),
    radial-gradient(circle at 14% 50%, #a97d5c 6%, transparent 10%),
    radial-gradient(circle at 86% 50%, #a97d5c 6%, transparent 10%),
    #edc196;
}
.feedback {
  color: var(--accent);
  font-size: .9rem;
  font-weight: 900;
  white-space: nowrap;
}
.feedback.correct { color: #36572e; }
.impact {
  position: absolute;
  inset: 32% auto auto 70%;
  width: 29px;
  height: 28px;
  opacity: 0;
  pointer-events: none;
}
.impact span {
  display: block;
  width: 100%;
  margin-bottom: 7px;
  height: 3px;
  border-radius: 99px;
  background: var(--accent);
}
.impact span:first-child { rotate: -25deg; }
.impact span:last-child { rotate: 24deg; }
.puzzle {
  border: 1.5px solid var(--ink);
  background: var(--light);
  border-radius: 6px 4px 8px 5px;
  padding: .45rem clamp(10px, 4vw, 18px) .55rem;
}
.puzzle-values { display: flex; justify-content: space-between; margin-bottom: .35rem; }
.puzzle-values div { display: grid; line-height: 1.13; }
.puzzle-values div:last-child { text-align: right; }
.puzzle-values span { font-size: .82rem; font-weight: 850; color: var(--muted); }
.puzzle-values strong { font: 950 clamp(1.65rem, 4.4vh, 1.95rem) var(--mono); }
.puzzle.over #sum { color: var(--accent); }
.number-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.number-grid button {
  position: relative;
  min-width: 0;
  min-height: 44px;
  min-height: clamp(44px, 5.9svh, 49px);
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 4px 5px 3px 5px;
  background: #fffaf0;
  font: 950 clamp(1.3rem, 3.8vh, 1.64rem) var(--mono);
  -webkit-tap-highlight-color: transparent;
}
.number-grid button[aria-pressed="true"] { background: var(--peach); box-shadow: inset 0 -2px #d89564; }
.number-grid button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 47%;
  right: 11%;
  width: 9px;
  height: 5px;
  border-left: 1.5px solid;
  border-bottom: 1.5px solid;
  rotate: -46deg;
}
.number-grid .latest::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}
.number-grid button:active { transform: translateY(1px); }
.trial-instruction {
  margin-top: .45rem;
  text-align: center;
  font-size: .83rem;
  color: var(--muted);
}
.trial-clear {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .7rem;
  text-align: center;
  padding: 1rem 0;
}
.clear-picture {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(12px, 4vw, 24px);
  min-height: 113px;
}
.clear-stamp {
  width: 115px;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  grid-auto-flow: column;
  align-items: baseline;
  border: 4px double var(--accent);
  border-radius: 45% 53% 47% 54%;
  color: var(--accent);
  background: #fbe0ac;
  box-shadow: 3px 5px #d4a584;
  rotate: -12deg;
  font: 950 4rem var(--mono);
  animation: stamp .25s cubic-bezier(.14,.72,.39,1.15) both;
}
.clear-stamp span { font-size: .45em; }
@keyframes stamp { from { opacity: 0; scale: 1.24; rotate: -20deg; } }
.trial-clear h3 { font-size: clamp(2.75rem, 14vw, 3.75rem); font-weight: 1000; line-height: 1.15; }
.trial-clear p { margin-bottom: .65rem; }
.trial-clear .ink-button { max-width: 310px; }
.retry {
  min-height: 44px;
  padding: .35em .85em;
  margin-top: .35rem;
  border: 1px solid var(--ink);
  border-radius: 6px 3px 7px 4px;
  background: var(--light);
  font-weight: 850;
}

@media (max-width: 520px) and (orientation: portrait) {
  .trial-dialog { margin-bottom: max(18px, env(safe-area-inset-bottom)); }
  html:has(.trial-dialog[open]) .title-block { translate: 0 -25px; }
}

@media (max-height: 590px) {
  .plaza-inner { padding-top: 12px; }
  .crossing { height: 165px; }
  .chick-button { width: 110px; bottom: 19px; }
  .chick-shadow { bottom: 16px; width: 95px; }
  .sign-rules { bottom: 14px; }
  .sign-tips { bottom: 65px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
