/* Hallennacht — Design-Tokens exakt nach Spec §10 */
:root {
  --page: #0F0E0C;
  --surface: #1B1813;
  --raised: #25211A;
  --border: #37322A;
  --chalk: #EDE6D6;
  --text: #F4EFE7;
  --muted: #A89F8E;
  --accent: #F56B1F;
  --accent-text: #140E08;
  --danger: #E5484D;
  --danger-dim: #4A1D1D;
  --live: #5FBF7A;
  --hairline: #262118;
  --free: #57503F;

  --font-display: 'Anton', 'Arial Narrow', sans-serif;
  --font-label: 'Oswald', 'Arial Narrow', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-text: 'Inter', Arial, sans-serif;
}

@font-face {
  font-family: 'Anton';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/assets/fonts/anton-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url('/assets/fonts/oswald-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('/assets/fonts/oswald-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/assets/fonts/inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url('/assets/fonts/inter-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('/assets/fonts/inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/assets/fonts/inter-latin-700-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: block;
  src: url('/assets/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
  color-scheme: dark;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.teams-screen,
.spielplan-screen,
.admin-screen,
.three-screen {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 24px max(20px, env(safe-area-inset-right)) 42px max(20px, env(safe-area-inset-left));
}

/* Screen-Header: Oswald-Kicker, Anton-Titel, orange Court-Linie */
.screen-header {
  position: relative;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.screen-header-row {
  min-height: 16px;
}

.screen-kicker {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  line-height: 1.3;
  text-transform: uppercase;
}

.screen-title {
  margin: 3px 0 0;
  color: var(--chalk);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.06;
  text-transform: uppercase;
}

.screen-meta {
  margin: -3px 0 0;
  color: var(--accent);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  line-height: 1.25;
  text-align: right;
  text-transform: uppercase;
}

.live-badge {
  position: absolute;
  top: 31px;
  right: 0;
  display: inline-flex;
  align-items: center;
  color: var(--live);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  line-height: 1;
  text-transform: uppercase;
}

.live-badge::before {
  width: 8px;
  height: 8px;
  margin-right: 7px;
  background: currentColor;
  content: '';
}

.live-badge.is-offline {
  color: var(--danger);
}

/* Formulare und Eingaben */
.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.48fr);
  gap: 14px 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.add-form .field:first-of-type,
.add-form .add-submit {
  grid-column: 1 / -1;
}

.add-form .form-error {
  grid-column: 2;
  align-self: stretch;
  margin: 0;
}

.late-add-form {
  display: flex;
  flex-direction: column;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2.5px;
  line-height: 1.3;
  text-transform: uppercase;
}

.field-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  outline: none;
  background: var(--page);
  color: var(--text);
  caret-color: var(--accent);
  font-size: 16px;
  font-weight: 500;
}

.field-input:focus {
  border-color: var(--accent);
}

.field-input::selection {
  background: var(--accent);
  color: var(--accent-text);
}

/* Buttons: kantige Anton-Blöcke, keine Pills */
.button {
  display: inline-flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.5px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  user-select: none;
}

.button:focus-visible,
.team-remove:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 2px;
}

.button-primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.button-primary:active {
  transform: translateY(1px);
}

.button-primary:disabled {
  border-color: var(--free);
  background: var(--free);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.button-dashed,
.button-ghost {
  width: 100%;
  border-color: var(--free);
  background: transparent;
  color: var(--chalk);
}

.button-dashed {
  border-style: dashed;
}

.button-ghost {
  border-color: var(--border);
}

.button-dashed:hover,
.button-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button-danger {
  width: 100%;
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--text);
}

/* Fehlerbox: zweizeilig, Oswald-Kicker + Inter-Detail */
.error-box {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--danger);
  border-radius: 3px;
  background: var(--danger-dim);
  overflow-wrap: anywhere;
}

.error-kicker {
  color: var(--danger);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  line-height: 1.25;
  text-transform: uppercase;
}

.error-detail {
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

/* Teamerfassung */
.team-add {
  margin-bottom: 19px;
}

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 2px 6px;
}

.list-title,
.team-count {
  margin: 0;
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2.5px;
  line-height: 1.3;
  text-transform: uppercase;
}

.list-title {
  color: var(--muted);
}

.team-count {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.team-list {
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  list-style: none;
}

.team-row {
  display: grid;
  min-height: 52px;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  gap: 8px;
  grid-template-columns: 20px minmax(0, 1fr) auto 28px;
  padding: 6px 0;
}

.team-row:last-child {
  border-bottom: 0;
}

.team-number {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
}

.team-name,
.slot-team {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.slot-team {
  font-size: 16px;
  font-weight: 700;
}

.team-age,
.slot-age,
.group-range {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
}

.team-age {
  font-size: 13px;
}

.team-remove {
  display: inline-flex;
  width: 28px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.team-remove:hover {
  color: var(--danger);
}

/* 3er-Contest */
.three-list {
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  list-style: none;
}

.three-row {
  display: grid;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  grid-template-columns: minmax(0, 1fr) 28px;
}

.three-row:last-child {
  border-bottom: 0;
}

.three-row-link {
  display: grid;
  min-height: 58px;
  align-items: center;
  color: inherit;
  gap: 10px;
  grid-template-columns: 31px minmax(0, 1fr) auto;
  padding: 7px 4px;
  text-decoration: none;
}

.three-row-link:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: -2px;
}

.three-row.is-top-three {
  background: linear-gradient(90deg, rgba(245, 107, 31, 0.16), transparent 72%);
}

.three-rank {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--raised);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1;
}

.three-row.is-top-three .three-rank {
  background: var(--accent);
  color: var(--accent-text);
}

.three-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.three-name {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.three-team {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.three-score {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.three-back-link {
  display: inline-flex;
  margin: -4px 0 14px;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-decoration: none;
  text-transform: uppercase;
}

.three-back-link:hover,
.three-back-link:focus-visible {
  color: var(--accent);
}

.three-total {
  margin-bottom: 14px;
  padding: 18px 14px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
}

.three-total-label {
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.three-total-value {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 400;
  line-height: 0.95;
}

.three-attempt-pad {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.three-attempt-button {
  min-height: 96px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: clamp(20px, 7vw, 30px);
  font-weight: 400;
  letter-spacing: 0.5px;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.three-attempt-button:focus-visible {
  outline: 2px solid var(--chalk);
  outline-offset: 2px;
}

.three-attempt-button:active {
  transform: translateY(1px);
}

.three-attempt-miss {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--text);
}

.three-attempt-hit {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.three-correction {
  margin-top: 16px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.three-correction .list-header {
  margin: 0 0 10px;
}

.three-save-status {
  color: var(--live);
  font-family: var(--font-label);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.three-correction-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.three-correction .form-error {
  margin-top: 10px;
}

/* Spielplan / Abschreib-Ansicht */
.copy-hint {
  margin: 14px 0 16px;
  padding: 10px 12px;
  border: 1px dashed var(--free);
  border-radius: 3px;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
}

.groups {
  display: grid;
  gap: 16px;
}

.group-block {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 2px solid var(--accent);
  gap: 12px;
}

.group-title {
  margin: 0;
  color: var(--chalk);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.slot-list {
  margin: 0;
  padding: 0 14px;
  list-style: none;
}

.slot-row {
  display: grid;
  min-height: 51px;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  gap: 10px;
  grid-template-columns: 30px minmax(0, 1fr) auto 28px;
  padding: 7px 0;
}

.slot-row:last-child {
  border-bottom: 0;
}

.slot-row.slot-free {
  min-height: 42px;
  margin: 7px 0;
  padding: 5px 8px;
  border: 1px dashed var(--free);
  border-radius: 3px;
}

.slot-row.slot-free:last-child {
  border-bottom: 1px dashed var(--free);
}

.slot-badge {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
}

.slot-badge-free {
  border: 1px dashed var(--free);
  background: transparent;
  color: var(--free);
}

.slot-free-label {
  grid-column: 2 / 5;
  color: var(--free);
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* Late-Add */
.late-add {
  margin-top: 18px;
}

.late-add-open {
  min-height: 50px;
  font-size: 13px;
}

.late-add-dialog {
  margin-top: 12px;
}

.late-add-form {
  gap: 14px;
}

#late-add-error {
  margin-top: 12px;
}

.late-add-suggestion {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
}

.late-add-suggestion-text {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.late-add-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.late-add-actions .button {
  min-height: 46px;
  font-size: 15px;
}

/* Admin / Scoreboard */
.admin-scoreboard {
  margin-bottom: 18px;
}

.admin-preview {
  display: grid;
  min-height: 150px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  gap: 20px;
  grid-template-columns: 115px minmax(0, 1fr);
}

.admin-scoreboard-number {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 92px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 0.9;
  text-align: left;
}

.admin-scoreboard-copy {
  min-width: 0;
}

.admin-scoreboard-label {
  margin: 0 0 8px;
  color: var(--chalk);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  line-height: 1.3;
  text-transform: uppercase;
}

.admin-preview-template,
.admin-preview-sizes {
  margin: 3px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-preview-sizes {
  font-family: var(--font-mono);
  font-size: 13px;
}

.admin-generate-button {
  min-height: 62px;
  font-size: 17px;
}

.admin-hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.danger-zone {
  margin-top: 28px;
  padding: 14px;
  border: 1.5px dashed var(--danger);
  border-radius: 4px;
}

.danger-title {
  margin: 0 0 10px;
  color: var(--danger);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  line-height: 1.3;
  text-transform: uppercase;
}

.danger-action + .danger-action {
  margin-top: 10px;
}

.danger-action .button {
  min-height: 46px;
  font-size: 13px;
}

.danger-button-multiline {
  flex-direction: column;
  gap: 3px;
}

.danger-button-main,
.danger-button-subline {
  display: block;
  line-height: 1;
}

.danger-button-subline {
  font-size: 10px;
  letter-spacing: 0.12em;
}

/* Login-Poster */
.login-screen {
  position: relative;
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  padding: max(118px, 15svh) max(28px, env(safe-area-inset-right)) 40px max(28px, env(safe-area-inset-left));
}

.center-circle-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.center-circle-decor::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 320px;
  height: 320px;
  border: 2px solid var(--chalk);
  border-radius: 50%;
  content: '';
  opacity: 0.08;
  transform: translate(-50%, -50%);
}

.center-circle-decor::after {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--chalk);
  content: '';
  opacity: 0.08;
}

.login-poster {
  position: relative;
  z-index: 1;
}

.login-kicker {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 4px;
}

.login-title {
  margin: 24px 0 66px;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 0.98;
  text-transform: uppercase;
}

.login-title-line {
  display: block;
  color: var(--chalk);
  font-size: clamp(38px, 11.7vw, 44px);
}

.login-title-accent {
  color: var(--accent);
  font-size: clamp(46px, 14.9vw, 56px);
}

.login-form {
  width: 100%;
}

.pin-field {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-boxes {
  display: flex;
  order: 1;
  justify-content: center;
  gap: 12px;
}

.pin-field .field-label {
  order: 2;
  margin: 18px 0 0;
  font-size: 11px;
  letter-spacing: 3px;
  text-align: center;
}

.pin-digit {
  width: 58px;
  height: 66px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  caret-color: var(--accent);
  font-family: var(--font-display);
  font-size: 26px;
  text-align: center;
}

.pin-digit:focus {
  border-color: var(--accent);
}

.login-error {
  margin-top: 16px;
}

.login-submit {
  margin-top: 32px;
  min-height: 57px;
  font-size: 18px;
  letter-spacing: 1px;
}

@media (max-width: 360px) {
  .teams-screen,
  .spielplan-screen,
  .admin-screen,
  .three-screen {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .add-form {
    padding: 14px;
  }

  .admin-preview {
    gap: 14px;
    padding: 16px 14px;
  }

  .admin-scoreboard-number {
    min-width: 76px;
    font-size: 76px;
  }

  .pin-digit {
    width: 52px;
    height: 60px;
  }
}
