:root {
  color-scheme: dark;
  --bg: #0d0714;
  --bg-glow: #1c0f2e;
  --ink: #f7f2ff;
  --muted: #b9a9ca;
  --line: #3b2854;
  --panel: #171023;
  --panel-soft: #211631;
  --brand: #9146ff;
  --brand-dark: #6f2ee0;
  --accent: #c084fc;
  --danger: #ff5f7a;
  --ok: #24133a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(145, 70, 255, 0.32), transparent 34rem),
    radial-gradient(circle at 82% 18%, rgba(192, 132, 252, 0.16), transparent 26rem),
    linear-gradient(135deg, var(--bg), var(--bg-glow) 52%, #08050d);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 0.75rem 1rem;
}

button:hover {
  background: var(--brand-dark);
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #100b19;
  color: var(--ink);
  padding: 0.8rem 0.9rem;
}

input[type="checkbox"] {
  accent-color: var(--brand);
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.user-app {
  width: min(980px, calc(100% - 28px));
}

.join-screen,
.waiting-screen,
.game-screen {
  min-height: calc(100vh - 72px);
}

.join-screen,
.waiting-screen {
  display: grid;
  place-items: center;
  padding: 36px 0;
}

.mlem-logo {
  width: min(560px, 92vw);
  height: auto;
  max-height: 360px;
  display: block;
  margin: 0 auto 24px;
  object-fit: contain;
}

.mlem-logo.small {
  width: min(220px, 38vw);
  height: auto;
  max-height: 160px;
  margin: 0;
}

.join-card,
.bingo-card,
.custom-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.join-card {
  width: min(440px, 100%);
  padding: 24px;
  text-align: center;
}

.waiting-card {
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  padding: 28px;
}

.join-card.waiting-card h1 {
  border: 0;
  background: transparent;
  font-size: clamp(2.4rem, 8vw, 4rem);
  line-height: 1;
  margin: 0;
  padding: 0;
  text-transform: none;
}

.waiting-card .muted-copy {
  max-width: 38rem;
  margin: 0 auto;
}

.waiting-player {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #100b19;
  padding: 16px;
}

.waiting-player span,
.waiting-player small {
  color: var(--muted);
}

.waiting-player strong {
  color: var(--accent);
  font-size: 1.4rem;
}

.join-card h1,
.bingo-card h1 {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #100b19;
  font-size: clamp(2.3rem, 8vw, 4rem);
  line-height: 1;
  margin-bottom: 20px;
  padding: 10px 12px;
}

.status-message {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #100b19;
  color: var(--muted);
  line-height: 1.35;
  margin-bottom: 14px;
  padding: 12px;
}

.status-message:empty {
  display: none;
}

.status-message strong {
  color: var(--ink);
}

.status-message[data-status="active"] strong {
  color: var(--accent);
}

.join-card form.is-disabled {
  opacity: 0.56;
}

.pre-suggest {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
  text-align: left;
}

.pre-suggest .eyebrow {
  margin-bottom: 0;
}

.join-card form,
.choice-box,
.rules-box {
  display: grid;
  gap: 12px;
}

.category-choice-list {
  display: grid;
  gap: 10px;
}

.join-card label {
  color: var(--muted);
  font-weight: 800;
}

.choice-box,
.rules-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 2px 0 0;
  padding: 14px;
  text-align: left;
}

.choice-box legend,
.rules-box legend {
  color: var(--accent);
  font-weight: 900;
  padding: 0 8px;
}

.choice-box label,
.rules-box label {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  line-height: 1.35;
}

.rules-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.2rem;
}

.choice-box input,
.rules-box input {
  flex: 0 0 auto;
  margin-top: 3px;
  width: auto;
}

.game-screen {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 24px 0 48px;
}

.game-header {
  align-items: flex-start;
  display: flex;
  justify-content: center;
  position: relative;
  width: 100%;
}

.game-note {
  position: absolute;
  right: 0;
  top: 0;
  display: grid;
  gap: 4px;
  max-width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.92);
  color: var(--muted);
  padding: 12px;
  text-align: right;
}

.game-note strong {
  color: var(--ink);
}

.bingo-card {
  width: min(760px, 100%);
  padding: 18px;
  text-align: center;
}

.bingo-card h2 {
  max-width: none;
  font-size: clamp(1.8rem, 6vw, 3rem);
  margin-bottom: 14px;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: min(760px, 100%);
}

.game-actions button {
  width: auto;
}

.admin-dashboard > .game-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  width: 100%;
}

.custom-card {
  width: min(760px, 100%);
  padding: 18px;
}

.admin-app {
  width: min(1240px, calc(100% - 28px));
}

.admin-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  padding: 28px 0 52px;
}

.dashboard-panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.88);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dashboard-panel summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  user-select: none;
}

.dashboard-panel summary span {
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 900;
}

