:root {
  --primary: #6366f1;
  /* Indigo 500 */
  --primary-hover: #4f46e5;
  --bg-color: #0f172a;
  /* Slate 900 */
  --surface: #1e293b;
  /* Slate 800 */
  --surface-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #334155;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* Typography */
h1,
h2,
h3 {
  font-weight: 600;
}

.header-title {
  font-size: 1.25rem;
  letter-spacing: 0.05em;
}

.screen-header {
  padding: 1.5rem;
}

.screen-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.screen-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.section-title {
  font-size: 1.1rem;
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* Layout & Common Classes */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

main {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
  position: relative;
}

.screen {
  display: none;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen.active {
  display: block;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons and Inputs */
button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  outline: none;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--surface-hover);
}

.text-btn {
  color: var(--primary);
  font-weight: 500;
  padding: 0.5rem;
  font-size: 1rem;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: white;
  border-radius: 14px;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
}

.primary-btn:hover,
.primary-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px 0 rgba(99, 102, 241, 0.2);
}

.primary-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 1rem;
  font-size: 0.95rem;
  width: 100%;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: var(--surface-hover);
  border-style: solid;
  border-color: var(--text-muted);
}

.danger-btn {
  background: var(--danger);
  color: white;
  border-radius: 14px;
  padding: 1rem;
  font-weight: 600;
  width: 100%;
}

.danger-btn.outline {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: white;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 1rem;
  transition: border 0.3s, box-shadow 0.3s;
}

.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.num-input {
  width: 70px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  color: white;
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  text-align: center;
  font-size: 1rem;
}

.num-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* Utility */
.hidden {
  display: none !important;
}

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

.mt-4 {
  margin-top: 1.5rem;
}

.mb-2 {
  margin-bottom: 0.75rem;
}

/* Drawer */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  transition: opacity 0.3s;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  background: var(--bg-color);
  border-right: 1px solid var(--border);
  z-index: 60;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding-top: 70px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem;
}

.drawer li button {
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  border-radius: 12px;
  transition: all 0.2s;
  color: var(--text-muted);
}

.drawer li button:hover {
  background: var(--surface);
  color: var(--text-main);
}

.drawer li button.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  font-weight: 600;
}

/* Main Screen (Roulette) */
.roulette-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 2rem 1rem;
  margin-top: 1rem;
}

.indicator {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-main);
  font-size: 2.5rem;
  text-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

canvas {
  max-width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(0, 0, 0, 0.5);
  background: var(--surface);
}

.main-actions {
  padding: 1.5rem;
  text-align: center;
}

.preset-name {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  color: var(--primary);
}

.spin-btn {
  height: 74px;
  font-size: 1.5rem;
  letter-spacing: 0.15em;
  border-radius: 37px;
}

/* Items List */
.items-list {
  padding: 0 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--surface);
  padding: 0.5rem;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.item-row .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 0.5rem;
  font-size: 1.2rem;
}

.item-row .delete-btn {
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
}

.item-row .delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
}

/* Bottom Bar */
.pb-bottom-bar {
  padding-bottom: 200px;
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 30;
}

.column-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* Preset List */
.preset-list {
  padding: 0 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preset-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.preset-card:active {
  transform: scale(0.98);
}

.preset-card.active-preset {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.preset-card.active-preset::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.preset-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
  color: #fff;
}

.preset-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal.hidden {
  display: none !important;
  opacity: 0;
}

.modal-content {
  background: var(--surface);
  border-radius: 24px;
  padding: 3rem 2rem;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(1) translateY(0);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal.hidden .modal-content {
  transform: scale(0.95) translateY(20px);
}

.modal-title {
  color: var(--primary);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.winner-text {
  font-size: 2.8rem;
  font-weight: 800;
  color: white;
  margin-bottom: 1.5rem;
  line-height: 1.2;
  word-break: break-word;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Form Group */
.form-group {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group label {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}