@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --bg: #07101f;
  --bg-2: #0b1630;
  --surface: rgba(9, 16, 32, 0.58);
  --surface-strong: rgba(11, 19, 38, 0.82);
  --surface-soft: rgba(76, 135, 255, 0.08);
  --border: rgba(95, 147, 255, 0.2);
  --text: #f2f7ff;
  --muted: #9fb4d6;
  --accent: #4f8dff;
  --accent-2: #cfe0ff;
  --shadow: 0 18px 48px rgba(3, 8, 20, 0.34);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 50% 18%, rgba(79, 141, 255, 0.12), transparent 22%),
    radial-gradient(circle at top left, rgba(79, 141, 255, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(145, 179, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145, 179, 255, 0.12) 1px, transparent 1px),
    radial-gradient(circle at 50% 34%, rgba(79, 141, 255, 0.1), transparent 0 22%, rgba(79, 141, 255, 0.05) 38%, transparent 62%);
  background-size: 84px 84px, 84px 84px, 100% 100%;
  background-position: 0 0, 0 0, center center;
  opacity: 0.34;
  transform: perspective(900px) translateZ(0);
  will-change: background-position, transform, opacity;
  animation: landingPageGridDrift 6.4s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 32%, rgba(79, 141, 255, 0.18), transparent 0 10%, rgba(79, 141, 255, 0.08) 18%, rgba(79, 141, 255, 0.03) 30%, transparent 52%),
    radial-gradient(circle at 50% 32%, rgba(79, 141, 255, 0.16), transparent 0 14%, rgba(79, 141, 255, 0.06) 26%, transparent 48%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0.9;
  filter: blur(24px);
  mix-blend-mode: screen;
  will-change: transform, opacity;
  animation: landingPageGlowPulse 3.2s ease-in-out infinite;
}

body.site-locked {
  overflow: hidden;
}

body.site-locked .page {
  pointer-events: none;
  user-select: none;
}

body.site-locked .countdown-overlay {
  pointer-events: auto;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 800;
}

.section-title,
.landing-title {
  margin: 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.04em;
  color: var(--accent-2);
}

.landing-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.landing-hero {
  position: relative;
  isolation: isolate;
}

.landing-hero {
  width: min(920px, 100%);
  padding: clamp(28px, 5vw, 52px);
  text-align: center;
  animation: fadeUp 0.7s ease both;
}

