/**
 * Web Roulette Plugin Styles
 * v1.3
 */

:root {
  /* メインカラーと背景設定 */
  --wr-bg-main: #46757e;
  --wr-bg-card: #ebebeb;

  /* テキストカラー */
  --wr-text-main: #333333;
  --wr-text-muted: #666666;

  /* アクセント・状態 */
  --wr-accent-primary: #46757e;
  --wr-accent-hover: #5a8e99;
  --wr-danger: #ff4b5c;

  /* 装飾要素 */
  --wr-radius-lg: 24px;
  --wr-radius-md: 16px;
  --wr-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --wr-shadow-md: 0 10px 24px rgba(0, 0, 0, 0.12);
  --wr-transition: all 0.2s ease;
}

/* -----------------------------
   全体コンテナ
----------------------------- */
.wr-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 16px;
  background: var(--wr-bg-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--wr-text-main);
  line-height: 1.6;
}

.wr-app *, .wr-app *::before, .wr-app *::after {
  box-sizing: border-box;
}

/* キーボード操作時のフォーカス表示 */
.wr-app :focus-visible {
  outline: 3px solid var(--wr-accent-primary);
  outline-offset: 2px;
}

/* -----------------------------
   ヘッダー（タイトル・説明文）
----------------------------- */
.wr-header {
  text-align: center;
  margin-bottom: 40px;
}

.wr-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  color: #ffffff !important; /* 背景色の上で読ませるため白 */
}

.wr-desc-card {
  display: inline-block;
  text-align: left;
  background: rgba(255, 255, 255, 0.95);
  padding: 20px 28px;
  border-radius: var(--wr-radius-md);
  box-shadow: var(--wr-shadow-sm);
  font-size: 14px;
  max-width: 700px;
  color: var(--wr-text-main) !important;
}

.wr-desc-card p {
  margin: 0 0 8px;
}

.wr-desc-card p:last-child {
  margin-bottom: 0;
}

/* -----------------------------
   メインレイアウト
----------------------------- */
main.wr-main {
  display: flex;
  gap: 56px;
  align-items: flex-start;
}

.wr-left, .wr-right {
  flex: 1 1 0;
  min-width: 0;
}

.wr-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* -----------------------------
   左側：ルーレットカード
----------------------------- */
.wr-wheel-card {
  position: relative;
  background: var(--wr-bg-card);
  border-radius: var(--wr-radius-lg);
  padding: 40px 32px;
  box-shadow: var(--wr-shadow-md);
}

/* 紙吹雪レイヤー */
.wr-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--wr-radius-lg);
  pointer-events: none;
  z-index: 30;
}

.wr-wheel-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wr-wheel-wrapper {
  position: relative;
  width: 320px;
  max-width: 100%;
  margin: 20px auto 30px;
}

.wr-wheel-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 10px solid #333333;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.2);
  background: #ffffff;
}

.wr-app.is-spinning .wr-wheel-wrapper canvas {
  animation: wr-halo 1.1s ease-in-out infinite alternate;
}

@keyframes wr-halo {
  from {
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.2),
                0 0 0 4px rgba(255, 214, 72, 0.18),
                0 0 18px rgba(255, 214, 72, 0.3);
  }
  to {
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.2),
                0 0 0 9px rgba(255, 214, 72, 0.3),
                0 0 38px rgba(255, 214, 72, 0.55);
  }
}

/* 下向き矢印。境目を越えるたびにJSが弾かせる */
.wr-pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 32px solid var(--wr-danger);
  z-index: 10;
  transform-origin: 50% 0;
  will-change: transform;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.2));
}

.wr-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 56px;
  border-radius: 999px;
  border: none;
  background: #111111;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--wr-transition);
  box-shadow: 0 6px 0 #444444;
}

.wr-start-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #444444;
}

.wr-start-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #444444;
}

.wr-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 黒いボタンの上では枠色を変える */
.wr-start-btn:focus-visible {
  outline-color: #ffd648;
  outline-offset: 4px;
}

.wr-sound-btn {
  margin-top: 14px;
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--wr-text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--wr-transition);
}

.wr-sound-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--wr-text-main);
}

.wr-sound-btn.is-muted {
  opacity: 0.55;
}

/* 結果表示エリア */
.wr-result-area {
  margin-top: 32px;
}

