/* ==========================================================================
   スマートゲーム カジノ共通スタイル（/css/casino.css）
   /js/casino.js とセットで使う。カジノ系ゲーム（blackjack / texas-holdem /
   baccarat / roulette）が読み込む共有ファイル。

   - チップバー ＋ カジノ内移動パネル（.sgc-bar / .sgc-panel）
   - トランプの見た目（.sgc-card）
   - カジノ共通のボタン・チップ表示（.sgc-btn / .sgc-chip）

   ゲーム側の style.css より後に読み込むこと（ゲーム側の button {} 等に
   打ち消されないよう、効かせたいプロパティは省略せず明示している）。
   ========================================================================== */

:root {
  --sgc-felt-1: #1a7a52;
  --sgc-felt-2: #0f5137;
  --sgc-felt-3: #08301f;
  --sgc-gold: #e9c46a;
  --sgc-gold-hi: #f8e3a8;
  --sgc-red: #c0392b;
  --sgc-ink: #17202a;
  --sgc-text: #f3f7f2;
  --sgc-dim: rgba(243, 247, 242, 0.62);
  --sgc-line: rgba(233, 196, 106, 0.32);
  --sgc-ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sgc-card-font: "Palatino", "Georgia", "Times New Roman", serif;
  --sgc-card-radius: 7.5%;
}

.sgc-hidden { display: none !important; }

/* ==========================================================================
   チップバー
   ========================================================================== */

#casino-bar {
  position: relative;
  flex: none;
  z-index: 30;
  /* casino.js（defer）がチップバーを入れる前から .sgc-bar の高さぶん場所を取っておく（初回表示のレイアウトシフト防止） */
  min-height: 38px;
}

.sgc-bar,
.sgc-bar *,
.sgc-panel,
.sgc-panel * {
  box-sizing: border-box;
}

.sgc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 5px 10px;
  background: linear-gradient(180deg, rgba(6, 30, 20, 0.92) 0%, rgba(4, 20, 14, 0.92) 100%);
  box-shadow: inset 0 -1px 0 var(--sgc-line);
  font-family: var(--sgc-ui-font);
  color: var(--sgc-text);
  line-height: 1.2;
}

.sgc-wallet {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.sgc-coin {
  font-size: 15px;
  line-height: 1;
  align-self: center;
}

.sgc-amount {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--sgc-gold-hi);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(233, 196, 106, 0.35);
  transition: color 0.2s ease;
}

.sgc-unit {
  font-size: 11px;
  color: var(--sgc-dim);
}

.sgc-best {
  font-size: 11px;
  color: var(--sgc-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* 増減のフィードバック */
.sgc-bar.sgc-up .sgc-amount { animation: sgc-pop-up 0.5s ease; }
.sgc-bar.sgc-down .sgc-amount { animation: sgc-pop-down 0.5s ease; }

@keyframes sgc-pop-up {
  0% { transform: scale(1); color: var(--sgc-gold-hi); }
  35% { transform: scale(1.16); color: #7dffb0; }
  100% { transform: scale(1); color: var(--sgc-gold-hi); }
}

@keyframes sgc-pop-down {
  0% { transform: scale(1); color: var(--sgc-gold-hi); }
  35% { transform: scale(0.92); color: #ff8f80; }
  100% { transform: scale(1); color: var(--sgc-gold-hi); }
}

.sgc-nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  margin: 0;
  padding: 5px 9px;
  border: 1px solid var(--sgc-line);
  border-radius: 999px;
  background: rgba(233, 196, 106, 0.12);
  color: var(--sgc-gold-hi);
  font-family: var(--sgc-ui-font);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s ease;
}

.sgc-nav-toggle:hover { background: rgba(233, 196, 106, 0.22); }
.sgc-nav-toggle:active { transform: translateY(1px); }

.sgc-nav-icon { font-size: 13px; }
.sgc-nav-caret { font-size: 9px; opacity: 0.8; }

/* ==========================================================================
   カジノ移動パネル
   ========================================================================== */

.sgc-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 8px;
  left: auto;
  width: min(340px, calc(100vw - 16px));
  z-index: 2147482400;   /* 共通ヘッダー(2147482500)より下、広告(2147482000)より上 */
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--sgc-line);
  border-radius: 12px;
  background: #0a2418;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  font-family: var(--sgc-ui-font);
  color: var(--sgc-text);
  animation: sgc-panel-in 0.16s ease;
}

@keyframes sgc-panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sgc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sgc-panel-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--sgc-gold-hi);
}