.landing-kicker {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.landing-title {
  font-size: clamp(3.8rem, 11vw, 7.8rem);
  line-height: 0.92;
  margin: 8px auto 0;
  color: #4f8dff;
  text-shadow: 0 0 30px rgba(79, 141, 255, 0.28);
}

.landing-line {
  width: min(760px, 94%);
  height: 5px;
  margin: 20px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, #3f7fff 18%, #87b1ff 50%, #3f7fff 82%, transparent 100%);
  box-shadow: 0 0 26px rgba(79, 141, 255, 0.82);
}

.rules-heading {
  margin: 24px 0 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  color: var(--text);
  font-weight: 500;
}

.rules-grid {
  width: min(760px, 100%);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rule-column {
  text-align: left;
  padding: 16px 18px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
}

.rule-column h3 {
  margin: 0;
  text-align: center;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.02em;
  color: var(--text);
  font-size: 1.05rem;
}

.rule-column--accent {
  border-color: rgba(79, 141, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(79, 141, 255, 0.06);
}

.rule-column ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.75;
  font-size: 0.9rem;
}

.landing-cta {
  width: min(560px, 100%);
  margin: 30px auto 0;
  display: grid;
  justify-items: center;
  gap: 12px;
}

.primary-button,
.difficulty-button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  background: linear-gradient(180deg, #4f8dff 0%, #3774f0 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(79, 141, 255, 0.35), 0 0 18px rgba(79, 141, 255, 0.18);
}

#personalizeButton {
  width: 260px;
}

.primary-button--small {
  min-height: 48px;
  padding: 0 20px;
}

.primary-button:hover,
.difficulty-button:hover {
  transform: translateY(-2px);
}

.or-divider {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: lowercase;
}

.seed-launcher {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  justify-items: center;
}

.seed-launcher__label {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.seed-launcher__row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.seed-launcher input,
.seed-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(79, 141, 255, 0.3);
  background: rgba(9, 16, 32, 0.72);
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.seed-launcher input::placeholder,
.seed-field input::placeholder {
  color: #7e91b5;
}

.seed-launcher input:focus-visible,
.seed-field input:focus-visible {
  outline: 3px solid rgba(79, 141, 255, 0.18);
  outline-offset: 2px;
}

.field-error {
  min-height: 1.3em;
  margin: 0;
  color: #ff8f8f;
  font-size: 0.95rem;
}

.settings-panel,
.card-header,
.board-panel,
.landing-footer {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.landing-footer {
  display: none;
}

.landing-copy {
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.65;
}

.primary-button:focus-visible,
.difficulty-button:focus-visible,
.seed-field input:focus-visible,
.secondary-button:focus-visible,
.penalty-check input:focus-visible + span {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

.settings-page,
.card-page {
  display: grid;
  gap: 16px;
  align-content: start;
  min-height: 100vh;
}

.settings-panel {
  width: min(1040px, 100%);
  margin: clamp(14px, 4vw, 40px) auto 0;
  padding: clamp(22px, 4vw, 36px);
  animation: fadeUp 0.7s ease both;
}

.settings-hero {
  display: grid;
  gap: 12px;
}

.settings-hero-actions {
  margin-top: 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 800;
  transition: color 0.16s ease, transform 0.12s ease;
}

.back-link__arrow {
  display: inline-block;
  transform: translateX(-2px);
  transition: transform 0.18s ease, opacity 0.12s ease;
  opacity: 0.9;
}

.back-link:hover,
.back-link:focus {
  color: #ffffff;
  transform: translateX(2px);
}

.back-link:hover .back-link__arrow,
.back-link:focus .back-link__arrow {
  transform: translateX(-6px);
}

.penalties-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.penalties-header-actions .points-spent {
  margin: 0;
  padding: 6px 10px;
}

.settings-title {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  color: #4f8dff;
  text-shadow: 0 0 30px rgba(79, 141, 255, 0.24);
}

.settings-layout {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.settings-block {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(95, 147, 255, 0.16);
}

.settings-block__header {
  display: grid;
  gap: 4px;
}

.settings-block__title {
  margin: 0;
  color: var(--accent-2);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.03em;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.settings-block__header--row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.settings-block__hint {
  color: var(--muted);
  margin-top:5px;
  font-size: 0.92rem;
}

.settings-block--penalties {
  padding: 0;
  overflow: clip;
}

.penalties-card__toggle {
  width: 100%;
  appearance: none;
  border: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  color: inherit;
  text-align: left;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}

.penalties-card__toggle:hover {
  background: linear-gradient(180deg, rgba(79, 141, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.penalties-card__chevron {
  width: 14px;
  height: 14px;
  border-right: 2px solid rgba(191, 214, 255, 0.92);
  border-bottom: 2px solid rgba(191, 214, 255, 0.92);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  justify-self: end;
}

.settings-block--penalties.is-open .penalties-card__chevron {
  transform: rotate(225deg);
}

.penalties-panel {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
  overflow: clip;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 0.22s ease, opacity 0.2s ease, transform 0.22s ease, padding 0.22s ease;
}

.penalties-panel.is-expanded {
  max-height: 420px;
  opacity: 1;
  transform: translateY(0);
  padding: 0 18px 18px;
}

.penalties-table-wrap {
  overflow: auto;
  max-height: 260px;
}

.settings-block--penalties.is-open {
  box-shadow: 0 18px 48px rgba(3, 8, 20, 0.38);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.difficulty-button {
  min-height: 52px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(95, 147, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.difficulty-button.is-active {
  background: linear-gradient(180deg, rgba(79, 141, 255, 0.2) 0%, rgba(79, 141, 255, 0.1) 100%);
  border-color: rgba(79, 141, 255, 0.36);
  color: var(--accent);
}

.settings-footer {
  display: grid;
  justify-items: center;
  margin-top: 6px;
}

.settings-start-button {
  margin-top:20px;
  width: min(360px, 100%);
}

.secondary-button {
  appearance: none;
  border: 1px solid rgba(95, 147, 255, 0.24);
  border-radius: 12px;
  min-height: 48px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.secondary-button:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 141, 255, 0.42);
  background: rgba(79, 141, 255, 0.1);
}

.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.penalties-table-wrap {
  overflow: auto;
}

.penalties-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.penalties-table th {
  text-align: left;
  padding: 0 14px 4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.penalties-table td {
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(95, 147, 255, 0.14);
  border-bottom: 1px solid rgba(95, 147, 255, 0.14);
  vertical-align: middle;
}

.penalties-table tr td:first-child {
  border-left: 1px solid rgba(95, 147, 255, 0.14);
  border-radius: 16px 0 0 16px;
}

.penalties-table tr td:last-child {
  border-right: 1px solid rgba(95, 147, 255, 0.14);
  border-radius: 0 16px 16px 0;
}

.penalties-table tr.is-selected td {
  background: rgba(79, 141, 255, 0.11);
  border-color: rgba(79, 141, 255, 0.28);
}

.penalties-table tr {
  cursor: pointer;
}

.penalties-table tr:focus-visible td,
.penalties-table tr:hover td {
  border-color: rgba(79, 141, 255, 0.34);
}

.penalties-table tr:focus-visible td {
  outline: 3px solid rgba(79, 141, 255, 0.16);
  outline-offset: -2px;
}

.penalties-table tr.is-selected:hover td {
  background: rgba(79, 141, 255, 0.15);
}

.penalty-cell--meta {
  min-width: 0;
}

.penalty-name {
  font-weight: 700;
}

.penalty-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.points-spent {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(95, 147, 255, 0.18);
  color: var(--text);
  font-weight: 700;
}

.points-spent strong {
  font-size: 1.1rem;
  color: var(--accent);
}

.seed-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.seed-field--output {
  display: grid;
  gap: 8px;
}

.seed-field__label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.seed-field input[readonly] {
  cursor: text;
}

.settings-feedback {
  margin-top: -2px;
}

.card-page {
  padding-top: clamp(18px, 4vw, 36px);
  display: grid;
  gap: 18px;
}

.card-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  animation: fadeUp 0.7s ease both;
}

.card-toolbar__timer-block {
  display: grid;
  gap: 6px;
}

.card-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 0.14em;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(2.1rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--accent-2);
  text-shadow: 0 0 22px rgba(79, 141, 255, 0.2);
}

.card-timer__ms {
  font-size: 0.34em;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0.72;
}

.card-timer.is-ended {
  color: #ffcf82;
  text-shadow: 0 0 22px rgba(255, 199, 112, 0.2);
}

.card-end-button {
  width: min(360px, 100%);
  justify-self: center;
  min-height: 58px;
  padding-inline: 28px;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-pause-button {
  justify-self: end;
  min-width: 72px;
  padding-inline: 0;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
}

.card-board {
  display: grid;
  gap: 16px;
  padding: 18px;
  animation: fadeUp 0.8s ease both;
  animation-delay: 0.08s;
}

.card-meta-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.card-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-weight: 700;
}

.card-board-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 250px);
  gap: 12px;
  align-items: stretch;
}

.board-wrap {
  overflow: auto;
}

#bingo {
  width: min(100%, 880px);
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 8px;
}

#bingo td {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(95, 147, 255, 0.16);
  border-radius: 0;
  padding: 18px 14px;
  text-align: center;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
  vertical-align: middle;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

#bingo td:not(.popout) {
  height: 116px;
}

#bingo td:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(3, 8, 20, 0.15);
  border-color: rgba(79, 141, 255, 0.34);
  background: rgba(79, 141, 255, 0.08);
}

#bingo td.is-completed {
  background: rgba(42, 184, 106, 0.18);
  border-color: rgba(42, 184, 106, 0.5);
}

#bingo td.is-completed:hover {
  background: rgba(42, 184, 106, 0.24);
  border-color: rgba(42, 184, 106, 0.62);
}

#bingo td.is-blocked {
  background: rgba(223, 78, 78, 0.18);
  border-color: rgba(223, 78, 78, 0.52);
}

#bingo td.is-blocked:hover {
  background: rgba(223, 78, 78, 0.24);
  border-color: rgba(223, 78, 78, 0.64);
}

#bingo td.popout {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

#bingo td.popout {
  padding-inline: 6px;
}

