:root {
  --bg-primary: #000000; /* 純黒 = 加算式ディスプレイでは透明 */
  --felt-light: #17402f;
  --felt-mid: #0e2c20;
  --felt-dark: #081b13;
  --gold: #e8c85a;
  --gold-deep: #b08d2e;
  --gold-bright: #ffe9a0;
  --text-primary: #ffffff;
  --text-secondary: #cfd4cd;
  --text-muted: #8d968e;
  --red: #e6485a;
  --red-deep: #a81f30;
  --blue: #4a90e6;
  --blue-deep: #1f4fa8;
  --card-ivory: #f7f3e8;
  --card-ivory-dim: #e6dfc9;
  --suit-red: #d22b3a;
  --suit-black: #22222c;
  --focus-ring: #ffd76a;
  --focus-glow: rgba(255, 215, 106, 0.45);
  --radius-md: 12px;
  --radius-lg: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- 画面 --- */
.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 8px;
}
.screen.hidden { display: none; }

/* --- カジノテーブル面 --- */
.table {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  border: 2px solid var(--gold-deep);
  background:
    radial-gradient(ellipse 90% 70% at 50% 25%, var(--felt-light) 0%, var(--felt-mid) 55%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 6px rgba(232, 200, 90, 0.12),
    inset 0 0 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  overflow: hidden;
}

/* --- 共通ボタン --- */
.btn {
  min-height: 52px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}
.btn-gold {
  background: linear-gradient(180deg, #f4d97c 0%, #d3ab3f 55%, #a97f1f 100%);
  color: #3a2a05;
  text-shadow: 0 1px 0 rgba(255, 244, 200, 0.55);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.btn-outline {
  background: rgba(8, 22, 15, 0.7);
  color: var(--gold);
  border-color: var(--gold-deep);
}
.btn-small {
  min-height: 44px;
  font-size: 15px;
  padding: 8px 16px;
}

/* --- フォーカス状態（D-pad / EMG 用・最重要） --- */
.focusable { cursor: pointer; }
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-ring), 0 0 26px var(--focus-glow);
  transform: scale(1.04);
}

/* ============ ホーム ============ */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}
.logo { text-align: center; }
.logo-suits {
  font-size: 26px;
  letter-spacing: 18px;
  margin-bottom: 6px;
}
.s-red { color: var(--red); text-shadow: 0 0 12px rgba(230, 72, 90, 0.6); }
.s-black { color: #e9ecf2; text-shadow: 0 0 12px rgba(233, 236, 242, 0.4); }
.logo-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 58px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 18px rgba(232, 200, 90, 0.35));
}
.logo-amp { font-size: 44px; }
.logo-sub {
  margin-top: 4px;
  font-size: 15px;
  letter-spacing: 0.5em;
  color: var(--gold);
  text-transform: uppercase;
}
.balance-plate {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 30px;
  border-radius: 999px;
  background: rgba(6, 18, 12, 0.75);
  border: 2px solid var(--gold-deep);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
}
.coin { font-size: 22px; }
.balance-num {
  font-size: 34px;
  font-weight: 800;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}
.balance-unit { font-size: 15px; color: var(--text-secondary); }
.home-stats {
  display: flex;
  align-items: center;
  gap: 22px;
}
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat-label { font-size: 14px; color: var(--text-secondary); }
.stat-value { font-size: 22px; font-weight: 800; color: #fff; }
.stat-divider { width: 1px; height: 24px; background: var(--gold-deep); }
.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 320px;
}
.home-buttons .btn { width: 100%; }

