:root {
  --bg: #0e1117;
  --ink: #f8fafc;
  --muted: #a8b0bd;
  --panel: #171b24;
  --panel-strong: #202636;
  --line: #30384a;
  --accent: #ff5a4f;
  --accent-dark: #ffb454;
  --teal: #24d2c8;
  --yellow: #ffc857;
  --green: #65d183;
  --blue: #6ea8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

[data-theme="cyberpunk"] {
  --bg: #050505;
  --panel: rgba(10, 10, 10, 0.9);
  --accent: #00f2ff;
  --accent-dark: #ff00ff;
  --ink: #fff;
  --line: #300030;
}

[data-theme="casino"] {
  --bg: #1a472a;
  --panel: rgba(20, 40, 30, 0.9);
  --accent: #ffd700;
  --accent-dark: #c0c0c0;
  --ink: #fffad5;
  --line: #2d5a3e;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  transition: background 0.8s ease;
  overscroll-behavior-y: none; /* Prevent rubber-band lockup during fast scrolls */
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 0% 0%, var(--accent) 0%, transparent 35%),
    radial-gradient(circle at 100% 0%, var(--accent-dark) 0%, transparent 35%),
    radial-gradient(circle at 100% 100%, var(--accent) 0%, transparent 35%),
    radial-gradient(circle at 0% 100%, var(--accent-dark) 0%, transparent 35%);
  filter: blur(80px);
  opacity: 0.35;
  animation: mesh-float 20s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes mesh-float {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.1) translate(20px, -20px); }
  100% { transform: scale(1) translate(-10px, 20px); }
}

/* Disable heavy animation on mobile/low-end/reduced-motion */
@media (max-width: 760px), (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
    filter: blur(60px);
    opacity: 0.22;
  }
}

body.presentation-mode .control-panel,
body.presentation-mode .topbar,
body.presentation-mode .result-panel {
  display: none;
}

body.presentation-mode .app-shell {
  grid-template-columns: 1fr;
}

body.presentation-mode .workspace {
  min-height: calc(100vh - 48px);
}

body.presentation-mode .stage {
  min-height: calc(100vh - 48px);
  padding: 24px;
}

body.presentation-mode .wheel-wrap {
  width: min(82vh, 92vw);
}

body.presentation-mode .live-strip {
  position: static;
  width: min(360px, calc(100% - 44px));
}

body.presentation-mode .spin-button {
  width: clamp(112px, 14vw, 160px);
}

.presentation-exit {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  z-index: 20;
  display: none;
  min-height: 44px;
  border: 1px solid rgba(255, 180, 84, 0.75);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffb454, #ff5a4f);
  color: #171717;
  padding: 0 16px;
  font-weight: 900;
  box-shadow: 0 14px 26px rgba(255, 90, 79, 0.24);
}

body.presentation-mode .presentation-exit {
  display: inline-flex;
  align-items: center;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:active:not(:disabled) {
  transform: scale(0.96) translateY(1px);
}

.icon-button:hover,
.ghost-button:hover,
.primary-small:hover {
  border-color: var(--accent);
  background: var(--panel-strong);
  box-shadow: 0 0 20px rgba(255, 90, 79, 0.15);
}

.shuffle-button:hover {
  transform: scale(1.02) translateY(-2px);
  box-shadow: 0 20px 40px rgba(255, 90, 79, 0.35);
}

.spin-button:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.97);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

.workspace,
.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: background 0.8s ease, border-color 0.8s ease;
}

