:root {
  color-scheme: light;
  --blue-950: #09245d;
  --blue-900: #0d327f;
  --blue-700: #174bb7;
  --blue-600: #1f5bda;
  --blue-100: #e8efff;
  --ink: #12213f;
  --muted: #65718b;
  --line: #dce2ee;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --yellow: #ffd75e;
  --night: #6f5bed;
  --night-light: #eeeafe;
  --danger: #b42318;
  --radius-lg: 26px;
  --radius-md: 16px;
  --shadow: 0 22px 60px rgba(20, 45, 94, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgba(31, 91, 218, 0.12), transparent 32rem),
    var(--canvas);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(72, 124, 243, 0.32), transparent 26rem),
    radial-gradient(circle at 90% 90%, rgba(111, 91, 237, 0.23), transparent 28rem),
    linear-gradient(145deg, var(--blue-900), var(--blue-950));
}

.auth-card {
  width: min(440px, 100%);
  padding: clamp(28px, 6vw, 44px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.auth-logo {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 16px;
  color: var(--blue-950);
  background: var(--yellow);
  font-size: 1.35rem;
  font-weight: 900;
  transform: rotate(-4deg);
}

.auth-kicker {
  margin: 0 0 8px;
  color: #9ebaff;
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(1.9rem, 6vw, 2.55rem);
  letter-spacing: -0.045em;
}

.auth-copy {
  margin: 12px 0 28px;
  color: #bac8e7;
  font-size: 1rem;
  line-height: 1.55;
}

.auth-card label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.9rem;
  font-weight: 750;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.password-row input {
  min-width: 0;
  height: 52px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 13px;
  outline: none;
  padding: 0 16px;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  font-size: 1.1rem;
  letter-spacing: 0.18em;
}

.password-row input::placeholder {
  color: #8da0c8;
}

.password-row input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 215, 94, 0.14);
}

.password-row button {
  min-height: 52px;
  border: 0;
  border-radius: 13px;
  padding: 0 19px;
  cursor: pointer;
  color: var(--blue-950);
  background: var(--yellow);
  font-weight: 850;
}

.password-row button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.auth-error {
  min-height: 1.3em;
  margin: 10px 2px 0;
  color: #ffb8b1;
  font-size: 0.88rem;
  font-weight: 750;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--blue-950);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--blue-600);
  box-shadow: 0 8px 20px rgba(31, 91, 218, 0.28);
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.privacy-pill,
.lock-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #d8e0ef;
  border-radius: 999px;
  color: #50607d;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.8rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.privacy-pill span {
  color: #17a36b;
  font-size: 0.6rem;
}

.lock-button {
  cursor: pointer;
}

.lock-button:hover {
  color: var(--blue-700);
  border-color: #bfcbed;
}

.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 34px 2px 27px;
}

.eyebrow,
.step-label {
  margin: 0 0 8px;
  color: var(--blue-600);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  color: var(--blue-950);
  font-size: clamp(2.45rem, 6vw, 4.7rem);
  font-weight: 850;
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.hero-copy {
  max-width: 410px;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 15px;
  padding: 7px;
  border: 1px solid #dfe5ef;
  border-radius: 20px;
  background: #e9edf4;
}

.mode-tab {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
  border: 1px solid transparent;
  border-radius: 15px;
  padding: 12px 15px;
  cursor: pointer;
  color: #667189;
  background: transparent;
  text-align: left;
  transition:
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.mode-tab.active {
  border-color: rgba(25, 63, 139, 0.08);
  color: var(--blue-950);
  background: white;
  box-shadow: 0 7px 18px rgba(20, 45, 94, 0.11);
}

.mode-tab:focus-visible {
  outline: 3px solid rgba(31, 91, 218, 0.25);
  outline-offset: 2px;
}

.mode-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--blue-600);
  font-size: 0.95rem;
  font-weight: 900;
}

.night-icon {
  color: #2c236e;
  background: #cfc7ff;
  font-size: 1.3rem;
}

.mode-tab strong,
.mode-tab small {
  display: block;
}

.mode-tab strong {
  margin-bottom: 3px;
  font-size: 0.95rem;
}

.mode-tab small {
  color: #7d879a;
  font-size: 0.79rem;
}

.mode-panel:focus {
  outline: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  overflow: hidden;
  border: 1px solid rgba(20, 45, 94, 0.08);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-card,
.result-card {
  min-height: 520px;
  padding: clamp(24px, 4vw, 40px);
}

.card-heading,
.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 21px;
}

.card-heading h2,
.result-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  letter-spacing: -0.035em;
}

.count-badge {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--blue-700);
  background: var(--blue-100);
  font-size: 0.8rem;
  font-weight: 800;
}

.night-label {
  color: var(--night);
}

.night-badge {
  color: #5141ba;
  background: var(--night-light);
}

