/* Turnierverwaltung – Stylesheet
   Mobil zuerst: die Tabelle wird meist per QR-Code am Platz aufgerufen. */

:root {
  --court:      #14532d;   /* Rasengrün, dunkel */
  --court-soft: #166534;
  --clay:       #c2603a;   /* Sandplatz */
  --ball:       #d9f99d;   /* Filzgelb */
  --bg:         #f6f7f4;
  --card:       #ffffff;
  --line:       #e3e6df;
  --ink:        #1a1d19;
  --ink-soft:   #5d6459;
  --ok:         #15803d;
  --warn:       #b45309;
  --err:        #b91c1c;
  --radius:     14px;
  --shadow:     0 1px 2px rgba(16,24,16,.06), 0 8px 24px -12px rgba(16,24,16,.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12140f; --card: #1b1e18; --line: #2c3128;
    --ink: #eef1e9; --ink-soft: #a3ab9c; --ball: #d9f99d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
}

/* --- Kopfzeile ---------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .85rem clamp(1rem, 4vw, 2rem);
  background: var(--court);
  color: #f2f7ef;
  padding-top: max(.85rem, env(safe-area-inset-top));
}

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem;
  color: #fff; text-decoration: none;
}

.ball {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ball);
  box-shadow: inset 0 0 0 2px rgba(20,83,45,.45);
  flex: none;
}

/* Vereinslogo, falls public/assets/logo.* hinterlegt ist */
.logo {
  height: 30px; width: auto; max-width: 140px;
  display: block; flex: none;
  object-fit: contain;
}
@media (min-width: 640px) { .logo { height: 34px; max-width: 180px; } }

.topnav { display: flex; gap: 1.1rem; font-size: .92rem; }
.topnav a { color: #dcefd6; text-decoration: none; }
.topnav a:hover { color: #fff; text-decoration: underline; }
.topnav a.muted { opacity: .78; }

/* --- Layout ------------------------------------------------------------- */

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem) clamp(.85rem, 4vw, 2rem) 4rem;
}

.foot {
  text-align: center; color: var(--ink-soft);
  font-size: .82rem; padding: 0 1rem 2.5rem;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
}
.foot p { margin: 0; }

.foot .made { margin-top: .45rem; font-size: .78rem; letter-spacing: .01em; opacity: .85; }
.foot .made a {
  color: inherit; font-weight: 600; text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  padding-bottom: 1px; transition: color .12s ease, border-color .12s ease;
}
.foot .made a:hover { color: var(--court-soft); border-bottom-color: currentColor; }
@media (prefers-color-scheme: dark) {
  .foot .made a:hover { color: var(--ball); }
}

h1 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.2; margin: 0 0 .3rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; letter-spacing: -.01em; }
h3 { font-size: .98rem; margin: 1.25rem 0 .5rem; }

.sub { color: var(--ink-soft); margin: 0 0 1.5rem; font-size: .95rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.4rem);
  margin-bottom: 1.1rem;
}

.card > :first-child { margin-top: 0; }
.card > :last-child  { margin-bottom: 0; }

.grid2 { display: grid; gap: 1.1rem; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: .75rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }

/* --- Formulare ---------------------------------------------------------- */

label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .3rem; }

input[type=text], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%;
  padding: .62rem .75rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--court-soft);
  box-shadow: 0 0 0 3px rgba(22,101,52,.16);
}

.field { margin-bottom: .9rem; }
.fields { display: grid; gap: .9rem; }
@media (min-width: 640px) { .fields.cols2 { grid-template-columns: 1fr 1fr; } .fields.cols3 { grid-template-columns: repeat(3, 1fr); } }

.hint { font-size: .78rem; color: var(--ink-soft); margin: .3rem 0 0; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .62rem 1.1rem;
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--court); color: #fff;
  cursor: pointer; text-decoration: none;
  transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(.94); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-soft); filter: none; }
.btn.danger { background: var(--err); }
.btn.small { padding: .38rem .7rem; font-size: .85rem; }

/* --- Tabellen ----------------------------------------------------------- */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }

th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-soft); font-weight: 700;
  padding: .5rem .55rem; border-bottom: 2px solid var(--line); white-space: nowrap;
}

td { padding: .62rem .55rem; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }

