/* style.css — Glücksrad */

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

/* ─── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f8;
  --bg2: #e8eaf2;
  --surface: #ffffff;
  --surface2: #f5f6fa;
  --border: #e0e3ef;
  --text: #1a1d2e;
  --text2: #6b7280;
  --accent: #5c6ef8;
  --accent-hover: #4a5cf5;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --toolbar-h: 56px;
  --tabs-h: 48px;
  --sidebar-w: 340px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ─── Toolbar ──────────────────────────────────────────────────────────────── */
#toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  box-shadow: var(--shadow);
  z-index: 10;
  flex-shrink: 0;
}

.toolbar-logo {
  font-size: 20px;
  font-weight: 900;
  color: var(--accent);
  margin-right: 8px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
  white-space: nowrap;
}
.toolbar-btn:hover, .toolbar-btn:active { background: var(--bg2); color: var(--text); }

.toolbar-btn svg {
  width: 18px; height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.toolbar-sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.toolbar-spacer { flex: 1; }

#fullscreen-btn {
  padding: 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  min-height: 44px; min-width: 44px;
  display: flex; align-items: center; justify-content: center;
}
#fullscreen-btn svg { width: 20px; height: 20px; fill: currentColor; }
#fullscreen-btn:hover { background: var(--bg2); }

/* ─── Wheel Tabs ───────────────────────────────────────────────────────────── */
#wheel-tabs-bar {
  height: var(--tabs-h);
  min-height: var(--tabs-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  scrollbar-width: none;
}
#wheel-tabs-bar::-webkit-scrollbar { display: none; }

#wheel-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.wheel-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  background: transparent;
  border: 2px solid transparent;
  min-height: 36px;
  white-space: nowrap;
  transition: all 0.15s;
}
.wheel-tab:hover { background: var(--bg2); color: var(--text); }
.wheel-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.wheel-tab-name { pointer-events: none; }

.wheel-tab-rename-input {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  background: none;
  border: none;
  outline: none;
  color: white;
  width: 80px;
}

.wheel-tab-del {
  font-size: 14px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: white;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.wheel-tab-del:hover { background: rgba(255,255,255,0.4); }

.wheel-tab-add {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border: 2px dashed var(--accent);
  background: transparent;
  min-height: 36px;
  white-space: nowrap;
  transition: all 0.15s;
  opacity: 0.7;
}
.wheel-tab-add:hover { opacity: 1; background: rgba(92,110,248,0.06); }

/* ─── Main Content ─────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ─── Wheel Area ───────────────────────────────────────────────────────────── */
#wheel-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  background: linear-gradient(135deg, #f0f2ff 0%, #e8ecff 50%, #f0f4ff 100%);
  overflow: hidden;
  min-width: 0;
}

#wheel-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 30%, rgba(92,110,248,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 70%, rgba(92,110,248,0.04) 0%, transparent 60%);
  pointer-events: none;
}

#wheel-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: visible;
}

#wheel-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
}

#wheel-canvas {
  display: block;
  will-change: transform;
  transform-origin: center center;
  cursor: pointer;
  flex-shrink: 0;
}

/* Pointer: arrow on the right side, left set by JS */
#wheel-pointer {
  position: absolute;
  top: 50%;
  left: 50%; /* overridden by JS */
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 18px solid transparent;
  border-bottom: 18px solid transparent;
  border-right: 34px solid #c62828;
  filter: drop-shadow(-2px 0 5px rgba(0,0,0,0.4));
  z-index: 5;
  pointer-events: none;
}

#spin-btn {
  margin-top: 16px;
  padding: 14px 48px;
  background: var(--accent);
  color: white;
  font-size: 18px;
  font-weight: 900;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(92,110,248,0.4);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  letter-spacing: 0.5px;
  min-height: 54px;
  min-width: 200px;
  flex-shrink: 0;
}
#spin-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(92,110,248,0.5); }
#spin-btn:active { transform: translateY(0); }
#spin-btn:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }
#spin-btn.spinning { background: #7986cb; }

.spin-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

#sidebar-toggle {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 48px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px 0 0 8px;
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  box-shadow: -2px 0 8px rgba(0,0,0,0.1);
  cursor: pointer;
}

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.sidebar-tab-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  min-height: 48px;
}
.sidebar-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.badge {
  background: var(--accent);
  color: white;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

/* ─── Entries Tab ──────────────────────────────────────────────────────────── */
#tab-entries {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0;
}