.workspace {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px 10px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.top-actions,
.preset-row,
.history-head,
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  align-self: start;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-switcher {
  display: flex;
  gap: 5px;
  background: var(--panel-strong);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.theme-switcher button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

[data-theme-btn="default"] { background: linear-gradient(135deg, #ff5a4f, #24d2c8); }
[data-theme-btn="cyberpunk"] { background: linear-gradient(135deg, #00f2ff, #ff00ff); }
[data-theme-btn="casino"] { background: linear-gradient(135deg, #ffd700, #1a472a); }

.icon-button,
.shuffle-button,
.ghost-button,
.primary-small,
.primary-button,
.preset-row button,
.history-head button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  font-size: 1.2rem;
}

.shuffle-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 16px 0 10px;
  border-color: rgba(255, 180, 84, 0.75);
  background: linear-gradient(135deg, #ffb454, #ff5a4f);
  color: #171717;
  box-shadow: 0 14px 26px rgba(255, 90, 79, 0.24);
}

.shuffle-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: rgba(23, 23, 23, 0.18);
  color: #171717;
  font-size: 0.72rem;
}

.ghost-button {
  min-height: 44px;
  padding: 0 16px;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(340px, 760px);
  align-items: center;
  justify-content: center;
  gap: 28px;
  flex: 1;
  padding: 16px 30px 34px;
}

.live-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  width: min(420px, 100%);
  justify-self: center;
}

.live-strip div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid rgba(101, 209, 131, 0.28);
  border-radius: 8px;
  background: rgba(16, 20, 28, 0.78);
  text-align: center;
}

.live-strip span {
  color: var(--green);
  font-size: 1.35rem;
  font-weight: 900;
}

.live-strip small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.wheel-wrap {
  position: relative;
  width: min(72vh, 100%, 760px);
  max-width: 760px;
  aspect-ratio: 1;
  margin: auto;
}

.wheel-wrap:hover {
  transform: scale(1.01);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wheel-wrap {
  cursor: grab;
  transition: transform 0.4s ease;
}

.wheel-wrap:active {
  cursor: grabbing;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.45);
  animation: idle-spin 18s linear infinite;
  border-radius: 50%;
  will-change: transform;
  touch-action: pan-y; /* Allow vertical scroll through the wheel */
}

.wheel-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
  pointer-events: none;
  z-index: 2;
}

canvas.spinning {
  animation: none;
}

canvas.idle-off {
  animation: none;
}

@keyframes idle-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.pointer {
  position: absolute;
  top: 50%;
  right: -3px;
  width: 0;
  height: 0;
  border-top: 18px solid transparent;
  border-bottom: 18px solid transparent;
  border-right: 38px solid var(--ink);
  transform: translateY(-50%);
  filter: drop-shadow(0 4px 0 rgba(255, 255, 255, 0.55));
}

.spin-button {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: clamp(98px, 16vw, 136px);
  aspect-ratio: 1;
  place-items: center;
  border: 8px solid #202636;
  border-radius: 50%;
  background: #f8fafc;
  color: #171717;
  font-size: 1.35rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow: 0 18px 38px rgba(23, 23, 23, 0.28);
  touch-action: none;
}

.spin-button:disabled {
  cursor: wait;
  opacity: 0.86;
}

.result-panel {
  width: min(680px, 100%);
  justify-self: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: auto;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 38, 54, 0.62);
}

.status-dot {
  width: 13px;
  height: 13px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(90, 164, 105, 0.15);
}

.panel-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-panel h2 {
  margin-bottom: 12px;
  font-size: clamp(1.75rem, 3vw, 2.75rem);
  line-height: 1;
}

.result-panel p:last-of-type {
  color: var(--muted);
  line-height: 1.55;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.stat-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-grid div:hover {
  transform: translateY(-4px);
  border-color: var(--accent-dark);
}

.stat-grid strong,
.stat-grid span {
  display: block;
}

.stat-grid strong {
  font-size: 1.5rem;
}

.stat-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 8px;
  padding: 22px;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.panel-header {
  justify-content: space-between;
}

.panel-header h2 {
  margin-bottom: 0;
  font-size: 1.6rem;
}

.primary-small,
.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #0e1117;
}

.primary-small {
  min-height: 40px;
  padding: 0 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

.field input,
.field select,
.entry input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141c;
  padding: 0 12px;
  color: var(--ink);
}

.field select {
  appearance: none;
}

.preset-row {
  flex-wrap: wrap;
}

.preset-row button,
.history-head button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
}

.toolbar,
.customize-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.customize-card {
  gap: 13px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.entries {
  display: grid;
  gap: 10px;
}

.entry {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 42px 62px 36px;
  gap: 9px;
  align-items: center;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--line);
}

.entry input[type="number"] {
  padding: 0 6px;
  text-align: center;
}

.color-input {
  min-height: 42px;
  padding: 4px;
}

.palette-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.palette-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141c;
  color: var(--muted);
  font-weight: 800;
}

.palette-row button.active {
  border-color: var(--accent-dark);
  background: rgba(255, 180, 84, 0.14);
  color: var(--ink);
}

.range-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