textarea {
  display: block;
  width: 100%;
  min-height: 245px;
  resize: vertical;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  padding: 16px 18px;
  color: var(--ink);
  background: #fbfcff;
  font-size: 1rem;
  line-height: 1.65;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea:hover {
  border-color: #bdc8da;
}

textarea:focus {
  border-color: var(--blue-600);
  background: white;
  box-shadow: 0 0 0 4px rgba(31, 91, 218, 0.12);
}

.input-help,
.input-message {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.input-message {
  min-height: 1.25em;
  color: var(--danger);
  font-weight: 700;
}

.winner-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fc;
}

.winner-control label {
  display: block;
  font-size: 0.9rem;
  font-weight: 750;
}

.winner-range-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.winner-control select {
  min-width: 116px;
  height: 42px;
  border: 1px solid #cdd5e3;
  border-radius: 11px;
  outline: none;
  padding: 0 32px 0 12px;
  color: var(--ink);
  background: white;
  font-size: 0.9rem;
  font-weight: 750;
}

.winner-control select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.winner-control select:focus {
  border-color: var(--night);
  box-shadow: 0 0 0 3px rgba(111, 91, 237, 0.13);
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.primary-button,
.secondary-button,
.copy-button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.primary-button {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 22px;
  color: white;
  background: var(--blue-600);
  box-shadow: 0 11px 24px rgba(31, 91, 218, 0.24);
}

.primary-button span {
  font-size: 1.3rem;
}

.night-button {
  background: var(--night);
  box-shadow: 0 11px 24px rgba(111, 91, 237, 0.24);
}

.secondary-button {
  padding: 0 18px;
  color: #59657c;
  background: #eef1f6;
}

.primary-button:hover {
  background: #174fc5;
}

.night-button:hover {
  background: #5e4bd4;
}

.secondary-button:hover {
  color: var(--ink);
  background: #e3e8f0;
}

.primary-button:active,
.secondary-button:active,
.copy-button:active {
  transform: translateY(1px) scale(0.99);
}

.result-card {
  display: flex;
  flex-direction: column;
  color: white;
  background:
    radial-gradient(circle at 100% 0, rgba(60, 117, 244, 0.33), transparent 23rem),
    linear-gradient(145deg, var(--blue-900), var(--blue-950));
}

.night-result-card {
  background:
    radial-gradient(circle at 100% 0, rgba(154, 137, 255, 0.34), transparent 23rem),
    linear-gradient(145deg, #302776, #16123f);
}

.step-label-light {
  color: #8eb2ff;
}

.step-label-night {
  color: #bdb3ff;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 0 13px;
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.copy-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.copy-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.result-list {
  flex: 1;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  align-content: center;
  padding: 26px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 66px;
  height: 66px;
  margin-bottom: 16px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 21px;
  color: var(--blue-950);
  background: var(--yellow);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
  font-size: 1.6rem;
  font-weight: 900;
  transform: rotate(-5deg);
}

.empty-icon.night-empty-icon {
  color: #2c236e;
  background: #cfc7ff;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.empty-state p {
  max-width: 310px;
  margin: 0;
  color: #abbad9;
  font-size: 0.88rem;
  line-height: 1.55;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.result-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  opacity: 0;
  transform: translateY(8px);
  animation: enter 420ms cubic-bezier(0.2, 0.75, 0.2, 1) forwards;
}

.letter,
.winner-number {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  color: var(--blue-950);
  background: var(--yellow);
  font-size: 0.87rem;
  font-weight: 900;
}

.winner-number {
  color: #2c236e;
  background: #cfc7ff;
}

.person-name {
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.night-winner-grid {
  grid-template-columns: 1fr;
}

.night-winner-grid .result-item {
  min-height: 76px;
  padding: 17px;
}

.night-winner-grid .person-name {
  font-size: 1.08rem;
}

.result-note {
  margin: 18px 0 0;
  color: #9aabd0;
  font-size: 0.8rem;
  line-height: 1.45;
}

footer {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 27px 0 40px;
  color: #7b8498;
  font-size: 0.8rem;
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  padding: 12px 16px;
  border-radius: 12px;
  color: white;
  background: #11244b;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

@keyframes enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
  }

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

  .input-card,
  .result-card {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .site-header,
  .page-shell,
  footer {
    width: min(100% - 24px, 1160px);
  }

  .site-header {
    padding: 15px 0;
  }

  .privacy-pill {
    display: none;
  }

  .lock-button {
    padding: 0 10px;
  }

  .hero {
    padding: 25px 3px 22px;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 12vw, 3.5rem);
  }

  .mode-switch {
    gap: 7px;
    padding: 5px;
    border-radius: 17px;
  }

  .mode-tab {
    gap: 9px;
    padding: 10px;
  }

  .mode-icon {
    width: 35px;
    height: 35px;
  }

  .mode-tab strong {
    font-size: 0.86rem;
  }

  .mode-tab small {
    display: none;
  }

  .workspace {
    border-radius: 20px;
  }

  .input-card,
  .result-card {
    padding: 24px 18px;
  }

  textarea {
    min-height: 220px;
  }

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

  .empty-state {
    min-height: 260px;
  }

  .button-row {
    flex-wrap: wrap;
  }

  .primary-button {
    flex-basis: 65%;
  }

  .password-row {
    grid-template-columns: 1fr;
  }

  .password-row button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
