/* 全体リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ベース設定 */
body {
  font-family: sans-serif;
  line-height: 1.6;
  padding: 20px;
  background: #f5f5f5;
  color: #333;
}

/* 背景装飾 */
body {
  background: linear-gradient(180deg,#f7fbff 0%, #eef6ff 40%, #f5f5f5 100%);
}

header h1 {
  font-size: 28px;
  color: #073b66;
  margin-bottom: 8px;
  letter-spacing: .6px;
}

header {
  margin-bottom: 20px;
}

button {
  padding: 10px 16px;
  border: none;
  background: #111;
  color: #fff;
  cursor: pointer;
  border-radius: 6px;
}

button:hover {
  opacity: 0.8;
}

/* ルーレット用スタイル */
.roulette-container {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.wheel-wrap {
  position: relative;
  width: 420px;
  height: 420px;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  transform: rotate(0deg);
}

.wheel-wrap::before {
  /* 外側のリム（装飾） */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 8px;
  background: conic-gradient(from 180deg at 50% 50%, rgba(0,0,0,0.03), transparent 10%);
  -webkit-mask: radial-gradient(circle at center, black 64%, transparent 65%);
  pointer-events: none;
}

.pointer {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 6;
}

.pointer .pin {
  display: block;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid #e53935;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.12));
}

/* 中心の装飾 */
.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(180deg,#fff 0%, #f2f7ff 100%);
  box-shadow: 0 6px 18px rgba(10, 20, 40, 0.08), inset 0 -6px 12px rgba(0,0,0,0.03);
  border: 3px solid rgba(255,255,255,0.7);
  z-index: 4;
}

/* pointer animation while spinning */
.spinning .pin {
  animation: pointer-wiggle 650ms ease-in-out infinite;
}

@keyframes pointer-wiggle {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(2px) rotate(-6deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(2px) rotate(6deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* 無限回転アニメーション（停止ボタンが押されるまで） */
@keyframes spin-inf {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 大きな停止オーバーレイ */
.big-stop-overlay {
  position: fixed;
  inset: 0;
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  background: rgba(10,20,40,0.32);
  backdrop-filter: blur(4px);
  z-index: 1200;
}
.big-stop-overlay.hidden { display:none; }
.big-stop-btn {
  width: 320px;
  height: 120px;
  border-radius: 24px;
  border: none;
  background: linear-gradient(180deg,#ff8a65 0%, #ff6d00 60%);
  color: #fff;
  font-size: 36px;
  font-weight: 900;
  box-shadow: 0 14px 44px rgba(0,0,0,0.36), 0 0 0 6px rgba(255,110,60,0.06);
  transform: translateZ(0);
  cursor: pointer;
  animation: big-pulse 1000ms ease-in-out infinite;
  display:flex;
  align-items:center;
  justify-content:center;
  letter-spacing: 2px;
  z-index: 10;
}
.big-stop-btn:active { transform: scale(0.98); }

.pause-btn {
  width: 120px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg,#4caf50 0%, #388e3c 60%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: 20px;
  z-index: 10;
}

.pause-btn:active { transform: scale(0.95); }

@keyframes big-pulse {
  0% { transform: scale(1); box-shadow: 0 10px 40px rgba(0,0,0,0.45), 0 0 0 6px rgba(255,80,60,0.06); }
  50% { transform: scale(1.05); box-shadow: 0 14px 48px rgba(0,0,0,0.5), 0 0 0 18px rgba(255,80,60,0.06); }
  100% { transform: scale(1); box-shadow: 0 10px 40px rgba(0,0,0,0.45), 0 0 0 6px rgba(255,80,60,0.06); }
}

/* 微調整: stop btn small (in control area) hidden while overlay shown */
#stopBtn { opacity: 0.9; }
.big-stop-overlay.hidden ~ script + * { }

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#spinBtn {
  padding: 12px 20px;
  background: linear-gradient(180deg,#0077ff,#005fcc);
  border-radius: 8px;
  color: white;
  font-weight: 600;
}

#spinBtn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,119,255,0.18); }

.spin-row { display:flex; gap:8px; align-items:center; }

#stopBtn {
  padding: 10px 14px;
  background: linear-gradient(180deg,#ff6b6b,#e53935);
  border-radius: 8px;
  color: white;
  font-weight: 600;
  border: none;
}

#stopBtn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(229,57,53,0.18); }

.result {
  min-width: 200px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

/* 編集用フォーム */
.editor {
  margin-top: 8px;
  width: 220px;
}

.editor label { display:block; margin-bottom:6px; font-weight:600; }
.input-row { display:flex; gap:8px; }
.input-row input {
  flex: 1;
  padding:8px 10px;
  border-radius:6px;
  border:1px solid #ddd;
}
.input-row button { padding:8px 10px; border-radius:6px; }

.list-area { margin-top:10px; }
.list-area h4 { margin-bottom:8px; font-size:14px; }
.list-area ul { list-style:none; max-height:160px; overflow:auto; padding:6px; background:#fafafa; border-radius:6px; border:1px solid #eee; }
.list-area li { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 8px; border-radius:4px; }
.list-area li:nth-child(odd) { background: rgba(0,0,0,0.02); }
.list-area .item-label { flex:1; padding-right:8px; word-break:break-word; }
.list-area .item-actions button { margin-left:6px; }
.list-actions { display:flex; gap:8px; margin-top:8px; }

.special-area { margin-top:12px; }
.special-item { margin-bottom:8px; display:flex; flex-direction:column; gap:4px; }
.special-item label { font-size:14px; font-weight:bold; }
.special-item input { padding:4px; border:1px solid #ccc; border-radius:4px; }

.archive-area { margin-top:12px; }
.archive-controls { display:flex; gap:8px; align-items:center; margin-bottom:8px; }
.archive-controls input[type="text"] { flex:1; padding:8px; border-radius:6px; border:1px solid #e6e6e6; }
.archive-area ul { list-style:none; max-height:170px; overflow:auto; padding:6px; background:#fffdfa; border-radius:6px; border:1px solid #efe6d6; }
.archive-area li { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px; border-radius:6px; }
.archive-area li:nth-child(odd) { background: rgba(0,0,0,0.02); }
.archive-meta { font-size:12px; color:#666; }
.archive-actions button { margin-left:6px; }

button[disabled] { opacity:0.6; cursor:not-allowed; }

/* 結果オーバーレイ */
.result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}

.result-overlay.hidden { display: none; }

.big-result {
  font-size: 72px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  animation: resultFade 5s ease-in-out forwards;
}

.barrage-comment {
  position: absolute;
  font-size: 24px;
  font-weight: bold;
  color: #ff5722;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  animation: barrageFly 4s linear forwards;
  pointer-events: none;
}

@keyframes barrageFly {
  0% {
    transform: translateX(-100%);
    opacity: 1;
  }
  100% {
    transform: translateX(100vw);
    opacity: 0;
  }
}

/* 特別イベントオーバーレイ */
.special-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1600;
}

.special-overlay.hidden { display: none; }

.special-message {
  font-size: 60px;
  font-weight: bold;
  text-align: center;
  animation: specialEffect 2s ease-in-out;
}

.special-message.angel {
  color: #fff;
  text-shadow: 0 0 20px #fff, 0 0 40px #fff, 0 0 60px #fff;
}

.special-message.god {
  color: #ff0000;
  text-shadow: 0 0 20px #ff0000, 0 0 40px #ff0000, 0 0 60px #ff0000;
}

.special-penalty {
  font-size: 36px;
  font-weight: bold;
  text-align: center;
  margin-top: 20px;
  opacity: 0;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

@keyframes specialEffect {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* small screens: center layout */
@media (max-width: 700px) {
  .roulette-container { flex-direction: column; }
  .editor { width: 90%; }
}

@media (max-width: 600px) {
  .wheel-wrap { width: 320px; height: 320px; }
}

@keyframes resultFade {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
