/* 出目洗い弁天 専用スタイル */
/* base.css を先に読み込むこと（body背景・.bgm-header 含む） */
/* 色は theme.css のトークンのみ。3D シーン内の色は js/deme-wash/ 側で持つ */

.deme-wash-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: var(--spacing-xl) 0;
  box-sizing: border-box;
}

.deme-wash-tool {
  max-width: 760px;
  margin: 0 auto;
}

/* ========================================
   ツールバー（モード・タイマー・たわし）
   ======================================== */
.deme-wash-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.deme-wash-modes[hidden] {
  display: none;
}

.deme-wash-modes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 3px;
  border: var(--border-width) solid var(--color-border-light);
  border-radius: var(--border-radius-pill);
  background-color: var(--color-surface-light);
}

.deme-wash-modes__legend {
  float: left;
  padding: 0 6px 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  line-height: 28px;
}

.deme-wash-modes__option {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  height: 28px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.deme-wash-modes__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.deme-wash-modes__option:has(input:checked) {
  background-color: var(--color-primary);
  color: var(--color-text);
}

.deme-wash-modes__option:has(input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.deme-wash-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0 12px;
  height: 34px;
  line-height: 34px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  border: var(--border-width) solid var(--color-border-light);
  border-radius: var(--border-radius-pill);
  background-color: var(--color-surface-light);
}

.deme-wash-timer[hidden] {
  display: none;
}

.deme-wash-timer__value {
  min-width: 2.6em;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.deme-wash-timer.is-urgent .deme-wash-timer__value {
  color: var(--color-danger);
}

/* ========================================
   進捗バー（ステージ上端の中央に 1 本。洗いは水色、エンドレスで洗い終えたら磨きを黄で上塗り）
   ======================================== */
.deme-wash-progress {
  position: absolute;
  top: 22px;
  left: 50%;
  width: 50%;
  min-width: 160px;
  transform: translateX(-50%);
  z-index: 1;
  height: 8px;
  border-radius: var(--border-radius-pill);
  background-color: var(--color-surface-light);
  box-shadow: 0 1px 4px var(--shadow-color);
  overflow: hidden;
  pointer-events: none;
}

.deme-wash-progress__fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background-color: var(--color-link); /* 実際の水色は main.js の PROGRESS_WASH_COLOR で上書き */
  transition: width 0.2s ease-out;
}

.deme-wash-progress__fill--polish {
  background-color: var(--color-primary);
}

/* 柄杓の水が効いている間：バーの縁が脈打つように光る */
.deme-wash-progress.is-boost {
  animation: deme-wash-boost 0.9s ease-in-out infinite alternate;
}

@keyframes deme-wash-boost {
  from {
    box-shadow: 0 0 0 2px var(--color-surface-light), 0 0 4px var(--color-primary);
  }
  to {
    box-shadow: 0 0 0 2px var(--color-primary), 0 0 12px var(--color-primary);
  }
}

@media (prefers-reduced-motion: reduce) {
  .deme-wash-progress.is-boost {
    animation: none;
    box-shadow: 0 0 0 2px var(--color-primary);
  }
}

@media (prefers-reduced-motion: reduce) {
  .deme-wash-progress__fill {
    transition: none;
  }
}

/* ========================================
   3D ステージ
   ======================================== */
.deme-wash-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: var(--border-width) solid var(--color-border-light);
  border-radius: var(--border-radius-xl);
  background-color: var(--color-surface-panel);
  box-shadow: inset 0 2px 12px var(--shadow-color-inset);
  overflow: hidden;
}

.deme-wash-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
}

/* たわし・ダイスの上では「つまめる」手 */
.deme-wash-canvas.is-over {
  cursor: grab;
}

.deme-wash-canvas.is-scrubbing,
.deme-wash-canvas.is-grabbing {
  cursor: grabbing;
}

.deme-wash-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-muted);
  pointer-events: none;
}

.deme-wash-fallback[hidden] {
  display: none;
}

/* 清め完了時の白フラッシュ */
.deme-wash-flash {
  position: absolute;
  inset: 0;
  background-color: var(--color-surface-light);
  opacity: 0;
  pointer-events: none;
}

.deme-wash-flash.is-active {
  animation: deme-wash-flash 480ms ease-out forwards;
}

@keyframes deme-wash-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