.card-penalties {
  display: grid;
  gap: 12px;
  padding: 18px 20px 20px;
  animation: fadeUp 0.86s ease both;
  animation-delay: 0.14s;
}

.card-penalties__header {
  display: grid;
  gap: 4px;
}

.card-penalties__title {
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
}

.card-penalties__empty {
  margin: 0;
  color: var(--muted);
}

.selected-penalties-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.selected-penalty-item {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(95, 147, 255, 0.16);
}

.selected-penalty-item strong {
  color: var(--text);
}

.selected-penalty-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.selected-penalty-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

.card-splits {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(95, 147, 255, 0.14);
  min-height: 0;
  overflow: hidden;
  animation: fadeUp 0.92s ease both;
  animation-delay: 0.2s;
}

.card-splits__header {
  display: grid;
  gap: 2px;
}

.card-splits .section-label {
  margin-bottom: 2px;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.card-splits__title {
  font-size: clamp(0.98rem, 1.7vw, 1.18rem);
}

.card-splits__empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.completed-goals-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  grid-auto-rows: min-content;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.completed-goal-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(95, 147, 255, 0.12);
}

.completed-goal-item__name {
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
  font-size: 0.78rem;
}

.completed-goal-item__time {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  color: #add7ff;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.76rem;
  white-space: nowrap;
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(79, 141, 255, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(6, 12, 25, 0.88) 0%, rgba(10, 19, 38, 0.96) 100%);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.countdown-overlay.is-visible {
  opacity: 1;
}

.countdown-card {
  text-align: center;
  min-width: min(420px, calc(100vw - 32px));
  padding: 30px 34px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(11, 19, 38, 0.92) 0%, rgba(6, 12, 25, 0.98) 100%);
  border: 1px solid rgba(95, 147, 255, 0.28);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 36px rgba(79, 141, 255, 0.16);
  position: relative;
  overflow: hidden;
}

