/* ドパチャイポ — visual skin.
 *
 * Cards are chai-po.com's: a solid suit-coloured tile with one big white rank
 * (spade grey / heart red / diamond blue / club green / joker purple, jester mark for JOKER).
 * Everything around them is VALORANT-flavoured tactical UI: near-black ground, hairline
 * geometry, cut corners, uppercase condensed type, red accent.
 *
 * Type: Anton for latin and numerals, Noto Sans JP (gothic) for Japanese. Anton has no kana
 * or kanji, so Japanese automatically falls through to the gothic stack.
 */

:root {
  /* --- ground & lines ------------------------------------------------- */
  --bg: #05070a;
  --panel: rgba(13, 17, 22, .82);
  --panel-2: rgba(20, 26, 33, .9);
  --hair: rgba(255, 255, 255, .13);
  --hair-2: rgba(255, 255, 255, .28);
  --grid: rgba(255, 255, 255, .045);

  /* --- ink ------------------------------------------------------------ */
  --text: #ece8e1;
  --dim: #8794a3;
  --dim-2: #5d6874;

  /* --- signal --------------------------------------------------------- */
  --accent: #ff4655;      /* valorant red: danger, opponent, SUDDEN DEATH */
  --accent-2: #00e5ff;    /* cyan: you, your clock, your placements */
  --gold: #ffcf5c;
  --good: #21d99a;
  --bad: #ff4655;

  /* --- cards (chai-po palette) ---------------------------------------- */
  --card-s: #505055;
  --card-h: #bd160e;
  --card-d: #283acb;
  --card-c: #08ac26;
  --card-joker: #6334a4;

  /* ボードに置いた札（現状維持） */
  --ch: clamp(26px, 6.1vh, 58px);
  --card-h-h: var(--ch);
  --card-w: calc(var(--ch) * .72);
  /* 自分の手札は大きく取る（焦っても誤タップしないため）。相手のボードは小さく。 */
  --tray-ch: clamp(48px, 9.2vh, 94px);
  --tray-w: calc(var(--tray-ch) * .72);
  --opp-ch: clamp(20px, 4.2vh, 38px);
  --opp-w: calc(var(--opp-ch) * .72);
  --shake: 8px;

  --font-display: 'Anton', 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  --font-ui: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Meiryo', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ============================ タッチのドラッグ&ドロップを成立させる要（実機不具合の修正）
 * 既定では、指を動かすとブラウザがスクロール／ピンチを始めてしまい、
 * pointermove が止まり pointercancel が飛ぶ = ドラッグが中断される。
 * 「自分がドラッグできるカード」だけ touch-action: none にして、
 * カード上で始まったジェスチャをブラウザに渡さない。
 * これで pointerdown → pointermove → pointerup が最後まで届く。
 * click は引き続き発火するので、タップでの選択・配置もそのまま使える。
 * 相手のボードのカードには付けない（#opponents のスクロールを潰さないため）。 */
.seat--mine .tray-card,
.seat--mine .playing-card.in-slot.editable,
.playing-card.ghost {
  touch-action: none;
}
.playing-card {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* 自分の席は確定ボタンを下端に固定するため内部スクロールを持つ。
   カード以外（余白）をなぞったときだけ縦スクロールさせ、
   カード上の指はドラッグとして扱う（touch-action は祖先との積で決まる）。 */
.seat--mine { touch-action: pan-y; }

html, body {
  margin: 0; height: 100%;
  background-color: var(--bg);
  /* black ground with a white geometric mesh: two hairline lattices + a soft top light */
  background-image:
    repeating-linear-gradient(60deg, var(--grid) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(-60deg, var(--grid) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 46px),
    radial-gradient(1200px 620px at 50% -12%, rgba(255,255,255,.075), transparent 62%),
    radial-gradient(760px 520px at 88% 108%, rgba(255,70,85,.10), transparent 60%);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  /* スマホで URL バーの伸縮やオーバースクロールで盤面がずれる／見切れるのを防ぐ */
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* a faint oversized chevron so the ground never reads as flat */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(115deg, transparent 49.7%, rgba(255,255,255,.05) 49.7% 50%, transparent 50%),
    linear-gradient(65deg, transparent 49.7%, rgba(255,255,255,.035) 49.7% 50%, transparent 50%);
  background-size: 340px 340px, 340px 340px;
  background-position: -60px -40px, 120px 60px;
  opacity: .8;
}

/* 100dvh = 実際に見えている高さ。100vh だとスマホの URL バーぶんはみ出して
   下の手札・確定ボタンが見切れる（実機で発生していた不具合の主因）。 */
#app {
  position: relative; z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  gap: 5px;
  touch-action: manipulation;
  overflow: hidden;
}
#app.shaking { animation: shake 380ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(calc(var(--shake) * -.25), 0, 0); }
  20%, 80% { transform: translate3d(calc(var(--shake) * .5), 0, 0); }
  30%, 50%, 70% { transform: translate3d(calc(var(--shake) * -.9), 0, 0); }
  40%, 60% { transform: translate3d(calc(var(--shake) * .9), 0, 0); }
}

/* ==================================================================== CARDS */
/* exactly the chai-po.com face: colour IS the suit, one big rank, no pips */

.playing-card {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--card-w); height: var(--card-h-h);
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1;
  padding: 0;
  position: relative;
  user-select: none;
  overflow: hidden;
  transition: transform 90ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.playing-card--s { background: var(--card-s); }
.playing-card--h { background: var(--card-h); }
.playing-card--d { background: var(--card-d); }
.playing-card--c { background: var(--card-c); }
.playing-card--joker { background: var(--card-joker); }

.playing-card .card-rank {
  font-size: calc(var(--card-h-h) * .62);
  letter-spacing: -.035em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.playing-card .card-rank--ten { transform: scaleX(.82); }
.playing-card .joker-mark { width: 74%; height: auto; }

/* face-down: opponent's tray */
.playing-card--back {
  background:
    repeating-linear-gradient(45deg, #14181f 0 6px, #1b212b 6px 12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}
.playing-card--back::after {
  content: '';
  width: 46%; height: 1px; background: var(--accent); opacity: .8;
  position: absolute; transform: rotate(-45deg);
}

.playing-card.tray-card { cursor: grab; }
.playing-card.tray-card:hover { transform: translateY(-5px); filter: brightness(1.12); }
.playing-card.tray-card.sel {
  transform: translateY(-9px);
  box-shadow: 0 0 0 2px var(--accent-2), 0 0 18px rgba(0, 224, 255, .55);
  z-index: 3;
}
.playing-card.ghost {
  position: fixed; z-index: 999; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-5deg);
  opacity: .95; box-shadow: 0 10px 28px rgba(0, 0, 0, .7);
}

/* ====================================================================== HUD */

#hud {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 200px) 1fr;
  gap: 12px;
  align-items: center;
  flex: 0 0 auto;
}
.hud-seat {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  position: relative;
  padding: 7px 10px 8px;
  background: var(--panel);
  border: 1px solid var(--hair);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}
.hud-seat[data-seat="1"] {
  align-items: flex-end;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
/* corner tick, the valorant tell */
.hud-seat::before {
  content: ''; position: absolute; left: 0; top: 0; width: 16px; height: 2px;
  background: var(--accent-2);
}
.hud-seat[data-seat="0"]::before { background: var(--accent); }
.hud-seat[data-out="1"] { opacity: .42; filter: grayscale(.7); }

.hud-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.hud-seat[data-seat="1"] .hud-line { flex-direction: row-reverse; }
.hud-name {
  font-family: var(--font-display);
  font-size: 14px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.badge {
  font-family: var(--font-display);
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  padding: 2px 7px; border: 1px solid var(--hair-2);
  color: var(--dim); white-space: nowrap; background: rgba(0, 0, 0, .35);
}
.badge-fl { border-color: #a06cff; color: #d9c2ff; background: rgba(99, 52, 164, .45); }
.badge-streak { border-color: var(--gold); color: #221800; background: var(--gold); }

.hp {
  position: relative; width: 100%; height: 20px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--hair);
  overflow: hidden;
}
.hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #00913f, var(--good));
  transition: width 240ms cubic-bezier(.2, .9, .2, 1), background 300ms;
}
.hud-seat[data-seat="1"] .hp-fill { background: linear-gradient(90deg, #0072a8, var(--accent-2)); }
.hud-seat[data-low="warn"] .hp-fill { background: linear-gradient(90deg, #a86b00, var(--gold)); }
.hud-seat[data-low="crit"] .hp-fill { background: linear-gradient(90deg, #7a0c17, var(--accent)); animation: hpPulse 700ms infinite; }
@keyframes hpPulse { 50% { filter: brightness(1.7); } }
.hp-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 14px; letter-spacing: .04em;
  text-shadow: 0 1px 3px #000;
}
.hud-seat.hurt { animation: hurt 520ms ease; }
.hud-seat.healed { animation: healed 620ms ease; }
@keyframes healed {
  0% { transform: translateY(0); }
  30% { transform: translateY(-3px); box-shadow: 0 0 22px rgba(33, 217, 154, .55); filter: brightness(1.3); }
  100% { transform: translateY(0); }
}
@keyframes hurt {
  0% { transform: translateX(0); }
  15% { transform: translateX(-9px); filter: brightness(2.4) saturate(.3); }
  40% { transform: translateX(7px); }
  70% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

/* per-seat hand clock: the opponent's bar shows who is about to blow up */
.hand-clock { width: 100%; height: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.hand-clock-fill { height: 100%; width: 0%; background: var(--accent-2); transition: width 90ms linear; }
.hud-seat[data-seat="0"] .hand-clock-fill { background: var(--accent); }
.hand-clock-fill[data-low="1"] { background: var(--gold); animation: tickPulse 380ms infinite; }
@keyframes tickPulse { 50% { filter: brightness(1.9); } }

.hud-score {
  display: flex; align-items: baseline; gap: 5px;
  font-size: 9px; letter-spacing: .14em; color: var(--dim-2); text-transform: uppercase;
}
.hud-score b { font-family: var(--font-display); font-size: 18px; color: var(--text); letter-spacing: .02em; }
.hud-score i { font-style: normal; }
.hud-score .sep { width: 1px; height: 10px; background: var(--hair); margin: 0 5px; }

#hud-center { display: flex; flex-direction: column; align-items: center; gap: 1px; }
#match-label { font-family: var(--font-display); font-size: 9px; letter-spacing: .3em; color: var(--dim-2); }
#match-clock {
  font-family: var(--font-display); font-size: 34px; line-height: 1;
  letter-spacing: .03em; color: var(--text);
}
#match-clock[data-low="1"] { color: var(--accent); animation: tickPulse 600ms infinite; }
#sudden {
  font-family: var(--font-display); font-size: 10px; letter-spacing: .2em;
  padding: 2px 10px; color: #fff; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 7px 100%);
  animation: warnBlink 480ms infinite;
}
@keyframes warnBlink { 50% { filter: brightness(1.5); } }

/* ==================================================================== TABLE */

#table {
  flex: 1 1 auto;
  display: grid; gap: 6px; min-height: 0; overflow: hidden;
  align-content: start;
  grid-template-rows: auto auto;
}
body[data-mode="local"] #table { grid-template-rows: 1fr 1fr; }

.seat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 5px 9px 6px;
  background: var(--panel);
  border: 1px solid var(--hair);
  min-height: 0; position: relative;
  max-width: 700px; width: 100%; margin-inline: auto;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  transition: box-shadow 180ms, border-color 180ms;
}
.seat[data-compact="1"] { --card-h-h: calc(var(--ch) * .74); --card-w: calc(var(--ch) * .74 * .72); }
body[data-mode="cpu"] .seat[data-seat="0"] { order: 0; }
body[data-mode="cpu"] .seat[data-seat="1"] { order: 1; }

.seat::before {
  content: ''; position: absolute; left: 0; top: 0; width: 26px; height: 2px; background: var(--hair-2);
}
.seat[data-seat-state="live"]::before { background: var(--accent-2); }
.seat[data-seat="0"][data-seat-state="live"]::before { background: var(--accent); }
.seat[data-seat-state="risk"] { border-color: rgba(255, 70, 85, .5); }
.seat[data-seat-state="risk"]::before { background: var(--accent); }
.seat[data-seat-state="foul"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 70, 85, .5); }
.seat.scored { animation: scored 620ms ease; }
@keyframes scored { 30% { box-shadow: inset 0 0 0 1px var(--gold); background: rgba(255, 207, 92, .07); } }
.seat.is-fast { border-color: rgba(255, 207, 92, .55); }
.seat.is-fast::before { background: var(--gold); }

/* the finished board is replaced instantly, so the score arrives as a tactical readout */
.hand-toast {
  position: absolute; right: 10px; top: 30px; z-index: 4;
  min-width: 186px; padding: 8px 10px 9px;
  background: rgba(6, 9, 13, .95);
  border: 1px solid var(--hair-2);
  border-left: 2px solid var(--gold);
  pointer-events: none; opacity: 0;
}
.hand-toast.in { animation: toastIn 200ms ease forwards; }
.hand-toast.out { animation: toastOut 240ms ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(10px); } }
.toast-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-family: var(--font-display); font-size: 10px; letter-spacing: .16em; color: var(--dim);
  padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--hair);
}
.toast-head b { font-size: 24px; color: var(--gold); letter-spacing: .02em; }
.toast-head.bad b { color: var(--accent); }
.toast-head i { font-style: normal; color: #c9a6ff; }
.toast-rows { display: flex; flex-direction: column; gap: 3px; }
.toast-row { display: grid; grid-template-columns: 16px 1fr auto; gap: 7px; font-size: 10px; align-items: baseline; }
.toast-row i { font-style: normal; color: var(--dim-2); }
.toast-row b { font-weight: 700; color: #cdd7e2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-row em { font-style: normal; font-family: var(--font-display); font-size: 12px; color: var(--gold); }
.hand-toast[data-bad="1"] { border-left-color: var(--accent); }
.hand-toast[data-bad="1"] .toast-head b { color: var(--accent); }
.toast-heal {
  margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--hair);
  font-family: var(--font-display); font-size: 11px; letter-spacing: .1em;
  color: var(--good); text-align: right;
}

.seat-head { display: flex; align-items: center; gap: 9px; font-size: 11px; }
.seat-name {
  font-family: var(--font-display); font-size: 13px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--text);
}
.seat-hand {
  font-family: var(--font-display); font-size: 11px; letter-spacing: .14em;
  color: var(--accent-2); padding: 1px 6px; border: 1px solid rgba(0, 229, 255, .35);
}
.seat[data-seat="0"] .seat-hand { color: var(--accent); border-color: rgba(255, 70, 85, .35); }
.seat-progress { font-family: var(--font-display); font-size: 11px; letter-spacing: .1em; color: var(--dim); }
.seat-fl {
  font-family: var(--font-display); font-size: 9px; letter-spacing: .14em;
  padding: 2px 8px; color: #fff; background: var(--card-joker);
  clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 100%, 6px 100%);
  animation: flGlow 1.1s infinite;
}
@keyframes flGlow { 50% { filter: brightness(1.4); } }
.seat-total {
  margin-left: auto; font-family: var(--font-display); font-size: 24px; letter-spacing: .02em;
  color: var(--gold); transition: transform 140ms;
}
.seat-total.is-foul { color: var(--accent); }

.board { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex; align-items: center; gap: 7px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, .035);
  border-left: 2px solid rgba(255, 255, 255, .12);
  transition: border-color 140ms, background 140ms;
}
.row[data-state="full"] { border-left-color: rgba(255, 255, 255, .38); }
.row.row-risk { border-left-color: var(--accent); background: rgba(255, 70, 85, .09); }
.row.drop { border-left-color: var(--accent-2); background: rgba(0, 229, 255, .1); }
.row.pop { animation: pop 260ms ease; }
@keyframes pop { 45% { transform: translateX(3px); filter: brightness(1.35); } }
.row-tag {
  width: 32px; flex: 0 0 32px;
  font-family: var(--font-display); font-size: 10px; letter-spacing: .08em;
  color: var(--dim-2); text-transform: uppercase;
}
.slots { display: flex; gap: 4px; flex-wrap: nowrap; }
.slot {
  width: var(--card-w); height: var(--card-h-h);
  border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .022);
  position: relative;
}
.slot::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 6px; height: 1px; background: rgba(255, 255, 255, .16);
}
.row-pts {
  margin-left: auto; min-width: 34px; text-align: right;
  font-family: var(--font-display); font-size: 14px; letter-spacing: .02em;
  color: var(--gold);
}

