:root {
  --blue: #00509e;          /* NTNU blue - the one accent */
  --blue-dark: #003c77;
  --bg: #ffffff;
  --bg-soft: #f4f6f9;
  --ink: #121721;
  --muted: #5c6875;
  --line: #e2e7ed;
  --danger: #c0272d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1, h2 { line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 32px 0 12px; }
a { color: var(--blue); }

/* ---------- tab bar ---------- */

.tabbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: block;
  padding: 14px 0;
  margin-right: auto;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark .tag { font-weight: 400; color: var(--muted); }

.tabbar nav { display: flex; gap: 20px; }
.tabbar nav a {
  padding: 14px 0;
  font-size: 0.94rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabbar nav a:hover { color: var(--ink); }
.tabbar nav a.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ---------- table landing hero ---------- */

.hero {
  position: relative;
  height: 320px;
  background-color: var(--blue);
  background-image: linear-gradient(150deg, var(--blue) 0%, var(--blue-dark) 100%);
  background-size: cover;
  background-position: center;
}
/* the photo layer sits on top of that gradient, so a missing file just
   leaves the blue showing - no broken image, no javascript */
.hero .photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--bg) 100%);
}
.hero h1 {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;                       /* over the faded part */
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 8px;
  font-size: clamp(2rem, 8vw, 3rem);
}

/* ---------- link cards ---------- */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cards a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.cards a:hover { border-color: var(--blue); background: #fff; }
.cards a::after { content: "→"; color: var(--blue); font-weight: 400; }
.cards .sub { display: block; margin-top: 2px; font-weight: 400; font-size: 0.88rem; color: var(--muted); }
.lede { color: var(--muted); margin-top: 0; }

/* ---------- standings ---------- */

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
td.elo, th.elo, td.rank, th.rank { text-align: right; }
td.rank { color: var(--muted); width: 2.5em; }
td.elo { font-variant-numeric: tabular-nums; font-weight: 600; }
tbody tr:first-child td.elo { color: var(--blue); }

#matches { list-style: none; padding: 0; margin: 0; }
#matches li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }

/* ---------- record form ---------- */

label { display: block; margin-top: 14px; font-weight: 600; font-size: 0.9rem; }
input {
  font: inherit;
  padding: 9px 11px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
input:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
label input { display: block; width: 100%; }

.player { display: flex; gap: 12px; align-items: flex-end; }
.player > label:first-child { flex: 1; }
.player .pin { flex: 0 0 6.5em; }
.player .pin input { text-align: center; letter-spacing: 0.3em; }
.hint { font-size: 0.85rem; margin: 10px 0 0; }

.games { border: 0; padding: 0; margin: 26px 0 0; }
.games legend { padding: 0; font-weight: 600; font-size: 0.9rem; }
.game-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.game-row span { min-width: 4.5em; color: var(--muted); font-size: 0.9rem; }
.game-row input { width: 4.5em; text-align: center; margin-top: 0; }
.game-row.invalid input { border-color: var(--danger); background: #fff6f6; }

button {
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--blue); color: var(--blue); }
button[type="submit"] { background: var(--blue); border-color: var(--blue); color: #fff; }
button[type="submit"]:hover { background: var(--blue-dark); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); color: var(--ink); }
button[type="submit"]:disabled:hover { background: var(--blue); color: #fff; }

#summary { font-weight: 600; margin: 20px 0 0; min-height: 1.5em; }
#result { margin: 16px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--bg-soft); }
#result:empty { display: none; }
.error { color: var(--danger); }
.muted { color: var(--muted); }

@media (max-width: 520px) {
  .wordmark .tag { display: none; }
  .tabbar { gap: 14px; }
  .tabbar nav { gap: 14px; }
  .hero { height: 240px; }
}

footer { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--line); font-size: 0.88rem; }
footer p { margin: 4px 0; }