.countdown-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(79, 141, 255, 0.08), transparent 40%);
  pointer-events: none;
}

.countdown-label {
  position: relative;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.countdown-number {
  position: relative;
  margin-top: 10px;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(3.6rem, 12vw, 8rem);
  line-height: 1;
  color: #4f8dff;
  text-shadow: 0 0 26px rgba(79, 141, 255, 0.36);
  animation: countdownPop 0.35s ease;
}

.countdown-number::after {
  content: "";
  display: block;
  width: min(240px, 60vw);
  height: 4px;
  margin: 14px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, #3f7fff 18%, #87b1ff 50%, #3f7fff 82%, transparent 100%);
  box-shadow: 0 0 20px rgba(79, 141, 255, 0.75);
}

body[data-page="final"] {
  overflow-x: hidden;
}

body[data-page="final"]::before {
  opacity: 0.2;
  animation-duration: 11s;
}

body[data-page="final"]::after {
  opacity: 0.22;
  animation-duration: 4.2s;
}

body[data-page="final"].is-win::after,
body[data-page="final"].is-finish::after {
  opacity: 0.32;
}

body[data-page="final"].is-loss::after {
  opacity: 0.26;
}

.final-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-top: clamp(18px, 4vw, 36px);
  padding-bottom: clamp(18px, 4vw, 36px);
}

.final-stage {
  position: relative;
  width: min(1120px, 100%);
  min-height: calc(100vh - clamp(36px, 8vw, 72px));
  overflow: clip;
  padding: clamp(24px, 4vw, 40px);
  display: grid;
  align-items: center;
}