.sgc-panel-close {
  margin: 0;
  padding: 2px 6px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sgc-text);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.sgc-panel-close:hover { background: rgba(255, 255, 255, 0.2); }

.sgc-panel-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--sgc-dim);
}

/* テーブルが増えても収まるよう、見出しごとに2列で並べてスクロールさせる */
.sgc-games {
  display: block;
  max-height: min(46vh, 340px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0 2px 0 0;
}

.sgc-games-head {
  margin: 8px 0 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--sgc-dim);
  text-transform: none;
}

.sgc-games-head:first-child { margin-top: 0; }

.sgc-games-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.sgc-game {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--sgc-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  transition: background 0.15s ease;
}

a.sgc-game:hover { background: rgba(233, 196, 106, 0.16); }

.sgc-game-current {
  border-color: var(--sgc-line);
  background: rgba(233, 196, 106, 0.14);
  color: var(--sgc-gold-hi);
}

.sgc-game-icon { font-size: 15px; line-height: 1; flex: none; }
.sgc-game-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgc-game-mark { font-size: 9px; color: var(--sgc-gold); flex: none; }

.sgc-refill-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--sgc-dim);
}

.sgc-refill {
  margin: 0;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--sgc-gold-hi) 0%, var(--sgc-gold) 100%);
  color: #3b2a06;
  font-family: var(--sgc-ui-font);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.sgc-refill:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sgc-dim);
  cursor: default;
}

/* 所持チップが 100億（11桁）以上のとき（casino.js が .sgc-long を付ける）。
   スマホ幅では数字を少し小さくし、「チップ」は読み上げ専用にして「最高」欄の場所を空ける */
@media (max-width: 699px) {
  .sgc-bar.sgc-long .sgc-amount { font-size: 15px; }
  .sgc-bar.sgc-long .sgc-unit {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (min-width: 700px) {
  #casino-bar { min-height: 42px; }
  .sgc-bar { min-height: 42px; padding: 6px 14px; gap: 10px; }
  .sgc-amount { font-size: 19px; }
  .sgc-best { font-size: 12px; }
  .sgc-nav-toggle { font-size: 13px; padding: 6px 11px; }
}

/* ==========================================================================
   共通ボタン・チップ表示
   ========================================================================== */

.sgc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #2a8f61 0%, #176844 100%);
  color: #fff;
  font-family: var(--sgc-ui-font);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  transition: filter 0.15s ease, transform 0.08s ease;
}

.sgc-btn:hover { filter: brightness(1.12); }
.sgc-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.sgc-btn:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }

.sgc-btn-gold {
  background: linear-gradient(180deg, var(--sgc-gold-hi) 0%, #d4a93f 100%);
  color: #3b2a06;
}

.sgc-btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--sgc-text);
  box-shadow: none;
}

.sgc-btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }

/* --- ベット用チップ（円形） --- */

.sgc-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--chip-c, #c0392b);
  color: #fff;
  font-family: var(--sgc-ui-font);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.9),
    inset 0 0 0 5px var(--chip-c, #c0392b),
    inset 0 -4px 8px rgba(0, 0, 0, 0.3),
    0 3px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, filter 0.15s ease;
}