.seat-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* 手札が余白を吸収して、警告とボタンの塊を必ず右端に固定する。
   塊ごと折り返すことはあっても、「確定」だけが離れて落ちることはない。 */
.tray { display: flex; gap: 5px; min-height: var(--card-h-h); align-items: center; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.seat-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; flex-wrap: nowrap; }
.seat-actions .confirm-btn, .seat-actions .reset-btn { margin-left: 0; }
.tray.hidden-tray { opacity: .45; }
.tray.pop { animation: pop 300ms ease; }

/* fantasy land shows 14-17 cards at once: shrink the faces and let the tray wrap so every
   card stays on screen and the confirm button never gets pushed off the bottom */
.seat[data-fantasy="1"] { --card-h-h: calc(var(--ch) * .78); --card-w: calc(var(--ch) * .78 * .72); }
.seat[data-fantasy="1"] .tray { gap: 4px; }
.seat[data-fantasy="1"] .set-buttons { gap: 4px; }
.discard {
  width: calc(var(--card-w) * 1.05); height: var(--card-h-h);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: calc(var(--card-h-h) * .2);
  color: var(--dim);
  border: 1px solid var(--hair);
  background: rgba(255, 255, 255, .03);
  position: relative;
}
.discard::after {
  content: 'DISCARD'; position: absolute; left: 0; right: 0; bottom: 6px; text-align: center;
  font-family: var(--font-display); font-size: 7px; letter-spacing: .1em; color: var(--dim-2);
}
.discard span { transform: translateY(-4px); }
.seat-warn {
  font-family: var(--font-display); font-size: 11px; letter-spacing: .12em;
  color: #fff; background: var(--accent); padding: 4px 11px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 7px 100%);
  animation: warnBlink 560ms infinite;
}