.dashboard-panel summary small {
  color: var(--muted);
  font-weight: 800;
}

.panel-body {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 16px;
}

.admin-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.words-panel {
  grid-row: span 2;
}

.players-panel {
  grid-column: 1 / -1;
}

.status-panel {
  grid-column: 1 / -1;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 0.8fr);
  gap: 10px;
}

.event-sections {
  display: grid;
  gap: 22px;
}

.word-group {
  display: grid;
  gap: 10px;
}

.word-group h3 {
  font-size: 1.45rem;
  text-align: left;
}

.compact-list {
  gap: 8px;
}

.compact-list .list-row {
  gap: 8px;
  padding: 8px;
}

.compact-list .list-row > div:first-child {
  min-width: 0;
}

.compact-list .actions {
  gap: 6px;
}

.compact-list .actions button {
  padding: 0.45rem 0.6rem;
}

.add-word-form,
.add-category-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip-wrap {
  display: inline-flex;
  gap: 4px;
}

.filter-chip {
  width: auto;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.55rem 0.8rem;
}

.chip-remove {
  width: auto;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--danger);
  padding: 0.55rem 0.7rem;
}

.filter-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.word-list {
  max-height: 68vh;
  overflow: auto;
  gap: 12px;
  padding-right: 4px;
}

.word-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag-toggle {
  align-items: center;
  display: flex;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 5px 8px;
}

.tag-toggle input {
  width: auto;
}

.add-word-form button,
.add-category-form button {
  min-width: 46px;
  padding-inline: 0.9rem;
}

.player-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.player-mini-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.72);
  padding: 10px;
  text-align: center;
}

.player-mini-card h3 {
  font-size: 1.05rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.player-mini-card .mini-board {
  width: min(150px, 100%);
}

.player-mini-card .actions {
  justify-content: center;
}

.player-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.92);
  padding: 10px;
}

.player-card h3 {
  font-size: 1rem;
  text-align: center;
}

.mini-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  aspect-ratio: 1;
}

.mini-cell {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #120c1c;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.mini-cell.is-hit {
  background: #24133a;
  border-color: var(--brand);
  color: var(--accent);
}

.mini-cell.is-winning {
  background: var(--brand);
  border-color: var(--ink);
  color: white;
}

.player-card .actions {
  justify-content: center;
}

.topbar,
.hero,
.layout,
.panel-header,
.join-row,
.suggest-form,
.list-row,
.actions {
  display: flex;
  gap: 16px;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  max-width: 760px;
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  line-height: 1;
}

.hero h2:empty {
  display: none;
}

.suggest-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
}

.suggest-form.is-disabled {
  opacity: 0.62;
}

.suggest-form input {
  min-height: 42px;
  padding-block: 0.65rem;
}

.suggest-form button {
  min-width: 112px;
  padding-block: 0.65rem;
}

h3 {
  font-size: 1.25rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.room-pill,
.status-box,
.bingo-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.88);
}

.room-pill {
  display: grid;
  gap: 2px;
  min-width: 128px;
  padding: 10px 14px;
  color: var(--muted);
  text-align: right;
}

.room-pill strong {
  color: var(--accent);
}

.hero {
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid rgba(145, 70, 255, 0.34);
  padding: 24px 0 32px;
}

.hero p {
  max-width: 660px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 16px;
}

