:root {
  --ui-bg: rgba(255, 255, 255, 0.9);
  --ui-border: rgba(255, 255, 255, 0.65);
  --ui-shadow: 0 1.2rem 2.5rem rgba(0, 0, 0, 0.12);
  --ui-text: #1e1e1e;
  --ui-muted: #666;
  --ui-backdrop: rgba(0, 0, 0, 0.35);
  --ui-button: rgba(255, 255, 255, 0.95);
  --ui-button-hover: rgba(255, 255, 255, 1);
  --ui-accent: #111;
  --radius-xl: 1.5rem;
  --radius-lg: 1.1rem;
  --radius-md: 0.9rem;
  --radius-sm: 0.75rem;
  --transition: 220ms ease;
  --font-stack: "Poppins", "Inter", "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent !important;
  overflow: hidden;
  font-family: var(--font-stack);
  color: var(--ui-text);
}
body {
  display: grid;
  place-items: center;
}
.widget-shell {
  width: 100%;
  height: 100%;
  background: #f3f3f3;
  position: relative;
  overflow: hidden;
  transition: background 220ms ease;
}
.scale-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1000px;
  height: 1000px;
  transform-origin: center center;
  will-change: transform;
  pointer-events: auto;
}
.stage {
  position: relative;
  width: 1000px;
  height: 1000px;
  background: transparent;
}
.wheel-area {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: transparent;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}
.pointer {
  position: absolute;
  top: 2.8%;
  left: 50%;
  transform: translateX(-50%);
  width: 5.2%;
  height: auto;
  z-index: 20;
  filter: drop-shadow(0 0.35rem 0.6rem rgba(0, 0, 0, 0.15));
  pointer-events: none;
}
.spinner-button {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 19%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 15;
  display: grid;
  place-items: center;
}
.spinner-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.spinner-button:active {
  transform: translate(-50%, -50%) scale(0.985);
}
/* Floating controls */
.top-controls {
  position: fixed;
  bottom: 48px;
  right: 28px;
  display: flex;
  gap: 18px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.widget-shell:hover .top-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.theme-btn,
.settings-btn {
  border: 1px solid var(--ui-border);
  background: var(--ui-button);
  backdrop-filter: blur(0.8rem);
  -webkit-backdrop-filter: blur(0.8rem);
  color: var(--ui-text);
  width: clamp(56px, 5.8vw, 74px);
  height: clamp(56px, 5.8vw, 74px);
  border-radius: 999px;
  box-shadow: var(--ui-shadow);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), color var(--transition);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
}
.theme-btn:hover,
.settings-btn:hover {
  background: var(--ui-button-hover);
  transform: translateY(-1px);
}
.theme-btn img,
.settings-btn img {
  width: 54%;
  height: 54%;
  object-fit: contain;
  pointer-events: none;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ui-backdrop);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 200;
}
.modal-backdrop.show {
  display: flex;
}
.modal {
  width: min(92vw, 34rem);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 1.6rem 3.5rem rgba(0, 0, 0, 0.18);
  padding: 1.2rem;
}
.modal h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal p {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.modal-section {
  margin-top: 1rem;
}
.label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ui-text);
}
textarea,
select,
input[type="text"] {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  font: inherit;
  color: var(--ui-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea {
  min-height: 10.5rem;
  max-height: 18rem;
  resize: vertical;
  overflow: auto;
  line-height: 1.45;
}
textarea:focus,
select:focus,
input[type="text"]:focus {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.06);
}
.help {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--ui-muted);
  line-height: 1.45;
}
.palette-preview {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}
.swatch {
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex: 0 0 auto;
}
.modal-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.15rem;
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  border: none;
  border-radius: 999px;
  padding: 0.82rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: #111;
  color: #fff;
}
.btn-secondary {
  background: rgba(0, 0, 0, 0.06);
  color: #111;
}
#shufflePaletteBtn {
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.06);
  color: #111;
}
#shufflePaletteBtn:hover {
  background: rgba(0, 0, 0, 0.1);
}
.result-modal {
  text-align: center;
  padding: 1.5rem 1.25rem 1.25rem;
}
.result-modal h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
.result-book {
  margin: 0.8rem 0 0;
  font-size: 1.45rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ui-text);
  overflow-wrap: anywhere;
}
.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  pointer-events: none;
  padding: 18%;
  text-align: center;
  color: rgba(0, 0, 0, 0.52);
  font-size: 1.1rem;
  line-height: 1.45;
  font-weight: 500;
}
.widget-shell.dark-mode {
  background: #191919;
}
.widget-shell.dark-mode .theme-btn,
.widget-shell.dark-mode .settings-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  box-shadow: 0 1.2rem 2.5rem rgba(0, 0, 0, 0.28);
}
.widget-shell.dark-mode .theme-btn:hover,
.widget-shell.dark-mode .settings-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.widget-shell.dark-mode .theme-btn img,
.widget-shell.dark-mode .settings-btn img {
  filter: brightness(0) invert(1);
}
.widget-shell.dark-mode .modal {
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.widget-shell.dark-mode .modal h2,
.widget-shell.dark-mode .label,
.widget-shell.dark-mode .result-book {
  color: #ffffff;
}
.widget-shell.dark-mode .modal p,
.widget-shell.dark-mode .help,
.widget-shell.dark-mode .result-modal h3 {
  color: rgba(255, 255, 255, 0.72);
}
.widget-shell.dark-mode textarea,
.widget-shell.dark-mode select,
.widget-shell.dark-mode input[type="text"] {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.widget-shell.dark-mode textarea:focus,
.widget-shell.dark-mode select:focus,
.widget-shell.dark-mode input[type="text"]:focus {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.08);
}
.widget-shell.dark-mode .btn-secondary,
.widget-shell.dark-mode #shufflePaletteBtn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.widget-shell.dark-mode #shufflePaletteBtn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.hidden {
  display: none !important;
}
