@font-face {
  font-family: 'Quicksand';
  src: url('/fonts/quicksand-variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fdf1ef;
  --surface: #ffffff;
  --surface-alt: #fff7f5;
  --text: #2b1620;
  --text-muted: #7a5560;
  --primary: #e0344f;
  --primary-strong: #b8253c;
  --primary-contrast: #ffffff;
  --secondary: #1f9e93;
  --border: #f2d9d6;
  --shadow: rgba(43, 22, 32, 0.12);
}

:root[data-theme="dark"] {
  --bg: #191019;
  --surface: #241826;
  --surface-alt: #2c1e2f;
  --text: #f7e9ee;
  --text-muted: #cba8b6;
  --primary: #ff5d78;
  --primary-strong: #ff7d92;
  --primary-contrast: #1a0f14;
  --secondary: #33d6c6;
  --border: #3a2836;
  --shadow: rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191019;
    --surface: #241826;
    --surface-alt: #2c1e2f;
    --text: #f7e9ee;
    --text-muted: #cba8b6;
    --primary: #ff5d78;
    --primary-strong: #ff7d92;
    --primary-contrast: #1a0f14;
    --secondary: #33d6c6;
    --border: #3a2836;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Quicksand', 'Trebuchet MS', 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.icon-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:active {
  transform: scale(0.92);
}

.intro {
  margin: 12px 0 14px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.4;
}

.magic-number {
  margin: 0 0 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  width: fit-content;
}

.categories {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .categories {
    grid-template-columns: 1fr 1fr;
  }
}

.category {
  padding: 14px 14px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 2px 8px var(--shadow);
}

.category-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.category-icon {
  font-size: 22px;
  line-height: 1;
}

.category-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
}

.redo-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.redo-btn:active {
  transform: scale(0.9);
}

.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.options input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  touch-action: manipulation;
  transition: outline 0.1s ease, opacity 0.2s ease;
}

.options input::placeholder {
  color: var(--text-muted);
  opacity: 0.55;
  font-weight: 400;
}

.options input:focus {
  outline: 2px solid var(--secondary);
  outline-offset: 1px;
}

.options input[readonly] {
  cursor: default;
}

.options input.flash {
  outline: 2px solid var(--secondary);
  background: var(--bg);
}

.options input.eliminated {
  text-decoration: line-through;
  opacity: 0.4;
}

.options input.eliminated::placeholder {
  text-decoration: line-through;
}

.options input.winner {
  border-color: var(--primary);
  border-width: 2px;
  background: var(--surface);
  font-weight: 700;
  opacity: 1;
}

.options input.winner::placeholder {
  color: var(--text);
  opacity: 1;
  font-weight: 700;
}

.generator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  text-align: center;
}

.generator-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.swirl-wrap {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
}

#swirl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  touch-action: none;
  cursor: crosshair;
}

.or-divider {
  margin: 2px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.btn {
  width: 100%;
  max-width: 260px;
  min-height: 52px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-primary {
  color: var(--primary-contrast);
  background: var(--primary-strong);
  box-shadow: 0 4px 10px var(--shadow);
}

.btn-secondary {
  color: var(--primary-contrast);
  background: var(--secondary);
  box-shadow: 0 4px 10px var(--shadow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .redo-btn,
  .icon-btn {
    transition: none;
  }
}

@media print {
  .icon-group,
  .intro,
  .generator,
  .redo-btn {
    display: none;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .app {
    max-width: 100%;
    padding: 0;
  }

  .topbar h1 {
    color: #000000;
  }

  .categories {
    grid-template-columns: 1fr;
  }

  .category {
    background: #ffffff;
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .category-label {
    color: #000000;
  }

  .options input {
    background: #ffffff;
    border: none;
    color: #000000;
    font-size: 14px;
  }

  .options input::placeholder {
    color: #000000;
    opacity: 1;
  }

  .options input.eliminated {
    display: none;
  }

  .options input.winner {
    font-size: 17px;
    font-weight: 700;
  }
}
