/* ========================================
   3D 100面ダイス × 100個 シミュレーター
   ======================================== */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans JP', 'Orbitron', sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
}

/* --- Back to Site Button --- */
#back-to-site {
  position: fixed;
  top: max(16px, calc(env(safe-area-inset-top, 0px) + 4px));
  left: max(16px, calc(env(safe-area-inset-left, 0px) + 16px));
  z-index: 500;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  letter-spacing: 0.03em;
}

#back-to-site:hover {
  color: #00ff6a;
  border-color: rgba(0, 255, 106, 0.4);
  background: rgba(0, 255, 106, 0.08);
  box-shadow: 0 0 16px rgba(0, 255, 106, 0.15);
  transform: translateX(-2px);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* --- 3D Canvas --- */
#dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Overlay UI --- */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* safe-area-inset-top: ノッチ/ステータスバーの高さ分下にずらす */
  padding: max(20px, calc(env(safe-area-inset-top, 0px) + 56px)) 20px 20px;
  z-index: 10;
}

#title {
  font-family: 'Orbitron', monospace;
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a0a0a0, #ffffff, #a0a0a0);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

/* --- Button Row (Roll + Action Buttons) --- */
#btn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

#roll-btn {
  pointer-events: auto;
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 14px 48px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(40, 40, 50, 0.9), rgba(20, 20, 30, 0.95));
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#roll-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: linear-gradient(135deg, rgba(60, 60, 80, 0.95), rgba(30, 30, 50, 0.98));
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 255, 255, 0.1);
}

#roll-btn:active {
  transform: translateY(1px) scale(0.97);
}

#roll-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#subtitle {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 16px;
  letter-spacing: 0.1em;
}

#status-text {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.6);
  min-height: 1.5em;
  letter-spacing: 0.05em;
}

/* --- Action Buttons (Share / Screenshot) --- */
#action-btns {
  display: flex;
  gap: 12px;
  opacity: 0;
  max-width: 0;
  overflow: clip visible;
  pointer-events: none;
  transition: opacity 0.4s ease, max-width 0.5s ease;
}

#action-btns.visible {
  opacity: 1;
  max-width: 400px;
  pointer-events: auto;
}

.action-btn {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 24px;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 40px;
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.85), rgba(15, 15, 25, 0.9));
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  letter-spacing: 0.05em;
}

.action-btn:hover {
  border-color: rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, rgba(50, 50, 65, 0.9), rgba(25, 25, 40, 0.95));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 255, 255, 0.08);
}

.action-btn:active {
  transform: translateY(1px) scale(0.97);
}

#share-btn {
  border-color: rgba(29, 161, 242, 0.3);
  background: linear-gradient(135deg, rgba(15, 30, 50, 0.9), rgba(10, 20, 35, 0.95));
}

#share-btn:hover {
  border-color: rgba(29, 161, 242, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(29, 161, 242, 0.15);
}

#screenshot-btn {
  border-color: rgba(100, 200, 120, 0.3);
  background: linear-gradient(135deg, rgba(15, 35, 20, 0.9), rgba(10, 25, 15, 0.95));
}

#screenshot-btn:hover {
  border-color: rgba(100, 200, 120, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(100, 200, 120, 0.15);
}

/* --- Results Panel --- */
#results-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(5, 5, 15, 0.95) 0%, rgba(5, 5, 15, 0.85) 70%, transparent 100%);
  padding: 20px 30px 24px;
  z-index: 10;
  transform: translateY(100%);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(8px);
}

#results-panel.visible {
  transform: translateY(0%);
}

#results-grid {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 6px;
  max-width: 1100px;
  margin: 0 auto;
}

/* --- Dice Result Cell --- */
.dice-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 6px;
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: scale(0.5) rotateX(30deg);
  animation: cellAppear 0.4s ease forwards;
  will-change: transform, opacity;
}

/* --- Critical: 1-5 (Yellow/Gold glow) --- */
.dice-cell.critical {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.5);
  box-shadow:
    0 0 8px rgba(255, 215, 0, 0.4),
    0 0 20px rgba(255, 215, 0, 0.2),
    inset 0 0 8px rgba(255, 215, 0, 0.1);
  animation: cellAppear 0.4s ease forwards, pulseGold 2s ease-in-out infinite;
}

