/* Reset and base styles */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --danger: #dc2626;
  --panel: #f8fafc;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0,0,0,0.1);
}

body.dark {
  --bg: #0b0f14;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --primary-contrast: #0b0f14;
  --danger: #f87171;
  --panel: #111827;
  --border: #1f2937;
  --shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; gap: 8px; }

.btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn:hover { filter: brightness(0.95); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: transparent;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 16px;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
  min-height: 200px;
}
.panel h2 { margin: 0 0 8px 0; font-size: 16px; }
.hint { margin: 0 0 8px 0; color: var(--muted); font-size: 13px; }

.left textarea {
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.left .panel-actions { display: flex; gap: 8px; margin-top: 8px; }

.center { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.wheel-wrap {
  --size: min(80vh, 80vw);
  position: relative;
  width: var(--size);
  max-width: 700px;
  aspect-ratio: 1 / 1;
  margin: 4px auto;
}
.wheel-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.06), transparent 50%);
  border: 1px solid var(--border);
}
.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(16px, 2vw, 24px);
}
.center-hint { color: var(--muted); font-size: 13px; }

.right .ads-placeholder { display: flex; flex-direction: column; gap: 8px; }
.right .ad-slot {
  height: 80px;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05) 10px, transparent 10px, transparent 20px);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal[aria-hidden="false"] { display: flex; }
.modal-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  padding: 16px;
}
.modal-content h3 { margin-top: 0; }
.winner-text { font-weight: 600; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: none;
  justify-content: center;
  z-index: 200;
}
.cookie-banner .cookie-inner {
  margin: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  max-width: 800px;
  width: calc(100% - 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cookie-banner .cookie-actions { flex-shrink: 0; }

.footer {
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .right { order: 3; }
  .left { order: 2; }
  .center { order: 1; }
  .wheel-wrap { --size: min(80vw, 80vh); }
}

.icon-btn { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; }
.settings-content { max-width: 700px; }
.settings-section { margin-top: 12px; }
.personalization-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.personalization-row { display: grid; grid-template-columns: 1fr 90px 90px; gap: 8px; align-items: center; }
.personalization-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.personalization-row input[type="number"] { width: 100%; }
.personalization-row input[type="color"] { width: 100%; height: 32px; padding: 0; border: none; background: none; }
/* Make the wheel obviously clickable */
.wheel-wrap { cursor: pointer; }