/* placed-but-still-editable cards read as "grab me back" */
.playing-card.in-slot.editable {
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--accent-2), 0 0 8px rgba(0, 229, 255, .5);
}
.seat[data-seat="0"] .playing-card.in-slot.editable { box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(255, 70, 85, .5); }
.playing-card.tray-card.in-group { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(255, 207, 92, .6); }
.playing-card.ghost .ghost-count {
  position: absolute; right: -7px; top: -7px;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 12px; color: #201600;
  background: var(--gold); border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}

/* confirm button: the single pacing control */
.confirm-btn {
  margin-left: auto;
  font-family: var(--font-display); font-size: 15px; letter-spacing: .2em;
  padding: 7px 18px 8px; cursor: pointer; border: 1px solid var(--hair-2);
  color: var(--dim); background: rgba(255, 255, 255, .05);
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 100%, 9px 100%);
  transition: all 120ms;
}
.confirm-btn i { font-style: normal; font-family: var(--font-ui); font-size: 9px; letter-spacing: .06em; margin-left: 6px; opacity: .8; }
.confirm-btn.ready {
  color: #04122a; background: var(--accent-2); border-color: var(--accent-2);
  box-shadow: 0 0 22px rgba(0, 229, 255, .5);
  animation: confirmGlow 900ms infinite;
}
.seat[data-seat="0"] .confirm-btn.ready { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 22px rgba(255, 70, 85, .5); }
@keyframes confirmGlow { 50% { filter: brightness(1.25); } }
.confirm-btn[hidden] { display: none; }

