:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --bg-end: #ebe5db;
  --ink: #17202a;
  --muted: #65717d;
  --line: #d9d4ca;
  --panel: #ffffff;
  --panel-soft: #fffaf1;
  --panel-border: rgba(23, 32, 42, 0.08);
  --input-bg: #ffffff;
  --chip-bg: #f0eee9;
  --surface-subtle: #fbfaf7;
  --ghost-bg: #e7ebed;
  --navy: #12355b;
  --action-bg: #12355b;
  --green: #0f7b6c;
  --red: #b94343;
  --gold: #d99b32;
  --gold-ink: #7a5518;
  --on-gold: #102137;
  --toast-bg: rgba(255, 250, 241, 0.96);
  --toast-text: #574220;
  --silver: #b9c0c7;
  --bronze: #b7794a;
  --green-soft: rgba(15, 123, 108, 0.13);
  --red-soft: rgba(185, 67, 67, 0.12);
  --navy-soft: rgba(18, 53, 91, 0.12);
  --gold-soft: rgba(217, 155, 50, 0.16);
  --shadow: 0 1px 2px rgba(23, 32, 42, 0.05), 0 12px 28px rgba(23, 32, 42, 0.08);
  --shadow-lift: 0 2px 4px rgba(23, 32, 42, 0.06), 0 18px 36px rgba(23, 32, 42, 0.12);
  --font-display: Georgia, "Times New Roman", ui-serif, serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"),
    radial-gradient(circle at top left, rgba(15, 123, 108, 0.12), transparent 32rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-end) 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

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

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

button {
  min-height: 2.5rem;
  border: 0;
  border-radius: 8px;
  background: var(--action-bg);
  color: white;
  cursor: pointer;
  font-weight: 800;
  padding: 0 1rem;
  transition: box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

button:hover {
  filter: brightness(1.06);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(217, 155, 50, 0.62);
  outline-offset: 2px;
}

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

button.ghost {
  background: var(--ghost-bg);
  color: var(--ink);
}

button.danger {
  background: var(--red);
}

.button-link {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--action-bg);
  color: white;
  font-weight: 850;
  padding: 0 1rem;
  transition: box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

.button-link.ghost {
  background: var(--ghost-bg);
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 0.72rem 0.85rem;
}

input[type="file"] {
  padding: 0.55rem;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.check-row.compact {
  justify-content: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar {
  width: min(1180px, calc(100% - 2rem));
  min-height: 4.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: 0 auto;
  padding: 0.8rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-gold);
  font-size: 1.4rem;
  font-weight: 950;
}

.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0;
  line-height: 0.95;
}

.brand small {
  color: var(--muted);
  font-weight: 800;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.nav > a,
.nav-user,
.nav form {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
}

.nav > a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  font-weight: 850;
  padding: 0 0.8rem;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.nav form {
  margin: 0;
}

.nav-user {
  gap: 0.45rem;
}

.theme-toggle {
  min-width: 4.8rem;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

.flash-stack {
  position: sticky;
  z-index: 5;
  top: 0.5rem;
  width: min(1180px, calc(100% - 2rem));
  display: grid;
  gap: 0.5rem;
  margin: 0 auto;
}

.flash {
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow);
}

.flash.error {
  background: var(--red);
}

.flash.success {
  background: var(--green);
}

.auth-layout {
  min-height: calc(100vh - 7rem);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 430px);
  align-items: center;
  gap: 1rem;
}

.auth-hero {
  min-height: 30rem;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 53, 91, 0.95), rgba(15, 123, 108, 0.88)),
    repeating-linear-gradient(90deg, transparent 0 76px, rgba(255, 255, 255, 0.08) 76px 78px);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 6vw, 4rem);
  box-shadow: var(--shadow);
}

.auth-hero h1,
.page-title h1,
.section-header h1 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: 0;
}