.final-shell {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.final-header {
  text-align: center;
  display: grid;
  gap: 10px;
}

.final-badge {
  color: #ffd166;
}

.final-title {
  font-size: clamp(2.8rem, 7vw, 5rem);
  color: #f8fbff;
  text-shadow: 0 0 28px rgba(255, 209, 102, 0.18), 0 0 42px rgba(79, 141, 255, 0.18);
}

.final-subtitle {
  margin: 0 auto;
  max-width: 66ch;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.final-summary {
  width: min(760px, 100%);
  margin: 10px auto 0;
  padding: clamp(22px, 4vw, 34px);
  display: grid;
  gap: 24px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.final-summary__time,
.final-summary__points,
.final-summary__splits {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.final-total-time {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(2.8rem, 8vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: var(--accent-2);
  text-shadow: 0 0 26px rgba(79, 141, 255, 0.18);
}

.final-total-time small {
  font-size: 0.36em;
  opacity: 0.76;
}

.final-goal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  width: 100%;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.final-goal-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(95, 147, 255, 0.12);
}

.final-goal-item strong {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.35;
}

.final-goal-item time {
  color: var(--muted);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 0.82rem;
  white-space: nowrap;
}

.final-points {
  margin: 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: #fff2bf;
}

.final-points-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.final-summary__empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.final-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.final-actions .secondary-button,
.final-actions .primary-button {
  min-width: 210px;
}

.final-fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

body[data-page="final"].is-loss .final-fireworks {
  inset: -12%;
  opacity: 0.95;
}

body[data-page="final"].is-loss .final-fireworks::before,
body[data-page="final"].is-loss .final-fireworks::after {
  content: "";
  position: absolute;
  inset: 0;
}

body[data-page="final"].is-loss .final-fireworks::before {
  background:
    radial-gradient(circle at 16% 24%, rgba(255, 145, 168, 0.34), transparent 0 10%, transparent 36%),
    radial-gradient(circle at 78% 18%, rgba(139, 233, 253, 0.22), transparent 0 12%, transparent 42%),
    radial-gradient(circle at 72% 74%, rgba(167, 243, 208, 0.18), transparent 0 10%, transparent 40%),
    radial-gradient(circle at 36% 80%, rgba(255, 209, 102, 0.12), transparent 0 14%, transparent 44%);
  filter: blur(18px);
  opacity: 0.9;
  animation: lossBackgroundDrift 14s ease-in-out infinite alternate;
}

body[data-page="final"].is-loss .final-fireworks::after {
  background:
    linear-gradient(120deg, transparent 0 41%, rgba(255, 145, 168, 0.08) 44% 48%, transparent 51% 100%),
    linear-gradient(300deg, transparent 0 54%, rgba(79, 141, 255, 0.08) 57% 61%, transparent 64% 100%);
  background-size: 220% 220%;
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: lossBackgroundSweep 11s linear infinite;
}

body[data-page="final"].is-loss .firework,
body[data-page="final"].is-loss .confetti {
  display: none;
}

.firework,
.confetti {
  position: absolute;
}

.firework {
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  color: var(--accent);
  transform: translate(-50%, -50%) scale(0.18);
  opacity: 0;
  animation: fireworkBurst 3.4s ease-out infinite;
  animation-delay: var(--delay);
  filter: drop-shadow(0 0 18px currentColor);
}

.firework::before,
.firework::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, currentColor 0 8%, transparent 9%),
    radial-gradient(circle at center, transparent 0 17%, currentColor 18% 20%, transparent 21% 100%);
  mask:
    radial-gradient(circle at center, transparent 0 10%, #000 11% 100%);
}

.firework::after {
  transform: rotate(45deg);
}

.confetti {
  left: var(--x);
  top: -12%;
  width: 10px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
  animation: confettiFall 4.8s linear infinite;
  animation-delay: var(--delay);
  box-shadow: 0 0 16px currentColor;
}

.confetti:nth-child(odd) {
  width: 8px;
  height: 18px;
}

body[data-page="final"].is-win .final-title {
  color: #fff4c8;
}

body[data-page="final"].is-win .final-badge {
  color: #ffdf7a;
}

body[data-page="final"].is-loss .final-title {
  color: #ffe0e6;
  text-shadow: 0 0 28px rgba(255, 143, 171, 0.18), 0 0 42px rgba(79, 141, 255, 0.12);
}

body[data-page="final"].is-loss .final-badge {
  color: #ff91a8;
}

body[data-page="final"].is-loss .final-subtitle {
  color: var(--muted);
}

@keyframes fireworkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.12) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  45% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1) rotate(130deg);
  }

  70% {
    opacity: 0.18;
    transform: translate(-50%, -50%) scale(1.08) rotate(240deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.14) rotate(360deg);
  }
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -8vh, 0) rotate(0deg);
    opacity: 0;
  }

  12% {
    opacity: 1;
  }

  100% {
    transform: translate3d(calc(var(--drift, 1) * 24px), 112vh, 0) rotate(540deg);
    opacity: 0;
  }
}

