@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-primary: #f5f6fa;
  --bg-secondary: #fff;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-light: #999;
  --border-color: #e2e5ef;
  --shadow: rgba(0,0,0,0.06);
  --primary-color: #4f7df3;
  --primary-light: rgba(79,125,243,0.08);
  --primary-glow: rgba(79,125,243,0.2);
  --gradient-primary: linear-gradient(135deg, #4f7df3, #7c5cf5);
  --danger-color: #ef4444;
  --success-color: #10b981;
  --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-mode,
body.dark-mode {
  --bg-primary: #0c0c18;
  --bg-secondary: #161627;
  --text-primary: #eaeaf2;
  --text-secondary: #a0a0b8;
  --text-light: #8686ab;
  --border-color: #252540;
  --shadow: rgba(0,0,0,0.35);
  --primary-light: rgba(79,125,243,0.12);
  --primary-glow: rgba(79,125,243,0.3);
}

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s var(--transition), color 0.4s var(--transition);
}

body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(79,125,243,0.07) 0%, transparent 65%);
  pointer-events: none;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 24px 60px;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 20px;
}

.header-left { flex: 1; }

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--primary-color);
  text-decoration: none;
  margin-bottom: 10px;
  font-weight: 600;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  background: var(--primary-light);
  transition: all 0.25s var(--transition);
}

.home-link:hover {
  background: var(--primary-glow);
  transform: translateX(-3px);
}

.header-left h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 6px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 400;
}

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

header button {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 9px 12px;
  border-radius: 12px;
  transition: all 0.25s var(--transition);
  color: var(--text-primary);
  line-height: 1;
}

header button:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

/* 다크모드/도움말/언어 아이콘 버튼 — 홈페이지와 동일한 구조 */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.25s var(--transition);
  color: var(--text-secondary);
}

.icon-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--primary-color);
  transform: none;
  box-shadow: none;
}

.theme-icon {
  width: 18px;
  height: 18px;
}

.lang-select {
  position: relative;
}

.lang-toggle {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s var(--transition);
  z-index: 200;
}

.lang-select.open .lang-toggle {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 9px 10px;
  border-radius: 8px;
  transition: all 0.2s var(--transition);
}

.lang-option:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

.lang-option.active {
  color: var(--primary-color);
}

.lang-option .lang-check {
  opacity: 0;
  color: var(--primary-color);
}

.lang-option.active .lang-check {
  opacity: 1;
}

/* ── Style Selector ── */
.style-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.style-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--transition);
  white-space: nowrap;
}

.style-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.style-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* ── Layout ── */
.roulette-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 24px var(--shadow);
}

.panel-left {
  flex: 1;
  min-width: 0;
}

.panel-right {
  flex: 1.2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Input Section ── */
.input-section {
  margin-bottom: 20px;
}

.input-section label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-row {
  display: flex;
  gap: 8px;
}

#item-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.25s var(--transition), box-shadow 0.25s var(--transition);
  min-width: 0;
}

#item-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

#item-input::placeholder {
  color: var(--text-light);
}

/* ── Primary / Action Buttons ── */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--transition);
  box-shadow: 0 3px 10px var(--primary-glow);
  white-space: nowrap;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--transition);
}

.action-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

