/* ---------- 結果（勝ち：盤の下 / 負け：カード内） ---------- */
#result {
  display: none;
  width: 100%;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: var(--panel);
  animation: resultIn .4s ease-out;
}
#dopaArea.has-result #result { display: block; }
@keyframes resultIn { from { opacity: 0; transform: translateY(10px); } }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.result-head .label { font-size: .75rem; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.result-head .diff { font-size: .72rem; font-weight: 800; padding: 2px 8px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: var(--muted); }
/* 称号は虹色の枠で囲む */
.title-badge {
  position: relative;
  padding: 10px 12px 9px;
  border-radius: 12px;
  text-align: center;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(90deg, #ff3b5c, #ff9f1a, #ffe11a, #36d36b, #1aa8ff, #7a5cff, #ff3bd4) border-box;
  border: 3px solid transparent;
}
.title-badge .name {
  font-family: "Dela Gothic One", "Hiragino Sans", sans-serif;
  font-size: clamp(20px, 6.4vw, 28px);
  line-height: 1.15;
  color: #fff;
}
.title-badge .why { margin-top: 4px; font-size: .78rem; color: var(--muted); }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.stat {
  padding: 6px 4px 5px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  text-align: center;
}
.stat .v { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .7rem; font-weight: 700; margin-left: 1px; color: var(--muted); }
.stat .k { margin-top: 2px; font-size: .68rem; color: var(--muted); }
.stat.best { box-shadow: inset 0 0 0 1px #ffd666; }
.stat.best .k::after { content: " 自己ベスト!"; color: #ffd666; font-weight: 800; }
/* シェアと事前登録（勝ち負けどちらでも同じ落ち着いた見た目） */
.share-btn, .prereg-btn {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.share-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 0;
  font-size: .95rem;
  letter-spacing: .08em;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.3);
}
.share-btn:disabled { opacity: .5; }
.prereg {
  margin-top: 10px;
  padding: 10px 10px 11px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,.22);
  text-align: center;
}
.prereg[hidden], .prereg-btn[hidden] { display: none; }
.prereg-lead { font-size: .9rem; font-weight: 800; }
.prereg-sub { margin-top: 2px; font-size: .72rem; color: var(--muted); }
.prereg-btns { display: flex; gap: 8px; margin-top: 8px; }
.prereg-btn {
  flex: 1;
  padding: 9px 0;
  font-size: .85rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.25);
}
.prereg-note { margin-top: 8px; font-size: .68rem; color: var(--muted); }
.prereg-note a { color: inherit; }
.share-btn:active, .prereg-btn:active { background: rgba(255,255,255,.18); }

/* 負けは質素に：称号の枠は灰色、自己ベストの金色だけは残す */
#result.lose .title-badge {
  background: linear-gradient(var(--panel), var(--panel)) padding-box, rgba(255,255,255,.18) border-box;
}
#result.lose .title-badge .name { color: var(--muted); }

/* ---------- 勝利表示（盤の上） ---------- */
#winLayer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  border-radius: 10px;
  background: rgba(12, 12, 16, .38);
}
#winLayer.show { display: flex; animation: winFade .3s ease-out; }
@keyframes winFade { from { opacity: 0; } }
.win-text {
  font-family: "Dela Gothic One", "Hiragino Sans", sans-serif;
  font-size: clamp(64px, 22vw, 116px);
  line-height: 1;
  letter-spacing: .02em;
  background: linear-gradient(90deg, #ff3b5c, #ff9f1a, #ffe11a, #36d36b, #1aa8ff, #7a5cff, #ff3bd4, #ff3b5c);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 2px var(--ink)) drop-shadow(0 0 2px var(--ink)) drop-shadow(5px 5px 0 var(--ink));
  animation: rainbow 2s linear infinite, winPop .5s cubic-bezier(.2, 1.6, .4, 1);
}
/* 負けの 敗北… は虹も影もなく、静かに出す */
#winLayer.lose { background: rgba(12, 12, 16, .55); }
#winLayer.lose .win-text {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 800;
  letter-spacing: .1em;
  background: none;
  color: var(--muted);
  filter: none;
  animation: winFade .4s ease-out;
}
@keyframes winPop {
  from { transform: scale(.3) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
.win-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: winFade .3s ease-out .35s backwards;
}
.win-actions .paper-btn { width: min(62vw, 240px); padding: 11px 0; font-size: 1.05rem; letter-spacing: .12em; padding-left: .12em; }
/* 盤面を見る（控えめな文字ボタン） */
.peek-btn, .peek-back {
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #fff;
  background: rgba(14, 14, 18, .75);
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.peek-back { display: none; position: absolute; top: 10px; right: 10px; }
/* 盤面を見ている間は、暗幕と結果を消して石だけを見せる */
#winLayer.peek { background: transparent; pointer-events: none; }
#winLayer.peek .win-text,
#winLayer.peek .win-actions { display: none; }
#winLayer.peek .peek-back { display: block; pointer-events: auto; }