/* ============ ゲーム ============ */
.game-top {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(6, 18, 12, 0.75);
  border: 1.5px solid var(--gold-deep);
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}
.pill .coin { font-size: 16px; }
.pill-label { font-size: 12px; color: var(--text-secondary); letter-spacing: 0.1em; }
.pill-pot { border-color: var(--gold); box-shadow: 0 0 14px rgba(232, 200, 90, 0.25); }
.pill-streak { color: #ffb36a; font-size: 15px; }
.fire { font-size: 15px; }

/* --- カード --- */
.card-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 12px 0 4px;
  flex-shrink: 0;
}
.card-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.slot-label { font-size: 13px; color: var(--text-secondary); letter-spacing: 0.08em; }
.vs-badge {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  border: 2px solid var(--gold-deep);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 18, 12, 0.7);
  box-shadow: 0 0 16px rgba(232, 200, 90, 0.2);
  flex-shrink: 0;
}
.pcard {
  width: 138px;
  height: 192px;
  perspective: 700px;
}
.pcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.05, 0.3, 1);
}
.pcard.face-down .pcard-inner { transform: rotateY(180deg); }
.pcard.no-anim .pcard-inner { transition: none; }
.pcard-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.pcard-front {
  background: linear-gradient(160deg, #fffdf6 0%, var(--card-ivory) 45%, var(--card-ivory-dim) 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pcard-back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(232, 200, 90, 0.16) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #7c1626 0%, #4d0d18 100%);
  border: 5px solid #a8872f;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-gem {
  font-size: 44px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(232, 200, 90, 0.7);
}
.corner {
  position: absolute;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}
.corner-tl { top: 8px; left: 10px; }
.corner-br { bottom: 8px; right: 10px; transform: rotate(180deg); }
.big-suit { font-size: 74px; line-height: 1; }
.big-rank {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: Georgia, serif;
  font-size: 44px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.suit-red { color: var(--suit-red); }
.suit-black { color: var(--suit-black); }

/* 勝敗時のカード演出 */
.pcard.glow-win .pcard-front {
  box-shadow: 0 0 30px rgba(232, 200, 90, 0.85), 0 4px 16px rgba(0, 0, 0, 0.5);
}
.pcard.glow-lose .pcard-front {
  box-shadow: 0 0 26px rgba(230, 72, 90, 0.7), 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* --- 結果バナー --- */
.banner-zone {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.banner {
  padding: 8px 34px;
  border-radius: 999px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.08em;
  animation: banner-pop 0.3s ease;
}
@keyframes banner-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.banner-win {
  background: linear-gradient(180deg, rgba(232, 200, 90, 0.25), rgba(232, 200, 90, 0.08));
  border: 2px solid var(--gold);
  color: var(--gold-bright);
  text-shadow: 0 0 16px rgba(255, 233, 160, 0.8);
}
.banner-lose {
  background: rgba(168, 31, 48, 0.25);
  border: 2px solid var(--red);
  color: #ff97a4;
}
.banner-draw {
  background: rgba(74, 144, 230, 0.18);
  border: 2px solid var(--blue);
  color: #a8c8f2;
}

/* --- 操作エリア --- */
.controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}
.controls.hidden { display: none; }
.prompt {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

/* カジノチップボタン */
.chip-row {
  display: flex;
  gap: 16px;
  align-items: center;
}
.chip-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 6px double rgba(255, 255, 255, 0.85);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 0 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}
.chip-num { line-height: 1.1; display: inline-block; }
.chip-25 { background: radial-gradient(circle at 35% 30%, #3fae74, #1d6b43 70%, #124a2d); }
.chip-50 { background: radial-gradient(circle at 35% 30%, #5b9cf0, #2760b8 70%, #1a4485); }
.chip-100 { background: radial-gradient(circle at 35% 30%, #ef6a75, #b52738 70%, #821522); }
.chip-allin {
  background: radial-gradient(circle at 35% 30%, #f2d878, #b8912e 70%, #7d5f16);
  color: #33240a;
  text-shadow: 0 1px 0 rgba(255, 244, 200, 0.6);
  font-size: 17px;
}
.chip-btn:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-ring), 0 0 30px var(--focus-glow), inset 0 0 14px rgba(0, 0, 0, 0.35);
  transform: scale(1.08);
}

/* HIGH / LOW ボタン */
.hl-row {
  display: flex;
  gap: 18px;
  width: 100%;
  justify-content: center;
}
.hl-btn {
  width: 220px;
  min-height: 84px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0.1em;
  border-radius: 16px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.hl-arrow { font-size: 21px; vertical-align: 2px; }
.hl-high {
  background: linear-gradient(180deg, #f0705e 0%, #c93a3a 55%, var(--red-deep) 100%);
  box-shadow: 0 4px 12px rgba(168, 31, 48, 0.5);
}
.hl-low {
  background: linear-gradient(180deg, #64a4f0 0%, #3568c9 55%, var(--blue-deep) 100%);
  box-shadow: 0 4px 12px rgba(31, 79, 168, 0.5);
}
#win-controls .btn, #lose-controls .btn { min-width: 220px; }

/* ============ あそびかた ============ */
.help-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 4px;
}
.help-title {
  font-family: Georgia, serif;
  font-size: 27px;
  color: var(--gold);
  letter-spacing: 0.12em;
}
.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.help-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(6, 18, 12, 0.6);
  border: 1px solid rgba(176, 141, 46, 0.45);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.help-icon { font-size: 20px; flex-shrink: 0; }
.t-red { color: #ff8d9b; }
.t-blue { color: #8fbcf5; }
.t-gold { color: var(--gold-bright); }
.help-content .btn { width: 260px; }

/* --- トースト --- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: rgba(10, 24, 16, 0.95);
  color: var(--gold-bright);
  padding: 12px 26px;
  border-radius: 24px;
  font-size: 17px;
  font-weight: 700;
  border: 1.5px solid var(--gold);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); color: #ff97a4; }

/* --- ユーティリティ --- */
.hidden { display: none !important; }