.btn-danger-outline {
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.btn-danger-outline:hover {
  background: var(--danger-color);
  color: #fff;
  border-color: var(--danger-color);
}

/* ── Items List ── */
.items-list-section {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.items-header h2 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.item-count {
  font-weight: 400;
  color: var(--text-light);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.items-list::-webkit-scrollbar {
  width: 4px;
}

.items-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.empty-msg {
  color: var(--text-light);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

.item-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  transition: all 0.2s var(--transition);
  animation: tagIn 0.25s var(--transition);
}

@keyframes tagIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.item-row:hover {
  border-color: var(--danger-color);
}

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

.item-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.item-delete:hover {
  color: var(--danger-color);
  background: rgba(231, 76, 60, 0.1);
}

/* ── Spin Button ── */
.btn-spin {
  padding: 16px 40px;
  font-size: 1.1rem;
  min-width: 160px;
  border-radius: 14px;
  letter-spacing: -0.3px;
}

/* ── Roulette Wheel ── */
.roulette-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
}

.pointer-arrow {
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid var(--primary-color);
  z-index: 10;
  filter: drop-shadow(0 2px 6px var(--primary-glow));
  margin-bottom: -8px;
}

.roulette-wheel {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px var(--shadow);
  position: relative;
  overflow: hidden;
  border: 4px solid var(--border-color);
  transition: border-color 0.3s, box-shadow 0.3s;
}

/* 네온: 테마에 따라 글로우 스타일 분리 */
.roulette-wheel[data-style="neon"] {
  border-color: #3a86ff;
  box-shadow: 0 0 20px rgba(58,134,255,0.3), 0 8px 32px var(--shadow);
}

body.dark-mode .roulette-wheel[data-style="neon"] {
  box-shadow: 0 0 0 2px #0f0f1f, 0 0 24px rgba(58,134,255,0.5), 0 8px 32px rgba(0,0,0,0.6);
}

/* 브랜드: 사이트 그라데이션 테두리 */
.roulette-wheel[data-style="brand"] {
  border-color: transparent;
  background: linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
              linear-gradient(135deg, #4f7df3, #ec4899) border-box;
  box-shadow: 0 8px 32px rgba(79,125,243,0.2);
}

#wheel-canvas {
  width: 100%;
  height: 100%;
}

/* ── Result Section ── */
.result-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  animation: fadeIn 0.4s var(--transition);
  width: 100%;
  margin-top: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.result-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-box {
  background: var(--bg-secondary);
  border: 2px solid var(--primary-color);
  border-radius: 14px;
  padding: 20px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 16px;
  box-shadow: 0 4px 16px var(--primary-glow);
  letter-spacing: -0.5px;
}

/* ── Spin History ── */
.spin-history {
  margin-top: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 20px;
}

.history-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-primary);
  font-size: 0.85rem;
  transition: background 0.2s;
}

.history-item.latest {
  background: var(--primary-light);
  border: 1px solid var(--primary-color);
}

.history-item-name {
  font-weight: 700;
  color: var(--text-primary);
}

.history-item.latest .history-item-name {
  color: var(--primary-color);
}

.history-item-time {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeBg 0.2s ease;
  padding: 20px;
}

@keyframes fadeBg {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.35s var(--transition);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.modal-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

@keyframes modalIn {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-box h2 {
  margin-bottom: 18px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.shortcuts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 10px;
  transition: background 0.2s;
}

.shortcut-item:hover {
  background: var(--primary-light);
}

.shortcut-item kbd {
  background: var(--gradient-primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Inter', monospace;
  box-shadow: 0 2px 6px var(--primary-glow);
  letter-spacing: 0.3px;
}

.shortcut-item span {
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-close-btn {
  width: 100%;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 3px 10px var(--primary-glow);
}

.modal-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }

::selection {
  background: var(--primary-glow);
  color: var(--text-primary);
}

*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .roulette-layout {
    flex-direction: column;
  }

  .container {
    padding: 24px 16px 50px;
  }

  .lang-toggle { min-width: 140px; right: -4px; }
  .lang-option { padding: 8px 8px; font-size: 0.8rem; }

  .panel {
    padding: 20px;
  }

  .roulette-wheel {
    width: 260px;
    height: 260px;
  }

  .header-left h1 {
    font-size: 1.5rem;
  }

  .btn-spin {
    min-width: 140px;
    padding: 12px 28px;
    font-size: 1rem;
  }

  .result-box {
    font-size: 1.2rem;
  }

  .items-list {
    max-height: 200px;
  }

  .style-selector {
    gap: 4px;
  }

  .style-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color);
  animation: toastIn 0.35s var(--transition);
}

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* 모바일 가로 스크롤 방지 — 배경 장식(fixed blob)이 뷰포트 밖으로 넘쳐도 가로 스크롤이 생기지 않게 한다 */
html { overflow-x: hidden; }