/* --- Fumble: 96-100 (Purple glow) --- */
.dice-cell.fumble {
  color: #c084fc;
  background: rgba(162, 89, 255, 0.15);
  border-color: rgba(162, 89, 255, 0.5);
  box-shadow:
    0 0 8px rgba(162, 89, 255, 0.4),
    0 0 20px rgba(162, 89, 255, 0.2),
    inset 0 0 8px rgba(162, 89, 255, 0.1);
  animation: cellAppear 0.4s ease forwards, pulsePurple 2s ease-in-out infinite;
}

/* --- Animations --- */
@keyframes cellAppear {
  to {
    opacity: 1;
    transform: scale(1) rotateX(0deg);
  }
}

@keyframes pulseGold {

  0%,
  100% {
    box-shadow:
      0 0 8px rgba(255, 215, 0, 0.4),
      0 0 20px rgba(255, 215, 0, 0.2),
      inset 0 0 8px rgba(255, 215, 0, 0.1);
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
  }

  50% {
    box-shadow:
      0 0 14px rgba(255, 215, 0, 0.7),
      0 0 35px rgba(255, 215, 0, 0.4),
      inset 0 0 14px rgba(255, 215, 0, 0.2);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.9);
  }
}

@keyframes pulsePurple {

  0%,
  100% {
    box-shadow:
      0 0 8px rgba(162, 89, 255, 0.4),
      0 0 20px rgba(162, 89, 255, 0.2),
      inset 0 0 8px rgba(162, 89, 255, 0.1);
    text-shadow: 0 0 6px rgba(162, 89, 255, 0.6);
  }

  50% {
    box-shadow:
      0 0 14px rgba(162, 89, 255, 0.7),
      0 0 35px rgba(162, 89, 255, 0.4),
      inset 0 0 14px rgba(162, 89, 255, 0.2);
    text-shadow: 0 0 12px rgba(162, 89, 255, 0.9);
  }
}

/* --- Responsive --- */
@media (max-width: 900px) {
  #results-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
  }

  .dice-cell {
    font-size: 0.6rem;
  }

  #title {
    font-size: 1.5rem;
  }

  .stats-count {
    font-size: 2.8rem;
  }

  .stats-container {
    padding: 24px 32px;
    gap: 14px;
  }

  .stats-vs {
    font-size: 1.6rem;
  }
}

/* --- スマホ縦画面 (600px以下) --- */
@media (max-width: 600px) {
  #overlay {
    padding: max(12px, calc(env(safe-area-inset-top, 0px) + 12px)) 12px 0;
  }

  #title {
    font-size: 1.2rem;
    margin-bottom: 6px;
    letter-spacing: 0.08em;
  }

  #subtitle {
    font-size: 0.72rem;
    margin-bottom: 10px;
  }

  #roll-btn {
    font-size: 1rem;
    padding: 11px 32px;
  }

  .action-btn {
    font-size: 0.75rem;
    padding: 8px 16px;
  }

  #status-text {
    font-size: 0.82rem;
  }

  #results-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
  }

  .dice-cell {
    font-size: 0.5rem;
    aspect-ratio: auto;
    padding: 4px 0;
  }

  #results-panel {
    padding: 10px 10px 12px;
  }

  /* 演出メッセージ: vw固定で必ず小さく */
  .result-message {
    font-size: 4vw;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    text-align: center;
    width: 100%;
    left: 0;
    right: 0;
    top: 8%;
    padding: 0 16px;
    letter-spacing: 0;
    box-sizing: border-box;
    transform: scale(0);
    animation: messagePopInMobile 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
  }

  /* 統計オーバーレイ: 上寄せ */
  .stats-overlay {
    align-items: flex-start;
    justify-content: stretch;
    padding-top: 35%;
  }

  /* 統計コンテナ: Gridで【クリ｜VS｜ファン】＋平均値を完全制御 */
  .stats-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    width: 100%;
    padding: 10px 8px;
    gap: 6px 4px;
    border-radius: 0;
    box-sizing: border-box;
  }

  /* .stats-avg は2行目に全幅 */
  .stats-avg {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: center;
    margin-top: 2px;
  }

  /* VSテキストは列超ししない */
  .stats-vs {
    grid-row: 1;
    align-self: center;
    font-size: 0.85rem;
    padding: 0 2px;
    text-align: center;
  }

  .stats-box {
    grid-row: 1;
    min-width: 0;
    padding: 8px 6px;
    border-radius: 10px;
  }

  .stats-count {
    font-size: 1.8rem;
  }

  .stats-label {
    font-size: 0.6rem;
  }

  .stats-unit {
    font-size: 0.65rem;
  }

  .stats-avg-value {
    font-size: 1.2rem;
  }

  .stats-avg-label {
    font-size: 0.72rem;
  }

  /* 戻るボタン */
  #back-to-site {
    top: max(10px, calc(env(safe-area-inset-top, 0px) + 4px));
    left: 10px;
    font-size: 0.72rem;
    padding: 6px 12px;
  }
}

