:root {
  color-scheme: dark;
  --bg: #0d0d0b;
  --surface: #171715;
  --surface-2: #21201c;
  --surface-3: #2b2924;
  --line: #454137;
  --strong-line: #6f674f;
  --text: #f7f4ea;
  --muted: #b7b0a0;
  --faint: #7d7567;
  --gold: #f2c94c;
  --green: #5dd39e;
  --red: #ef767a;
  --blue: #7aa2f7;
  --violet: #c099ff;
  --card-radius: 8px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(242, 201, 76, 0.08), transparent 260px),
    linear-gradient(135deg, rgba(93, 211, 158, 0.07), transparent 380px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  border-bottom: 1px solid rgba(247, 244, 234, 0.1);
  background: rgba(13, 13, 11, 0.93);
  backdrop-filter: blur(12px);
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, calc(100vw - 36px));
  min-height: 58px;
  margin: 0 auto;
}

.brand-link,
.nav-links a {
  color: var(--text);
  text-decoration: none;
}

.brand-link {
  flex: 0 0 auto;
  font-size: 1.1rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.nav-links .nav-play {
  min-width: 72px;
  border: 1px solid var(--strong-line);
  background: var(--text);
  color: #14120e;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.brand-link:hover,
.brand-link:focus-visible {
  color: #ffffff;
}

.nav-links .nav-play:hover,
.nav-links .nav-play:focus-visible {
  color: #14120e;
  background: #ffffff;
}

.nav-links .nav-active:not(.nav-play) {
  background: rgba(242, 201, 76, 0.12);
  color: #ffe9a3;
}

.account-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.account-name {
  max-width: 170px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 8px;
  font-weight: 950;
}

.nav-auth-login {
  border: 0;
  background: var(--green);
  color: #07150e;
}

.nav-auth-signup,
.nav-auth-signout {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.nav-auth-button:hover,
.nav-auth-button:focus-visible {
  filter: brightness(1.08);
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  text-align: center;
}

.topbar p {
  width: min(720px, 100%);
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

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

.rngdle-game {
  display: grid;
  gap: 18px;
}

.hero-board {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 0.72fr);
  align-items: stretch;
  gap: 18px;
}

.hero-copy,
.roll-card,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgba(33, 32, 28, 0.98), rgba(23, 23, 21, 0.98));
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 360px;
  padding: clamp(22px, 4vw, 46px);
}

.eyebrow,
.micro-label {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-title {
  margin: 10px 0 0;
  font-size: clamp(3.2rem, 10vw, 7.8rem);
  font-weight: 1000;
  letter-spacing: 0;
  line-height: 0.88;
  text-transform: uppercase;
}

.game-subtitle {
  width: min(590px, 100%);
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.6;
}

.roll-card {
  display: grid;
  align-content: center;
  gap: 16px;
  min-height: 360px;
  padding: 18px;
}

.roll-card-top,
.panel-heading,
.badge-title-row,
.roll-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.number-display {
  margin-top: 6px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(3.1rem, 9vw, 5.6rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.number-display.is-rolling {
  color: var(--gold);
  text-shadow: 0 0 28px rgba(242, 201, 76, 0.34);
}

.rarity-pill {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1;
  text-align: center;
}

.rarity-pill.common {
  border-color: #9da3ae;
  color: #e0e5ed;
}

.rarity-pill.uncommon {
  border-color: var(--green);
  color: #bff4dc;
}

.rarity-pill.rare {
  border-color: var(--blue);
  color: #cbdcff;
}

.rarity-pill.epic {
  border-color: var(--violet);
  color: #e4d4ff;
}

.rarity-pill.anomaly {
  border-color: var(--gold);
  color: #ffe9a3;
  box-shadow: 0 0 26px rgba(242, 201, 76, 0.2);
}

.rarity-pill.trash {
  border-color: #9d7550;
  color: #e1c39f;
}

.generate-button,
.secondary-button,
.content-card .content-cta a {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 950;
  letter-spacing: 0;
}

.generate-button {
  width: 100%;
  min-height: 74px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent),
    #f0b429;
  color: #12110d;
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.16),
    0 14px 34px rgba(240, 180, 41, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.generate-button:not(:disabled):hover,
.generate-button:not(:disabled):focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.generate-button:disabled {
  background: #403d34;
  color: var(--faint);
  box-shadow: inset 0 0 0 1px var(--line);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.summary-strip div {
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 13, 11, 0.55);
}

.summary-strip span {
  display: block;
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 850;
}

.summary-strip strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.status-line {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 760;
  line-height: 1.45;
  text-align: center;
}

.roll-actions {
  justify-content: center;
}

.secondary-button {
  min-width: 112px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.secondary-button:not(:disabled):hover,
.secondary-button:not(:disabled):focus-visible {
  border-color: var(--gold);
  color: #ffe9a3;
}

.secondary-button:disabled {
  color: var(--faint);
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 0.38fr);
  gap: 18px;
}

.result-panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.08;
}

.panel-heading > span {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.badge-list {
  display: grid;
  gap: 8px;
}

.badge-list.empty {
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--faint);
  text-align: center;
}

.badge-list.empty p {
  margin: 0;
}

.badge-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(242, 201, 76, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.badge-card.muted {
  opacity: 0.58;
}

.badge-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  font-size: 1.35rem;
}

.badge-body {
  min-width: 0;
}

.badge-title-row h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.2;
}

.badge-title-row span {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
}

.badge-card.muted .badge-title-row span {
  color: var(--faint);
}

.badge-card p {
  margin: 4px 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.badge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-meta span {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 850;
}

.side-panel {
  align-self: start;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.panel-heading.compact h2 {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  font-variant-numeric: tabular-nums;
}

.rules-list {
  display: grid;
  gap: 8px;
}

.rules-list p {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 13, 11, 0.5);
  color: var(--muted);
  line-height: 1.45;
}

.rules-list strong {
  color: var(--text);
}

.seo-content,
.content-shell {
  width: min(920px, 100%);
  margin: 42px auto 0;
}

.content-shell {
  padding-top: 10px;
  padding-bottom: 36px;
}

.content-card {
  max-width: 860px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 23, 21, 0.94);
  box-shadow: var(--shadow);
}

.seo-content h2,
.content-card h1,
.content-card h2 {
  margin: 0 0 12px;
}

.content-card h1 {
  max-width: none;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.04;
}

.seo-content p,
.seo-content li,
.content-card p,
.content-card li {
  color: var(--muted);
  line-height: 1.65;
}

.seo-content a,
.content-card a {
  color: #ffe9a3;
}

.content-meta {
  margin-top: -4px;
  color: var(--faint);
  font-size: 0.92rem;
}

.content-card ul,
.content-card ol {
  padding-left: 1.35rem;
}

.content-card .content-cta a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  background: var(--text);
  color: #14120e;
  text-decoration: none;
}

.faq-accordion {
  width: min(1080px, 100%);
  padding: 18px 0 0;
}

.faq-accordion > h2 {
  margin: 0 0 18px;
  color: var(--text);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.faq-item {
  border: 1px solid rgba(242, 201, 76, 0.18);
  border-radius: 8px;
  background: rgba(23, 23, 21, 0.92);
  overflow: hidden;
}

.faq-item + .faq-item {
  margin-top: 10px;
}

.faq-item summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 13px 18px 13px 36px;
  color: var(--text);
  font-weight: 900;
  list-style: none;
  outline: 0;
  cursor: pointer;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::before {
  content: "";
  position: absolute;
  left: 17px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--gold);
  transition: transform 0.18s ease;
}

.faq-item[open] summary::before {
  transform: rotate(90deg);
}

.faq-item summary h2 {
  margin: 0;
  color: inherit;
  font-size: 1rem;
  line-height: 1.25;
}

.faq-body {
  padding: 0 36px 18px;
  border-top: 1px solid rgba(247, 244, 234, 0.08);
}

.faq-body p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 11, 0.72);
  backdrop-filter: blur(7px);
}

