/* ==========================================================================
   Roulette - Minimal & Clean White Design System
   背景真っ白・余計な機能を削ぎ落とした洗練の極上デザイン
   ========================================================================== */

:root {
  --bg-page: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-muted: #F8FAFC;
  --bg-hover: #F1F5F9;

  --text-main: #0F172A;
  --text-sub: #64748B;
  --text-light: #94A3B8;

  --border-color: #E2E8F0;
  --border-focus: #0F172A;

  --primary: #0F172A;
  --primary-hover: #1E293B;
  --accent: #F59E0B;

  --font-sans: "Plus Jakarta Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 35px -8px rgba(15, 23, 42, 0.1), 0 8px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-wheel: 0 16px 40px -10px rgba(0, 0, 0, 0.12), 0 0 1px 1px rgba(0, 0, 0, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.app-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ヘッダー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
}

.brand-title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sound-test {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  color: #B45309;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.btn-sound-test:hover {
  background: #FDE68A;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.btn-sound-test:active {
  transform: scale(0.96);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: #CBD5E1;
}

/* メインレイアウト */
.main-content {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 40px;
  align-items: start;
}

/* 左側：ルーレットステージ */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.status-banner {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-sub);
  padding: 6px 16px;
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.status-banner.active {
  background: #FEF3C7;
  color: #B45309;
  border-color: #FDE68A;
}

.status-banner.super-spin {
  background: #FEE2E2;
  color: #DC2626;
  border-color: #FECACA;
  animation: pulseSuper 0.3s infinite alternate;
}

@keyframes pulseSuper {
  0% { transform: scale(1); }
  100% { transform: scale(1.04); }
}

.wheel-wrapper {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wheelCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 50%;
  cursor: grab;
  user-select: none;
  touch-action: none;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.1));
  transition: transform var(--transition);
}

#wheelCanvas:active {
  cursor: grabbing;
}

#wheelCanvas.spinning {
  cursor: default;
}

/* 画面シェイク */
.wheel-section.shake-impact {
  animation: sectionShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes sectionShake {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(3px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 2px, 0); }
  40%, 60% { transform: translate3d(4px, -2px, 0); }
}

/* 操作コントロール */
.controls-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.btn-spin {
  width: 100%;
  height: 52px;
  position: relative;
  overflow: hidden;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  transition: all var(--transition);
  user-select: none;
  touch-action: manipulation;
}

/* チャージプログレスバー */
.btn-spin::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--charge-progress, 0%);
  background: linear-gradient(90deg, #F59E0B, #EF4444);
  pointer-events: none;
  transition: width 0.05s linear;
}

.btn-spin span {
  position: relative;
  z-index: 1;
}

.btn-spin:hover:not(:disabled):not(.charging) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
}

.btn-spin:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-spin.charging {
  transform: scale(0.97);
}

.btn-spin.max-charge {
  animation: maxChargeGlow 0.2s infinite alternate;
}

@keyframes maxChargeGlow {
  0% { box-shadow: 0 0 15px #F59E0B, 0 0 30px #EF4444; }
  100% { box-shadow: 0 0 25px #EF4444, 0 0 45px #F59E0B; }
}

.btn-spin:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hint-text {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
}

/* 右側：項目管理パネル */
.items-section {
  width: 100%;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-text:hover {
  background: var(--bg-muted);
  color: var(--text-main);
}

/* 追加フォーム */
.add-form {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg-page);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.btn-add {
  height: 42px;
  padding: 0 16px;
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-add:hover {
  background: #E2E8F0;
  border-color: #CBD5E1;
}

.btn-add:active {
  transform: scale(0.97);
}

.items-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-sub);
  padding-top: 4px;
}

.meta-tip {
  color: var(--text-light);
}

/* 項目リスト */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

/* スクロールバー */
.item-list::-webkit-scrollbar {
  width: 5px;
}
.item-list::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.item-row:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.item-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all var(--transition);
}

.btn-remove:hover {
  background: #FEE2E2;
  color: #EF4444;
}

/* 当選モーダル */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-card {
  transform: scale(1);
}

.modal-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #94A3B8;
  margin-bottom: 12px;
}

.modal-winner-name {
  font-size: 32px;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 24px;
  word-break: break-all;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-modal-primary {
  width: 100%;
  height: 48px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-modal-primary:hover {
  background: var(--primary-hover);
}

.btn-modal-secondary {
  width: 100%;
  height: 40px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-sub);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-modal-secondary:hover {
  background: var(--bg-muted);
  color: var(--text-main);
}

/* レスポンシブ */
@media (max-width: 860px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .wheel-wrapper {
    max-width: 360px;
  }
  .app-container {
    padding: 16px 16px 36px;
  }
}