/* --- スマホ極小 (480px以下) --- */
@media (max-width: 480px) {
  #overlay {
    padding: max(8px, calc(env(safe-area-inset-top, 0px) + 8px)) 8px 0;
  }

  #title {
    font-size: 1rem;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
  }

  #subtitle {
    font-size: 0.65rem;
    margin-bottom: 8px;
  }

  #roll-btn {
    font-size: 0.85rem;
    padding: 10px 24px;
    letter-spacing: 0.06em;
  }

  .action-btn {
    font-size: 0.68rem;
    padding: 7px 12px;
  }

  #btn-row {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }

  #status-text {
    font-size: 0.72rem;
    margin-top: 6px;
  }

  #results-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 1px;
  }

  .dice-cell {
    font-size: 0.4rem;
    aspect-ratio: auto;
    padding: 3px 0;
    border-radius: 3px;
  }

  #results-panel {
    padding: 6px 6px 8px;
  }

  /* 演出メッセージ */
  .result-message {
    font-size: 3.5vw;
    top: 8%;
    padding: 0 12px;
  }

  /* 統計 */
  .stats-overlay {
    padding-top: 35%;
  }

  .stats-container {
    padding: 8px 4px;
    gap: 4px 2px;
  }

  .stats-box {
    padding: 6px 4px;
  }

  .stats-count {
    font-size: 1.5rem;
  }

  .stats-label {
    font-size: 0.52rem;
  }

  .stats-unit {
    font-size: 0.58rem;
  }

  .stats-vs {
    font-size: 0.72rem;
    padding: 0;
  }

  .stats-avg-value {
    font-size: 1rem;
  }

  .stats-avg-label {
    font-size: 0.62rem;
    margin-right: 4px;
  }

  /* 戻るボタン */
  #back-to-site {
    top: max(8px, calc(env(safe-area-inset-top, 0px) + 4px));
    left: 8px;
    font-size: 0.65rem;
    padding: 5px 10px;
    border-radius: 20px;
  }
}

