*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #e8e8e8;
  padding: 1rem;
  line-height: 1.5;
}

.wrap { max-width: 52rem; margin: 0 auto; }

header { text-align: center; margin-bottom: 1.25rem; }

header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }

header h1 a { color: inherit; text-decoration: none; }

header p { color: #9ca3af; font-size: 0.9rem; margin-top: 0.25rem; }

.site-brand {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.site-brand a {
  color: #60a5fa;
  text-decoration: none;
}

.site-brand a:hover { text-decoration: underline; }

header .page-tagline { margin-top: 0.35rem; }

.page-intro {
  max-width: 42rem;
  margin: 0 auto 1.25rem;
  padding: 0 0.25rem;
  font-size: 0.9rem;
  color: #9ca3af;
  line-height: 1.65;
}

.page-intro p + p { margin-top: 0.65rem; }

.page-intro a { color: #60a5fa; }

.page-intro code {
  font-size: 0.85em;
  background: rgba(255,255,255,0.08);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}

.main-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.main-tabs a {
  flex: 1;
  min-width: 7rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.06);
  color: #e8e8e8;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.main-tabs a:hover { background: rgba(255,255,255,0.12); }

.main-tabs a.active {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-color: transparent;
  color: #fff;
}

.card {
  background: rgba(22, 22, 35, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  max-height: 8rem;
  overflow-y: auto;
  padding-bottom: 0.25rem;
}

.sub-nav button {
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 2rem;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
}

.sub-nav button.active {
  background: rgba(96, 165, 250, 0.25);
  border-color: #60a5fa;
  color: #fff;
}

.tool-panel { display: none; }
.tool-panel.active { display: block; }

.tool-panel h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: #f1f5f9; }

.tool-panel p.hint { font-size: 0.85rem; color: #9ca3af; margin-bottom: 0.75rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

label {
  font-size: 0.85rem;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

input[type="number"],
input[type="text"],
select,
textarea {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.5rem;
  color: #fff;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
  min-width: 4rem;
}

textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  font-family: inherit;
}

input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: #3b82f6; }

.inline-label { flex-direction: row; align-items: center; gap: 0.5rem; }

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.shortcut-grid button,
.action-btn {
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 0.65rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff;
  transition: transform 0.1s;
}

.shortcut-grid button:active,
.action-btn:active { transform: scale(0.98); }

.action-btn.secondary {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
}

.result-box {
  min-height: 4.5rem;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0.75rem;
  background: rgba(0,0,0,0.25);
  border: 1px dashed rgba(255,255,255,0.12);
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #60a5fa;
  word-break: break-word;
  cursor: default;
  transition: background 0.15s, color 0.15s;
}

.result-box.has-result { cursor: pointer; border-style: solid; }

.result-box.has-result:hover { background: rgba(96, 165, 250, 0.12); }

.result-box.copied { color: #86efac; background: rgba(34, 197, 94, 0.15); }

.result-box.placeholder { font-size: 1rem; font-weight: 500; color: #4b5563; }

.result-box.multi {
  font-size: 1rem;
  text-align: left;
  line-height: 1.8;
  white-space: pre-wrap;
}

.result-box .lotto-line { display: block; margin: 0.35rem 0; }

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.ball {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(145deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.ball.star { background: linear-gradient(145deg, #eab308, #ca8a04); }
.ball.power { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.ball.booster { background: linear-gradient(145deg, #a855f7, #7e22ce); }

.hex-swatch {
  width: 4rem;
  height: 4rem;
  border-radius: 0.5rem;
  margin: 0.5rem auto 0;
  border: 2px solid rgba(255,255,255,0.2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.toast {
  text-align: center;
  font-size: 0.85rem;
  color: #86efac;
  min-height: 1.25rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.visible { opacity: 1; }

.shuffle-area {
  min-height: 6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

.shuffle-area .ball.shuffling { animation: pulse 0.4s ease infinite alternate; }

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* Rich generator layout */
.opt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.opt-row select { min-width: 9rem; }

.gen-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: #cbd5e1;
}

.gen-line input { width: 5rem; text-align: center; font-weight: 600; }

.icon-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #e8e8e8;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover { background: rgba(255,255,255,0.18); }

.add-line-btn { display: block; margin: 0.25rem auto 1rem; }

.shortcut-section { margin-top: 1.25rem; }

.shortcut-section h3 {
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.chip {
  padding: 0.4rem 0.8rem;
  border-radius: 2rem;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #e8e8e8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.chip:hover { background: rgba(96,165,250,0.2); border-color: #60a5fa; }

.chip.active { background: rgba(96,165,250,0.25); border-color: #60a5fa; color: #fff; }

.chip.wide { width: 100%; max-width: 20rem; margin: 0.25rem auto; display: block; }

.info-box {
  text-align: center;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0.75rem;
  background: rgba(96,165,250,0.12);
  border: 1px solid rgba(96,165,250,0.25);
  font-size: 0.95rem;
  color: #cbd5e1;
}

.info-box strong { color: #60a5fa; font-size: 1.1rem; }

.magic-panel {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
}

.magic-panel[hidden] { display: none; }

.chip.magic-toggle {
  background: linear-gradient(180deg, #dc2626, #b91c1c);
  border-color: transparent;
  color: #fff;
  width: 100%;
  max-width: 14rem;
  margin: 0 auto 0.5rem;
  display: block;
}

/* Yes / No item randomizer */
.item-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 0.75rem;
}

.item-or {
  color: #6b7280;
  font-size: 0.9rem;
  font-style: italic;
}

.item-chip {
  position: relative;
  padding: 0.55rem 1.5rem 0.55rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  font-weight: 600;
  font-size: 1rem;
}

.item-chip .remove {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: none;
  background: #4b5563;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.item-chip .remove:hover { background: #ef4444; }

.add-item-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
  max-width: 20rem;
  margin-left: auto;
  margin-right: auto;
}

.add-item-row input { flex: 1; min-width: 0; }

.result-box.pick-yes { color: #86efac; font-size: 4rem; }
.result-box.pick-no { color: #f87171; font-size: 4rem; }
.result-box.pick-maybe { color: #fbbf24; font-size: 3.5rem; }

/* Web colors / hex generator */
.color-lines {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
  text-align: left;
  width: 100%;
}

.color-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.color-dot {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.color-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #9ca3af;
  margin-left: 0.25rem;
}

.rgb-box {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
}

.rgb-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  color: #f1f5f9;
}

.rgb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.rgb-row input { min-width: 8rem; flex: 1; max-width: 12rem; }

.rgb-result {
  margin-top: 0.65rem;
  font-size: 1rem;
  color: #60a5fa;
  min-height: 1.5rem;
}

.status-bar {
  text-align: center;
  font-size: 0.85rem;
  color: #9ca3af;
  margin: 0.5rem 0 0;
  min-height: 1.25rem;
}

.result-box.binary-out {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 1.5rem;
  letter-spacing: 0.08em;
}

.format-panel[hidden] { display: none; }

.result-box.func-out .func-result {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-box.func-out .func-sep {
  font-size: 1.5rem;
  color: #9ca3af;
  margin: 0 0.35rem;
}

.result-box.func-out .func-root {
  font-size: 2rem;
  font-weight: 800;
  color: #60a5fa;
  font-variant-numeric: tabular-nums;
}

.section-label {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #9ca3af;
  margin-top: 1.25rem;
  letter-spacing: 0.03em;
}

.list-wrap { margin: 0 auto 1rem; max-width: 28rem; }

.divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 1.25rem 0 0;
}

/* Home page category cards */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}

.home-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(22, 22, 35, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  transition: transform 0.15s, border-color 0.15s;
}

.home-card:hover { transform: translateY(-3px); border-color: #60a5fa; }

.home-card .icon { font-size: 2rem; }

.home-card h2 { font-size: 1.2rem; margin: 0.5rem 0 0.35rem; color: #f1f5f9; }

.home-card p { font-size: 0.85rem; color: #9ca3af; }

footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: #6b7280;
}