/* RESET: いま配られたパケットの札を全部手札へ戻す。FLの13枚を1枚ずつ戻すのは無理なので用意。
 * 戻す札が無いときは淡く無効化するだけで、場所は動かさない（連打の指が迷わない）。 */
.reset-btn {
  font-family: var(--font-display); font-size: 13px; letter-spacing: .16em;
  padding: 7px 13px 8px; cursor: pointer; border: 1px solid var(--hair-2);
  color: var(--dim); background: rgba(255, 255, 255, .04);
  clip-path: polygon(9px 0, 100% 0, calc(100% - 9px) 100%, 0 100%);
  transition: all 120ms;
}
.reset-btn i {
  font-style: normal; font-family: var(--font-ui); font-size: 9px;
  letter-spacing: .06em; margin-left: 5px; opacity: .85;
}
.reset-btn:not(:disabled) { color: var(--gold); border-color: rgba(255, 207, 92, .5); background: rgba(255, 207, 92, .1); }
.reset-btn:not(:disabled):active { background: rgba(255, 207, 92, .24); transform: scale(.97); }
.reset-btn:disabled { opacity: .32; cursor: default; }
.reset-btn[hidden] { display: none; }
body[data-screen="game"][data-me-out="1"] #my-seat .reset-btn { display: none; }

/* FL toolbar: sort + hand-set quick-select */
.fl-tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 2px;
}
.fl-tools[hidden] { display: none; }
.sort-toggle { display: flex; align-items: center; gap: 4px; }
.sort-label { font-size: 9px; letter-spacing: .16em; color: var(--dim-2); margin-right: 2px; }
.sort-btn {
  font-family: var(--font-display); font-size: 10px; letter-spacing: .1em;
  padding: 3px 10px; cursor: pointer; color: var(--dim);
  border: 1px solid var(--hair); background: rgba(255, 255, 255, .03);
}
.sort-btn.on { color: #04122a; background: var(--accent-2); border-color: var(--accent-2); }
.set-buttons { display: flex; gap: 5px; flex-wrap: wrap; }
.set-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-ui); font-weight: 700; font-size: 11px;
  padding: 4px 9px; cursor: pointer; color: #c8d4ff;
  border: 1px solid var(--hair); background: rgba(255, 255, 255, .04);
}
.set-btn b { font-weight: 700; }
.set-btn i {
  font-style: normal; font-family: var(--font-display); font-size: 10px;
  color: var(--dim-2); min-width: 10px; text-align: center;
}
.set-btn:hover:not(:disabled) { border-color: var(--hair-2); background: rgba(255, 255, 255, .09); }
.set-btn.on { color: #201600; background: var(--gold); border-color: var(--gold); }
.set-btn.on i { color: #201600; }
.set-btn:disabled { opacity: .28; cursor: default; }

/* ================================================================ FX LAYER */

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 500; overflow: hidden; }

.fx-flash { position: absolute; inset: 0; animation: fxFlash linear forwards; }
@keyframes fxFlash { from { opacity: .95; } to { opacity: 0; } }

.fx-ring {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border: 3px solid var(--accent-2); border-radius: 50%;
  animation: fxRing 620ms cubic-bezier(.2, .8, .2, 1) forwards;
}
.fx-ring-place { border-color: rgba(255, 255, 255, .85); }
@keyframes fxRing { to { transform: scale(9); opacity: 0; } }

.fx-num {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: 38px; letter-spacing: .01em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .65), 0 0 22px currentColor;
  animation: fxNum 1300ms cubic-bezier(.2, .9, .2, 1) forwards;
  white-space: nowrap;
}
.fx-num-royalty { color: var(--gold); }
.fx-num-speed { color: var(--accent-2); font-size: 22px; }
.fx-num-heal { color: var(--good); font-size: 26px; text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 20px var(--good); }
.fx-num-damage { color: #ff7a86; }
.fx-num-big { color: #fff; font-size: 62px; text-shadow: 0 3px 0 #7a0c17, 0 0 34px var(--accent); }
.fx-num.fx-fly { animation: fxFly 1000ms cubic-bezier(.3, .8, .2, 1) forwards; }
@keyframes fxNum {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.4); }
  18% { opacity: 1; transform: translate(-50%, -60%) scale(1.18); }
  30% { transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(.92); }
}
@keyframes fxFly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1.1); }
}