/* モバイル用メッセージ登場アニメーション */
@keyframes messagePopInMobile {
  0% {
    transform: scale(0) rotate(-5deg);
  }

  60% {
    transform: scale(1.1) rotate(2deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* ========================================
   演出オーバーレイ
   ======================================== */

/* --- 共通オーバーレイ --- */
.celebration-overlay,
.disappointment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
  transition: opacity 1s ease;
}

.celebration-overlay.fade-out,
.disappointment-overlay.fade-out {
  opacity: 0;
}

/* --- 共通メッセージ --- */
.result-message {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%) scale(0);
  font-family: 'Orbitron', 'Noto Sans JP', monospace;
  font-size: 2.5rem;
  font-weight: 900;
  white-space: nowrap;
  animation: messagePopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
  text-align: center;
  letter-spacing: 0.05em;
}

/* stats-label small タグ（ラベル折り返し用） */
.stats-label small {
  display: block;
  font-size: 0.75em;
  opacity: 0.75;
  margin-top: 2px;
}

/* --- おめでとうメッセージ --- */
.celebration-message {
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.5),
    0 0 80px rgba(255, 215, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* --- がっかりメッセージ --- */
.disappointment-message {
  color: #c084fc;
  text-shadow:
    0 0 20px rgba(162, 89, 255, 0.8),
    0 0 40px rgba(162, 89, 255, 0.5),
    0 0 80px rgba(162, 89, 255, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* --- 紙吹雪パーティクル --- */
.confetti {
  position: absolute;
  top: -20%;
  border-radius: 2px;
  animation: confettiFall linear infinite;
  will-change: transform, opacity;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  85% {
    opacity: 1;
  }

  100% {
    transform: translateY(130vh) rotate(720deg);
    opacity: 0;
  }
}

/* --- 紫の雨パーティクル --- */
.purple-rain {
  position: absolute;
  top: -15%;
  width: 2px;
  height: 20px;
  background: linear-gradient(to bottom, transparent, #a259ff, #7c3aed);
  border-radius: 0 0 2px 2px;
  animation: purpleRainFall linear infinite;
  box-shadow: 0 0 6px rgba(162, 89, 255, 0.6);
  will-change: transform, opacity;
}

@keyframes purpleRainFall {
  0% {
    transform: translateY(0);
    opacity: 0.8;
  }

  85% {
    opacity: 0.6;
  }

  100% {
    transform: translateY(130vh);
    opacity: 0;
  }
}

/* --- おめでとう絵文字 --- */
.celebration-emoji {
  position: absolute;
  animation: emojiBounce 2.5s ease-in-out infinite;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
  will-change: transform, opacity;
}

@keyframes emojiBounce {
  0% {
    opacity: 0;
    transform: scale(0) translateY(50px);
  }

  20% {
    opacity: 1;
    transform: scale(1.3) translateY(-30px);
  }

  40% {
    transform: scale(1) translateY(0);
  }

  60% {
    opacity: 1;
    transform: scale(1.1) translateY(-15px);
  }

  80% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
}

/* --- がっかり絵文字 --- */
.disappointment-emoji {
  position: absolute;
  animation: emojiSink 3s ease-in-out infinite;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(162, 89, 255, 0.6));
  will-change: transform, opacity;
}

@keyframes emojiSink {
  0% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }

  15% {
    opacity: 1;
    transform: scale(1.2) rotate(-10deg);
  }

  40% {
    opacity: 0.8;
    transform: scale(1) rotate(5deg);
  }

  70% {
    opacity: 0.6;
    transform: scale(0.9) rotate(-3deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.5) rotate(15deg) translateY(60px);
  }
}

/* --- メッセージ登場 --- */
@keyframes messagePopIn {
  0% {
    transform: translateX(-50%) scale(0) rotate(-5deg);
  }

  60% {
    transform: translateX(-50%) scale(1.15) rotate(2deg);
  }

  100% {
    transform: translateX(-50%) scale(1) rotate(0deg);
  }
}

/* ========================================
   統計オーバーレイ
   ======================================== */
.stats-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: nowrap;
  animation: statsSlideIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
  transform: translateY(30px);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
  padding: 32px 48px;
  border-radius: 24px;
}

@keyframes statsSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-box {
  text-align: center;
  padding: 16px 28px;
  border-radius: 16px;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  min-width: 140px;
}

.stats-critical {
  background: rgba(255, 215, 0, 0.12);
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.2), inset 0 0 20px rgba(255, 215, 0, 0.05);
}

.stats-fumble {
  background: rgba(162, 89, 255, 0.12);
  border-color: rgba(162, 89, 255, 0.4);
  box-shadow: 0 0 30px rgba(162, 89, 255, 0.2), inset 0 0 20px rgba(162, 89, 255, 0.05);
}

.stats-label {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  opacity: 0.8;
}

.stats-critical .stats-label {
  color: #ffd700;
}

.stats-fumble .stats-label {
  color: #c084fc;
}

.stats-count {
  font-family: 'Orbitron', monospace;
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
}

.stats-critical .stats-count {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
}

.stats-fumble .stats-count {
  color: #c084fc;
  text-shadow: 0 0 20px rgba(162, 89, 255, 0.6), 0 0 40px rgba(162, 89, 255, 0.3);
}

.stats-unit {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  opacity: 0.7;
  color: #ccc;
  margin-top: 4px;
}

.stats-vs {
  font-family: 'Orbitron', monospace;
  font-size: 2rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  padding: 0 8px;
}

.stats-avg {
  width: 100%;
  text-align: center;
  margin-top: 8px;
}

.stats-avg-label {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin-right: 10px;
}

.stats-avg-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

/* ========================================
   まあまあ演出（クリファン同数）
   ======================================== */
.neutral-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.neutral-star {
  position: absolute;
  top: -10%;
  animation: neutralStarFall linear infinite;
  will-change: transform, opacity;
}

@keyframes neutralStarFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.6;
  }

  50% {
    opacity: 0.4;
  }

  100% {
    transform: translateY(130vh) rotate(360deg);
    opacity: 0;
  }
}

