*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: #f3e2d4;
  color: #6b4f45;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font-family: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.app {
  position: relative;
  width: min(100%, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(12px + env(safe-area-inset-top))
    14px
    calc(56px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  background: #f7ebdf;
  overflow: hidden;
}

.hud {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

.pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fffaf6;
  color: #7a5648;
  font-size: 13px;
  box-shadow: 0 2px 0 #f0d9cc;
}

.pill strong {
  font-size: 18px;
  line-height: 1;
  color: #6a4034;
  font-variant-numeric: tabular-nums;
}

.pill-status {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.meter {
  height: 8px;
  margin: 8px 2px 10px;
  border-radius: 999px;
  background: #f3e0d4;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0c08a, #e08a72);
}

.meter.is-hot > span {
  background: #e07a6a;
}

.meter.is-safe > span {
  background: #8fca86;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 280px;
}

.shop {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  overflow: hidden;
  background: #f6e3d4;
}

.wall {
  position: absolute;
  inset: 0 0 30% 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.45), transparent 28%),
    linear-gradient(#f8e7d8, #f3d8c6);
}

.floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%),
    repeating-linear-gradient(90deg, #f0d2ad 0 22px, #e8c49a 22px 24px);
}

.lamp {
  position: absolute;
  top: 0;
  left: 16%;
  width: 22px;
  height: 16px;
  border-radius: 0 0 12px 12px;
  background: #ffe7a8;
  box-shadow: 0 16px 28px rgba(255, 206, 120, 0.55);
  z-index: 3;
}

.sign {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 4;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fffaf6;
  color: #b07b68;
  font-size: 12px;
  letter-spacing: 0.18em;
}

.window {
  position: absolute;
  left: 6%;
  top: 16%;
  width: 22%;
  height: 22%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: #f7efe6;
  z-index: 2;
}