.entries-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.action-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
}
.action-btn:hover { background: var(--bg2); border-color: #c0c4d8; }
.action-btn:active { background: #dde0f0; }

#entries-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  overscroll-behavior: contain;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
}
.entry-item:hover { background: var(--surface2); }
.entry-item:hover .entry-del-btn { opacity: 1; }

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

.entry-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  padding: 2px 4px;
  border-radius: 4px;
  min-height: 24px;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.entry-name:focus { background: rgba(92,110,248,0.08); }

.entry-del-btn {
  opacity: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(239,68,68,0.12);
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}
.entry-del-btn:hover { background: rgba(239,68,68,0.22); }

/* On touch devices always show delete */
@media (hover: none) {
  .entry-del-btn { opacity: 0.6; }
}

.new-entry-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

#new-entry-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font: 700 14px 'Nunito', sans-serif;
  background: var(--surface2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px;
  user-select: text;
  -webkit-user-select: text;
}
#new-entry-input:focus { border-color: var(--accent); }
#new-entry-input::placeholder { color: var(--text2); font-weight: 600; }

#add-entry-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-size: 24px;
  font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#add-entry-btn:hover { background: var(--accent-hover); }
#add-entry-btn:active { transform: scale(0.95); }

/* ─── Results Tab ──────────────────────────────────────────────────────────── */
#tab-results {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.results-header span { font-size: 13px; font-weight: 700; color: var(--text2); }

#clear-results-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s;
  min-height: 36px;
}
#clear-results-btn:hover { background: rgba(239,68,68,0.2); }

#results-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  overscroll-behavior: contain;
}

.results-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.result-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--text2);
  min-width: 28px;
}

.result-winner {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.result-time {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Winner Modal ─────────────────────────────────────────────────────────── */
#winner-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 40, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(4px);
}
#winner-modal.visible { opacity: 1; pointer-events: all; }

.winner-card {
  background: white;
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  max-width: 480px;
  width: 90%;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
}

@keyframes popIn {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.winner-trophy { font-size: 56px; margin-bottom: 8px; line-height: 1; }

.winner-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text2);
  margin-bottom: 10px;
}

#winner-name {
  font-size: 36px;
  font-weight: 900;
  color: var(--text);
  word-break: break-word;
  margin-bottom: 28px;
  line-height: 1.2;
}

#winner-close-btn {
  padding: 14px 40px;
  background: var(--accent);
  color: white;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(92,110,248,0.4);
  transition: transform 0.12s, box-shadow 0.12s;
  min-height: 52px;
}
#winner-close-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(92,110,248,0.5); }

/* ─── Settings Panel ───────────────────────────────────────────────────────── */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#settings-overlay.open { opacity: 1; pointer-events: all; }

#settings-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(400px, 95vw);
  height: 100%;
  background: var(--surface);
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#settings-panel.open { transform: translateX(0); }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  flex-shrink: 0;
}

.settings-header h2 {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
}

#settings-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text2);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#settings-close:hover { background: var(--bg2); }

.settings-body { padding: 20px; display: flex; flex-direction: column; gap: 28px; }

.settings-section h3 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 12px;
}

/* Color schemes */
.color-scheme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.color-scheme-btn {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
  min-height: 64px;
}
.color-scheme-btn:hover { border-color: var(--accent); }
.color-scheme-btn.active { border-color: var(--accent); background: rgba(92,110,248,0.08); }

.scheme-swatches {
  display: flex;
  gap: 3px;
}
.scheme-swatches span {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: block;
}

/* Spin duration */
.btn-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.spin-duration-btn {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  min-height: 44px;
}
.spin-duration-btn:hover { border-color: var(--accent); }
.spin-duration-btn.active { border-color: var(--accent); background: rgba(92,110,248,0.08); color: var(--accent); }

/* Toggles */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.toggle-row label { font-size: 14px; font-weight: 700; color: var(--text); cursor: pointer; }

.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 48px; height: 28px;
  border-radius: 14px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle:checked { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle:checked::after { transform: translateX(20px); }

/* Radio group */
.radio-group { display: flex; flex-direction: column; gap: 10px; }
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}
.radio-row:hover { border-color: var(--accent); }
.radio-row input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }
.radio-row .radio-label { font-size: 13px; font-weight: 700; }
.radio-row .radio-desc { font-size: 12px; color: var(--text2); font-weight: 600; margin-top: 1px; }

/* ─── Confetti Canvas ──────────────────────────────────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 210; /* above winner modal */
}

/* ─── Responsive: Portrait / Small ────────────────────────────────────────── */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
  :root {
    --sidebar-w: 100%;
  }

  #main-content {
    flex-direction: column;
  }

  #wheel-area {
    flex: 0 0 55%;
    padding: 10px;
  }

  #sidebar {
    flex: 1;
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  #sidebar.collapsed {
    flex: 0 0 0;
    height: 0;
  }

  #sidebar-toggle {
    left: 50%;
    transform: translateX(-50%);
    top: -22px;
    width: 48px;
    height: 22px;
    border-radius: 8px 8px 0 0;
    font-size: 12px;
  }

  #spin-btn { font-size: 16px; padding: 12px 36px; }

  .wheel-tab-add { display: none; }
}

@media (max-width: 480px) {
  :root { --toolbar-h: 52px; }
  .toolbar-btn .btn-text { display: none; }
  .toolbar-btn { padding: 8px 10px; }
  #winner-name { font-size: 28px; }
  .winner-card { padding: 28px 24px; }
}

/* Scrollbar styling */
* { scrollbar-width: thin; scrollbar-color: #d1d5db transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* Prevent zoom on input focus iOS */
input, textarea, select { font-size: 16px; }
@media (min-width: 769px) {
  input, textarea, select { font-size: inherit; }
}