.neutral-emoji {
  position: absolute;
  animation: neutralFloat 3s ease-in-out infinite;
  opacity: 0;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.3));
  will-change: transform, opacity;
}

@keyframes neutralFloat {
  0% {
    opacity: 0;
    transform: scale(0) translateY(20px);
  }

  20% {
    opacity: 0.8;
    transform: scale(1.1) translateY(-10px);
  }

  50% {
    opacity: 0.7;
    transform: scale(1) translateY(5px);
  }

  80% {
    opacity: 0.8;
    transform: scale(1.05) translateY(-5px);
  }

  100% {
    opacity: 0;
    transform: scale(0.8) translateY(15px);
  }
}

.neutral-message {
  color: #bbbbcc;
  text-shadow:
    0 0 15px rgba(200, 200, 220, 0.6),
    0 0 30px rgba(200, 200, 220, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ========================================
   ダイス落下演出
   ======================================== */
.fallen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

/* 落下パーティクル（角ばったダイス風の小片が落ちる） */
.fallen-particle {
  position: absolute;
  top: -10%;
  width: 6px;
  height: 6px;
  background: #00bcd4;
  border-radius: 1px;
  animation: fallenDrop linear infinite;
  box-shadow: 0 0 6px rgba(0, 188, 212, 0.6);
  will-change: transform, opacity;
}

@keyframes fallenDrop {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.7;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    transform: translateY(130vh) rotate(540deg);
    opacity: 0;
  }
}

/* 落下絵文字 */
.fallen-emoji {
  position: absolute;
  animation: fallenSink 3s ease-in-out infinite;
  opacity: 0;
  filter: drop-shadow(0 0 6px rgba(0, 188, 212, 0.5));
  will-change: transform, opacity;
}

@keyframes fallenSink {
  0% {
    opacity: 0;
    transform: scale(0) translateY(-20px);
  }

  15% {
    opacity: 0.9;
    transform: scale(1.2) translateY(0);
  }

  40% {
    opacity: 0.7;
    transform: scale(1) translateY(15px) rotate(-5deg);
  }

  70% {
    opacity: 0.5;
    transform: scale(0.9) translateY(30px) rotate(5deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.6) translateY(60px) rotate(-10deg);
  }
}

/* 落下メッセージ */
.fallen-message {
  color: #00bcd4;
  text-shadow:
    0 0 15px rgba(0, 188, 212, 0.8),
    0 0 30px rgba(0, 188, 212, 0.5),
    0 0 60px rgba(0, 188, 212, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ========================================
   爆発演出（ファンブル10超え）
   ======================================== */

/* 赤フラッシュ */
.explosion-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(255, 60, 0, 0.9), rgba(255, 0, 0, 0.6), transparent 70%);
  z-index: 200;
  pointer-events: none;
  animation: flashBang 0.6s ease-out forwards;
}

@keyframes flashBang {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

/* 爆発オーバーレイ */
.explosion-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}

/* 爆発パーティクル */
.explosion-particle {
  position: absolute;
  animation: explodeFly 1.5s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes explodeFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3) rotate(720deg);
  }
}

