@charset "UTF-8";

:root {
  --red: #8a1c1f;
  --red-dark: #5c1013;
  --gold: #c9a227;
  --gold-light: #e8c96a;
  --ink: #1c1410;
  --panel-bg: rgba(20, 12, 10, 0.82);
  --panel-border: rgba(201, 162, 39, 0.35);
  --text-light: #f5ecd8;
  --text-dim: #cbb99a;
  --win: #3fae5a;
  --lose: #c94b3d;
  --draw: #9c8a5e;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1210;
  color: var(--text-light);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ===== ローディング ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at 50% 40%, #2a1a15, #120b09);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.4s ease;
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-dice {
  font-size: 64px;
  animation: spin-bounce 1s ease-in-out infinite;
}
.loading-text {
  color: var(--text-dim);
  letter-spacing: 0.1em;
  font-size: 14px;
}
@keyframes spin-bounce {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(180deg) translateY(-10px); }
}

/* ===== 演出用フラッシュ(結果が決まった瞬間に一瞬光る) ===== */
#flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
}
#flash-overlay.flash-win { background: #ffffff; animation: flash-pop 0.45s ease-out; }
#flash-overlay.flash-gold { background: var(--gold-light); animation: flash-pop 0.6s ease-out; }
#flash-overlay.flash-lose { background: #7a2020; animation: flash-pop 0.45s ease-out; }
@keyframes flash-pop {
  0% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* ===== UIルート(空白部分はクリック透過してカメラドラッグ可能) ===== */
#ui-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ===== トップバー ===== */
#topbar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(to bottom, rgba(10, 6, 5, 0.75), transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 18px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.brand-dice { font-size: 22px; }
.brand-deluxe {
  color: var(--gold-light);
  font-size: 13px;
  letter-spacing: 0.06em;
  margin-left: 2px;
}
.topbar-right { display: flex; gap: 8px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-light);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.icon-btn:active { transform: scale(0.92); }

/* ===== チップ表示 ===== */
#chips-display {
  pointer-events: auto;
  position: absolute;
  top: calc(56px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 6px 18px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.chips-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; }
.chips-value { font-size: 20px; font-weight: 800; color: var(--gold-light); }

/* ===== 役表示 ===== */
#hand-labels {
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
}
.hand-label {
  pointer-events: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 96px;
  text-align: center;
  backdrop-filter: blur(3px);
}
.hand-owner { font-size: 10px; color: var(--text-dim); }
.hand-text { font-size: 14px; font-weight: 700; color: var(--text-light); }

/* ===== 結果バナー ===== */
#result-banner {
  pointer-events: none;
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 20;
}
#result-banner.hidden { display: none; }
#result-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#result-banner.show.win #result-banner-inner,
#result-banner.show.lose #result-banner-inner { animation: banner-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
#result-banner.show.win #result-title { animation: title-glow-pulse 1.1s ease-out 0.1s; }
@keyframes banner-pop {
  0% { transform: scale(0.4) rotate(-6deg); }
  55% { transform: scale(1.12) rotate(2deg); }
  80% { transform: scale(0.96) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes title-glow-pulse {
  0%, 100% { text-shadow: 0 0 16px rgba(63, 174, 90, 0.6); }
  40% { text-shadow: 0 0 34px rgba(232, 201, 106, 0.95), 0 0 60px rgba(232, 201, 106, 0.5); }
}
#result-banner-inner {
  padding: 16px 34px;
  border-radius: 16px;
  text-align: center;
  border: 2px solid var(--gold);
  background: rgba(10, 6, 5, 0.88);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#result-title { font-size: 34px; font-weight: 900; letter-spacing: 0.05em; }
#result-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
#result-banner.win #result-title { color: var(--win); text-shadow: 0 0 16px rgba(63, 174, 90, 0.6); }
#result-banner.lose #result-title { color: var(--lose); text-shadow: 0 0 16px rgba(201, 75, 61, 0.6); }
#result-banner.draw #result-title { color: var(--draw); }

/* ===== ステータスメッセージ(下部パネルの上部に常設) ===== */
#status-message {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  min-height: 1.4em;
}

/* ===== 下部パネル ===== */
#bottom-panel {
  pointer-events: auto;
  background: linear-gradient(to top, rgba(10, 6, 5, 0.92), rgba(10, 6, 5, 0.55) 70%, transparent);
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#bet-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px;
}
#bet-display {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
}
.bet-label { font-size: 11px; color: var(--text-dim); }
#bet-amount { font-size: 22px; font-weight: 800; color: var(--gold-light); }
#bet-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.chip-btn {
  flex: 1 1 auto;
  min-width: 56px;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, #3a2620, #241512);
  color: var(--text-light);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.chip-btn:active { transform: scale(0.94); }