.join-panel {
  flex: 0 0 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.has-player .join-panel {
  display: none;
}

.join-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.layout {
  align-items: flex-start;
  margin-top: 28px;
}

.sidebar {
  position: sticky;
  top: 16px;
  flex: 0 0 220px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.tab,
.secondary,
.ghost {
  width: 100%;
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.tab.is-active,
.secondary:hover,
.ghost:hover {
  background: var(--brand);
  color: white;
}

.status-box {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 14px;
}

.status-box span {
  color: var(--muted);
  font-size: 0.85rem;
}

.notice {
  min-height: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin-bottom: 12px;
  padding: 0;
}

.notice:not(:empty) {
  background: var(--panel-soft);
  border-color: var(--line);
  padding: 10px 12px;
}

.notice.is-success {
  border-color: var(--accent);
  color: var(--accent);
}

.notice.is-error {
  border-color: var(--danger);
  color: var(--danger);
}

.secondary,
.ghost {
  margin-bottom: 10px;
}

.ghost {
  color: var(--danger);
}

.view {
  display: none;
  flex: 1;
  min-width: 0;
  gap: 18px;
}

.view.is-active {
  display: grid;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(12px);
}

.panel-header {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.bingo-state {
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 14px;
}

.bingo-state.is-bingo {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

.cell {
  display: grid;
  min-height: 118px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #120c1c;
  color: var(--ink);
  line-height: 1.25;
  padding: 10px;
  text-align: center;
}

.cell.is-hit {
  background: var(--ok);
  border-color: var(--brand);
  color: var(--accent);
}

.cell.is-free {
  background: linear-gradient(135deg, #9146ff, #c084fc);
  color: white;
}

.cell.is-winning {
  background: var(--brand);
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.28), 0 0 24px rgba(145, 70, 255, 0.42);
  color: white;
}

.cell.is-empty {
  border-style: dashed;
  color: var(--muted);
}

.preset-select {
  width: 100%;
  min-height: 118px;
  border: 2px solid var(--brand);
  border-radius: 8px;
  background: #100b19;
  color: var(--ink);
  padding: 10px;
}

.muted-copy {
  color: var(--muted);
  line-height: 1.5;
}

.custom-card .muted-copy {
  font-size: 0.9rem;
  margin: 8px 0;
}

.list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-row {
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #120c1c;
  padding: 12px;
}

.list-row p {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
}

.actions {
  flex: 0 0 auto;
  gap: 8px;
}

.actions button {
  padding: 0.55rem 0.75rem;
}

.review-list {
  min-width: 0;
}

.review-row {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.review-row > div:first-child {
  min-width: 0;
}

.review-row .actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  width: 100%;
}

.review-row .actions button {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.waiting-row {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.waiting-row .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  width: 100%;
}

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

.danger:hover {
  background: #963b35;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.board .empty {
  grid-column: 1 / -1;
}

.list-row.is-winner {
  background: #24133a;
  border-color: var(--accent);
}

.suggestion-slot {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 6px;
  background: #1f1330;
  color: var(--ink);
  padding: 7px 8px;
}

.suggestion-slot span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.suggestion-status {
  border: 1px solid rgba(192, 132, 252, 0.38);
  border-radius: 6px;
  background: #120c1c;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.48rem 0.7rem;
  white-space: nowrap;
}

.suggestion-status.is-approved,
.suggestion-status.is-merged {
  background: var(--brand);
  color: white;
}

.suggestion-status.is-rejected {
  border-color: rgba(255, 95, 122, 0.46);
  color: var(--danger);
}

.site-footer {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 112px;
  margin-top: auto;
  background: #3b2854;
  gap: 14px;
  padding: 20px 18px;
}

.social-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  justify-content: center;
}

.social-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(247, 242, 255, 0.16);
  border-radius: 999px;
  background: #7c3cff;
  box-shadow: 0 0 22px rgba(124, 60, 255, 0.38), 0 10px 24px rgba(0, 0, 0, 0.24);
  color: #f7f2ff;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.social-button:hover,
.social-button:focus-visible {
  background: #9146ff;
  box-shadow: 0 0 28px rgba(145, 70, 255, 0.58), 0 12px 28px rgba(0, 0, 0, 0.28);
  outline: none;
  transform: translateY(-2px);
}

.social-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.legal-links a {
  color: rgba(247, 242, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.legal-links a:hover,
.legal-links a:focus-visible {
  color: #f7f2ff;
  outline: none;
  text-decoration: underline;
}

.legal-page {
  width: min(900px, calc(100% - 28px));
}

.legal-card {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 16, 35, 0.92);
  box-shadow: var(--shadow);
  line-height: 1.6;
  padding: 24px;
}

.legal-card h1 {
  font-size: clamp(2rem, 6vw, 3.8rem);
}

.legal-card h2 {
  font-size: 1.35rem;
  line-height: 1.2;
  margin-top: 10px;
}

.legal-card a {
  color: var(--accent);
}

.legal-card ul {
  margin: 0;
  padding-left: 1.25rem;
}

.legal-warning {
  border: 1px solid rgba(192, 132, 252, 0.34);
  border-radius: 8px;
  background: #1f1330;
  color: var(--accent);
  font-weight: 800;
  padding: 12px;
}

@media (max-width: 860px) {
  .topbar,
  .hero,
  .layout,
  .join-row,
  .suggest-form,
  .list-row {
    flex-direction: column;
  }

  .join-panel,
  .sidebar {
    flex-basis: auto;
    width: 100%;
  }

  .sidebar {
    position: static;
  }

  .board {
    gap: 6px;
  }

  .cell {
    min-height: 86px;
    font-size: 0.86rem;
  }

  .game-note {
    position: static;
    margin-left: auto;
  }

  .game-header {
    align-items: center;
    justify-content: space-between;
  }

  .game-actions button {
    width: 100%;
  }

  .admin-dashboard {
    grid-template-columns: 1fr;
  }

  .words-panel,
  .players-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .word-list {
    max-height: none;
    overflow: visible;
  }

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

@media (max-width: 520px) {
  .player-gallery {
    grid-template-columns: 1fr;
  }

  .site-footer {
    min-height: 108px;
    padding: 18px 14px;
  }

  .social-links {
    gap: 18px;
  }

  .social-button {
    width: 46px;
    height: 46px;
  }
}