.fx-banner {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  animation: bannerIn 240ms cubic-bezier(.2, 1.4, .3, 1) both;
}
.fx-banner.out { animation: bannerOut 320ms ease forwards; }
.fx-banner-title {
  font-family: var(--font-display); font-size: 54px; letter-spacing: .04em; line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .5), 0 0 34px currentColor;
}
.fx-banner-sub {
  font-family: var(--font-ui); font-weight: 900;
  font-size: 15px; color: rgba(255, 255, 255, .82); margin-top: 4px; letter-spacing: .1em;
}
.fx-banner-hand .fx-banner-title { font-size: 40px; color: #cfe6f2; }
.fx-banner-result .fx-banner-title { font-size: 28px; color: #d7e2ec; }
.fx-banner-foul .fx-banner-title { color: var(--accent); }
.fx-banner-break .fx-banner-title { color: var(--gold); font-size: 64px; }
.fx-banner-ko .fx-banner-title { color: #fff; font-size: 76px; text-shadow: 0 4px 0 #7a0c17, 0 0 44px var(--accent); }
.fx-banner-fl .fx-banner-title { color: #c9a6ff; font-size: 46px; }
.fx-banner-start .fx-banner-title { color: var(--accent-2); }
.fx-banner-combo .fx-banner-title { color: var(--gold); font-size: 34px; }
.fx-banner-heal .fx-banner-title { color: var(--good); font-size: 40px; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.62); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes bannerOut { to { opacity: 0; transform: translate(-50%, -70%) scale(.95); } }

.fx-confetti {
  position: absolute; top: -20px; width: 8px; height: 14px;
  animation: confetti linear forwards;
}
@keyframes confetti {
  to { transform: translateY(105vh) rotate(var(--spin, 360deg)); opacity: .9; }
}

/* ================================================================= OVERLAY */

#overlay {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
  background:
    repeating-linear-gradient(60deg, rgba(255,255,255,.035) 0 1px, transparent 1px 46px),
    radial-gradient(900px 600px at 50% 0%, rgba(255, 255, 255, .07), transparent 60%),
    rgba(3, 5, 8, .93);
  backdrop-filter: blur(6px);
  overflow: auto;
}
#overlay[hidden] { display: none; }

.panel {
  width: min(920px, 100%);
  padding: 26px 28px 24px;
  background: var(--panel-2);
  border: 1px solid var(--hair);
  position: relative;
  text-align: center;
  /* 中央寄せの flex 内で中身が画面より高くなると、上側がはみ出して
     スクロールでも到達できなくなる。margin:auto にすると余白が無いときは
     先頭に揃うので、長いリザルト（10人戦）でも上から読める。 */
  margin: auto;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%);
}
.panel::before {
  content: ''; position: absolute; left: 0; top: 0; width: 64px; height: 2px; background: var(--accent);
}

.logo { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.logo-jp {
  font-family: var(--font-ui); font-weight: 900;
  font-size: 44px; letter-spacing: .06em; color: var(--text);
}
.logo-en {
  font-family: var(--font-display); font-size: 13px; letter-spacing: .62em;
  color: var(--accent);
}
.tagline { color: var(--dim); font-size: 13px; margin: 4px 0 16px; }
.tagline b { color: var(--text); }

.rules-brief { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 14px; }
.rules-brief span {
  font-size: 11px; font-weight: 700; color: #c2ccd6;
  padding: 4px 10px; border: 1px solid var(--hair);
  background: rgba(255, 255, 255, .03);
}

.opt-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 9px 0; }
.opt {
  font-family: var(--font-display); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  padding: 9px 16px; cursor: pointer;
  color: var(--dim); background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hair);
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 8px 100%);
  transition: all 140ms;
}
.opt:hover { color: var(--text); border-color: var(--hair-2); background: rgba(255, 255, 255, .08); }
.opt.on {
  color: #fff; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 22px rgba(255, 70, 85, .4);
}
.cta {
  font-family: var(--font-display); font-size: 20px; letter-spacing: .22em; text-transform: uppercase;
  margin-top: 18px; padding: 15px 54px; cursor: pointer; border: 0;
  color: #fff; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 14px 100%);
  box-shadow: 0 0 40px rgba(255, 70, 85, .45);
  transition: transform 90ms, filter 90ms;
}
.cta:hover { filter: brightness(1.12); transform: translateY(-1px); }
.cta:active { transform: translateY(2px); }
.cta.ghost { background: rgba(255, 255, 255, .09); box-shadow: none; border: 1px solid var(--hair-2); }
.foot-note { margin-top: 14px; font-size: 11px; color: var(--dim-2); }
.foot-note b { color: var(--accent-2); }

.joker-note {
  font-size: 11px; color: var(--dim); margin: 10px auto 0; max-width: 600px; line-height: 1.7;
  padding: 9px 13px; background: rgba(255, 255, 255, .035);
  border-left: 2px solid var(--accent-2); text-align: left;
}
.joker-note b { color: var(--gold); }

.verdict {
  font-family: var(--font-display); font-size: 72px; line-height: 1;
  letter-spacing: .04em; color: var(--text);
}
.panel-result.win .verdict { color: var(--gold); animation: verdictIn 520ms cubic-bezier(.2, 1.5, .3, 1) both; }
.panel-result.podium .verdict { color: var(--text); }
.panel-result.lose .verdict { color: #7d8a97; }
.panel-result.draw .verdict { color: var(--dim); }
@keyframes verdictIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.verdict-sub {
  font-family: var(--font-display); color: var(--dim); font-size: 12px;
  letter-spacing: .22em; margin-bottom: 16px;
}
.res-table { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; }
.res-row {
  display: grid; grid-template-columns: 1.1fr repeat(8, 1fr) .8fr; gap: 6px; align-items: center;
  padding: 9px 13px; background: rgba(255, 255, 255, .04);
  border-left: 2px solid var(--hair); font-size: 12px; text-align: left;
}
.res-row.win { border-left-color: var(--gold); background: rgba(255, 207, 92, .07); }
.res-name { font-family: var(--font-display); font-size: 14px; letter-spacing: .12em; }
.res-cell i {
  display: block; font-style: normal; font-size: 9px; color: var(--dim-2); letter-spacing: .04em;
}
.res-cell b { font-family: var(--font-display); font-size: 17px; letter-spacing: .02em; }
.res-hp { font-family: var(--font-display); font-size: 17px; color: var(--gold); }
.res-best { font-size: 12px; color: var(--dim); margin-top: 6px; }
.res-best b { color: var(--gold); }

#hint {
  flex: 0 0 auto; text-align: center; font-size: 10px; color: var(--dim-2);
  letter-spacing: .04em;
}
#hint b { color: var(--accent-2); }
body[data-screen="title"] #hint, body[data-screen="result"] #hint { display: none; }