/* 外周のダッシュ（本物のチップのエッジスポット） */
.sgc-chip::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.92) 0deg 14deg, transparent 14deg 45deg);
  -webkit-mask: radial-gradient(circle, transparent 68%, #000 69%);
  mask: radial-gradient(circle, transparent 68%, #000 69%);
  pointer-events: none;
}

.sgc-chip:hover { filter: brightness(1.1); }
.sgc-chip:active { transform: scale(0.94); }
.sgc-chip:disabled { opacity: 0.35; cursor: default; filter: grayscale(0.4); }
.sgc-chip.sgc-chip-on { transform: translateY(-4px); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 0 0 5px var(--chip-c, #c0392b), 0 0 0 3px var(--sgc-gold), 0 6px 10px rgba(0, 0, 0, 0.5); }

.sgc-chip-1    { --chip-c: #f5f5f5; color: #333; text-shadow: none; }
.sgc-chip-5    { --chip-c: #c0392b; }
.sgc-chip-25   { --chip-c: #1f7a4d; }
.sgc-chip-100  { --chip-c: #2b3a67; }
.sgc-chip-500  { --chip-c: #6c3483; }
.sgc-chip-1000 { --chip-c: #b7950b; }

/* ==========================================================================
   トランプ
   --sgc-cw / --sgc-ch を親要素で指定して大きさを決める
   ========================================================================== */

.sgc-card {
  position: relative;
  width: var(--sgc-cw, 62px);
  height: var(--sgc-ch, 87px);
  flex: none;
  font-size: calc(var(--sgc-cw, 62px) * 0.21);
  perspective: 700px;
}

.sgc-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.3, 0.8, 0.4, 1);
}

.sgc-card.sgc-face-down .sgc-card-inner { transform: rotateY(180deg); }

.sgc-card-face,
.sgc-card-back {
  position: absolute;
  inset: 0;
  border-radius: var(--sgc-card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.sgc-card-face {
  background: linear-gradient(150deg, #ffffff 0%, #fbfaf6 60%, #f1eee4 100%);
  border: 1px solid #c9c4b4;
  color: var(--sgc-ink);
  font-family: var(--sgc-card-font);
  overflow: hidden;
}

.sgc-card.sgc-red .sgc-card-face { color: var(--sgc-red); }

.sgc-card-back {
  transform: rotateY(180deg);
  background-color: #7a1f2b;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.08) 75%, transparent 75%),
    radial-gradient(circle at 50% 50%, #a13040 0%, #5c141f 100%);
  background-size: 7px 7px, 100% 100%;
  border: 1px solid #3d0d15;
  box-shadow: inset 0 0 0 3px #f4efe3, inset 0 0 0 4px #c98a95, 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* --- コーナー表記 --- */

.sgc-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.sgc-c-rank {
  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.sgc-c-suit { font-size: 0.88em; margin-top: 0.08em; }

.sgc-tl { top: 4%; left: 6%; }
.sgc-br { bottom: 4%; right: 6%; transform: rotate(180deg); }

/* --- 中央ピップ --- */

.sgc-pips { position: absolute; inset: 11% 22%; }

.sgc-pip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.35em;
  line-height: 1;
}

.sgc-pip-flip { transform: translate(-50%, -50%) rotate(180deg); }

/* --- 絵札 --- */

.sgc-court {
  position: absolute;
  inset: 16% 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1em;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.92;
}

.sgc-court-letter { font-size: 2.1em; font-weight: 700; line-height: 1; }
.sgc-court-suit { font-size: 1.2em; line-height: 1; }

/* ==========================================================================
   サイコロ（大小 / クラップス / 丁半 / チンチロで共通）
   --sgc-dw を親要素で指定して大きさを決める
   ========================================================================== */

.sgc-die {
  position: relative;
  width: var(--sgc-dw, 48px);
  height: var(--sgc-dw, 48px);
  flex: none;
  border-radius: 22%;
  background: linear-gradient(145deg, #ffffff 0%, #f6f3ea 55%, #ded8c8 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -3px 6px rgba(0, 0, 0, 0.18),
    0 3px 7px rgba(0, 0, 0, 0.45);
}

.sgc-die-face {
  position: absolute;
  inset: 15%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.sgc-die-pip {
  display: block;
  width: 58%;
  height: 58%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #545b66 0%, #1b2027 72%);
  box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.22);
}

/* 和風のサイコロ（丁半・チンチロ）は 1 の目だけ大きな赤 */
.sgc-die-red[data-value="1"] .sgc-die-pip {
  width: 86%;
  height: 86%;
  background: radial-gradient(circle at 36% 30%, #e35d4a 0%, #a8231a 74%);
}

@media (prefers-reduced-motion: reduce) {
  .sgc-card-inner,
  .sgc-panel,
  .sgc-amount { transition: none !important; animation: none !important; }
}
