/* 痛バ詰め。背景は引き算してグッズの色を主役にする（ほんのりピンクの白）。
   装飾の文法は「値札（タグ）」の形1つに統一する：左端がとがって穴のあいた札。 */
:root {
  --bg: #f8f0f3;
  --paper: #fffdfd;
  --ink: #3a2f36;
  --ink-soft: rgba(58, 47, 54, 0.66);
  --line: rgba(58, 47, 54, 0.18);
  --gold: #b8861b;
  --accent: #c9568c;
  --danger: #d8343f;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
body.playing { overflow: hidden; overscroll-behavior: none; }
body.playing .footer { display: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
button, a { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app { width: min(100%, 480px); margin: 0 auto; padding: 0 16px; }
.screen { padding: 16px 0 24px; }

/* 値札の形 */
.tag, .tag-button {
  --notch: 18px;
  position: relative;
  background: var(--paper);
  clip-path: polygon(var(--notch) 0, 100% 0, 100% 100%, var(--notch) 100%, 0 50%);
  padding: 8px 14px 8px calc(var(--notch) + 16px);
  filter: drop-shadow(0 1px 0 var(--line));
}
.tag::before, .tag-button::before {
  content: "";
  position: absolute;
  left: calc(var(--notch) * 0.55);
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.08em; line-height: 1.2; }

.tag-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 0;
  font-size: 17px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.tag-button.primary { background: var(--accent); color: #fff; }
.tag-button.primary::before { background: var(--bg); box-shadow: none; }
.tag-button:hover { filter: drop-shadow(0 2px 0 var(--line)) brightness(1.04); }
.tag-button:active { transform: translateY(1px); }
.text-button { background: none; border: 0; padding: 12px; font-weight: 700; color: var(--ink-soft); text-decoration: underline; cursor: pointer; min-height: 44px; }

/* タイトル */
.title-screen { text-align: center; }
.logo h1 { margin: 0; font-size: clamp(44px, 13vw, 60px); line-height: 1.1; letter-spacing: 0.06em; color: var(--accent); }
.logo-sub { margin: 8px 0 2px; font-size: 13px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.2em; }
.preview { width: 140px; height: 200px; margin: 8px auto 0; display: block; }
.lead { margin: 4px 0 16px; font-size: 15px; font-weight: 700; }
.setup { display: grid; gap: 18px; text-align: left; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 14px; font-weight: 800; margin-bottom: 8px; padding: 0; }
.options { display: grid; gap: 8px; }
.options input { position: absolute; opacity: 0; pointer-events: none; }
.shape-options { grid-template-columns: repeat(3, 1fr); }
.shape-options label, .skin-options label {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px transparent;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
}
.shape-options small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.shape-options .mult { font-size: 16px; color: var(--gold); font-weight: 900; }
.options label:has(input:checked) { box-shadow: inset 0 0 0 3px var(--accent); }
.options label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.color-options { grid-template-columns: repeat(9, 1fr); gap: 6px; }
.color-options label { display: grid; place-items: center; min-height: 44px; cursor: pointer; border-radius: 50%; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line); }
.color-options label:has(input:checked) { box-shadow: none; }
.color-options label:has(input:checked) .swatch { box-shadow: 0 0 0 3px var(--ink); }
.skin-options { grid-template-columns: repeat(3, 1fr); }
.skin-dots { display: flex; gap: 2px; }
.skin-dots span { width: 12px; height: 12px; border-radius: 50%; }
.setup .tag-button { width: 100%; margin-top: 4px; font-size: 20px; min-height: 60px; }
.chain-help { margin-top: 20px; text-align: left; background: var(--paper); border-radius: 14px; padding: 4px 14px; }
.chain-help summary { cursor: pointer; font-weight: 800; padding: 10px 0; min-height: 44px; }
.tier-list { margin: 0 0 12px; padding-left: 1.6em; font-size: 14px; }
.tier-list li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.tier-list .price { font-weight: 800; color: var(--gold); }

/* プレイ中：縦持ち前提。HUD は総額・NEXT・グッズの進化・ベストの4点だけ */
.play-screen { display: flex; flex-direction: column; height: 100dvh; padding: max(8px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom)); }
.hud { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.total-tag { min-width: 0; }
.total { display: block; font-size: clamp(28px, 8.5vw, 38px); font-weight: 900; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total.bump { animation: bump 220ms ease-out; }
@keyframes bump { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }
.best-line { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.next-box { text-align: center; }
.next-box canvas { width: 56px; height: 56px; display: block; }
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.board { display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; border-radius: 12px; }
.chain { position: absolute; top: 12%; left: 0; right: 0; margin: 0; text-align: center; font-size: 28px; font-weight: 900; color: var(--accent); pointer-events: none; opacity: 0; }
.chain.show { animation: chain 900ms ease-out; }
@keyframes chain { 0% { opacity: 0; transform: scale(0.6); } 15% { opacity: 1; transform: scale(1.15); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-12px); } }
.warning { position: absolute; top: 2%; left: 50%; transform: translateX(-50%); margin: 0; padding: 2px 12px; border-radius: 999px; background: var(--danger); color: #fff; font-weight: 900; font-size: 14px; pointer-events: none; animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.evolution-tag { margin-top: 6px; padding-top: 4px; padding-bottom: 2px; }
.evolution { display: block; width: 100%; height: 44px; }
.controls { display: flex; justify-content: center; gap: 8px; padding-top: 6px; }
.icon-button { min-height: 44px; min-width: 76px; padding: 6px 12px; border: 0; border-radius: 999px; background: var(--paper); font-size: 14px; font-weight: 800; cursor: pointer; box-shadow: 0 1px 0 var(--line); touch-action: manipulation; }

/* 結果 */
.result-screen { text-align: center; }
.praise { margin: 8px 0 0; font-size: clamp(30px, 9vw, 40px); color: var(--accent); line-height: 1.2; }
.praise .second { display: block; font-size: 0.6em; color: var(--ink); }
.best-badge { display: inline-block; margin: 8px 0 0; padding: 2px 14px; border-radius: 999px; background: var(--danger); color: #fff; font-weight: 900; }
.result-total { display: inline-block; margin: 14px auto 0; text-align: left; padding-right: 22px; }
.total.big { font-size: clamp(44px, 14vw, 64px); }
.result-detail { margin: 10px 0 0; font-weight: 800; }
.result-gap { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.result-image { display: block; width: 100%; aspect-ratio: 1200 / 630; margin: 14px 0 0; border-radius: 12px; background: var(--paper); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.result-actions .tag-button { width: 100%; }
.result-actions .text-button { grid-column: 1 / -1; }
.itaba-link { display: inline-block; margin-top: 8px; padding: 10px; font-weight: 800; color: var(--accent); min-height: 44px; }

.footer { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 8px 16px 24px; }
.footer p { margin: 2px 0; }
.footer a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  .total.bump, .chain.show, .warning { animation: none; }
  .chain.show { opacity: 1; }
}
@media (min-width: 720px) {
  .app { width: min(100%, 520px); }
}
