:root {
  --bg: #0f1220;
  --text: #e9ecf1;
  --muted: #a7afc2;
  --primary: #6c9cff;
  --primary-700: #4e7ee3;
  --surface: #171b2e;
  --surface-2: #1e2540;
  --accent: #ffd166;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Apple Color Emoji, Segoe UI Emoji;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, #1b2040, #0f1220 60%);
}

.app-header {
  padding: 24px 20px 8px;
  text-align: center;
}
.app-header h1 { margin: 0; font-size: 28px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; display: none; }

.layout { display: grid; grid-template-columns: minmax(0,1fr) 420px; gap: 24px; padding: 0 20px 24px; align-items: start; justify-items: center; min-height: calc(100vh - 120px); }
.layout.full-width { grid-template-columns: 1fr; }
.layout.full-width { align-items: center; }

.wheel-section { display: flex; flex-direction: column; align-items: center; gap: 12px; justify-content: center; width: 100%; }
.wheel-wrapper { position: relative; width: min(90vmin, 640px); height: min(90vmin, 640px); margin-inline: auto; }
.wheel-wrapper canvas { width: 100%; height: 100%; border-radius: 50%; background: var(--surface); box-shadow: 0 20px 60px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.05); }
.pointer { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 28px; color: var(--accent); text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.pointer::after { content: ""; position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 12px solid var(--accent); filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }

.controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#spinButton { display: block; width: min(380px, 90%); font-size: 20px; padding: 14px 22px; align-self: center; order: -1; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--primary); color: white; font-weight: 600; }
button.secondary { background: var(--surface-2); color: var(--text); }
button:hover { filter: brightness(1.06); }
button.secondary:hover { box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
button:disabled { opacity: .6; cursor: not-allowed; }

.result { min-height: 36px; font-size: 28px; font-weight: 800; letter-spacing: .2px; }

.editor-section { background: rgba(255,255,255,.02); border-radius: 16px; padding: 16px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); height: fit-content; transition: grid-template-rows .3s ease, opacity .25s ease, transform .25s ease; overflow: hidden; }
.editor-section.collapsed { padding-top: 0; padding-bottom: 0; height: 0; opacity: 0; transform: translateY(-6px); box-shadow: none; }
.editor-section h2 { margin-top: 0; }

.table-wrap { max-height: 420px; overflow: auto; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; }
thead tr { background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr:nth-child(odd) { background: rgba(255,255,255,.02); }
input[type="text"], input[type="number"] { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); background: #0f1220; color: var(--text); }

.meta { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; background: var(--surface-2); cursor: pointer; user-select: none; }
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox.active { outline: 2px solid rgba(255,255,255,.12); background: #24305a; }

.storage { margin-top: 12px; display: flex; gap: 8px; }
.storage { flex-wrap: wrap; }

.app-footer { text-align: center; color: var(--muted); padding: 16px; font-size: 12px; position: sticky; top: 100vh; margin-top: auto; }
.app-footer a { color: var(--primary); }

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-result {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 30px 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
}

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

.modal-btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
}

.modal-btn-danger {
  background: var(--danger);
  color: white;
}

.modal-btn-danger:hover {
  background: #e55555;
  transform: translateY(-1px);
}

.modal-btn:active {
  transform: translateY(0);
}

@media (max-width: 1024px) { .layout { grid-template-columns: 1fr; } }