/* ============ 基本 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b2547 0%, transparent 60%),
    radial-gradient(900px 500px at 80% 110%, #241a3d 0%, transparent 55%),
    #0b1020;
  color: #e8ecf4;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

.screen {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

/* ============ ボタン ============ */
.btn {
  display: block;
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  transition: transform .1s, filter .15s;
  text-align: center;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.big { width: min(320px, 86vw); padding: 16px 12px; font-size: 17px; margin: 8px 0; }
.btn.small { padding: 9px 16px; font-size: 14px; border-radius: 10px; }
.btn.tiny { padding: 5px 12px; font-size: 12px; border-radius: 8px; margin-left: 10px; }
.btn.gold {
  background: linear-gradient(160deg, #ffe9a3, #f5c542 45%, #d99b1e);
  color: #3a2a05;
  box-shadow: 0 4px 18px rgba(245, 197, 66, .35), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn.blue {
  background: linear-gradient(160deg, #7fb1ff, #3f7ae8 50%, #2a55b8);
  color: #fff;
  box-shadow: 0 4px 18px rgba(63, 122, 232, .35), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn.ghost {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.18);
  color: #cfd8ea;
}
.icon-btn {
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
}
.icon-btn:active { transform: scale(.9); }

/* ============ フォーム ============ */
.scr-h { font-size: 22px; margin-bottom: 14px; letter-spacing: .1em; }
.panel {
  width: min(340px, 90vw);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
}
.form-label { display: block; font-size: 13px; color: #9fb0cc; margin: 12px 0 6px; }
.form-label:first-child { margin-top: 0; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.14);
  color: #b9c6dd;
  font-size: 14px;
  font-weight: 700;
}
.seg button.on {
  background: linear-gradient(160deg, #ffe9a3, #f5c542);
  color: #3a2a05;
  border-color: #f5c542;
}
.text-input, .num-input {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.3);
  color: #fff;
  font-size: 16px;
}
.hint { font-size: 12px; color: #8494b3; margin-top: 10px; line-height: 1.7; text-align: center; }
.status { margin-top: 12px; font-size: 13px; color: #f5c542; min-height: 1.4em; text-align: center; }

/* ============ タイトル ============ */
.title-box { text-align: center; display: flex; flex-direction: column; align-items: center; }
.title-gems { display: flex; gap: 14px; margin-bottom: 18px; }
.title-gems .tg { width: 52px; height: 52px; filter: drop-shadow(0 0 14px currentColor); animation: floatGem 3s ease-in-out infinite; }
.tg1 { color: #4d8df0; } .tg1 polygon { fill: #4d8df0; stroke: #a8c8ff; stroke-width: 1; }
.tg2 { color: #f0524d; animation-delay: .5s !important; } .tg2 polygon { fill: #e8453f; stroke: #ffb3b0; stroke-width: 1; }
.tg3 { color: #31c26a; animation-delay: 1s !important; } .tg3 polygon { fill: #2bb567; stroke: #a5f0c5; stroke-width: 1; }
@keyframes floatGem { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.game-title {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 34px;
  letter-spacing: .12em;
  background: linear-gradient(180deg, #fff6d8, #f5c542 60%, #c98f18);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(245,197,66,.25);
}
.game-sub { color: #8494b3; letter-spacing: .5em; font-size: 13px; margin: 8px 0 26px; }

/* ============ ロビー ============ */
.lobby-word { font-size: 14px; color: #9fb0cc; margin-bottom: 10px; text-align: center; }
.lobby-word b { color: #f5c542; font-size: 16px; letter-spacing: .06em; }
.lobby-p {
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 15px;
  animation: pop .25s ease-out;
}
.lobby-p.empty { color: #5a6885; background: rgba(255,255,255,.02); border-style: dashed; }
.lobby-p.dis { opacity: .5; }
.me-tag {
  font-size: 11px;
  background: #f5c542;
  color: #3a2a05;
  border-radius: 6px;
  padding: 1px 6px;
  font-weight: 700;
}
.dis { color: #f0524d; font-size: 11px; }

/* ============ ゲーム画面レイアウト ============ */
#scr-game { padding: 0; justify-content: flex-start; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

#game-scroll {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 6px 8px 2px;
  padding-top: max(6px, env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* SVGアイコン */
.ico { width: 1em; height: 1em; fill: currentColor; vertical-align: -0.12em; }
.ico-crown { fill: #f5c542; }
.ico-crown .jewel { fill: #fff3c4; }
.ico-gold { fill: #f5c542; width: 22px; height: 22px; }

#top-row { display: flex; gap: 6px; align-items: stretch; }
#btn-menu {
  flex: 0 0 40px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: #cfd8ea;
  display: flex;
  align-items: center;
  justify-content: center;
}
#btn-menu .ico { width: 20px; height: 20px; }
#btn-menu:active { transform: scale(.92); }
/* 手番の順番バッジ（名前の前） */
.ord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(245,197,66,.18);
  border: 1px solid rgba(245,197,66,.45);
  color: #ffe9a3;
  font-size: 9px;
  font-weight: 800;
  margin-right: 3px;
  flex-shrink: 0;
  vertical-align: -2px;
}
.cpu-tag {
  font-size: 9px;
  background: #5a6885;
  color: #fff;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
  font-weight: 700;
  vertical-align: middle;
}

/* ============ 相手パネル（コンパクト2行） ============ */
#opponents { display: flex; gap: 6px; flex: 1; min-width: 0; }
.opp {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 3px 7px;
  transition: border-color .3s, box-shadow .3s;
}
.opp-main { flex: 1; min-width: 0; }
/* 確保したてのカード表示（1周回るまで） */
.card.micro { width: 27px; animation: pop .3s ease-out; flex: 0 0 auto; }
.card.micro .card-cost { display: none; }
.card.micro .card-top { padding: 1px 2px; }
.card.micro .card-pts { font-size: 10px; }
.card.micro .card-gem { width: 9px; height: 9px; }
.card.micro.back .back-lv { font-size: 10px; }
.card.micro.back .back-deco { font-size: 7px; }
.opp.active {
  border-color: #f5c542;
  box-shadow: 0 0 12px rgba(245,197,66,.35);
  background: rgba(245,197,66,.08);
}
.opp-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.opp-name { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.opp-pts { font-size: 15px; font-weight: 900; color: #f5c542; flex-shrink: 0; }
.opp-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-height: 15px;
}
.opp-bon { display: flex; gap: 2px; flex-wrap: nowrap; overflow: hidden; min-width: 0; }
.opp .bon-chip { min-width: 13px; height: 13px; font-size: 9px; }
.opp-mini {
  font-size: 10px;
  color: #a8b8d4;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
.opp-mini .ico { width: 10px; height: 10px; margin-left: 3px; }
.opp-tokens {
  display: flex;
  gap: 5px;
  align-items: center;
  min-height: 15px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.otk { display: inline-flex; align-items: center; gap: 1px; font-size: 11px; font-weight: 800; }
.otk .gem { width: 13px; height: 13px; }
.otk-none { font-size: 9px; color: #5a6885; }

/* ============ 貴族（画面の高さに応じて拡大縮小） ============ */
#nobles { display: flex; gap: .6em; justify-content: center; min-height: 10px; flex-shrink: 0; font-size: clamp(9px, 1.6dvh, 14px); }
.noble {
  font-size: inherit;
  width: 6.5em;
  background: linear-gradient(160deg, #3d3357, #241a3d);
  border: 1px solid #b78ee0;
  border-radius: .8em;
  padding: .35em;
  text-align: center;
  position: relative;
  animation: cardIn .35s ease-out;
  box-shadow: 0 2px 10px rgba(183,142,224,.25);
}
.noble-pts {
  position: absolute; top: .12em; left: .4em;
  font-size: 1.15em; font-weight: 800; color: #f5c542;
}
.noble-face { margin: .12em 0; line-height: 1; }
.noble-face .ico { width: 1.9em; height: 1.55em; filter: drop-shadow(0 0 4px rgba(245,197,66,.5)); }
.noble.big .noble-face .ico { width: 40px; height: 33px; }
.noble.pick .noble-face .ico { width: 26px; height: 22px; }
.noble-req { display: flex; gap: .18em; justify-content: center; flex-wrap: wrap; }
/* 貴族タイル内の要求チップはタイルに収まるサイズに連動 */
.noble .cost {
  width: 1.5em; height: 1.5em;
  font-size: 1em;
  border-width: 1px;
  box-shadow: none;
}
.noble.big { font-size: 13px; width: 110px; padding: 10px; margin: 0 auto; }
.noble.big .noble-pts { font-size: 16px; }
.noble.big .cost { width: 20px; height: 20px; font-size: 13px; }
.noble.pick { font-size: 11px; width: 90px; cursor: pointer; }
.noble.pick:active { transform: scale(.94); }
.noble.pick .cost { width: 17px; height: 17px; font-size: 11px; }
.noble-choice { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }

/* ============ カード ============ */
#card-rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 6px; justify-content: center; }
/* 盤面のカードは「画面の高さ」と「横幅」の小さい方に合わせて縮む
   → スクロールせずに貴族・カード3段・宝石が全部見える */
#card-rows .card,
#card-rows .deck {
  height: min(12.5vh, 25vw, 118px);
  height: min(12.5dvh, 25vw, 118px);
  width: auto;
  flex: 0 0 auto;
}
#card-rows .deck { aspect-ratio: 4 / 7; }
.card {
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  background: #182034;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  animation: cardIn .35s ease-out;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card:active { transform: scale(.95); }
.card.empty, .card.slot-empty {
  background: rgba(255,255,255,.03);
  border: 1px dashed rgba(255,255,255,.12);
  box-shadow: none;
  animation: none;
}
.card.slot-empty {
  font-size: 9px; color: #5a6885;
  align-items: center; justify-content: center; display: flex;
}
/* 色ごとの背景 */
.card.c-w { background: linear-gradient(165deg, #4b586b 0%, #232c3f 55%, #1a2233); }
.card.c-u { background: linear-gradient(165deg, #2a4a8f 0%, #1a2c57 55%, #131f3d); }
.card.c-g { background: linear-gradient(165deg, #1f6e44 0%, #143f2a 55%, #0f2e20); }
.card.c-r { background: linear-gradient(165deg, #8f2a2a 0%, #571a1a 55%, #3d1313); }
.card.c-b { background: linear-gradient(165deg, #3d3d46 0%, #1f1f26 55%, #141419); }
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 3px 4px;
  background: rgba(255,255,255,.09);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.card-pts {
  font-size: clamp(15px, 5.6vw, 23px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 6px rgba(245,197,66,.9), 0 1px 2px rgba(0,0,0,.8);
  line-height: 1;
  min-height: .9em;
}
.card-gem { width: clamp(16px, 5.2vw, 22px); height: clamp(16px, 5.2vw, 22px); flex-shrink: 0; }
.card-cost {
  display: flex;
  flex-direction: column-reverse;
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  gap: 2px;
  padding: 3px 4px;
  max-height: 64%;
}
.cost {
  width: clamp(15px, 4.8vw, 20px);
  height: clamp(15px, 4.8vw, 20px);
  border-radius: 50%;
  font-size: clamp(10px, 3.4vw, 13px);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255,255,255,.5);
  text-shadow: 0 1px 1px rgba(0,0,0,.35);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.cost.sq { border-radius: 4px; }
.cbg-w { background: #e8edf3; color: #333; }
.cbg-u { background: #3f7ae8; color: #fff; }
.cbg-g { background: #2bb567; color: #fff; }
.cbg-r { background: #e8453f; color: #fff; }
.cbg-b { background: #35353d; color: #fff; border-color: rgba(255,255,255,.55); }
/* 買えるカード（金枠＋淡い光。チェックマークはコストと被るため無し） */
.card.can-buy { border-color: #f5c542; }
.card.can-buy::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 9px;
  box-shadow: inset 0 0 12px rgba(245,197,66,.28);
  animation: canBuyPulse 1.6s infinite;
  pointer-events: none;
}
@keyframes canBuyPulse { 0%,100% { opacity: .4 } 50% { opacity: 1 } }
/* カード裏 */
.card.back {
  align-items: center;
  justify-content: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: linear-gradient(160deg, #2c2440 0%, #191327 60%);
  border-color: #f5c542;
}
.card.back .back-lv { font-size: 16px; color: #f5c542; font-weight: 800; }
.card.back .back-deco { color: #b78ee0; font-size: 12px; }
/* 山札 */
.deck {
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: linear-gradient(160deg, #2c2440 0%, #191327 60%);
  border: 1px solid #6a5a8f;
  box-shadow: 2px 2px 0 #191327, 4px 4px 0 #120e1d;
  position: relative;
}
.deck:active { transform: scale(.95); }
.deck-lv { font-size: 15px; color: #f5c542; font-weight: 800; }
.deck-count { font-size: 10px; color: #9f8ec4; }
.deck.lv1 { border-color: #5f9c6f; } .deck.lv1 .deck-lv { color: #8ee6a5; }
.deck.lv2 { border-color: #b7a153; } .deck.lv2 .deck-lv { color: #ffe08a; }
.deck.lv3 { border-color: #8ea7e0; } .deck.lv3 .deck-lv { color: #aecbff; }
/* ミニ・大カード */
.card.mini { width: 42px; font-size: 8px; animation: none; }
.card.mini .card-pts { font-size: 11px; }
.card.mini .card-gem { width: 11px; height: 11px; }
.card.mini .cost { width: 11px; height: 11px; font-size: 8px; }
.card.mini.rsv { border-color: #f5c542; cursor: pointer; }
.card.big { width: 130px; margin: 0 auto; }
.card.big .card-pts { font-size: 26px; }
.card.big .card-gem { width: 28px; height: 28px; }
.card.big .cost { width: 24px; height: 24px; font-size: 14px; }
@keyframes cardIn {
  from { transform: translateY(-14px) scale(.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============ 宝石SVG ============ */
.gem { display: inline-block; vertical-align: middle; }
.gem .facet { fill: none; stroke: rgba(255,255,255,.5); stroke-width: .8; }
.gem .shine { fill: rgba(255,255,255,.55); }
.gem-w .body { fill: #eef3f8; stroke: #b9c6d4; stroke-width: 1; }
.gem-u .body { fill: #3f7ae8; stroke: #8ab2ff; stroke-width: 1; }
.gem-g .body { fill: #2bb567; stroke: #7fe3a8; stroke-width: 1; }
.gem-r .body { fill: #e8453f; stroke: #ff9d99; stroke-width: 1; }
.gem-b .body { fill: #3a3a44; stroke: #9298a8; stroke-width: 1.2; }
.gem-j .body { fill: #f5c542; stroke: #ffe9a3; stroke-width: 1; }
.gem-j .star { fill: #fff3c4; }

/* ============ トークン ============ */
/* バンクは盤面の一番下（自分エリアの直上）に寄せて余白を消す */
#bank-wrap {
  position: relative;
  margin-top: auto;
  flex-shrink: 0;
}
#bank {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 2px 0 5px;
}
.token {
  position: relative;
  width: min(13.5vw, 7vh, 58px);
  width: min(13.5vw, 7dvh, 58px);
  height: min(13.5vw, 7vh, 58px);
  height: min(13.5vw, 7dvh, 58px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.16), rgba(0,0,0,.3)), #1c2438;
  border: 2px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s, border-color .2s, box-shadow .2s;
}
.token .gem { width: 55%; height: 55%; }
.token:active { transform: scale(.9); }
.token.zero { opacity: .3; }
.token.selected {
  border-color: #f5c542;
  box-shadow: 0 0 14px rgba(245,197,66,.6);
  transform: translateY(-4px);
}
.tk-count {
  position: absolute;
  bottom: -5px;
  right: -3px;
  background: #0b1020;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 11px;
  font-size: 13px;
  font-weight: 900;
  padding: 1px 7px;
}
.tk-sel {
  position: absolute;
  top: -6px;
  right: -2px;
  background: #f5c542;
  color: #3a2a05;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  animation: pop .2s ease-out;
}
.t-w { box-shadow: 0 0 10px rgba(238,243,248,.15); }
.t-u { box-shadow: 0 0 10px rgba(63,122,232,.25); }
.t-g { box-shadow: 0 0 10px rgba(43,181,103,.25); }
.t-r { box-shadow: 0 0 10px rgba(232,69,63,.25); }
.t-j { box-shadow: 0 0 12px rgba(245,197,66,.35); }
@keyframes pop { from { transform: scale(.4); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ============ 自分エリア ============ */
#my-area {
  width: 100%;
  position: relative;
  background: rgba(0,0,0,.45);
  border-top: 1px solid rgba(245,197,66,.25);
  padding: 6px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 5;
}
#toasts {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 20;
}
.toast {
  background: rgba(10, 14, 28, .94);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  max-width: 92%;
  animation: pop .25s ease-out;
  transition: opacity .4s;
}
.toast.warn { border-color: #e8453f; color: #ffd7d5; }
.toast.log { color: #cfd8ea; }
.toast.out { opacity: 0; }
/* 選択トレイはバンクの真上に端から端まで浮かべる帯
   （盤面の高さを変えず、自分の情報にも宝石にも被らない） */
#tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #1d2438;
  border: 1px solid rgba(245,197,66,.6);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.55);
  animation: pop .2s ease-out;
}
#tray-sel { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.tray-gem { width: 24px; height: 24px; animation: pop .2s ease-out; }
.tray-label { font-size: 13px; color: #ffe9a3; margin-left: 4px; white-space: nowrap; }
.me-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 4px;
}
.me-name { font-size: 13px; font-weight: 700; color: #ffe9a3; }
.me-bon { display: flex; gap: 3px; flex: 1; flex-wrap: wrap; }
.me-nobles { font-size: 12px; }
.me-pts { font-size: 22px; font-weight: 900; color: #f5c542; }
.me-pts small { font-size: 10px; color: #9fb0cc; }
.bon-chip {
  min-width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1px solid rgba(255,255,255,.35);
}
.me-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me-tokens { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tok-mini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
}
.tok-mini .gem { width: 16px; height: 16px; }
.me-tokens .tok-mini { font-size: 15px; font-weight: 800; }
.me-tokens .tok-mini .gem { width: 21px; height: 21px; }
#me-panel.my-turn {
  background: rgba(245,197,66,.09);
  border-radius: 12px;
  box-shadow: 0 0 0 1.5px rgba(245,197,66,.5), 0 0 16px rgba(245,197,66,.18);
  padding: 4px 8px;
}
.tok-mini.sm .gem { width: 12px; height: 12px; }
.tok-mini.dim { opacity: .3; }
.tok-total { font-size: 10px; color: #8494b3; margin-left: 2px; }
.me-reserved { display: flex; gap: 4px; }
.spectate-note { text-align: center; font-size: 13px; color: #9fb0cc; padding: 10px; }
.none { color: #5a6885; font-size: 12px; }

/* ============ モーダル ============ */
/* flexで中央配置（transformだと出現アニメと衝突して端からスライドして見える） */
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-back { position: absolute; inset: 0; background: rgba(4,6,14,.72); backdrop-filter: blur(3px); }
.modal-box {
  position: relative;
  width: min(330px, 92vw);
  max-height: 86dvh;
  overflow-y: auto;
  background: linear-gradient(170deg, #1c2438, #121829);
  border: 1px solid rgba(245,197,66,.4);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 50px rgba(0,0,0,.7), 0 0 30px rgba(245,197,66,.12);
  animation: pop .22s ease-out;
  text-align: center;
}
.modal-msg { font-size: 14px; line-height: 1.7; margin: 10px 0; }
.modal-msg small { color: #8494b3; }
.modal-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.modal-btns .btn { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; font-weight: 700; }
.modal-card-wrap { margin: 4px 0 8px; }
.pts-t { color: #f5c542; }
.pay-info { font-size: 13px; padding: 8px; border-radius: 10px; margin: 6px 0; }
.pay-info.ok { background: rgba(43,181,103,.12); border: 1px solid rgba(43,181,103,.4); }
.pay-info.ng { background: rgba(232,69,63,.12); border: 1px solid rgba(232,69,63,.4); color: #ffb3b0; }
.ret-tokens { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.pm-line { font-size: 13px; text-align: left; margin: 6px 0; color: #cfd8ea; }
.pm-cards { display: flex; gap: 6px; justify-content: center; margin: 8px 0; }
.pm-cards.wrap { flex-wrap: wrap; max-height: 40dvh; overflow-y: auto; }

/* 結果 */
.result-title { font-size: 24px; font-weight: 900; margin-bottom: 12px; }
.result-title.gold-t {
  background: linear-gradient(180deg, #fff6d8, #f5c542);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  font-size: 14px;
}
.rank-row.win {
  background: linear-gradient(90deg, rgba(245,197,66,.22), rgba(245,197,66,.06));
  border: 1px solid rgba(245,197,66,.5);
}
.rank-m { width: 30px; display: flex; align-items: center; justify-content: center; }
.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: #1a1408;
}
.rank-badge.n1 { background: linear-gradient(160deg, #ffe9a3, #d99b1e); }
.rank-badge.n2 { background: linear-gradient(160deg, #eef2f6, #9aa7b5); }
.rank-badge.n3 { background: linear-gradient(160deg, #e8b284, #a05f2c); }
.rank-badge.n4 { background: #4a5468; color: #cfd8ea; }
.log-list {
  max-height: 46dvh;
  overflow-y: auto;
  text-align: left;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-row {
  font-size: 12px;
  color: #cfd8ea;
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  padding: 5px 9px;
}
.log-row b { color: #ffe9a3; }
.log-row.none { color: #5a6885; text-align: center; }
.rank-n { flex: 1; text-align: left; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-p { font-weight: 900; color: #f5c542; }
.rank-c { font-size: 11px; color: #8494b3; }

/* ============ エフェクト ============ */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.fx-p {
  position: absolute;
  border-radius: 50%;
  animation: fxfly .7s ease-out forwards;
  box-shadow: 0 0 6px currentColor;
}
@keyframes fxfly {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}
/* 自分の番の背景点滅 */
.fx-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(245,197,66,.08) 0%, rgba(245,197,66,.24) 100%);
  animation: bgFlash .45s ease-in-out 3;
  opacity: 0;
  pointer-events: none;
}
@keyframes bgFlash { 0%, 100% { opacity: 0 } 50% { opacity: 1 } }
.fx-fly {
  position: absolute;
  transform: translate(-50%, -50%);
  transition: transform .6s cubic-bezier(.3, .7, .4, 1), opacity .6s ease-in;
  z-index: 110;
  pointer-events: none;
}
.fx-fly .gem {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 7px rgba(255,255,255,.45));
}
.fx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 900;
  color: #f5c542;
  text-shadow: 0 0 10px rgba(245,197,66,.8), 0 2px 4px rgba(0,0,0,.6);
  animation: floatUp 1.1s ease-out forwards;
}
.fx-float.pts { font-size: 26px; }
@keyframes floatUp {
  from { transform: translate(-50%, -50%); opacity: 1; }
  to { transform: translate(-50%, -160%); opacity: 0; }
}
.fx-conf {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  animation: confFall linear forwards;
}
@keyframes confFall {
  from { transform: translate(0, -5vh) rotate(0); opacity: 1; }
  to { transform: translate(var(--sx), 108vh) rotate(var(--rx)); opacity: .8; }
}
#turn-banner {
  position: fixed;
  left: 0; right: 0;
  top: 34%;
  z-index: 90;
  text-align: center;
  padding: 14px 0;
  background: linear-gradient(90deg, transparent, rgba(12,16,32,.9) 22%, rgba(12,16,32,.9) 78%, transparent);
  border-top: 1px solid rgba(255,255,255,.18);
  border-bottom: 1px solid rgba(255,255,255,.18);
  pointer-events: none;
  opacity: 0;
}
#turn-banner.show { animation: bannerIn 1.6s ease-out forwards; }
#turn-banner.gold { border-color: rgba(245,197,66,.5); }
#turn-banner.gold .tb-main { color: #ffe9a3; text-shadow: 0 0 20px rgba(245,197,66,.6); }
.tb-main { font-size: 22px; font-weight: 900; letter-spacing: .1em; }
.tb-sub { font-size: 13px; color: #9fb0cc; margin-top: 4px; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(40px); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateX(-40px); }
}
body.shake { animation: bodyShake .45s; }
@keyframes bodyShake {
  0%, 100% { transform: none; }
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-4px, -1px); }
  80% { transform: translate(3px, 1px); }
}
.fx-glow { animation: glowPulse .9s ease-out; }
@keyframes glowPulse {
  0% { box-shadow: 0 0 0 rgba(245,197,66,0); }
  30% { box-shadow: 0 0 26px rgba(245,197,66,.8); }
  100% { box-shadow: 0 0 0 rgba(245,197,66,0); }
}

/* ============ エモート ============ */
.pass-btn {
  font-size: 11px;
  color: #8494b3;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 4px 9px;
  flex-shrink: 0;
}
.pass-btn:active { transform: scale(.9); }
.emote-btn {
  font-size: 17px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.emote-btn:active { transform: scale(.88); }
.emote-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}
.emote-grid button {
  font-size: 36px;
  padding: 10px 0;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
}
.emote-grid button:active { transform: scale(.9); }
.emote-bubble {
  position: absolute;
  transform: translate(-50%, 0);
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 25px;
  line-height: 1.2;
  box-shadow: 0 4px 16px rgba(0,0,0,.55);
  animation: bubblePop .22s ease-out;
  transition: opacity .3s, transform .3s;
  z-index: 120;
}
@keyframes bubblePop {
  from { transform: translate(-50%, 8px) scale(.5); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
.emote-bubble.out { opacity: 0; transform: translate(-50%, -12px); }
.emote-bubble .e { display: inline-block; animation: emoteWiggle .7s ease-in-out infinite; }
.emote-bubble.hard .e { animation: emoteShake .4s ease-in-out infinite; }
@keyframes emoteWiggle {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg) translateY(-2px); }
}
@keyframes emoteShake {
  0%, 100% { transform: translateX(-2px) rotate(-6deg); }
  25% { transform: translateY(-3px); }
  50% { transform: translateX(2px) rotate(6deg); }
  75% { transform: translateY(1px); }
}

/* ============ 小さい画面の調整 ============ */
@media (max-height: 700px) {
  #game-scroll { gap: 4px; }
  #tray { padding: 4px 8px; }
}
/* PCでは少し大きく中央に */
@media (min-width: 700px) {
  #scr-game { border-left: 1px solid rgba(255,255,255,.08); border-right: 1px solid rgba(255,255,255,.08); }
}