.chip-allin {
  background: linear-gradient(180deg, var(--gold), #a17f1c);
  color: #241512;
}
.chip-clear {
  background: linear-gradient(180deg, #444, #2a2a2a);
}

#btn-roll {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #241512;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.35);
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
#btn-roll:disabled {
  background: linear-gradient(180deg, #4a4238, #2f2a24);
  color: var(--text-dim);
  box-shadow: none;
  cursor: default;
}
#btn-roll:not(:disabled):active { transform: scale(0.97); }

/* ===== バージョンボタン ===== */
#btn-version {
  position: fixed;
  bottom: calc(6px + var(--safe-bottom));
  right: 6px;
  z-index: 15;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-dim);
  border: none;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
}

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  background: #1e1410;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px;
  max-width: 480px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.modal-card.center { text-align: center; }
.modal-card h2 {
  margin: 0 0 12px;
  color: var(--gold-light);
  font-size: 19px;
}
.modal-card p { font-size: 13px; line-height: 1.7; color: var(--text-light); }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
}
.primary-btn {
  margin-top: 10px;
  padding: 12px 26px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #241512;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 8px;
}
.rules-table th, .rules-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 7px 5px;
  text-align: center;
}
.rules-table th { color: var(--text-dim); font-weight: 600; }
.rn { font-weight: 800; }
.r-best { color: var(--gold-light); }
.r-good { color: #e0a15a; }
.r-bad { color: var(--draw); }
.r-worst { color: var(--lose); }
.rules-note { font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }

#log-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.log-item {
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  border-left: 3px solid var(--draw);
  background: rgba(255, 255, 255, 0.03);
}
.log-item.log-win { border-left-color: var(--win); }
.log-item.log-lose { border-left-color: var(--lose); }
.log-item.log-draw { border-left-color: var(--draw); }
.log-item-top { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 10.5px; }
.log-result { font-weight: 800; }
.log-item.log-win .log-result { color: var(--win); }
.log-item.log-lose .log-result { color: var(--lose); }
.log-item-mid { margin-top: 2px; }
.log-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 20px 0; }
#log-stats { margin-top: 10px; font-size: 12px; color: var(--gold-light); text-align: center; }

.changelog-item { margin-bottom: 14px; }
.changelog-version { font-weight: 800; color: var(--gold-light); font-size: 13px; }
.changelog-date { color: var(--text-dim); font-weight: 400; font-size: 11px; margin-left: 6px; }
.changelog-item ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.6; }

/* ===== デスクトップ向け調整 ===== */
@media (min-width: 720px) {
  .brand { font-size: 22px; }
  .icon-btn { width: 40px; height: 40px; font-size: 18px; }
  #chips-display { padding: 8px 26px; }
  .chips-value { font-size: 24px; }
  .hand-label { min-width: 130px; padding: 10px 16px; }
  .hand-text { font-size: 16px; }
  #bottom-panel { align-items: center; }
  #bet-row { max-width: 560px; width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  #bet-display { flex-direction: column; gap: 0; }
  #bet-chips { flex-wrap: nowrap; }
  .chip-btn { min-width: 68px; }
  #btn-roll { max-width: 560px; margin: 0 auto; }
}

@media (min-width: 1100px) {
  #bet-row, #btn-roll { max-width: 680px; }
}
