/* Number Generator 1 to 100 - shared styles, mobile first */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-hover: #4338ca;
  --brand-pressed: #4338ca;
  --brand-soft: #eef2ff;
  --line: #e2e8f0;
  --err: #b91c1c;
  --btn-ink: #ffffff;
  --brand-grad: #4338ca;
  --card-shadow: 0 8px 24px rgba(15, 23, 42, .07);
  --seg-bg: #eef2f7;
  --seg-frame: #e2e8f0;
  --result-bg: #f8fafc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --card: #131c30;
    --ink: #e5eaf3;
    --body: #b8c2d4;
    --muted: #8b97ab;
    --brand: #6366f1;
    --brand-dark: #a5b4fc;
    --brand-hover: #4f46e5;
    --brand-pressed: #4f46e5;
    --brand-soft: #1e2752;
    --line: #263351;
    --err: #f87171;
    --card-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  --brand-grad: #4f46e5;
    --seg-bg: #0d1526;
    --seg-frame: #1c2740;
    --result-bg: #0b1220;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --card: #131c30;
  --ink: #e5eaf3;
  --body: #b8c2d4;
  --muted: #8b97ab;
  --brand: #6366f1;
  --brand-dark: #a5b4fc;
  --brand-hover: #4f46e5;
  --brand-pressed: #4f46e5;
  --brand-soft: #1e2752;
  --line: #263351;
  --err: #f87171;
  --card-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  --brand-grad: #4f46e5;
  --seg-bg: #0d1526;
  --seg-frame: #1c2740;
  --result-bg: #0b1220;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
:where(button, a, input, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
:where(button, a, input):focus:not(:focus-visible) {
  outline: none;
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
body.no-scroll { overflow: hidden; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .8rem;
  padding: .8rem 1rem;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
}
.brand span { color: var(--brand); }
.theme-toggle {
  position: relative;
  margin-left: auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: .4rem;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.theme-toggle svg {
  position: absolute;
  width: 1.15rem;
  height: 1.15rem;
  transition: opacity .2s ease, transform .2s ease;
}
.theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(.5); }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
:root[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(.5); }
@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg { transition: none; }
  .result-num { animation: none; }
}
.theme-toggle:hover { border-color: var(--brand); }
.nav-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: .4rem;
  font-size: 1rem;
  line-height: 1;
  padding: .35rem .55rem;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.top-nav {
  flex-basis: 100%;
  display: none;
  flex-direction: column;
  gap: .1rem;
  padding-top: .5rem;
}
.top-nav.open { display: flex; }
.top-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: .45rem .55rem;
  border-radius: .4rem;
  font-size: .88rem;
  white-space: nowrap;
}
.top-nav a:hover, .top-nav a:focus-visible { background: var(--bg); color: var(--ink); }
.top-nav a[aria-current="page"] { color: var(--brand-dark); font-weight: 700; }

.crumbs {
  max-width: 46rem;
  margin: 0 auto;
  padding: .7rem 1rem 0;
  font-size: .85rem;
  color: var(--muted);
}
.crumbs a { color: var(--muted); }
main { max-width: 46rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.7rem; line-height: 1.25; margin: .3rem 0 .8rem; }
.hero { color: var(--body); margin-bottom: 1.2rem; }

.tool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1rem;
  margin-bottom: 2rem;
  box-shadow: var(--card-shadow);
}
.field-row { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.field { flex: 1; min-width: 8rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input[type="number"] {
  width: 100%;
  padding: .6rem .7rem;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="number"]:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.mode-row { display: flex; gap: .15rem; margin-bottom: .8rem; padding: 3px; background: var(--seg-bg); border: 1px solid var(--seg-frame); border-radius: .7rem; }
.mode-btn {
  flex: 1;
  padding: .6rem .5rem;
  border: 0;
  background: transparent;
  border-radius: .55rem;
  font-size: .95rem;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.mode-btn[aria-pressed="true"] {
  background: var(--card);
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.check {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .95rem;
  font-weight: 500;
  padding: .6rem 0 0;
  cursor: pointer;
}
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); }
.check.small { padding: 0; font-size: .9rem; }
.tool-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .8rem;
}
.option-btn {
  padding: .45rem .8rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--body);
  border-radius: .5rem;
  font-size: .9rem;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.option-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.generate {
  width: 100%;
  padding: .9rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--btn-ink);
  background: linear-gradient(180deg, var(--brand), var(--brand-grad));
  border: 0;
  border-radius: .6rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .28);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.generate:hover { box-shadow: 0 6px 20px rgba(79, 70, 229, .36); transform: translateY(-1px); }