.wr-result-card {
  background: #ffffff;
  border-radius: var(--wr-radius-md);
  padding: 24px;
  border: 2px dashed #d0b69b;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

/* 回転中：ポインタ上の名前が次々に切り替わる */
.wr-result-card.is-teasing {
  border-color: rgba(70, 117, 126, 0.4);
}

.wr-result-card.is-teasing .wr-result-text {
  color: var(--wr-text-muted);
  font-size: 20px;
  opacity: 0.85;
}

.wr-result-card.is-highlight {
  border-color: var(--wr-accent-primary);
  border-style: solid;
  background: #f4fafb;
  box-shadow: 0 0 0 4px rgba(70, 117, 126, 0.12);
  animation: wr-pop 0.6s cubic-bezier(0.18, 1.5, 0.4, 1);
}

.wr-result-card.is-highlight .wr-result-text {
  animation: wr-reveal 0.5s ease-out;
}

@keyframes wr-pop {
  0%   { transform: scale(0.94); }
  55%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}

@keyframes wr-reveal {
  0%   { opacity: 0; transform: translateY(8px); letter-spacing: 0.3em; }
  100% { opacity: 1; transform: none; letter-spacing: normal; }
}

.wr-result-label {
  display: block;
  font-size: 12px;
  color: var(--wr-text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.wr-result-text {
  font-size: 24px;
  font-weight: 800;
  color: var(--wr-accent-primary);
  word-break: break-word;
}

.wr-result-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.wr-respin-btn {
  background: transparent;
  border: 1px solid rgba(70, 117, 126, 0.5);
  color: var(--wr-accent-primary);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--wr-transition);
}

.wr-respin-btn:hover:not(:disabled) {
  background: var(--wr-accent-primary);
  color: #ffffff;
}

.wr-respin-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* -----------------------------
   右側：パネル設定
----------------------------- */
.wr-panel {
  background: #ffffff;
  border-radius: var(--wr-radius-md);
  padding: 24px;
  box-shadow: var(--wr-shadow-sm);
}

.wr-panel-title {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  border-left: 5px solid var(--wr-accent-primary);
  padding-left: 12px;
}

/* 通知メッセージ（alert / confirm の置き換え） */
.wr-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--wr-text-main);
  background: #f2f7f8;
  border: 1px solid rgba(70, 117, 126, 0.25);
  border-radius: 10px;
  padding: 0 14px;
  max-height: 0;
  margin-bottom: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, max-height 0.2s ease, margin-bottom 0.2s ease, padding 0.2s ease;
}

.wr-message.is-visible {
  max-height: 120px;
  padding: 10px 14px;
  margin-bottom: 16px;
  opacity: 1;
  pointer-events: auto;
}

.wr-message-text {
  min-width: 0;
}

.wr-undo-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--wr-accent-primary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* 項目リスト */
.wr-items-container {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  padding-right: 4px;
}

.wr-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wr-item-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #e0d0b8;
  background: #fdfcfb;
  font-size: 14px;
  transition: var(--wr-transition);
}

.wr-item-input:focus {
  outline: none;
  border-color: var(--wr-accent-primary);
  box-shadow: 0 0 0 3px rgba(70, 117, 126, 0.1);
}

.wr-color-dot {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.wr-delete-btn {
  background: none;
  border: none;
  color: #cccccc;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  transition: var(--wr-transition);
}

.wr-delete-btn:hover {
  color: var(--wr-danger);
}

/* 項目操作ボタン */
.wr-items-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.wr-outline-btn {
  background: var(--wr-accent-primary);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--wr-transition);
}

.wr-outline-btn:hover:not(:disabled) {
  background: var(--wr-accent-hover);
}

.wr-outline-btn:disabled,
.wr-text-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wr-text-btn {
  background: transparent;
  border: none;
  color: var(--wr-text-muted);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
}

/* 各種設定フィールド */
.wr-field {
  margin-bottom: 20px;
}

.wr-field:last-child {
  margin-bottom: 0;
}

.wr-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--wr-text-muted);
  cursor: pointer;
}

.wr-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e0d0b8;
  background: #fdfcfb;
}

.wr-range {
  width: 100%;
  accent-color: var(--wr-accent-primary);
  cursor: pointer;
}

/* -----------------------------
   レスポンシブ
----------------------------- */
@media (max-width: 900px) {
  main.wr-main {
    flex-direction: column;
    gap: 32px;
  }

  .wr-wheel-card {
    padding: 32px 20px;
  }

  .wr-wheel-wrapper {
    width: 280px;
  }

  .wr-items-container {
    max-height: none;
  }
}

/* -----------------------------
   モーション設定への配慮
----------------------------- */
@media (prefers-reduced-motion: reduce) {
  .wr-app *,
  .wr-app *::before,
  .wr-app *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}