/* ============================================================== RESPONSIVE */

@media (max-width: 820px) {
  #hud { grid-template-columns: 1fr 104px 1fr; gap: 7px; }
  .hud-name { font-size: 11px; letter-spacing: .1em; }
  #match-clock { font-size: 26px; }
  .row-tag { width: 24px; flex-basis: 24px; font-size: 9px; }
  .seat-total { font-size: 19px; }
  .seat { max-width: none; }
  .logo-jp { font-size: 30px; }
  .fx-banner-title { font-size: 38px; }
  .res-row { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #app.shaking, .hud-seat.hurt, .fx-flash, .fx-confetti { animation: none !important; }
}

/* ==================================================================== v0.4
 * N人対戦（2〜10人）とスマホ最適化。上の旧2人用レイアウトを後勝ちで上書きする。
 *   #hud      : プレイヤー人数ぶんのチップ + 時計
 *   #table    : 相手ボード（compact・手札欄なし）＋ 自分の席（巨大な手札）
 * ======================================================================== */

/* ---------------------------------------------------------------- HUD (N人) */
#hud {
  display: flex; align-items: stretch; gap: 6px;
  flex: 0 0 auto; min-height: 0;
}
#hud-players {
  flex: 1 1 auto; min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 4px; align-content: start;
  max-height: 30vh;
  overflow-y: auto; overscroll-behavior: contain;
}
.hud-player {
  position: relative; min-width: 0;
  padding: 4px 7px 5px;
  background: var(--panel);
  border: 1px solid var(--hair);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
  transition: box-shadow 180ms, opacity 180ms, filter 180ms;
}
.hud-player::before {
  content: ''; position: absolute; left: 0; top: 0; width: 14px; height: 2px; background: var(--accent);
}
.hud-player[data-mine="1"] { border-color: rgba(0, 229, 255, .42); background: rgba(0, 58, 78, .3); }
.hud-player[data-mine="1"]::before { background: var(--accent-2); }
.hud-player[data-out="1"] { opacity: .46; filter: grayscale(.65); }
.hud-player .hud-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.hud-player .hud-name { font-size: 12px; letter-spacing: .1em; }
.hud-hp {
  margin-left: auto; font-family: var(--font-display); font-size: 16px; line-height: 1;
  letter-spacing: .02em;
}
.hud-player[data-low="warn"] .hud-hp { color: var(--gold); }
.hud-player[data-low="crit"] .hud-hp { color: var(--accent); animation: tickPulse 700ms infinite; }
.hud-player .hp { height: 9px; margin-top: 3px; }
.hud-player .hud-score { font-size: 8px; letter-spacing: .1em; margin-top: 2px; }
.hud-player .hud-score b { font-size: 13px; }
.badge-rank { border-color: var(--gold); color: #221800; background: var(--gold); }
.badge-rank[hidden] { display: none; }
.hud-player.hurt { animation: hurt 520ms ease; }
.hud-player.healed { animation: healed 620ms ease; }

#hud-center {
  flex: 0 0 auto; width: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 4px 6px;
  background: var(--panel); border: 1px solid var(--hair);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}
#match-clock { font-size: 27px; }

/* ------------------------------------------------------- TABLE：相手と自分 */
#table {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1 1 auto; min-height: 0; overflow: hidden;
}
#opponents {
  flex: 0 1 auto; min-height: 0;
  /* 相手に使う高さは最大でも全体の34%。自分のボードと手札に必ず場所を残す */
  max-height: 34%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 5px; align-content: start;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 2px;
}
#my-seat { flex: 1 1 auto; min-height: 0; display: flex; }

.seat--opp {
  --card-h-h: var(--opp-ch);
  --card-w: var(--opp-w);
  padding: 3px 7px 4px;
}
.seat--opp .row { padding: 1px 5px; gap: 5px; }
.seat--opp .row-tag { width: 22px; flex-basis: 22px; font-size: 8px; }
.seat--opp .slots { gap: 2px; }
.seat--opp .seat-total { font-size: 17px; }
.seat--opp .seat-head { gap: 6px; font-size: 10px; }
.seat--opp .seat-name { font-size: 12px; }
.seat--opp[data-out="1"] { opacity: .5; }
.seat--opp .seat-rank { font-size: 12px; }

.seat--mine {
  flex: 1 1 auto;
  max-width: 960px; width: 100%; margin-inline: auto;
  display: flex; flex-direction: column; gap: 4px;
  /* 極端に低い画面でも確定ボタンが必ず見えるよう、席の中だけスクロールさせ、
     フッター（手札＋確定）を下端に固定する */
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
}
.seat--mine > .board { flex: 0 0 auto; }
.seat--mine .seat-foot {
  margin-top: auto;
  position: sticky; bottom: 0; z-index: 2;
  padding: 4px 0 2px;
  background: linear-gradient(180deg, rgba(5, 7, 10, .72), rgba(5, 7, 10, .97) 55%);
}

/* 自分の手札は大きく（誤タップ防止）。--card-h-h を差し替えるだけで
   カード本体・ランク文字・スロットがまとめて拡大する。 */
.seat--mine .tray { --card-h-h: var(--tray-ch); --card-w: var(--tray-w); gap: 7px; }
.seat--mine[data-fantasy="1"] .tray {
  --card-h-h: calc(var(--tray-ch) * .66);
  --card-w: calc(var(--tray-ch) * .66 * .72);
  gap: 5px;
}
.tray.hidden-tray { display: none; }
.discard { width: calc(var(--tray-w) * 1.02); height: var(--tray-ch); }

/* 置いた札も「掴める」ことを見せる（タップ戻しは廃止してドラッグに統一） */
.playing-card.in-slot.editable { cursor: grab; }
.playing-card.in-slot.editable:active { cursor: grabbing; }
.playing-card.dragging { opacity: .28; }
.row.drop, .discard.drop, .tray.drop {
  border-color: var(--accent-2);
  background: rgba(0, 229, 255, .12);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, .5);
}