.pane {
  border-radius: 8px;
  background: linear-gradient(180deg, #d7eef4, #f7e7c8);
}

.corridor {
  position: absolute;
  left: 50%;
  top: 9%;
  width: 34%;
  height: 40%;
  transform: translateX(-50%);
  border-radius: 16px 16px 12px 12px;
  background: #f4e4d6;
  box-shadow: inset 0 0 0 8px #f7ece3;
  z-index: 1;
  overflow: hidden;
}

.corridor-inner {
  position: absolute;
  inset: 8px 8px 0;
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(#c9aa92, transparent 46%),
    linear-gradient(90deg, #c4a088 0 16%, #e4cbb6 16% 84%, #c4a088 84% 100%);
}

.corridor-floor {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 0;
  height: 46%;
  background: linear-gradient(#d8b79a, #c9a484);
  clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
}

.footsteps {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 2;
}

.footsteps span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4a48c;
  opacity: 0.35;
}

.shop.is-walking .footsteps span {
  animation: step 0.8s ease-in-out infinite;
}

.shop.is-walking .footsteps span:nth-child(2) {
  animation-delay: 0.12s;
}

.shop.is-walking .footsteps span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes step {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.rack {
  position: absolute;
  top: 23%;
  width: 86px;
  height: 118px;
  z-index: 2;
}

.rack-left {
  left: 10px;
}

.rack-right {
  right: 10px;
}

.bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 999px;
  background: #e0b48a;
}

.garment {
  position: absolute;
  top: 8px;
  width: 24px;
  height: 78px;
  border-radius: 10px 10px 12px 12px;
  clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
}

.g1 { left: 4%; background: #f2b7c6; }
.g2 { left: 35%; background: #f6d58a; height: 68%; }
.g3 { left: 66%; background: #b7ddd4; }
.g4 { left: 4%; background: #c9c4ee; }
.g5 { left: 35%; background: #f2b7c6; height: 72%; }
.g6 { left: 66%; background: #f6d58a; }

.plant {
  position: absolute;
  right: 8px;
  bottom: 10px;
  width: 28px;
  height: 38px;
  z-index: 4;
}

.pot {
  position: absolute;
  left: 6px;
  bottom: 0;
  width: 24px;
  height: 16px;
  border-radius: 0 0 8px 8px;
  background: #e7a07a;
}

.leaf {
  position: absolute;
  width: 16px;
  height: 22px;
  border-radius: 16px 16px 16px 4px;
  background: #9dcaa6;
}

.leaf-a { left: 4px; bottom: 14px; transform: rotate(-20deg); }
.leaf-b { left: 14px; bottom: 16px; transform: rotate(24deg); background: #b7ddb4; }

.clerk {
  --p: 0;
  position: absolute;
  left: 50%;
  top: 12%;
  width: 22%;
  max-width: 108px;
  z-index: 3;
  transform: translateX(-50%) translateY(calc(var(--p) * 18px)) scale(calc(0.48 + var(--p) * 0.62));
  transform-origin: center top;
}

.clerk.is-hidden {
  opacity: 0;
}

.clerk.inspecting {
  z-index: 4;
}

.clerk-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.clerk.approaching .clerk-svg {
  animation: bob 0.28s ease-in-out infinite alternate;
}

@keyframes bob {
  from { transform: translateY(0); }
  to { transform: translateY(5px); }
}

.shadow { fill: rgba(176, 132, 104, 0.28); }
.c-arm {
  fill: none;
  stroke: #f6d3c0;
  stroke-width: 12;
  stroke-linecap: round;
}
.board { fill: #fffaf6; }
.board-line {
  fill: none;
  stroke: #e7c3b4;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.leg { fill: #f6d3c0; }
.shoe { fill: #c9897a; }
.skirt { fill: #8eaf9a; }
.shirt { fill: #fff8f3; }
.apron { fill: #f0997b; }
.pocket { fill: #e8876a; }
.neck,
.c-head { fill: #f6d3c0; }
.bun,
.c-hair { fill: #7f9e86; }
.pupil { fill: #6a5348; }
.brow,
.mouth {
  fill: none;
  stroke: #c9897a;
  stroke-width: 2.4;
  stroke-linecap: round;
}
.mouth-ask { display: none; }
.clerk.feinting .mouth-flat { display: none; }
.clerk.feinting .mouth-ask { display: inline; }
.clerk.inspecting .brow.left {
  transform: translateY(-1px) rotate(14deg);
  transform-origin: center;
}
.clerk.inspecting .brow.right {
  transform: translateY(-1px) rotate(-14deg);
  transform-origin: center;
}
.clerk.inspecting .pupil { fill: #5c463c; }

.check-zone {
  position: absolute;
  left: 50%;
  top: 47%;
  z-index: 4;
  width: 42%;
  height: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #e4c0a4;
  border-radius: 999px;
  background: rgba(255, 250, 246, 0.35);
  color: #c49a78;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.check-zone.is-active {
  border-style: solid;
  border-color: #e3927a;
  background: #ffd5cc;
  color: #8a4034;
  font-weight: 700;
}

.banner {
  position: absolute;
  left: 50%;
  top: 8px;
  z-index: 6;
  margin: 0;
  padding: 6px 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #fffaf6;
  color: #8d5a49;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(160, 100, 70, 0.12);
}

.banner[hidden] {
  display: none;
}

.banner.safe {
  color: #3f7d46;
  background: #e7f6df;
}

.banner.hot {
  color: #8a3e32;
  background: #ffd9d2;
}

.banner.warn {
  color: #9a5436;
  background: #fff1e4;
}

.cast {
  position: absolute;
  left: 1%;
  right: 1%;
  bottom: 0;
  z-index: 5;
  height: 62%;
  max-height: 360px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.actor {
  width: 31%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.actor-player {
  width: 38%;
}

.figure {
  width: 100%;
  flex: 1;
  min-height: 0;
}

.figure-svg {
  --skin: #f6d4c4;
  --limb: #e7b39a;
  --cloth: #f4c3cf;
  --hair: #e4bfae;
  --cheek: transparent;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.figure-svg.ref-left {
  --cloth: #9ecfc4;
}

.figure-svg.ref-right {
  --cloth: #f3c992;
}

.figure-svg.player {
  --skin: #f8c9aa;
  --limb: #efb088;
  --cloth: #f3b7c6;
  --hair: #e08b68;
  --cheek: #f2a99a;
}

.figure-svg .arms { display: none; }
.figure-svg.pose-neutral .arms-neutral,
.figure-svg.pose-one .arms-one,
.figure-svg.pose-both .arms-both,
.figure-svg.pose-hips .arms-hips { display: inline; }

.pedestal { fill: #efd0aa; }
.pole { fill: #f3e0d0; }
.arm-path {
  fill: none;
  stroke: var(--limb);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hand { fill: var(--limb); }
.head,
.neck { fill: var(--skin); }
.dress { fill: var(--cloth); }
.hair { fill: var(--hair); }
.tuft {
  display: none;
  fill: none;
  stroke: var(--hair);
  stroke-width: 5;
  stroke-linecap: round;
}
.player .tuft { display: inline; }
.eye {
  fill: none;
  stroke: #c4897a;
  stroke-width: 3.2;
  stroke-linecap: round;
}
.cheek { fill: var(--cheek); }

.figure-svg.pop {
  animation: pop 0.18s ease;
}

@keyframes pop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(4px) scale(0.96, 1.04); }
  100% { transform: translateY(0) scale(1); }
}

.name {
  margin-top: -2px;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 246, 0.88);
  color: #8a6556;
  font-size: 12px;
}

.name-you {
  background: #ffe1c4;
  color: #8a4e38;
  font-weight: 700;
}

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

.pose-btn {
  min-height: 84px;
  padding: 8px 4px 10px;
  border: 2px solid #f0d8c8;
  border-radius: 18px;
  background: #fffaf6;
  color: #6b4f45;
  font-size: 13px;
  font-weight: 700;
}

.pose-btn svg {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 2px;
}

.ico-skin { fill: #f6d7c8; }
.ico-body {
  fill: none;
  stroke: #f0b7c4;
  stroke-width: 7;
  stroke-linecap: round;
}
.ico-arm {
  fill: none;
  stroke: #efcbbd;
  stroke-width: 5;
  stroke-linecap: round;
}

.pose-btn[aria-pressed="true"] {
  border-color: #e7a27a;
  background: #ffe8d2;
  transform: translateY(-2px);
}

.pose-btn[aria-pressed="true"]::after {
  content: "";
  display: block;
  width: 18px;
  height: 4px;
  margin: 4px auto 0;
  border-radius: 999px;
  background: #e08a62;
}

.pose-btn:active {
  transform: translateY(1px) scale(0.98);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(72px + env(safe-area-inset-bottom));
  background: rgba(247, 236, 228, 0.72);
  overflow: auto;
}

.overlay[hidden] {
  display: none;
}

.card {
  width: min(100%, 340px);
  padding: 28px 22px 22px;
  border-radius: 28px;
  background: #fffaf6;
  box-shadow: 0 16px 40px rgba(180, 120, 90, 0.16);
  text-align: center;
}

h1 {
  margin: 0;
  color: #8d5a49;
  font-size: 32px;
  line-height: 1.25;
}

.lead {
  margin: 12px 0 22px;
  font-size: 16px;
  line-height: 1.6;
}

.title-best,
.result-best {
  margin: 12px 0 0;
  color: #a07a6a;
  font-size: 13px;
}

.btn-primary,
.btn-secondary {
  display: block;
  width: 100%;
  min-height: 52px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
}

.btn-primary {
  border: none;
  background: #f0b39a;
  color: #6a3b2c;
}

.btn-secondary {
  border: 2px solid #d7ead4;
  background: #fff;
  color: #5f7d64;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.clerk-line {
  margin: 0;
  color: #8d5a49;
  font-size: 18px;
  font-weight: 700;
}

.fail-reason {
  margin: 10px 0 0;
  color: #c45b52;
  font-size: 28px;
  font-weight: 800;
}

.result-text {
  margin: 12px 0 0;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 700;
}

.rank {
  margin: 8px 0 0;
  color: #c47b52;
  font-size: 20px;
  font-weight: 800;
}

.privacy {
  position: fixed;
  left: 50%;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid #d9f99d;
  border-radius: 999px;
  background: #fff;
  color: #3f6212;
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

@media (max-height: 700px) {
  .pose-btn {
    min-height: 72px;
  }

  .pose-btn svg {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 28px;
  }

  .corridor {
    height: 32%;
  }

  .check-zone {
    top: 39%;
  }

  .cast {
    height: 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shop.is-walking .footsteps span,
  .clerk.approaching .clerk-svg,
  .figure-svg.pop {
    animation: none;
  }
}