@keyframes lossBackgroundDrift {
  0% {
    transform: translate3d(-1.5%, -1%, 0) scale(1);
  }

  50% {
    transform: translate3d(1.2%, 0.8%, 0) scale(1.03);
  }

  100% {
    transform: translate3d(-0.6%, 1.4%, 0) scale(1.01);
  }
}

@keyframes lossBackgroundSweep {
  0% {
    background-position: 0% 0%, 100% 100%;
  }

  50% {
    background-position: 55% 20%, 35% 80%;
  }

  100% {
    background-position: 100% 100%, 0% 0%;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes landingGridDrift {
  0% {
    background-position: 0 0, 0 0, 0 0, 0 0;
    transform: perspective(700px) rotateX(0deg) scale(1);
  }

  50% {
    background-position: 0 0, 0 120%, 120% 0;
    transform: perspective(700px) rotateX(6deg) scale(1.01);
  }

  100% {
    background-position: 0 0, 0 240%, 240% 0;
    transform: perspective(700px) rotateX(0deg) scale(1);
  }
}

@keyframes landingGridPulse {
  0%,
  100% {
    opacity: 0.62;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

@keyframes landingPageGridDrift {
  0% {
    background-position: 0 0, 0 0, center center;
    transform: perspective(900px) translate3d(0, 0, 0) scale(1);
  }

  14.285% {
    background-position: 5px 8px, 8px 5px, center center;
    transform: perspective(900px) translate3d(4px, -2px, 0) scale(1.003);
  }

  28.571% {
    background-position: 14px 18px, 18px 14px, center center;
    transform: perspective(900px) translate3d(9px, -5px, 0) scale(1.007);
  }

  42.857% {
    background-position: 26px 28px, 28px 26px, center center;
    transform: perspective(900px) translate3d(13px, -9px, 0) scale(1.011);
  }

  57.142% {
    background-position: 40px 38px, 38px 40px, center center;
    transform: perspective(900px) translate3d(9px, -13px, 0) scale(1.013);
  }

  71.428% {
    background-position: 54px 48px, 48px 54px, center center;
    transform: perspective(900px) translate3d(2px, -10px, 0) scale(1.01);
  }

  85.714% {
    background-position: 32px 60px, 60px 32px, center center;
    transform: perspective(900px) translate3d(-5px, -6px, 0) scale(1.006);
  }

  100% {
    background-position: 0 84px, 84px 0, center center;
    transform: perspective(900px) translate3d(0, 0, 0) scale(1);
  }
}

@keyframes landingPageGlowPulse {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(1);
  }

  50% {
    opacity: 0.96;
    transform: scale(1.025);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .firework,
  .confetti {
    animation: none;
  }
}

@keyframes countdownPop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .rules-grid,
  .difficulty-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    width: 100%;
  }

  .seed-launcher__row {
    grid-template-columns: 1fr;
  }

  .settings-block__header--row,
  .seed-result-row {
    grid-template-columns: 1fr;
  }

  .penalties-card__toggle {
    grid-template-columns: 1fr;
  }

  .card-toolbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .card-board-content {
    grid-template-columns: 1fr;
  }

  .card-end-button,
  .card-delete-button {
    width: 100%;
    justify-self: stretch;
  }

  .card-meta-bar {
    align-items: flex-start;
  }

  .points-spent {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 14px;
  }

  .landing-hero,
  .settings-panel,
  .card-toolbar,
  .card-board,
  .card-penalties,
  .card-splits,
  .landing-footer {
    padding: 18px;
  }

  .settings-layout {
    margin-top: 18px;
  }

  .settings-block {
    padding: 14px;
  }

  .landing-title {
    font-size: clamp(2.8rem, 17vw, 5rem);
  }

  #bingo {
    border-spacing: 8px;
  }

  #bingo td {
    padding: 14px 12px;
    border-radius: 16px;
  }

  .card-meta {
    justify-items: start;
  }

  .countdown-card {
    padding: 22px;
  }

  .final-stage {
    min-height: auto;
  }

  .final-summary {
    width: 100%;
  }

  .final-actions .secondary-button,
  .final-actions .primary-button {
    width: 100%;
    min-width: 0;
  }
}