.auth-hero h1 {
  max-width: 11ch;
  font-size: clamp(3rem, 7.6vw, 5.6rem);
  line-height: 0.88;
}

.auth-hero .text-link {
  margin-top: -0.6rem;
}

.auth-forms,
.panel {
  display: grid;
  gap: 1rem;
}

.panel,
.stats-grid article,
.match-card,
.table-wrap,
.profile-preview,
.empty-state {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1rem;
}

.danger-panel {
  border-color: color-mix(in srgb, var(--red) 38%, var(--panel-border));
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--red-soft) 36%, var(--panel)));
}

.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1.05;
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.5rem;
}

.rule-strip span {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.45rem 0.75rem;
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-hero .eyebrow {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 0.75rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.3rem;
}

.stats-grid article {
  min-height: 6.2rem;
  display: grid;
  align-content: center;
  gap: 0.3rem;
  padding: 1rem;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.stats-grid strong {
  font-family: var(--font-display);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
}

.page-title,
.section-header {
  margin: 0.5rem 0 1rem;
}

.action-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.page-title h1,
.section-header h1 {
  font-size: clamp(2.25rem, 4.4vw, 4rem);
  line-height: 0.92;
}

.stage-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.2rem;
}

.stage-tabs a {
  min-height: 2.45rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  color: var(--ink);
  font-weight: 850;
  padding: 0 0.9rem;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.stage-tabs a.active {
  border-color: rgba(18, 53, 91, 0.2);
  background: var(--action-bg);
  color: white;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 0.55rem;
  padding: 1.2rem;
}

.empty-state.compact {
  box-shadow: none;
}

.empty-state h1,
.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state p,
.muted,
.form-note {
  color: var(--muted);
}

.round-section {
  margin: 0 0 2rem;
}

.group-block {
  margin: 0 0 1.2rem;
}

.group-block h2 {
  margin: 0 0 0.65rem;
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 1.12rem;
  text-transform: uppercase;
}

.match-list {
  display: grid;
  gap: 0.75rem;
}

.group-tip-form {
  display: grid;
  gap: 0.75rem;
}

.group-save {
  display: flex;
  justify-content: flex-end;
}

.match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  padding: 1rem;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.match-card.result-home {
  border-left: 4px solid var(--green);
}

.match-card.result-draw {
  border-left: 4px solid var(--muted);
}

.match-card.result-away {
  border-left: 4px solid var(--navy);
}

.match-info {
  display: grid;
  gap: 0.45rem;
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.match-meta span,
.match-meta time {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  border-radius: 999px;
  background: var(--chip-bg);
  padding: 0 0.55rem;
}

.match-meta .open {
  background: var(--green-soft);
  color: var(--green);
}

.match-meta .locked {
  background: var(--red-soft);
  color: var(--red);
}

.match-meta .powerup-label {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.match-meta .multiplier-chip {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.2rem;
}

.sort-toggle-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sort-toggle a {
  min-height: 2.1rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  color: var(--ink);
  font-weight: 850;
  font-size: 0.85rem;
  padding: 0 0.8rem;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.sort-toggle a.active {
  border-color: rgba(18, 53, 91, 0.2);
  background: var(--action-bg);
  color: white;
}

.streak-flame {
  white-space: nowrap;
  font-weight: 850;
}

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(1rem, 2vw, 1.28rem);
}

.teams strong:first-child {
  text-align: right;
}

.teams .scoreline {
  min-width: 3rem;
  color: var(--navy);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  text-align: center;
}

.team-flag {
  display: inline-block;
  margin-right: 0.28rem;
}

.match-note {
  color: var(--muted);
  font-weight: 750;
}

.tip-form {
  display: grid;
  grid-template-columns: 4.3rem auto 4.3rem minmax(9rem, 13rem);
  align-items: center;
  gap: 0.5rem;
}

.tip-form input,
.result-form input[type="number"] {
  text-align: center;
}

.powerup-select {
  min-width: 9rem;
  font-size: 0.78rem;
}

.powerup-select select {
  padding: 0.58rem 0.7rem;
}

.madness-toast {
  position: fixed;
  z-index: 20;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 0.35rem;
  place-items: center;
  width: min(22rem, calc(100vw - 2rem));
  border: 2px solid rgba(217, 155, 50, 0.72);
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--navy);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.92) rotate(-1deg);
  transition: opacity 160ms ease;
  padding: 1.2rem;
  text-align: center;
}

.madness-toast.show {
  animation: madness-pop 380ms ease both;
  opacity: 1;
}

.madness-toast strong {
  font-size: clamp(2.3rem, 8vw, 4.8rem);
  letter-spacing: 0;
  line-height: 0.9;
}

.madness-toast span {
  color: var(--toast-text);
  font-weight: 850;
}

.revealed-tips {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.revealed-tip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.revealed-tip-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--toast-text);
  font-size: 0.82rem;
  font-weight: 850;
  padding: 0.35rem 0.55rem;
}

.reaction-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.reaction-pill {
  min-height: 1.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  padding: 0 0.4rem;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 140ms ease, border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.reaction-pill.has-count {
  opacity: 1;
}

.reaction-pill:hover,
.reaction-pill:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
}

.reaction-pill.mine {
  border-color: var(--green);
  background: var(--green-soft);
}

.reaction-count {
  font-size: 0.74rem;
  font-weight: 850;
  color: var(--muted);
}

.reaction-pill.mine .reaction-count {
  color: var(--green);
}

.avatar-fallback,
.person img,
.nav-user img,
.revealed-tips img {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 950;
}

.avatar-fallback.large {
  width: 7rem;
  height: 7rem;
  font-size: 3rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.85rem;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.current-user-row {
  background: var(--gold-soft);
}

.rank-medal {
  width: 0.78rem;
  height: 0.78rem;
  display: inline-block;
  border-radius: 50%;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.rank-1 {
  background: var(--gold);
}

.rank-2 {
  background: var(--silver);
}

.rank-3 {
  background: var(--bronze);
}

.points-total,
.duel-points,
.challenge-stats dd,
.profile-stats dd,
td,
th {
  font-variant-numeric: tabular-nums;
}

.person {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 850;
}

.profile-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 1rem;
}

.profile-preview {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 18rem;
  gap: 1rem;
  padding: 1rem;
}

.profile-preview img {
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  object-fit: cover;
}

.profile-preview h1 {
  margin: 0;
}

.profile-stats {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.profile-stats div {
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 0.75rem;
}

.profile-stats dt {
  color: var(--muted);
  font-weight: 850;
}

.profile-stats dd {
  margin: 0.15rem 0 0;
  font-weight: 900;
}

.simple-list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding-left: 1.1rem;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 1rem;
  align-items: start;
}

.chat-panel {
  max-height: 42rem;
  overflow: auto;
}

.chat-message {
  display: grid;
  gap: 0.45rem;
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
}

.chat-message:first-child {
  padding-top: 0;
}

.chat-message:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-message time,
.challenge-card-head,
.challenge-stats,
.form-note {
  font-size: 0.84rem;
}

.chat-message time {
  color: var(--muted);
  font-weight: 750;
}

.challenge-sections,
.challenge-section,
.challenge-detail,
.side-panel,
.challenge-form,
.resolve-form,
.inline-form,
.prediction-list,
.prediction-answer-form {
  display: grid;
  gap: 1rem;
}

.prediction-card {
  align-content: start;
}

.prediction-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.prediction-card-head h2,
.prediction-card-head p,
.rules-page h2,
.rules-page p {
  margin: 0;
}

.prediction-card-head p,
.rules-page p {
  line-height: 1.55;
}

.admin-tools {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.admin-tools summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.compact-table table {
  min-width: 0;
}

.challenge-section h2,
.side-panel h2,
.resolve-form h2 {
  margin: 0;
}

.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.challenge-card {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.challenge-card h3,
.challenge-card p {
  margin: 0;
}

.challenge-card h3 {
  color: var(--navy);
  font-size: 1.2rem;
}

.challenge-card p,
.challenge-detail p {
  line-height: 1.5;
}

.challenge-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 850;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
  padding: 0 0.6rem;
}

.status-pill.open {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.locked {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.status-pill.resolved {
  background: var(--navy-soft);
  color: var(--navy);
}

.status-pill.void {
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
}

.status-pill.declined,
.status-pill.cancelled,
.status-pill.expired {
  background: var(--red-soft);
  color: var(--red);
}

.challenge-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0;
}

.challenge-stats div {
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 0.65rem;
}

.challenge-stats dt {
  color: var(--muted);
  font-weight: 850;
}

.challenge-stats dd {
  margin: 0.1rem 0 0;
  font-weight: 900;
}

.text-link {
  color: var(--green);
  font-weight: 900;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.challenge-detail {
  align-items: start;
}

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

.side-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.side-members .person {
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 0.35rem 0.6rem 0.35rem 0.35rem;
}

.settlement-box {
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 0.85rem;
}

.settlement-box h2,
.settlement-box p {
  margin: 0;
}

.settlement-box p {
  margin-top: 0.35rem;
}

.duel-points {
  margin: 0;
  color: var(--navy);
  font-size: 2.8rem;
  font-weight: 950;
}

.badge-card h3 {
  margin: 0;
}

.mystery-badge-card {
  display: grid;
  align-content: center;
  min-height: 9rem;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
}

.mystery-badge-card h3,
.mystery-badge-card p {
  margin: 0;
}

.mystery-badge-mark {
  display: inline-grid;
  place-items: center;
  justify-self: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: var(--navy);
  color: var(--cream);
  font-size: 1.7rem;
  font-weight: 950;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mystery-badge-pill {
  display: inline-grid;
  place-items: center;
  width: 1.65rem;
  min-width: 1.65rem;
  height: 1.65rem;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 950;
}

.banter-label {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-ink);
  font-style: normal;
  font-weight: 950;
  padding: 0 0.45rem;
}

.result-panel {
  min-width: 0;
}

.result-list {
  display: grid;
  gap: 0.6rem;
  max-height: 48rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.result-form {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) 8rem 4rem auto 4rem 7rem 4rem;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 0.6rem;
}

.result-match {
  display: grid;
  gap: 0.2rem;
}

.result-match span {
  color: var(--muted);
  font-size: 0.82rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151b;
  --bg-end: #18222d;
  --ink: #edf2f7;
  --muted: #aeb9c5;
  --line: #33404d;
  --panel: #17202a;
  --panel-soft: #202b34;
  --panel-border: rgba(255, 255, 255, 0.09);
  --input-bg: #111922;
  --chip-bg: #24303a;
  --surface-subtle: #1d2731;
  --ghost-bg: #293542;
  --navy: #9cc7ef;
  --action-bg: #285b83;
  --green: #5bc6b3;
  --red: #ff8b8b;
  --gold: #e1ad50;
  --silver: #c8d0d8;
  --bronze: #d29a6d;
  --gold-ink: #f2d391;
  --on-gold: #13202c;
  --toast-bg: rgba(32, 39, 46, 0.98);
  --toast-text: #f1d195;
  --green-soft: rgba(91, 198, 179, 0.15);
  --red-soft: rgba(255, 139, 139, 0.15);
  --navy-soft: rgba(156, 199, 239, 0.16);
  --gold-soft: rgba(225, 173, 80, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 12px 28px rgba(0, 0, 0, 0.26);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.28), 0 18px 36px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] body {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E"),
    radial-gradient(circle at top left, rgba(91, 198, 179, 0.14), transparent 32rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-end) 100%);
}

:root[data-theme="dark"] .auth-hero {
  background:
    linear-gradient(135deg, rgba(12, 30, 49, 0.98), rgba(16, 88, 80, 0.9)),
    repeating-linear-gradient(90deg, transparent 0 76px, rgba(255, 255, 255, 0.08) 76px 78px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10151b;
    --bg-end: #18222d;
    --ink: #edf2f7;
    --muted: #aeb9c5;
    --line: #33404d;
    --panel: #17202a;
    --panel-soft: #202b34;
    --panel-border: rgba(255, 255, 255, 0.09);
    --input-bg: #111922;
    --chip-bg: #24303a;
    --surface-subtle: #1d2731;
    --ghost-bg: #293542;
    --navy: #9cc7ef;
    --action-bg: #285b83;
    --green: #5bc6b3;
    --red: #ff8b8b;
    --gold: #e1ad50;
    --silver: #c8d0d8;
    --bronze: #d29a6d;
    --gold-ink: #f2d391;
    --on-gold: #13202c;
    --toast-bg: rgba(32, 39, 46, 0.98);
    --toast-text: #f1d195;
    --green-soft: rgba(91, 198, 179, 0.15);
    --red-soft: rgba(255, 139, 139, 0.15);
    --navy-soft: rgba(156, 199, 239, 0.16);
    --gold-soft: rgba(225, 173, 80, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.24), 0 12px 28px rgba(0, 0, 0, 0.26);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.28), 0 18px 36px rgba(0, 0, 0, 0.34);
  }

  :root:not([data-theme="light"]) body {
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E"),
      radial-gradient(circle at top left, rgba(91, 198, 179, 0.14), transparent 32rem),
      linear-gradient(180deg, var(--bg) 0%, var(--bg-end) 100%);
  }

  :root:not([data-theme="light"]) .auth-hero {
    background:
      linear-gradient(135deg, rgba(12, 30, 49, 0.98), rgba(16, 88, 80, 0.9)),
      repeating-linear-gradient(90deg, transparent 0 76px, rgba(255, 255, 255, 0.08) 76px 78px);
  }
}

@media (hover: hover) {
  button:hover,
  .button-link:hover,
  .nav > a:hover,
  .stage-tabs a:hover,
  .match-card:hover,
  .challenge-card:hover {
    box-shadow: var(--shadow-lift);
    transform: translateY(-2px);
  }
}

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

  button:hover,
  .button-link:hover,
  .nav > a:hover,
  .stage-tabs a:hover,
  .match-card:hover,
  .challenge-card:hover {
    transform: none;
  }
}

@media (max-width: 900px) {
  .auth-layout,
  .profile-grid,
  .admin-grid,
  .chat-layout,
  .side-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .nav {
    align-items: stretch;
    flex-direction: column;
  }

  .nav > a,
  .nav form,
  .nav button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-card,
  .result-form {
    grid-template-columns: 1fr;
  }

  .teams {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .teams strong:first-child {
    text-align: left;
  }

  .tip-form {
    display: flex;
    flex-wrap: wrap;
  }

  .tip-form input {
    width: 4.5rem;
  }

  .action-title {
    align-items: stretch;
    flex-direction: column;
  }

  .action-title .button-link {
    width: max-content;
  }
}

@media (max-width: 540px) {
  .topbar,
  .shell,
  .flash-stack {
    width: min(100% - 1rem, 1180px);
  }

  .auth-hero {
    min-height: 22rem;
    padding: 1.25rem;
  }

  .auth-hero h1 {
    font-size: 2.55rem;
  }

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

  .stage-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .stage-tabs a {
    flex: 0 0 auto;
  }

  .challenge-stats {
    grid-template-columns: 1fr;
  }
}

@keyframes madness-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.82) rotate(-2deg);
  }
  45% {
    transform: translate(-50%, -50%) scale(1.08) rotate(2deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(-1deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .madness-toast,
  .madness-toast.show {
    animation: none;
    transition: none;
  }
}