/* 「清めました」「出目」の吹き出し */
.deme-wash-callout {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 160px;
  padding: 10px 22px 12px;
  background-color: var(--color-surface-light);
  border: var(--border-width) solid var(--color-border-light);
  border-radius: var(--border-radius-xl);
  box-shadow: 0 6px 18px var(--shadow-color);
  text-align: center;
  color: var(--color-text);
  pointer-events: none;
  animation: deme-wash-callout-in 320ms ease-out;
}

.deme-wash-callout[hidden] {
  display: none;
}

@keyframes deme-wash-callout-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.deme-wash-callout__title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.deme-wash-callout__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted-medium);
  letter-spacing: 0.1em;
}

.deme-wash-callout__dice {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.deme-wash-callout__note strong {
  color: var(--color-text);
  font-weight: 700;
}

.deme-wash-callout__number {
  display: block;
  font-size: clamp(44px, 11vw, 80px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.deme-wash-callout__number--red {
  color: var(--color-danger);
}

.deme-wash-callout__number--blue {
  color: var(--color-link-strong);
}

.deme-wash-callout__note {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-muted-medium);
}

/* ========================================
   HUD（効果音の設定）
   ======================================== */
.deme-wash-hud {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.deme-wash-sound {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.deme-wash-volume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
}

.deme-wash-volume__range {
  width: 110px;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.deme-wash-volume__range:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

.deme-wash-mute[aria-pressed="true"] + .deme-wash-volume {
  opacity: 0.5;
}

.deme-wash-mute {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  background-color: var(--color-surface-light);
  border: var(--border-width) solid var(--color-border-light);
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.deme-wash-mute:hover {
  border-color: var(--color-muted-light);
}

.deme-wash-mute:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.deme-wash-mute__icon {
  position: relative;
  width: 14px;
  height: 14px;
}

/* スピーカー形：矩形＋三角 */
.deme-wash-mute__icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 5px;
  height: 6px;
  background-color: currentColor;
  border-radius: 1px;
}

.deme-wash-mute__icon::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  border-style: solid;
  border-width: 6px 0 6px 7px;
  border-color: transparent transparent transparent currentColor;
}

.deme-wash-mute[aria-pressed="true"] {
  color: var(--color-muted-light);
  background-color: var(--color-surface-soft);
}

.deme-wash-mute[aria-pressed="true"] .deme-wash-mute__icon {
  opacity: 0.55;
}

/* ========================================
   操作ボタン
   ======================================== */
/* ステージ（3D 表示）の下端に重ねる。スクロールしなくてもボタンが見える */
.deme-wash-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 0 12px;
  pointer-events: none; /* 隙間は 3D 側の操作を通す */
}

.deme-wash-actions > * {
  pointer-events: auto;
}

.deme-wash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.deme-wash-btn[hidden] {
  display: none;
}

.deme-wash-btn--primary {
  color: var(--color-text);
  background-color: var(--color-primary);
  border: var(--border-width) solid var(--color-primary);
  animation: deme-wash-pop 360ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.deme-wash-btn--primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.deme-wash-btn--primary:active {
  transform: translateY(0);
}

.deme-wash-btn--secondary {
  color: var(--color-text);
  background-color: var(--color-surface-light);
  border: var(--border-width) solid var(--color-border-light);
}

.deme-wash-btn--secondary:hover {
  border-color: var(--color-muted-light);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.deme-wash-btn--secondary:active {
  transform: translateY(0);
}

.deme-wash-btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.deme-wash-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

@keyframes deme-wash-pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.deme-wash-hint {
  margin: var(--spacing-sm) 0 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-muted-medium);
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 600px) {
  .deme-wash-stage {
    aspect-ratio: 1 / 1;
    border-radius: var(--border-radius-md);
  }

  .deme-wash-sound {
    width: 100%;
    justify-content: space-between;
  }

  .deme-wash-volume__range {
    width: 140px;
  }

  .deme-wash-btn {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
    padding: 11px 12px;
    font-size: 15px;
  }

  .deme-wash-callout {
    top: 36px;
    padding: 8px 16px 10px;
  }

  .deme-wash-toolbar {
    gap: 8px;
  }

  .deme-wash-modes__legend {
    display: none;
  }

}

@media (prefers-reduced-motion: reduce) {
  .deme-wash-flash.is-active,
  .deme-wash-callout,
  .deme-wash-btn--primary {
    animation: none;
  }

  .deme-wash-btn:hover {
    transform: none;
  }
}
