/* ================= v51: character & reference-UI overlay =================
   The 3D table (three.js scene) is untouched. Everything in
   this block is DOM laid OVER the stage — and the same layer
   serves the 2D board, whose heads / centre are rebuilt with
   the same plate markup. */
/* ---------- top bar: MENU / 東南戦 東○局 / 鳴き ---------- */
.topbar.refbar {
  background: linear-gradient(180deg, #3d3d42, #17181b);
  border: 1px solid rgba(0,0,0,.75); border-radius: 10px;
  padding: 5px 6px; gap: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.45);
  align-items: stretch;
}
.btn-orange {
  font: inherit; font-weight: 900; cursor: pointer; color: #fff8e6;
  background: linear-gradient(180deg, #ffb03a, #f06400);
  border: 1.5px solid #7a2d00; border-radius: 8px;
  text-shadow: 0 1px 2px rgba(90,30,0,.75);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 2px 6px rgba(0,0,0,.4);
  min-height: 38px; padding: 4px 15px; font-size: 15px; letter-spacing: .06em; white-space: nowrap;
}
.topbar .round-title {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  font-family: "Shippori Mincho B1", serif; font-weight: 800;
  font-size: clamp(15px, 4.4vw, 21px); color: #fff; letter-spacing: .08em; white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0,0,0,.85);
}
.naki-toggle.refskip {
  background: linear-gradient(180deg, #ffb03a, #f06400);
  border: 1.5px solid #7a2d00; border-radius: 8px; color: #fff8e6;
  text-shadow: 0 1px 2px rgba(90,30,0,.75);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 2px 6px rgba(0,0,0,.4);
  min-height: 38px; padding: 4px 12px; font-size: 14px; gap: 7px;
}
.naki-toggle.refskip .state {
  background: rgba(60,20,0,.55); color: #ffe9a8; border-radius: 4px;
  padding: 0 6px; font-size: 11px; line-height: 1.8; min-width: 0; text-shadow: none;
}
.naki-toggle.refskip.on {
  background: linear-gradient(180deg, #ffcf5e, #ff8a00);
  border-color: #ffd34d; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 0 12px rgba(255,170,40,.65);
}
.naki-toggle.refskip.on .state { background: #7a2d00; color: #ffd34d; }
.naki-toggle.refskip.auto {
  background: linear-gradient(180deg, #35c79e, #0d7a5f);
  border-color: #0a5c47; color: #eafff7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 12px rgba(40,200,160,.55);
}
.naki-toggle.refskip.auto .state { background: #063f31; color: #8ff5d2; }
.subbar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 0 2px 6px; }
.subbar .lbl { font-size: 11px; font-weight: 900; color: var(--ink-dim); }
.subbar .seg button { min-height: 26px; font-size: 11.5px; padding: 1px 9px; }

/* ---------- character plates (face + navy plate) ---------- */
.char-plate { display: flex; align-items: center; gap: 7px; pointer-events: none; }
.char-face {
  width: 50px; height: 55px; border-radius: 10px; object-fit: cover; object-position: 50% 6%;
  background: #0b5a34; flex: 0 0 auto;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.5));
  /* the green bust-up melts into the felt at its lower edge */
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent 98%);
  mask-image: linear-gradient(180deg, #000 78%, transparent 98%);
}
.plate-body {
  display: inline-flex; flex-direction: column; gap: 1px;
  background: linear-gradient(180deg, #2e5f8a 0%, #173d5e 45%, #0d2742 100%);
  border: 1.5px solid #6fb3d8; border-radius: 7px; padding: 3px 9px 4px; min-width: 118px;
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.35); color: #fff;
}
.plate-top { display: flex; align-items: center; gap: 6px; }
.wind-badge {
  background: linear-gradient(180deg, #e0483e, #a4161a); color: #fff; font-weight: 900; font-size: 11.5px;
  border: 1px solid rgba(255,255,255,.55); border-radius: 4px; padding: 0 5px; line-height: 1.65;
  white-space: nowrap; font-family: "Shippori Mincho B1", serif;
}
.plate-name { font-weight: 900; font-size: 14.5px; letter-spacing: .05em; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.65); }
.plate-tag { font-size: 10px; font-weight: 900; border-radius: 3px; padding: 1px 5px; line-height: 1.5; white-space: nowrap; }
.plate-tag.oya { background: #ffd34d; color: #241a02; }
.plate-tag.ri { background: var(--accent); color: #fff; }
.plate-sub { display: flex; align-items: baseline; gap: 7px; }
.plate-rank { font-size: 11.5px; font-weight: 900; color: #ffd34d; white-space: nowrap; }
.plate-score { font-size: 15.5px; font-weight: 900; font-variant-numeric: tabular-nums; color: #fff; white-space: nowrap; }
.plate-score small { font-size: 10.5px; font-weight: 700; margin-left: 1px; }
.char-plate.turn .plate-body {
  border-color: #ffd34d;
  box-shadow: 0 0 0 1.5px #ffd34d, 0 0 18px rgba(255,211,77,.8), inset 0 1px 0 rgba(255,255,255,.35);
}
.char-plate.turn .char-face { filter: drop-shadow(0 0 7px rgba(255,211,77,.95)); }
/* 3D stage: one plate per seat, on that seat's own side */
#seatPlates { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.char-plate.abs { position: absolute; }
.char-plate.pos2 { top: 8px; left: 50%; transform: translateX(-50%); }
.char-plate.pos1 { right: 8px; top: 40%; flex-direction: row-reverse; }
.char-plate.pos3 { left: 8px; top: 40%; }
.char-plate.pos0 { left: 10px; bottom: 10px; }
/* 2D board: the same plates in flow */
.opp-head.char-plate { margin-bottom: 5px; min-height: 0; }
.opp-head.char-plate.turn-glow { background: none; box-shadow: none; padding: 0; margin-left: 0; margin-right: 0; }
.b-bottom .opp-head.char-plate { margin-top: 6px; margin-bottom: 0; }
.seat-side { width: 102px; }
.seat-side .char-plate { flex-direction: column; align-items: flex-start; gap: 4px; }
.seat-side .plate-body { min-width: 0; }
.seat-side .char-face { width: 44px; height: 48px; }

/* ---------- centre panel (dora / wall count / sticks) ---------- */
.center-info.v51, #hudCenter.v51 {
  background: rgba(6,20,38,.88); border: 1.5px solid rgba(140,190,230,.6); border-radius: 10px;
  box-shadow: inset 0 0 14px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.35);
  color: #eaf3fb;
}
.center-info.v51 { min-height: 0; padding: 10px 8px; gap: 3px; }
#hudCenter.v51 {
  flex-direction: column; align-items: center; gap: 2px;
  top: 29%; padding: 6px 14px 7px; pointer-events: none;
}
.cp-dora { display: flex; align-items: center; gap: 3px; }
.cp-lbl { font-size: 10.5px; font-weight: 900; color: #9fc6e8; margin-right: 2px; white-space: nowrap; }
.cp-left { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.cp-left b {
  font-size: 27px; font-weight: 900; color: #ffd94d; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 5px rgba(0,0,0,.7); margin: 0 2px; line-height: 1;
}
.cp-sticks { display: flex; gap: 10px; font-size: 11px; font-weight: 700; color: #cfe2f2; white-space: nowrap; }
#hudRound { display: none; } /* the round now lives in the top bar */

/* thought bubbles sit by the speaker's face plate (3D stage) */
#cpuBubble.bub2 { top: 82px; }
#cpuBubble.bub1 { top: 50%; }
#cpuBubble.bub3 { top: 50%; }

/* ---------- big call + face cut-in ---------- */
#callCutin { position: fixed; inset: 0; z-index: 44; pointer-events: none; display: none; overflow: hidden; }
#callCutin.show { display: block; }
.cutin-wrap { position: absolute; animation: cutinfade 1.15s ease-out forwards; }
/* v60: the face is half its old size (190px -> 95px, phone
   140px -> 70px) — it read as overbearing next to the call
   text. The big call text, the anchor positions and the
   1.15s timing are unchanged; only the centring margins move
   with the new width. */
.cutin-wrap.s2 { top: 4%; left: 50%; margin-left: -47.5px; }
.cutin-wrap.s0 { bottom: 10%; left: 50%; margin-left: -47.5px; }
.cutin-wrap.s1 { right: 3%; top: 26%; }
.cutin-wrap.s3 { left: 3%; top: 26%; }
.cutin-face {
  display: block; width: 95px; max-width: 22vw; aspect-ratio: 190 / 218;
  object-fit: cover; object-position: 50% 6%;
  border-radius: 10px; border: 2.5px solid rgba(255,255,255,.9);
  box-shadow: 0 16px 44px rgba(0,0,0,.65);
  -webkit-mask-image: linear-gradient(180deg, #000 84%, transparent 99%);
  mask-image: linear-gradient(180deg, #000 84%, transparent 99%);
  animation: cutinzoom 1.15s cubic-bezier(.16,1.3,.3,1) forwards;
}
@keyframes cutinfade { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cutinzoom { 0% { transform: scale(.55); } 16% { transform: scale(1.06); } 30% { transform: scale(1); } 100% { transform: scale(1.03); } }
.cutin-text {
  position: absolute; left: 50%; top: 43%; transform: translate(-50%,-50%) rotate(-3deg);
  font-family: "Shippori Mincho B1", serif; font-weight: 800; white-space: nowrap;
  font-size: clamp(62px, 16.5vw, 124px); letter-spacing: .03em;
  -webkit-text-stroke: 3px rgba(255,255,255,.95);
  animation: cutintext 1.15s cubic-bezier(.16,1.4,.3,1) forwards;
}
@keyframes cutintext {
  0% { transform: translate(-50%,-50%) rotate(-8deg) scale(.25); opacity: 0; }
  15% { transform: translate(-50%,-50%) rotate(1.5deg) scale(1.18); opacity: 1; }
  28% { transform: translate(-50%,-50%) rotate(-3deg) scale(1); }
  80% { transform: translate(-50%,-50%) rotate(-3deg) scale(1.03); opacity: 1; }
  100% { transform: translate(-50%,-56%) rotate(-3deg) scale(1.06); opacity: 0; }
}
.cutin-text.k-riichi { color: #ff8a00; text-shadow: 0 5px 0 #a33d00, 0 12px 32px rgba(0,0,0,.65), 0 0 44px rgba(255,150,30,.55); }
.cutin-text.k-ron { color: #e60012; text-shadow: 0 5px 0 #7c0d12, 0 12px 32px rgba(0,0,0,.65), 0 0 44px rgba(255,60,40,.5); }
.cutin-text.k-tsumo { color: #ffd34d; text-shadow: 0 5px 0 #8a6a10, 0 12px 32px rgba(0,0,0,.65), 0 0 48px rgba(255,211,77,.75); }
.cutin-text.k-pon { color: #ffcf3f; text-shadow: 0 5px 0 #8a5c00, 0 12px 32px rgba(0,0,0,.65); }
.cutin-text.k-chi { color: #8fe388; text-shadow: 0 5px 0 #1e6b2f, 0 12px 32px rgba(0,0,0,.65); }
.cutin-text.k-kan { color: #6fc3ff; text-shadow: 0 5px 0 #144a7a, 0 12px 32px rgba(0,0,0,.65); }
/* while the cut-in is up, the stage's own fx text steps aside
   (its flash / burst / jingle still play) so the call reads once */
body.cutin-on #fxLayer .fx-big, body.cutin-on #winCall2d .fx-big { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .cutin-face, .cutin-wrap, .cutin-text { animation-duration: .4s; }
}
@media (max-width: 560px) {
  .btn-orange { min-height: 34px; padding: 3px 11px; font-size: 13.5px; }
  .naki-toggle.refskip { min-height: 34px; padding: 3px 9px; font-size: 12.5px; }
  .naki-toggle.refskip .state { font-size: 10px; }
  .char-face { width: 40px; height: 44px; }
  .seat-side { width: 86px; }
  .seat-side .char-face { width: 38px; height: 42px; }
  .plate-body { min-width: 96px; padding: 2px 7px 3px; }
  .plate-name { font-size: 12.5px; }
  .plate-score { font-size: 13.5px; }
  .wind-badge { font-size: 10.5px; }
  .char-plate.pos1 { top: 36%; }
  .char-plate.pos3 { top: 36%; }
  .char-plate.pos0 { left: 6px; bottom: 6px; }
  #hudCenter.v51 { top: 26%; padding: 4px 10px 5px; }
  .cp-left b { font-size: 23px; }
  #cpuBubble.bub2 { top: 66px; }
  .cutin-face { width: 70px; }
  .cutin-wrap.s2, .cutin-wrap.s0 { margin-left: -35px; }
}