/* 各行が何と読まれているか（ハイ/ペア/3カード/スト/フラ/フルハウス/4カード/…）。
   スマホには hover が無く title が読めないので、ファウルの原因を画面で説明するのに要る。 */
.row-hand {
  font-size: 9px; letter-spacing: .04em; color: var(--dim-2);
  white-space: nowrap; margin-left: 6px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.row[data-state="full"] .row-hand { color: var(--dim); }
.seat--opp .row-hand { display: none; }
.row.row-risk .row-hand { color: var(--accent); }

/* 新しい版が配信されたことの通知。押すと再読み込みする。 */
.update-bar {
  position: fixed; left: 50%; top: calc(6px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%); z-index: 999;
  font-family: var(--font-ui); font-weight: 700; font-size: 12px;
  padding: 9px 16px; cursor: pointer; border: 0; color: #04122a;
  background: var(--accent-2); box-shadow: 0 6px 22px rgba(0, 0, 0, .55);
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 100%, 9px 100%);
  animation: updatePulse 1.4s infinite;
}
.update-bar b { margin-left: 8px; text-decoration: underline; }
@keyframes updatePulse { 50% { filter: brightness(1.25); } }

/* 脱落順位バッジ（10人戦の 10th, 9th, …） */
.seat-rank {
  font-family: var(--font-display); font-size: 15px; letter-spacing: .06em;
  color: var(--gold); padding: 0 6px; border: 1px solid rgba(255, 207, 92, .5);
}
.seat-rank[hidden] { display: none; }
.seat--opp[data-out="1"] .seat-rank { color: var(--gold); opacity: 1; }

/* 脱落後も盤面は眺められる（観戦） */
body[data-screen="game"][data-me-out="1"] #my-seat .confirm-btn { display: none; }

/* --------------------------------------------------------- メニュー（v0.4） */
.panel-menu { width: min(560px, 100%); }
.panel-menu .logo-jp { font-size: 38px; }
.menu-block { margin: 14px 0 0; text-align: left; }
.menu-label {
  font-family: var(--font-display); font-size: 10px; letter-spacing: .26em;
  color: var(--dim-2); text-transform: uppercase; margin-bottom: 6px;
}
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; }
.seg .opt { text-align: center; padding: 11px 6px; font-size: 13px; }
.seg.seg-4 .opt { font-size: 12px; letter-spacing: .06em; }
.field-row { display: flex; flex-direction: column; gap: 6px; }
.text-input {
  width: 100%; font-family: var(--font-ui); font-size: 15px; font-weight: 700;
  padding: 11px 12px; color: var(--text);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--hair-2);
  border-radius: 0; outline: none;
}
.text-input:focus { border-color: var(--accent-2); background: rgba(0, 229, 255, .07); }
.text-input::placeholder { color: var(--dim-2); font-weight: 500; }
.text-input.bad { border-color: var(--accent); background: rgba(255, 70, 85, .1); }
.room-code { font-family: var(--font-display); letter-spacing: .32em; text-transform: uppercase; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn-row .opt { padding: 13px 8px; }

.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row .tick {
  font-family: var(--font-display); font-size: 11px; color: var(--dim-2); white-space: nowrap;
}
input[type="range"].joker-range {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; height: 26px; background: transparent; cursor: pointer;
}
input[type="range"].joker-range::-webkit-slider-runnable-track {
  height: 4px; background: linear-gradient(90deg, var(--accent-2), var(--hair-2));
}
input[type="range"].joker-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--accent-2); border: 2px solid #04122a;
  box-shadow: 0 0 14px rgba(0, 229, 255, .7);
}
input[type="range"].joker-range::-moz-range-track { height: 4px; background: var(--hair-2); }
input[type="range"].joker-range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #04122a;
  background: var(--accent-2);
}
.slider-val { font-family: var(--font-display); font-size: 18px; color: var(--accent-2); min-width: 56px; text-align: right; }

.menu-note { font-size: 11px; color: var(--dim); margin-top: 7px; line-height: 1.6; }
.menu-note b { color: var(--gold); }

.rules-btn {
  margin-top: 12px; width: 100%;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
  padding: 11px; cursor: pointer; color: #c2ccd6;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--hair-2);
}
.rules-btn:hover { color: var(--text); background: rgba(255, 255, 255, .09); }

