:root {
  color-scheme: light;
  --ink: #18211c;
  --muted: #68746d;
  --line: #d9ded8;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --green: #227455;
  --green-dark: #16543d;
  --gold: #d89a24;
  --red: #b34d42;
  --tile-light: #e8dfc7;
  --tile-dark: #2f6f58;
  --shadow: 0 18px 50px rgba(35, 44, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html[data-page="home"] .page-view:not([data-page="home"]),
html[data-page="anmeldung"] .page-view:not([data-page="anmeldung"]),
html[data-page="teilnehmer"] .page-view:not([data-page="teilnehmer"]),
html[data-page="spielplan"] .page-view:not([data-page="spielplan"]),
html[data-page="tabelle"] .page-view:not([data-page="tabelle"]),
html[data-page="regeln"] .page-view:not([data-page="regeln"]),
html[data-page="profil"] .page-view:not([data-page="profil"]),
html[data-admin-page="dashboard"] .admin-view:not([data-admin-page="dashboard"]),
html[data-admin-page="anmeldungen"] .admin-view:not([data-admin-page="anmeldungen"]),
html[data-admin-page="spieler"] .admin-view:not([data-admin-page="spieler"]),
html[data-admin-page="spielplan"] .admin-view:not([data-admin-page="spielplan"]),
html[data-admin-page="ergebnisse"] .admin-view:not([data-admin-page="ergebnisse"]) {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 5vw, 64px);
  border-bottom: 1px solid rgba(24, 33, 28, 0.1);
  background: rgba(251, 250, 245, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 22px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav-button {
  border: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.nav-button:hover {
  background: #eef1ec;
  color: var(--ink);
}

nav a:hover {
  background: #eef1ec;
  color: var(--ink);
}

main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.hero {
  min-height: calc(100svh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: center;
  gap: clamp(28px, 6vw, 84px);
  padding: clamp(28px, 7vw, 82px) 0 34px;
}

.compact-hero {
  min-height: min(720px, calc(100svh - 68px));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(52px, 10vw, 112px);
  line-height: 0.92;
  letter-spacing: 0;
}

.panel h1,
.table-section h1,
.rules h1 {
  font-size: clamp(30px, 4.5vw, 48px);
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 610px;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  background: #eef1ec;
  color: var(--ink);
}

.button.primary {
  background: var(--green);
  color: white;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.danger-button,
.danger-button {
  background: #f2ebe8;
  color: var(--red);
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.button.compact {
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #f2ebe8;
  color: var(--red);
  font-size: 20px;
}

.board-panel {
  align-self: stretch;
  min-height: 420px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.mini-board {
  width: min(100%, 560px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  overflow: hidden;
  border: 10px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  font-size: clamp(21px, 5vw, 44px);
}

.square.light {
  background: var(--tile-light);
}

.square.dark {
  background: var(--tile-dark);
  color: white;
}

.match-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(100%, 560px);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(35, 44, 38, 0.08);
}

.match-strip span {
  color: var(--muted);
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.stats div {
  padding: 22px;
  background: var(--panel);
}

.stats span {
  display: block;
  font-size: 34px;
  font-weight: 800;
}

.stats p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 22px;
  align-items: start;
}

.panel,
.table-section,
.rules {
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(35, 44, 38, 0.08);
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.signup-form,
.round-tools {
  display: grid;
  gap: 12px;
}

.signup-form {
  grid-template-columns: 1fr 110px auto;
  align-items: end;
  margin-bottom: 20px;
}

.wide-form {
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) auto;
}

.page-narrow {
  max-width: 860px;
  margin: clamp(28px, 6vw, 70px) auto 0;
}

.page-view.table-section,
.page-view.rules {
  margin-top: clamp(28px, 6vw, 70px);
}

.compact-actions {
  margin: 0 0 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  min-width: 0;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef1ec;
  color: var(--ink);
  font-size: 0.95em;
}

.form-status {
  min-height: 22px;
  margin: 8px 0 18px;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}

.profile-code-box {
  margin: 16px 0 22px;
  padding: 16px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: #eef8f3;
}

.profile-code-box strong {
  display: block;
  font-size: 32px;
  letter-spacing: 0.08em;
}

.profile-strip {
  width: 100%;
  margin-bottom: 14px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 760px) minmax(220px, 1fr);
  gap: 22px;
  align-items: start;
  padding: clamp(24px, 5vw, 56px) 0;
}

.board-wrap {
  position: relative;
  width: min(100%, 680px);
  margin-top: 18px;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 700;
}

.inline-status {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.move-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.game-alert {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #fff7e6;
  color: var(--ink);
}

.game-alert strong {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.game-alert span {
  color: var(--muted);
  font-weight: 700;
}

.game-alert.critical {
  border-color: var(--red);
  background: #fff0ee;
}

.game-over-badge {
  position: absolute;
  inset: 16px 16px auto;
  z-index: 2;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(24, 33, 28, 0.92);
  color: white;
  font-weight: 800;
  text-align: center;
}

input:focus,
select:focus {
  outline: 3px solid rgba(34, 116, 85, 0.18);
  border-color: var(--green);
}

.list,
.rounds {
  display: grid;
  gap: 10px;
}

.player-row,
.match-row,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.player-row div,
.admin-row div {
  min-width: 0;
}

.player-row strong {
  display: block;
}

.player-row span,
.empty,
.round-tools p {
  color: var(--muted);
  font-size: 14px;
}

.player-row button {
  width: 34px;
  height: 34px;
}

.round-tools {
  grid-template-columns: minmax(220px, 320px) 1fr;
  align-items: end;
  margin-bottom: 18px;
}

.round-tools p {
  margin: 0;
  line-height: 1.45;
}

.round-block {
  display: grid;
  gap: 10px;
}

.round-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.round-title h3 {
  margin: 0;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.match-row > strong {
  justify-self: end;
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.vs {
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
}

.result-buttons {
  display: flex;
  gap: 6px;
}

.result-buttons button {
  min-width: 42px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.result-buttons button.active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.admin-body h1 {
  font-size: clamp(30px, 4.5vw, 48px);
}

.login-panel {
  max-width: 560px;
  margin: clamp(32px, 10vw, 96px) auto;
}

.admin-login {
  display: grid;
  gap: 14px;
}

.admin-shell {
  padding-top: 28px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.admin-row strong,
.admin-row span {
  display: block;
}

.admin-row span {
  color: var(--muted);
  font-size: 14px;
}

.admin-edit-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(90px, 140px) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.danger-zone {
  margin-top: 22px;
  background: #fffafa;
}

.empty {
  padding: 18px;
  text-align: center;
}

.table-section,
.rules {
  margin-top: 22px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.rank {
  width: 48px;
  font-weight: 800;
}

.score {
  font-weight: 800;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.rule-grid article {
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.rule-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 0;
  padding: 24px 0 34px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  .hero,
  .workspace,
  .game-layout,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .board-panel {
    min-height: 0;
  }

  .signup-form,
  .wide-form,
  .round-tools,
  .admin-row,
  .admin-edit-row {
    grid-template-columns: 1fr;
  }

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

  .match-row > strong {
    justify-self: start;
  }

  .result-buttons {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    padding: 12px;
  }

  nav a {
    padding: 7px 8px;
    font-size: 13px;
  }

  h1 {
    font-size: 38px;
  }

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

  .panel-heading,
  .round-title,
  footer {
    flex-direction: column;
    align-items: stretch;
  }
}