/* 爆発メッセージ */
.explosion-message {
  color: #ff4400;
  text-shadow:
    0 0 20px rgba(255, 68, 0, 0.9),
    0 0 40px rgba(255, 68, 0, 0.6),
    0 0 80px rgba(255, 68, 0, 0.4),
    0 0 120px rgba(255, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.8);
  font-size: 3rem;
}

/* UIを吹き飛ばす */
.explode-fly {
  animation: uiFlyAway 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  pointer-events: none !important;
}

@keyframes uiFlyAway {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(-200vh) rotate(45deg);
    opacity: 0;
  }
}

.explode-fly-down {
  animation: uiFlyDown 1s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  pointer-events: none !important;
}

@keyframes uiFlyDown {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(200vh) rotate(-30deg);
    opacity: 0;
  }
}

/* キャンバス揺れ */
.explode-shake {
  animation: canvasShake 0.5s ease-out;
}

@keyframes canvasShake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  10% {
    transform: translate(-15px, 10px);
  }

  20% {
    transform: translate(15px, -10px);
  }

  30% {
    transform: translate(-10px, 15px);
  }

  40% {
    transform: translate(10px, -15px);
  }

  50% {
    transform: translate(-12px, 8px);
  }

  60% {
    transform: translate(8px, -12px);
  }

  70% {
    transform: translate(-5px, 10px);
  }

  80% {
    transform: translate(5px, -5px);
  }

  90% {
    transform: translate(-3px, 3px);
  }
}

/* ========================================
   デバッグパネル（developブランチ専用）
   ======================================== */
#debug-panel {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
}

#debug-title {
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  color: rgba(255, 200, 50, 0.8);
  text-align: center;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.debug-btn {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.debug-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.debug-btn:active {
  transform: scale(0.95);
}

/* ========================================
   スクショモード（html2canvasのCSS非対応対策）
   - animation forwards 最終状態の強制上書き
   - background-clip:text → 白テキストに
   - translate(-50%) → flex中央揃えに
   - backdrop-filter → 半透明背景に
   ======================================== */

/* タイトル: background-clip:text 非対応 → 白テキスト */
.screenshot-mode #title {
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: #ffffff !important;
  color: #ffffff !important;
  filter: none !important;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.4) !important;
}

/* 結果メッセージ: translate(-50%) 非対応 → flex中央揃え */
.screenshot-mode .result-message {
  left: 0 !important;
  width: 100% !important;
  text-align: center !important;
  transform: scale(1) !important;
  animation: none !important;
}

/* ダイスセル */
.screenshot-mode .dice-cell {
  opacity: 1 !important;
  transform: scale(1) rotateX(0deg) !important;
  animation: none !important;
}

/* 統計コンテナ */
.screenshot-mode .stats-container {
  opacity: 1 !important;
  transform: translateY(0) !important;
  animation: none !important;
}

/* 統計ボックス: backdrop-filter 非対応 → 半透明背景 */
.screenshot-mode .stats-box {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.screenshot-mode .stats-critical {
  background: rgba(40, 30, 0, 0.85) !important;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3), inset 0 0 20px rgba(255, 215, 0, 0.08) !important;
}

.screenshot-mode .stats-fumble {
  background: rgba(30, 15, 50, 0.85) !important;
  box-shadow: 0 0 30px rgba(162, 89, 255, 0.3), inset 0 0 20px rgba(162, 89, 255, 0.08) !important;
}

/* 絵文字 */
.screenshot-mode .celebration-emoji,
.screenshot-mode .disappointment-emoji,
.screenshot-mode .neutral-emoji {
  opacity: 0.9 !important;
  transform: scale(1) !important;
  animation: none !important;
}

.screenshot-mode .confetti {
  opacity: 0.8 !important;
}

.screenshot-mode .purple-rain {
  opacity: 0.5 !important;
}

.screenshot-mode .neutral-star {
  opacity: 0.5 !important;
}

.screenshot-mode .explosion-particle {
  opacity: 1 !important;
  animation: none !important;
}

.screenshot-mode .fallen-emoji {
  opacity: 0.9 !important;
  transform: scale(1) !important;
  animation: none !important;
}

.screenshot-mode .fallen-particle {
  opacity: 0.5 !important;
}
