/* どうぶつカーリング style.css — 構造は docs/design.md */
:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #6f6a7a;
  --c-paper: #fffdf7;
  --c-snow: #f6faff;
  --c-snow-shade: #d5e4f3;
  --c-line: #d8e2ee;
  --c-ice: #e6f5ff;
  --c-ice-deep: #bfe1f7;
  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-red-soft: #ffe1dc;
  --c-blue: #3f86e8;
  --c-blue-deep: #2a5fb0;
  --c-blue-soft: #dcebff;
  --c-mint: #7fd8b4;
  --c-mint-deep: #4fb592;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-pink: #ff7fa8;
  --c-lock: #a7a9b8;
  --c-night: #3c4a63;
  --c-bg: #cfe7fb;
  --c-bg-stripe: #e4f2fd;

  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, system-ui, sans-serif;

  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;
  --dur-fast: 0.12s;
  --dur-mid: 0.25s;
  --frame-w: 480px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-base);
  color: var(--c-ink);
  background: var(--c-night);
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }

/* PC では中央に縦長の領域。スマホは全面 */
.app {
  position: fixed; top: 0; bottom: 0; left: 50%;
  width: min(var(--frame-w), 100%);
  transform: translateX(-50%);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.9) 0 3px, transparent 4px) 0 0 / 64px 64px,
    radial-gradient(circle at 70% 75%, rgba(255,255,255,.8) 0 2px, transparent 3px) 0 0 / 48px 48px,
    repeating-linear-gradient(135deg, var(--c-bg) 0 28px, var(--c-bg-stripe) 28px 56px);
}
@media (min-width: 520px) {
  .app { border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
}

/* ---------- 画面 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  overflow-y: auto;
}
.screen.is-active { display: flex; animation: screen-in var(--dur-mid) ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--c-paper);
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  box-shadow: 0 8px 0 var(--c-ink);
  padding: 20px 22px;
}

/* ---------- ボタン ---------- */
.btn {
  --btn-bg: var(--c-red);
  --btn-edge: var(--c-red-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 28px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em; white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
  margin-bottom: var(--btn-depth);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 6px;
  border-radius: 999px; background: rgba(255,255,255,.35); pointer-events: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active, .btn.is-pressed {
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn:disabled { filter: grayscale(.8) opacity(.6); cursor: not-allowed; transform: none; }
.btn--block { display: flex; width: 100%; }
.btn--blue { --btn-bg: var(--c-blue); --btn-edge: var(--c-blue-deep); }
.btn--mint { --btn-bg: var(--c-mint); --btn-edge: var(--c-mint-deep); --btn-fg: var(--c-ink); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 40px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
  font-size: 20px; font-weight: 900; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.icon-btn--pause::before { content: ""; width: 12px; height: 14px; border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
.icon-btn--back::before { content: "‹"; font-size: 26px; margin-top: -3px; }
.icon-btn--help::before { content: "?"; }
.icon-btn--sound::before { content: "♪"; }
.icon-btn--sound.is-off { opacity: .55; }
.icon-btn--sound.is-off::after { content: ""; position: absolute; width: 26px; height: 3px; background: var(--c-ink); transform: rotate(-45deg); }
.icon-btn { position: relative; }
.btn:focus-visible, .icon-btn:focus-visible, .rival-card:focus-visible, .tray__stone:focus-visible {
  outline: 4px solid var(--c-gold); outline-offset: 4px;
}

/* ---------- 星・チーム印 ---------- */
.star {
  display: inline-block; width: 18px; height: 18px;
  background: var(--c-line);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.star.is-on { background: var(--c-gold); }
.stars { display: inline-flex; gap: 2px; filter: drop-shadow(1.5px 0 0 var(--c-ink)) drop-shadow(-1.5px 0 0 var(--c-ink)) drop-shadow(0 1.5px 0 var(--c-ink)) drop-shadow(0 -1.5px 0 var(--c-ink)); }
.stars--big .star { width: 54px; height: 54px; }
.team-dot {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-red);
}
.team-dot--cpu { background: var(--c-blue); }

/* ---------- タイトル ---------- */
.screen--title { gap: 18px; text-align: center; }
.logo { margin: 0; line-height: 1.05; }
.logo__sub {
  display: inline-block; padding: 4px 16px; margin-bottom: 8px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); font-size: 15px; font-weight: 800;
}
.logo__main {
  display: block;
  font-size: clamp(40px, 12vw, 64px); font-weight: 900; letter-spacing: .04em;
  color: #fff;
  -webkit-text-stroke: 10px var(--c-ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--c-ink);
}
.logo__main .is-red { color: var(--c-red); }
.logo__main .is-blue { color: var(--c-blue); }
.logo__main .is-gold { color: var(--c-gold); }
.title-art { width: min(320px, 80vw); aspect-ratio: 4 / 3; }
.title-art canvas { width: 100%; height: 100%; display: block; }
.title-art canvas { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.title-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; width: min(300px, 100%); }
.title-actions .btn { width: 100%; font-size: 24px; }
.title-tools { display: flex; gap: 10px; justify-content: center; }
.screen--title > a.back-to-games {
  position: absolute; top: calc(12px + var(--safe-top)); left: calc(12px + var(--safe-left)); z-index: 6;
  display: inline-flex; align-items: center; padding: 6px 12px 7px;
  font: 800 13px/1 var(--font-base); color: var(--c-ink); text-decoration: none;
  background: var(--c-paper); border: 3px solid var(--c-ink); border-radius: 999px; box-shadow: 0 3px 0 var(--c-ink);
}
.screen--title > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }

/* ---------- 相手選択 ---------- */
.screen--select { justify-content: flex-start; gap: 16px; }
.select-head { display: flex; align-items: center; gap: 12px; width: 100%; }
.select-head__title { flex: 1; margin: 0; font-size: 24px; font-weight: 900; text-align: center; }
.select-head::after { content: ""; width: 44px; }
.rival-list { display: flex; flex-direction: column; gap: 18px; width: 100%; padding-top: 10px; }
.rival-card {
  position: relative;
  display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; row-gap: 4px;
  align-items: center;
  padding: 12px 14px 12px 12px;
  border: 4px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper);
  box-shadow: 0 6px 0 var(--c-ink);
  cursor: pointer; text-align: left;
  transition: transform .08s ease, box-shadow .08s ease;
}
.rival-card:active { transform: translateY(6px); box-shadow: 0 0 0 var(--c-ink); }
.rival-card__no {
  position: absolute; top: -14px; left: 12px;
  height: 28px; padding: 0 10px;
  display: grid; place-items: center;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-blue); color: #fff;
  font: 900 14px var(--font-base);
}
.rival-card__pic {
  grid-row: 1 / 4;
  width: 96px; height: 96px; display: block;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: radial-gradient(circle at 50% 55%, var(--c-ice) 0 55%, var(--c-ice-deep) 56%);
}
.rival-card__name { font-size: 19px; font-weight: 900; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.rival-card__level {
  display: inline-block; margin-left: 6px; padding: 1px 8px; vertical-align: 2px;
  border: 2px solid var(--c-ink); border-radius: 999px;
  font-size: 12px; font-weight: 900; background: var(--c-mint);
}
.rival-card__level--2 { background: var(--c-gold); }
.rival-card__level--3 { background: var(--c-pink); color: #fff; -webkit-text-stroke: 3px var(--c-ink); paint-order: stroke fill; }
.rival-card__hint { margin: 0; font-size: 13px; font-weight: 800; color: var(--c-ink-sub); line-height: 1.45; }
.rival-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rival-card__team { display: flex; gap: 2px; }
.rival-card__team canvas { width: 28px; height: 28px; display: block; }
.rival-card__best { font: 800 12px var(--font-num); color: var(--c-ink-sub); }
.rival-card.is-cleared { background: #fffbea; }
.rival-card.is-next { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.rival-card.is-locked { cursor: not-allowed; background: #eceef3; border-color: var(--c-lock); box-shadow: 0 6px 0 var(--c-lock); animation: none; }
.rival-card.is-locked:active { transform: none; box-shadow: 0 6px 0 var(--c-lock); }
.rival-card.is-locked > :not(.rival-card__lock):not(.rival-card__no) { opacity: .35; }
.rival-card.is-locked .rival-card__pic { filter: grayscale(1) brightness(.6); }
.rival-card.is-locked .rival-card__no { background: var(--c-lock); }
.rival-card__lock {
  position: absolute; left: 12px; top: 12px; width: 96px; height: 96px;
  display: none; place-items: center;
}
.rival-card.is-locked .rival-card__lock { display: grid; }
.rival-card__lock::before {
  content: ""; width: 34px; height: 26px; margin-top: 18px;
  border: 4px solid var(--c-ink); border-radius: 6px; background: var(--c-gold);
}
.rival-card__lock::after {
  content: ""; position: absolute; width: 22px; height: 22px; margin-top: -14px;
  border: 4px solid var(--c-ink); border-bottom: 0; border-radius: 12px 12px 0 0;
}
.rival-card__locktext { grid-column: 2; font-size: 13px; font-weight: 900; color: var(--c-ink); }

/* ---------- ルール ---------- */
.modal {
  position: absolute; inset: 0; z-index: 30;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(40, 50, 70, .55);
}
.modal.is-open { display: flex; animation: screen-in var(--dur-mid) ease both; }
.rules { width: min(420px, 100%); text-align: center; }
.rules__title { margin: 0 0 10px; font-size: 22px; font-weight: 900; }
.rules__page { display: none; }
.rules__page.is-active { display: block; }
.rules__fig {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px; margin-bottom: 10px;
  background: var(--c-ice); border: 3px solid var(--c-ink); border-radius: var(--radius-m);
}
.rules__fig canvas { width: 100%; max-width: 300px; aspect-ratio: 3 / 2; display: block; }
.rules__text { margin: 0 0 12px; font-size: 17px; font-weight: 800; line-height: 1.6; }
.rules__text b { color: var(--c-red); }
.rules__pts { display: flex; justify-content: center; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.rules__pts li { padding: 2px 10px; border: 3px solid var(--c-ink); border-radius: 999px; font: 900 14px var(--font-base); }
.rules__pts li:nth-child(1) { background: var(--c-gold); }
.rules__pts li:nth-child(2) { background: var(--c-paper); }
.rules__pts li:nth-child(3) { background: var(--c-mint); }
.rules__dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.rules__dots i { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--c-ink); background: var(--c-paper); }
.rules__dots i.is-on { background: var(--c-gold); }
.rules__nav { display: flex; justify-content: center; gap: 12px; }

/* ---------- 試合 ---------- */
.screen--play { padding: 0; background: var(--c-night); justify-content: flex-start; }
.play-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 6px;
  padding: calc(8px + var(--safe-top)) calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.score-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 6px; min-height: 42px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); box-shadow: 0 3px 0 var(--c-ink);
}
.score-chip--cpu { justify-self: end; flex-direction: row-reverse; padding: 4px 6px 4px 10px; }
.score-chip__face { width: 30px; height: 30px; display: block; flex: none; }
.score-chip__name { font-size: 11px; font-weight: 900; line-height: 1.1; max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-chip__pts { font: 900 24px var(--font-num); min-width: 1.2em; text-align: center; }
.score-chip--player .score-chip__pts { color: var(--c-red); }
.score-chip--cpu .score-chip__pts { color: var(--c-blue); }
.score-chip.is-bump .score-chip__pts { animation: bump .45s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
.hud__center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.end-chip {
  padding: 3px 12px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-ink); color: #fff; font: 900 14px var(--font-base); white-space: nowrap;
}
.end-chip b { font-family: var(--font-num); font-size: 17px; color: var(--c-gold); }
.end-dots { display: flex; gap: 4px; }
.end-dots i { width: 10px; height: 10px; border: 2px solid var(--c-ink); border-radius: 50%; background: var(--c-paper); }
.end-dots i.is-player { background: var(--c-red); }
.end-dots i.is-cpu { background: var(--c-blue); }
.end-dots i.is-draw { background: var(--c-lock); }
.end-dots i.is-now { box-shadow: 0 0 0 2px var(--c-gold); }
.hud__tools { position: absolute; right: calc(8px + var(--safe-right)); top: calc(60px + var(--safe-top)); display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.hud__tools .icon-btn { width: 38px; height: 38px; font-size: 17px; }

.turn-badge {
  position: absolute; left: 50%; top: calc(64px + var(--safe-top)); z-index: 6;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-red); color: #fff;
  font-size: 15px; font-weight: 900; white-space: nowrap;
  -webkit-text-stroke: 3px var(--c-ink); paint-order: stroke fill;
  box-shadow: 0 3px 0 var(--c-ink);
  pointer-events: none;
}
.turn-badge.is-cpu { background: var(--c-blue); }
.turn-badge.is-cpu::after { content: ""; width: 18px; height: 6px; background: radial-gradient(circle, #fff 0 2px, transparent 3px) 0 0 / 6px 6px; animation: think 1s steps(3) infinite; }
@keyframes think { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.turn-badge.is-in { animation: badge-in .35s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes badge-in { from { transform: translateX(-50%) scale(.4); } to { transform: translateX(-50%) scale(1); } }
.hammer { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 2px solid var(--c-ink); border-radius: 50%; background: var(--c-gold); font: 900 11px var(--font-base); color: var(--c-ink); -webkit-text-stroke: 0; }

/* 手持ちコマのトレイ（画面下） */
.tray {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 10px calc(10px + var(--safe-bottom));
  pointer-events: none;
}
.tray__label {
  padding: 2px 12px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); font-size: 13px; font-weight: 900;
}
.tray__row { display: flex; gap: 10px; pointer-events: auto; }
.tray__stone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  width: 84px; padding: 6px 4px 4px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper);
  box-shadow: 0 5px 0 var(--c-ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background var(--dur-fast);
}
.tray__stone:active { transform: translateY(5px); box-shadow: 0 0 0 var(--c-ink); }
.tray__stone canvas { width: 56px; height: 56px; display: block; }
.tray__name { font-size: 12px; font-weight: 900; }
.tray__size {
  position: absolute; top: -10px; right: -8px;
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-mint); font: 900 13px var(--font-num);
}
.tray__size--M { background: var(--c-gold); }
.tray__size--L { background: var(--c-pink); color: #fff; }
.tray__stone.is-selected { background: #fff3c4; transform: translateY(-6px); box-shadow: 0 11px 0 var(--c-ink); }
.tray__stone.is-selected::after {
  content: ""; position: absolute; left: 50%; bottom: -20px; width: 0; height: 0;
  margin-left: -8px; border: 8px solid transparent; border-top-color: var(--c-gold);
}
.tray__stone.is-used { cursor: default; background: #eceef3; box-shadow: 0 5px 0 var(--c-lock); border-color: var(--c-lock); }
.tray__stone.is-used > * { opacity: .3; }
.tray__stone.is-used::before { content: "なげた"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 900; color: var(--c-ink-sub); z-index: 1; }
.tray.is-cpu .tray__row { pointer-events: none; filter: grayscale(.6) opacity(.75); }
.tray__hint {
  padding: 3px 12px; border-radius: 999px;
  background: rgba(59, 47, 47, .75); color: #fff; font-size: 13px; font-weight: 800;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .45; } }

/* 中央の大きな文字（エンド開始・ナイス！など） */
.callout {
  position: absolute; left: 50%; top: 40%; z-index: 9;
  transform: translate(-50%, -50%);
  font-size: clamp(36px, 11vw, 56px); font-weight: 900; color: var(--c-gold);
  -webkit-text-stroke: 10px var(--c-ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--c-ink);
  white-space: nowrap; pointer-events: none;
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.callout--white { color: #fff; }
.callout--red { color: var(--c-red); }
.callout--blue { color: var(--c-blue); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.3); } to { transform: translate(-50%, -50%) scale(1); } }
.toast {
  position: absolute; left: 50%; bottom: calc(150px + var(--safe-bottom)); z-index: 50;
  transform: translateX(-50%);
  padding: 8px 16px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-ink); color: #fff; font-weight: 800; white-space: nowrap;
}
.rotate-tip {
  position: fixed; inset: 0; z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--c-night); color: #fff; font-size: 20px; font-weight: 900;
}
.rotate-tip::before {
  content: ""; width: 44px; height: 72px; border: 5px solid #fff; border-radius: 10px;
  animation: tilt 1.6s ease-in-out infinite;
}
@keyframes tilt { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate-tip { display: flex; }
}

/* ---------- ポーズ ---------- */
.pause { width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.pause__title { margin: 0 0 6px; font-size: 26px; font-weight: 900; }

/* ---------- エンド結果 ---------- */
.end-result { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.end-result__title {
  margin: -40px 0 0; font-size: 38px; font-weight: 900; color: #fff; white-space: nowrap;
  -webkit-text-stroke: 9px var(--c-ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--c-ink);
}
.end-result.is-player .end-result__title { color: var(--c-red); }
.end-result.is-cpu .end-result__title { color: var(--c-blue); }
.end-result__rows { display: flex; flex-direction: column; gap: 8px; width: 100%; margin: 0; padding: 0; list-style: none; }
.end-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: 6px 10px; border: 3px solid var(--c-ink); border-radius: var(--radius-s);
  background: var(--c-red-soft);
}
.end-row--cpu { background: var(--c-blue-soft); }
.end-row__name { font-size: 15px; font-weight: 900; text-align: left; }
.end-row__stones { display: flex; gap: 3px; justify-content: flex-end; }
.end-row__stones canvas { width: 26px; height: 26px; display: block; }
.end-row__pt { font: 900 12px var(--font-num); padding: 1px 6px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-paper); }
.end-row__pt--3 { background: var(--c-gold); }
.end-row__pt--2 { background: #fff; }
.end-row__pt--1 { background: var(--c-mint); }
.end-row__sum { font: 900 30px var(--font-num); min-width: 1.6em; text-align: right; }
.end-row--player .end-row__sum { color: var(--c-red); }
.end-row--cpu .end-row__sum { color: var(--c-blue); }
.end-row.is-win { box-shadow: 0 0 0 3px var(--c-gold); animation: bump .5s .3s cubic-bezier(.2, 1.8, .4, 1) both; }
.end-result__total { font-size: 15px; font-weight: 800; color: var(--c-ink-sub); }
.end-result__total b { font: 900 20px var(--font-num); color: var(--c-ink); }

/* ---------- 最終結果 ---------- */
.screen--result { background: rgba(40, 50, 70, .55); }
.result { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.result__title {
  margin: -46px 0 0; font-size: clamp(32px, 11vw, 48px); font-weight: 900; color: var(--c-gold); white-space: nowrap;
  -webkit-text-stroke: 9px var(--c-ink); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--c-ink);
}
.result.is-lose .result__title { color: #bfe6ff; }
.result.is-draw .result__title { color: #fff; }
.result__art { width: 180px; height: 100px; display: block; }
.result__stars .star { animation: star-in .4s cubic-bezier(.2, 1.6, .4, 1) both; }
.result__stars .star:nth-child(2) { animation-delay: .15s; }
.result__stars .star:nth-child(3) { animation-delay: .3s; }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }

.scoreboard {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 3px solid var(--c-ink); border-radius: var(--radius-s); overflow: hidden;
  font-family: var(--font-num); background: var(--c-paper);
}
.scoreboard th, .scoreboard td { padding: 6px 4px; text-align: center; border-left: 2px solid var(--c-line); }
.scoreboard th:first-child, .scoreboard td:first-child { border-left: 0; }
.scoreboard thead th { background: var(--c-ink); color: #fff; font: 900 12px var(--font-base); }
.scoreboard tbody th { font: 900 13px var(--font-base); text-align: left; padding-left: 8px; white-space: nowrap; }
.scoreboard tbody tr + tr > * { border-top: 2px solid var(--c-line); }
.scoreboard td { font-size: 20px; font-weight: 900; }
.scoreboard tr.is-player td { color: var(--c-red); }
.scoreboard tr.is-cpu td { color: var(--c-blue); }
.scoreboard td.is-zero { color: var(--c-lock) !important; }
.scoreboard .is-total { background: #fff3c4; font-size: 24px; }
.scoreboard thead .is-total { background: var(--c-gold-deep); }
.scoreboard tr.is-win .is-total { box-shadow: inset 0 0 0 3px var(--c-gold); }

.result__note { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; }
.result__badge { padding: 2px 12px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font-weight: 900; font-size: 15px; }
.result__new { padding: 2px 12px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-red); color: #fff; font-weight: 900; transform: rotate(-4deg); }
.result__nearly {
  padding: 6px 14px; border: 3px dashed var(--c-ink); border-radius: var(--radius-s);
  background: var(--c-paper); font-size: 16px; font-weight: 900;
}
.result__nearly b { font: 900 22px var(--font-num); color: var(--c-red); }
.result__unlock { padding: 4px 14px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-mint); font-weight: 900; animation: pop-in .5s .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }
.result__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.result__actions .btn { padding: 10px 12px; font-size: 18px; }
.result__actions .btn--wide { grid-column: 1 / -1; }

/* ---------- 小さい画面 ---------- */
@media (max-height: 640px) {
  .title-art { width: 220px; }
  .rival-card { grid-template-columns: 72px 1fr; }
  .rival-card__pic, .rival-card__lock { width: 72px; height: 72px; }
  .tray__stone { width: 72px; }
  .tray__stone canvas { width: 44px; height: 44px; }
  .result { gap: 8px; }
  .result__art { display: none; }
  .stars--big .star { width: 40px; height: 40px; }
}
@media (max-width: 360px) {
  .btn { font-size: 17px; padding: 10px 18px; }
  .score-chip__name { display: none; }
  .tray__row { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .title-art canvas, .rival-card.is-next, .tray__hint { animation: none !important; }
}