.range-field-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.range-field input {
  accent-color: var(--accent);
  width: 100%;
  touch-action: pan-x;
  direction: ltr;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.range-scale span:last-child {
  color: var(--accent-dark);
}

.range-field output {
  color: var(--accent-dark);
  font-weight: 800;
}

.remove-entry {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141c;
  color: var(--muted);
  font-weight: 900;
}

.history-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.history-head {
  justify-content: space-between;
}

.history-head h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

ol {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  margin: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  overflow: auto;
}

dialog::backdrop {
  background: rgba(23, 23, 23, 0.48);
  backdrop-filter: blur(5px);
}

.dialog-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: var(--shadow);
}

.dialog-card h2 {
  margin-bottom: 10px;
  font-size: 3rem;
}

.dialog-card p:not(.eyebrow) {
  color: var(--muted);
}

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  animation: fall 1.8s linear forwards;
}

@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(1080deg); opacity: 0; }
}

.confetti.circle { border-radius: 50%; }
.confetti.triangle {
  width: 0; height: 0; background: transparent !important;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 10px solid var(--c);
}

.reveal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.reveal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.reveal-text {
  font-size: 5rem;
  font-weight: 900;
  color: var(--ink);
  text-shadow: 0 0 30px var(--accent);
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.28);
}

.reveal-overlay.active .reveal-text {
  transform: scale(1);
  opacity: 1;
}

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.seo-content {
  padding:
    48px max(24px, env(safe-area-inset-right))
    max(56px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  border-top: 1px solid rgba(75, 86, 112, 0.45);
  background: rgba(14, 17, 23, 0.92);
}

.seo-content-inner {
  max-width: 760px;
  margin: 0 auto;
}

.seo-content h2 {
  margin-bottom: 18px;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  line-height: 1.15;
}

.seo-content h3 {
  margin: 28px 0 12px;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  line-height: 1.25;
  color: var(--accent-dark);
}

.seo-content p {
  margin-bottom: 16px;
  color: #c5ccd8;
  font-size: 1rem;
  line-height: 1.75;
}

.seo-content p:last-child {
  margin-bottom: 0;
}

.seo-content strong {
  color: var(--ink);
  font-weight: 700;
}

body.presentation-mode .seo-content {
  display: none;
}

.faq-section {
  padding:
    0 max(24px, env(safe-area-inset-right))
    max(56px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  background: rgba(14, 17, 23, 0.92);
}

.faq-section .seo-content-inner {
  padding-top: 8px;
  border-top: 1px solid rgba(75, 86, 112, 0.35);
}

.faq-section h2 {
  margin-bottom: 10px;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  line-height: 1.15;
}

.faq-intro {
  margin-bottom: 22px;
  color: #c5ccd8;
  font-size: 1rem;
  line-height: 1.7;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  border: 1px solid rgba(75, 86, 112, 0.72);
  border-radius: 8px;
  background: rgba(23, 27, 36, 0.86);
  overflow: hidden;
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex-shrink: 0;
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item summary h3 {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.12rem);
  line-height: 1.35;
  color: var(--ink);
}

.faq-item p {
  margin: 0;
  padding: 0 18px 18px;
  color: #c5ccd8;
  font-size: 0.98rem;
  line-height: 1.75;
}

.faq-item p strong {
  color: var(--ink);
  font-weight: 700;
}

body.presentation-mode .faq-section {
  display: none;
}

body.presentation-mode .site-footer {
  display: none;
}

.site-footer {
  padding:
    28px max(24px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  border-top: 1px solid rgba(75, 86, 112, 0.45);
  background: rgba(14, 17, 23, 0.96);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  max-width: 960px;
  margin: 0 auto 18px;
}

.site-footer-brand {
  max-width: 320px;
}

.site-logo {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  text-decoration: none;
}

.site-footer-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.site-footer-nav a {
  color: #c5ccd8;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.site-footer-nav a:hover,
.site-footer-nav a:focus-visible,
.site-header-nav a:hover,
.site-header-nav a:focus-visible {
  color: var(--accent-dark);
}

.site-footer-copy {
  max-width: 960px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.site-header {
  padding:
    max(18px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    18px
    max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(75, 86, 112, 0.45);
  background: rgba(14, 17, 23, 0.96);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
}

.site-header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.site-header-nav a {
  color: #c5ccd8;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.site-header-nav a[aria-current="page"] {
  color: var(--accent-dark);
}

.site-header-home {
  position: sticky;
  top: 0;
  z-index: 10;
}

body.presentation-mode .site-header-home {
  display: none;
}

.info-page {
  max-width: 760px;
  margin: 0 auto;
  padding:
    36px max(24px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

.info-page h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.08;
}

.info-page .info-lead {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.info-page h2 {
  margin: 28px 0 10px;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: var(--accent-dark);
}

.info-page p,
.info-page li {
  color: #c5ccd8;
  font-size: 1rem;
  line-height: 1.75;
}

.info-page p {
  margin-bottom: 14px;
}

.info-page ul,
.info-page ol {
  margin: 0 0 16px;
  padding-left: 1.25rem;
}

.info-page li {
  margin-bottom: 8px;
}

.info-page a {
  color: var(--blue);
  font-weight: 600;
}

.info-updated {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.contact-card,
.contact-form {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 36, 0.86);
}

.contact-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141c;
  padding: 0 12px;
  color: var(--ink);
  font-size: 16px;
}

.contact-form textarea {
  min-height: 140px;
  padding: 12px;
  resize: vertical;
}

.contact-form button {
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #0e1117;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.contact-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Formspree Status Messages */
.form-status {
  display: none; /* Managed by @formspree/ajax */
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-weight: 600;
  text-align: center;
}

.form-status.success {
  background: rgba(30, 215, 96, 0.15);
  color: #1ed760;
  border: 1px solid rgba(30, 215, 96, 0.3);
}

.form-status.error {
  background: rgba(251, 77, 61, 0.15);
  color: #fb4d3d;
  border: 1px solid rgba(251, 77, 61, 0.3);
}

.field-error {
  display: block;
  margin-top: 4px;
  color: #fb4d3d;
  font-size: 0.75rem;
  font-weight: 600;
}

.contact-form input[aria-invalid="true"],
.contact-form textarea[aria-invalid="true"] {
  border-color: #fb4d3d;
}

.contact-details {
  display: grid;
  gap: 10px;
}

.contact-details div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.contact-details strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.contact-details span,
.contact-details a {
  color: #c5ccd8;
  font-size: 0.95rem;
}

@media (max-width: 760px) {
  .site-footer-inner {
    flex-direction: column;
  }

  .site-footer-nav {
    flex-direction: column;
    gap: 12px;
  }

  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .info-page {
    padding-top: 28px;
  }
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 220px);
  max-width: 640px;
  margin: 0 auto;
  padding:
    48px max(24px, env(safe-area-inset-right))
    max(56px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  text-align: center;
}

.error-code {
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: 900;
  line-height: 1;
}

.error-page h1 {
  margin-bottom: 12px;
  font-size: clamp(1.65rem, 5vw, 2.35rem);
  line-height: 1.1;
}

.error-page .info-lead {
  margin-bottom: 28px;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.error-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  touch-action: manipulation;
}

.error-button.primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #0e1117;
}

.error-button.ghost {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.error-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-top: 28px;
}

.error-links a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.error-links a:hover,
.error-links a:focus-visible {
  color: var(--accent-dark);
}

@media (max-width: 760px) {
  .error-page {
    min-height: calc(100dvh - 280px);
    padding-top: 32px;
  }

  .error-actions {
    flex-direction: column;
    width: 100%;
  }

  .error-button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .faq-section {
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  .faq-item summary {
    padding: 14px 16px;
  }

  .faq-item p {
    padding: 0 16px 16px;
    font-size: 0.96rem;
  }
}

@media (max-width: 760px) {
  .seo-content {
    padding-top: 36px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  .seo-content p {
    font-size: 0.96rem;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .wheel-wrap {
    width: min(100%, 560px);
  }

  .topbar {
    flex-direction: column;
    gap: 18px;
  }

  .top-actions {
    align-self: stretch;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  body {
    background:
      radial-gradient(circle at 12% 8%, rgba(255, 90, 79, 0.18), transparent 17rem),
      radial-gradient(circle at 88% 20%, rgba(36, 210, 200, 0.13), transparent 18rem),
      linear-gradient(135deg, #0e1117 0%, #161b25 52%, #10131a 100%);
  }

  /* Remove backdrop-filter on mobile for perf */
  .workspace,
  .control-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Reduce canvas shadow on mobile */
  canvas {
    filter: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  }

  .app-shell {
    gap: 14px;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .workspace,
  .control-panel {
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  }

  .topbar,
  .stage {
    padding-inline: 16px;
  }

  .topbar {
    flex-direction: column;
    gap: 16px;
    padding-top: 20px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.4rem);
    line-height: 1;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-self: stretch;
    gap: 8px;
  }

  .top-actions .ghost-button,
  .top-actions .shuffle-button {
    justify-content: center;
    width: 100%;
    padding-inline: 10px;
  }

  .top-actions .icon-button {
    width: 100%;
  }

  .stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding-top: 10px;
    padding-bottom: 20px;
  }

  .wheel-wrap {
    width: min(100%, 540px);
  }

  .pointer {
    right: -2px;
    border-top-width: 13px;
    border-bottom-width: 13px;
    border-right-width: 28px;
  }

  .spin-button {
    width: clamp(84px, 25vw, 112px);
    border-width: 6px;
    font-size: 1.1rem;
  }

  .live-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 auto;
  }

  .live-strip div {
    min-width: 0;
    padding-inline: 10px;
  }

  .result-panel {
    padding: 16px;
  }

  .result-panel h2 {
    overflow-wrap: anywhere;
  }

  .control-panel {
    gap: 15px;
    padding: 16px;
    overscroll-behavior: auto; /* Don't trap scroll on mobile */
  }

  .panel-header {
    align-items: end;
  }

  .toolbar,
  .customize-card,
  .history-card {
    padding: 13px;
  }

  .entry {
    grid-template-columns: 18px minmax(0, 1fr) 42px 52px 36px;
    gap: 7px;
  }

  .field input,
  .field select,
  .entry input {
    min-height: 44px;
  }

  .color-input {
    padding: 5px;
  }

  .dialog-card {
    padding: 24px 18px;
  }

  .dialog-card h2 {
    overflow-wrap: anywhere;
    font-size: 2.35rem;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .topbar,
  .stage {
    padding-inline: 12px;
  }

  .top-actions {
    grid-template-columns: 1fr 1fr;
  }

  .ghost-button,
  .shuffle-button {
    min-height: 42px;
  }

  .wheel-wrap {
    width: min(100%, 420px);
  }

  .live-strip small {
    font-size: 0.68rem;
  }

  .control-panel {
    padding: 14px 12px;
  }

  .panel-header h2 {
    font-size: 1.35rem;
  }

  .primary-small {
    min-height: 38px;
    padding-inline: 12px;
  }

  .preset-row,
  .palette-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preset-row button,
  .palette-row button {
    min-width: 0;
    padding-inline: 6px;
  }

  .entry {
    grid-template-columns: 16px minmax(0, 1fr) 38px 46px 34px;
    gap: 6px;
  }

  .swatch {
    width: 16px;
    height: 16px;
  }

  .entry input[type="number"] {
    padding-inline: 3px;
  }
}

@media (max-width: 340px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .entry {
    grid-template-columns: minmax(0, 1fr) 38px 46px 34px;
  }

  .entry .swatch {
    display: none;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
  }

  .wheel-wrap {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: min(100%, 62vh);
    align-self: center;
  }

  .live-strip {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
  }

  .result-panel {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
  }

  body.presentation-mode .wheel-wrap {
    width: min(74vh, 100%);
  }
}

@media (max-width: 760px) {
  body.presentation-mode .workspace,
  body.presentation-mode .stage {
    min-height: 100svh;
  }

  body.presentation-mode .stage {
    padding: 16px 12px;
  }

  body.presentation-mode .wheel-wrap {
    width: min(100%, 78vh);
  }

  body.presentation-mode .live-strip {
    width: min(360px, 100%);
  }

  .field input,
  .field select,
  .entry input {
    font-size: 16px;
  }

  .toggle {
    align-items: flex-start;
  }

  .toggle input {
    flex-shrink: 0;
    margin-top: 2px;
    width: 20px;
    height: 20px;
  }

  .remove-entry {
    width: 44px;
    height: 44px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .icon-button,
  .ghost-button,
  .shuffle-button,
  .primary-small,
  .primary-button,
  .preset-row button,
  .history-head button,
  .palette-row button,
  .remove-entry {
    min-height: 44px;
  }

  .spin-button {
    width: clamp(96px, 28vw, 128px);
  }

  /* Disable hover scale on touch to avoid sticky hover states */
  .wheel-wrap:hover {
    transform: none;
  }

  .stat-grid div:hover {
    transform: none;
  }

  button:active:not(:disabled) {
    transform: scale(0.95) translateY(0);
  }
}