.generate:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(79, 70, 229, .25); }
.generate:disabled { opacity: .55; cursor: wait; box-shadow: none; transform: none; }
.error { color: var(--err); font-size: .9rem; margin-top: .6rem; }

.result {
  margin-top: 1rem;
  text-align: center;
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--result-bg);
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: .8rem .5rem;
}
.result-num {
  font-size: clamp(3.5rem, 20vw, 6rem);
  font-weight: 800;
  line-height: 1;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  animation: result-pop .25s cubic-bezier(.2, .8, .3, 1.1);
}
.result-num.rolling { opacity: .85; animation: none; }
@keyframes result-pop {
  from { transform: scale(.8); opacity: .4; }
  to { transform: scale(1); opacity: 1; }
}
.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  justify-content: center;
}
.result-list li {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 1.2rem;
  padding: .3rem .7rem;
  border-radius: .5rem;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  font-variant-numeric: tabular-nums;
}
.result-note { color: var(--muted); font-size: .95rem; }

.result-tools {
  margin-top: .8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.result-meta { font-size: .85rem; color: var(--muted); margin-right: auto; }
.sort-row { display: flex; gap: .15rem; padding: 3px; background: var(--seg-bg); border: 1px solid var(--seg-frame); border-radius: .55rem; }
.sort-btn {
  padding: .3rem .6rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: .4rem;
  font-size: .82rem;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.sort-btn[aria-pressed="true"] {
  background: var(--card);
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.copy {
  width: 100%;
  margin-top: .8rem;
  padding: .65rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: .5rem;
  cursor: pointer;
  font-size: .95rem;
  color: var(--body);
  transition: color .15s ease, border-color .15s ease;
}
.copy:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.copy:disabled { opacity: .5; cursor: default; }
.history { margin-top: 1rem; border-top: 1px dashed var(--line); padding-top: .8rem; }
.history-title { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: .4rem; }
.history ol {
  list-style: none;
  font-size: .85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 9rem;
  overflow: auto;
}
.history ol li {
  padding: .35rem .1rem;
  border-bottom: 1px dashed var(--line);
}
.history ol li:last-child { border-bottom: 0; }

/* Classroom mode: full-screen overlay, big number, hold-to-exit */
.classroom {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}
.classroom-result {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(6rem, 42vw, 18rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  max-width: 100%;
}
.classroom-result.list-mode { font-size: clamp(2rem, 9vw, 4.5rem); }
.classroom-bar {
  width: 100%;
  max-width: 40rem;
  display: flex;
  gap: .7rem;
}
.classroom-generate {
  flex: 3;
  padding: 1.1rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--btn-ink);
  background: var(--brand);
  border: 0;
  border-radius: .8rem;
  cursor: pointer;
}
.classroom-generate:disabled { opacity: .55; cursor: wait; }
.classroom-exit {
  position: relative;
  overflow: hidden;
  flex: 1;
  padding: 1.1rem .6rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .8rem;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.exit-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--brand-soft);
}
.classroom-exit.holding .exit-fill {
  width: 100%;
  transition: width .9s linear;
}
.exit-label { position: relative; }

h2 { font-size: 1.3rem; margin: 1.9rem 0 .6rem; line-height: 1.3; }
h3 { font-size: 1.02rem; margin: 1rem 0 .25rem; }
p { margin-bottom: .8rem; }
main ol, main ul { margin: 0 0 .9rem 1.3rem; }
main li { margin-bottom: .35rem; }
.related {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding-top: 1rem;
  color: var(--body);
}
.related a { color: var(--brand-dark); }

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding: 1.2rem 1rem 2.2rem;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .9rem;
  justify-content: center;
  margin-bottom: .6rem;
}
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--ink); }

.footer-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* Draw style switch + wheel */
.style-row { display: flex; gap: .15rem; flex: 1; min-width: 12rem; padding: 3px; background: var(--seg-bg); border: 1px solid var(--seg-frame); border-radius: .7rem; }
.style-btn {
  flex: 1;
  padding: .42rem .4rem;
  border: 0;
  background: transparent;
  border-radius: .55rem;
  font-size: .88rem;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.style-btn[aria-pressed="true"] {
  background: var(--card);
  border-radius: .55rem;
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.style-btn:disabled { opacity: .45; cursor: default; }
.wheel {
  display: block;
  width: 100%;
  max-width: 400px;
  height: auto;
  margin: .5rem auto 0;
  filter: drop-shadow(0 6px 16px rgba(79, 70, 229, .25));
}

@media (min-width: 48rem) {
  .nav-btn { display: none; }
  .top-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: .15rem;
    padding-top: .5rem;
  }
}

@media (min-width: 40rem) {
  h1 { font-size: 2rem; }
  main { padding: 1.4rem 1rem; }
  .tool { padding: 1.3rem; }
}