th.num, td.num { text-align: right; }
td.name { font-weight: 600; }

/* Auf schmalen Displays entfallen die Detailspalten (S/U/N, Sp).
   Teamname, Tordifferenz und Punkte bleiben immer ohne Querscrollen sichtbar. */
@media (max-width: 620px) {
  th.opt, td.opt { display: none; }
  table { font-size: .9rem; }
  th, td { padding-left: .35rem; padding-right: .35rem; }
}

.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
  font-size: .8rem; font-weight: 700;
}
tr.qualified .rank { background: var(--ball); border-color: var(--ball); color: var(--court); }

td.pts { font-weight: 700; }

/* --- Spielplan ---------------------------------------------------------- */

.slot { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: .7rem; overflow: hidden; box-shadow: var(--shadow); }
.slot.done { opacity: .72; }
.slot.live { border-color: var(--clay); box-shadow: 0 0 0 2px rgba(194,96,58,.18), var(--shadow); }

.slot-head {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  padding: .55rem .85rem; background: color-mix(in srgb, var(--court) 7%, transparent);
  border-bottom: 1px solid var(--line);
}
.slot-round { font-weight: 700; font-size: .85rem; }
.slot-time { font-size: .85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.slot-tag { margin-left: auto; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--clay); }

.match { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem .75rem; align-items: center; padding: .6rem .85rem; border-bottom: 1px solid var(--line); }
.match:last-child { border-bottom: none; }
.court { font-size: .7rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.pairing { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.team { font-weight: 600; }
.team.win { color: var(--ok); }
.team.tbd { font-weight: 500; color: var(--ink-soft); font-style: italic; }
.vs { color: var(--ink-soft); font-size: .8rem; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score.open { color: var(--ink-soft); font-weight: 500; }

/* Spontane Verzögerung im Adminbereich */
.delay {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin: -.3rem 0 .9rem; padding: .45rem .7rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
  font-size: .82rem; color: var(--ink-soft);
}
.delay-label { margin-right: .2rem; }
.delay-label strong { color: var(--clay); }
.delay-next { margin-left: auto; font-variant-numeric: tabular-nums; }
.delay-custom { display: flex; gap: .3rem; align-items: center; }
.delay-custom input[type=number] { width: 4.6rem; padding: .3rem .4rem; font-size: .85rem; text-align: center; }
.delay .btn.small { padding: .3rem .6rem; font-size: .8rem; }

.bigbreak {
  display: flex; align-items: center; gap: .6rem;
  margin: .7rem 0; padding: .55rem .9rem;
  border: 1px dashed var(--clay); border-radius: var(--radius);
  color: var(--clay); font-size: .88rem; font-weight: 600;
  background: color-mix(in srgb, var(--clay) 6%, transparent);
}

/* --- Badges, Flash, QR -------------------------------------------------- */

.badge { display: inline-block; padding: .18rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; background: var(--bg); border: 1px solid var(--line); color: var(--ink-soft); }
.badge.ok   { background: color-mix(in srgb, var(--ok) 14%, transparent);   border-color: transparent; color: var(--ok); }
.badge.live { background: color-mix(in srgb, var(--clay) 16%, transparent); border-color: transparent; color: var(--clay); }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.flash.ok    { background: color-mix(in srgb, var(--ok) 10%, transparent);   border-color: color-mix(in srgb, var(--ok) 35%, transparent);   color: var(--ok); }
.flash.err   { background: color-mix(in srgb, var(--err) 10%, transparent);  border-color: color-mix(in srgb, var(--err) 35%, transparent);  color: var(--err); }
.flash.info  { background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }

.qr { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.qr img, .qr canvas, .qr svg { width: 160px; height: 160px; background: #fff; border-radius: 10px; padding: 8px; border: 1px solid var(--line); }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }

.empty { color: var(--ink-soft); font-size: .92rem; padding: 1.5rem 0; text-align: center; }

.inline-form { display: inline; }

/* Ergebniseingabe */
.result-form { display: grid; grid-template-columns: 1fr auto auto auto 1fr auto; gap: .4rem; align-items: center; }
.result-form input[type=number] { width: 3.6rem; text-align: center; padding: .4rem .3rem; }
@media (max-width: 560px) {
  .match { grid-template-columns: 1fr; }
  .court { order: -1; }
}