/* ルール説明は全面レイヤー（メニューの上半分を占めていた説明をここへ移した） */
.panel-rules { width: min(760px, 100%); text-align: left; max-height: 88dvh; overflow-y: auto; }
.panel-rules h2 {
  font-family: var(--font-display); font-size: 22px; letter-spacing: .16em;
  margin: 0 0 4px; color: var(--text);
}
.rules-sec { margin-top: 16px; }
.rules-sec h3 {
  font-family: var(--font-ui); font-weight: 900; font-size: 13px;
  color: var(--accent-2); margin: 0 0 7px; letter-spacing: .04em;
}
.rules-sec ul { margin: 0; padding-left: 18px; }
.rules-sec li { font-size: 12.5px; line-height: 1.85; color: #c2ccd6; }
.rules-sec li b { color: var(--text); }
.rules-sec li em { font-style: normal; color: var(--gold); }
.rules-tbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.rules-tbl th, .rules-tbl td {
  font-size: 12px; padding: 5px 8px; border-bottom: 1px solid var(--hair); text-align: left;
}
.rules-tbl th { color: var(--dim-2); font-weight: 700; }
.rules-tbl td { font-family: var(--font-display); letter-spacing: .04em; }

/* ------------------------------------------------------------ ロビー（友人戦） */
.panel-lobby { width: min(560px, 100%); }
.lobby-players { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; }
.lobby-slot {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; background: rgba(255, 255, 255, .04);
  border-left: 2px solid var(--hair); font-size: 13px;
}
.lobby-slot.filled { border-left-color: var(--accent-2); }
.lobby-slot.me { border-left-color: var(--gold); background: rgba(255, 207, 92, .07); }
.lobby-slot .who { font-family: var(--font-display); letter-spacing: .1em; }
.lobby-slot .tag { margin-left: auto; font-size: 10px; color: var(--dim-2); letter-spacing: .1em; }
.room-share {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: rgba(255, 255, 255, .035); border-left: 2px solid var(--accent-2);
}
.room-share .k { font-size: 10px; letter-spacing: .18em; color: var(--dim-2); }
.room-share .v { font-family: var(--font-display); font-size: 17px; letter-spacing: .18em; }
.room-share .url {
  flex: 1 1 100%; font-size: 11px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn {
  font-family: var(--font-ui); font-weight: 700; font-size: 11px;
  padding: 7px 12px; cursor: pointer; color: #04122a;
  background: var(--accent-2); border: 0;
}
.copy-btn.ghost { background: rgba(255, 255, 255, .1); color: var(--text); border: 1px solid var(--hair-2); }
.wait-note { font-size: 12px; color: var(--dim); margin-top: 10px; }
.wait-note b { color: var(--accent-2); }
.net-status {
  position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%);
  z-index: 900; font-size: 11px; padding: 4px 12px;
  background: rgba(6, 9, 13, .92); border: 1px solid var(--hair-2); color: var(--dim);
}
.net-status[hidden] { display: none; }

/* ------------------------------------------------------- 開始前カウントダウン
 * 3・2・1 の数字を画面中央に大きく出す。試合時計はこの間 0 で止まっているので、
 * 「カウントダウンが終わってから配牌」になる（操作も確定も受け付けない）。 */
#countdown {
  position: fixed; left: 50%; top: 56%; transform: translate(-50%, -50%);
  z-index: 850; pointer-events: none;
  font-family: var(--font-display); font-weight: 400; line-height: .88;
  font-size: clamp(112px, 34vw, 230px); color: #fff; letter-spacing: .02em;
  text-shadow: 0 0 52px rgba(255, 70, 85, .9), 0 0 14px rgba(255, 255, 255, .5),
               0 12px 36px rgba(0, 0, 0, .8);
}
#countdown[hidden] { display: none; }
/* 数字の周りだけ軽く暗くして視線を集める（盤面は見えたまま） */
#countdown::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(circle at 50% 52%,
              rgba(5, 7, 10, .66), rgba(5, 7, 10, .22) 42%, rgba(5, 7, 10, 0) 68%);
}
#countdown.cd-go {
  color: var(--gold); font-size: clamp(86px, 27vw, 190px);
  text-shadow: 0 0 60px rgba(255, 207, 92, .95), 0 0 16px rgba(255, 255, 255, .6),
               0 12px 36px rgba(0, 0, 0, .8);
}
#countdown.pop { animation: cdPop .52s cubic-bezier(.2, 1.5, .35, 1); }
@keyframes cdPop {
  0%   { transform: translate(-50%, -50%) scale(.5); opacity: .15; }
  55%  { transform: translate(-50%, -50%) scale(1.14); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #countdown.pop { animation: none; }
}

/* ------------------------------------------------------------ リザルト（順位） */
.res-row { grid-template-columns: .55fr 1.05fr repeat(8, 1fr) .8fr; }
.res-rank {
  font-family: var(--font-display); font-size: 19px; letter-spacing: .04em; color: var(--dim);
}
.res-row.win .res-rank { color: var(--gold); }
.res-row.me { background: rgba(0, 229, 255, .08); border-left-color: var(--accent-2); }
.res-row.out { opacity: .62; }
.panel-result.win .verdict { color: var(--gold); font-size: 84px; text-shadow: 0 0 40px rgba(255, 207, 92, .5); }
.rank-line {
  font-family: var(--font-display); font-size: 30px; letter-spacing: .1em; color: var(--text);
  margin: 2px 0 10px;
}
.rank-line b { color: var(--gold); }

/* -------------------------------------------------------------- レスポンシブ */
@media (max-width: 820px) {
  #hud { flex-direction: column; gap: 5px; }
  #hud-center { width: 100%; flex-direction: row; gap: 10px; padding: 3px 8px; }
  #match-clock { font-size: 22px; }
  #match-label { margin-left: auto; }
  #overtime-badge { margin-left: 0; }
  #hud-players { max-height: 76px; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .hud-player .hud-score { display: none; }
  /* スマホでは相手を極小のミニボードにして、そのぶん自分の手札を大きく取る */
  #opponents { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); max-height: 32%; gap: 3px; }
  .seat--opp { --opp-ch: clamp(15px, 2.6vh, 26px); padding: 2px 4px 3px; }
  .seat--opp .row-tag, .seat--opp .seat-progress, .seat--opp .seat-hand { display: none; }
  .seat--opp .row { padding: 1px 3px; gap: 3px; }
  .seat--opp .slots { gap: 1px; }
  .seat--opp .row-pts { min-width: 18px; font-size: 11px; }
  .seat--opp .seat-total { font-size: 13px; }
  .seat--opp .seat-head { gap: 4px; font-size: 9px; }
  .seat--opp .seat-name { font-size: 10px; letter-spacing: .06em; }
  .seat--opp .seat-rank { font-size: 11px; padding: 0 4px; }
  .seat--mine { max-width: none; }
  #hint { display: none; }
  .panel { padding: 18px 14px 16px; }
  .logo-jp { font-size: 26px; }
  .seg .opt { padding: 10px 4px; font-size: 12px; }
  .btn-row { grid-template-columns: 1fr; }
  /* リザルト: 1人1行に畳む（順位・名前・完走ハンド・残りライフ）。10人戦でも縦に収まる。 */
  .panel-result { padding: 16px 12px 14px; }
  .panel-result .verdict { font-size: 46px; }
  .panel-result.win .verdict { font-size: 52px; }
  .verdict-sub { font-size: 10px; letter-spacing: .14em; margin-bottom: 10px; }
  .res-table { gap: 3px; margin: 8px 0; }
  .res-row { grid-template-columns: .62fr 1.25fr 1fr auto; gap: 5px; padding: 7px 9px; font-size: 11px; }
  .res-row .res-cell:nth-child(n+4) { display: none; }
  .res-row .res-hp { display: block; font-size: 14px; }
  .res-rank { font-size: 16px; }
  .res-name { font-size: 12px; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .res-cell b { font-size: 15px; }
  .res-best { font-size: 11px; }
}