.auth-modal-card {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 23, 21, 0.98);
  box-shadow: var(--shadow);
}

.auth-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
}

.auth-modal-eyebrow,
.auth-modal-title,
.auth-message {
  margin: 0;
}

.auth-modal-eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-modal-title {
  font-size: 1.65rem;
  line-height: 1;
}

.google-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #111318;
  font-weight: 950;
}

.google-auth-button:disabled {
  opacity: 0.64;
}

.google-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    conic-gradient(from -40deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
  color: white;
  font-size: 0.82rem;
  font-weight: 950;
  line-height: 1;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11100e;
  color: var(--text);
}

.auth-submit {
  min-height: 46px;
  font-size: 1rem;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.35;
}

.auth-message[data-tone="good"] {
  color: #a7e0b8;
}

.auth-message[data-tone="bad"] {
  color: #f3aaa7;
}

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

@media (max-width: 920px) {
  .primary-nav {
    gap: 14px;
    min-height: 64px;
    padding: 8px 0;
  }

  .nav-links {
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 4px 0 8px;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    flex: 0 0 auto;
  }

  .account-menu {
    margin-left: auto;
  }

  .account-name {
    display: none;
  }

  .nav-auth-button {
    min-width: 74px;
    min-height: 38px;
    padding: 8px 10px;
  }

  .hero-board,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .roll-card {
    min-height: 0;
  }

  .hero-copy {
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .primary-nav,
  .app-shell {
    width: min(100vw - 18px, 1180px);
  }

  .brand-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.98rem;
  }

  .nav-links a {
    min-height: 42px;
    padding: 7px 9px;
    font-size: 0.84rem;
  }

  .nav-auth-signup {
    display: none;
  }

  .auth-modal {
    padding: 10px;
  }

  .auth-modal-card {
    padding: 18px;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .hero-copy,
  .roll-card,
  .result-panel,
  .content-card {
    padding: 14px;
  }

  .game-title {
    font-size: clamp(2.7rem, 17vw, 5rem);
  }

  .roll-card-top,
  .panel-heading,
  .badge-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .rarity-pill {
    min-width: 0;
  }

  .number-display {
    font-size: clamp(2.55rem, 15vw, 4.5rem);
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .roll-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .secondary-button {
    min-width: 0;
  }

  .badge-card {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .badge-icon {
    width: 38px;
    height: 38px;
  }
}
