:root {
  --phos: #39ff88;
  --dim: #8fe0b0; /* secondary text: 12.7:1 on --bg (the old 50 % green was 4.3:1) */
  --bg: #060b08;
  --panel: #0e1512;
  --line: #1e2a22;
  --amber: #ffb03a;
  --red: #ff4d4d;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--phos);
  font: 15px/1.6 var(--mono);
  -webkit-text-size-adjust: 100%;
}

body {
  padding: max(1rem, env(safe-area-inset-top)) 1rem
           max(1rem, env(safe-area-inset-bottom));
  max-width: 60rem;
  margin: 0 auto;
}

h1, h2, h3 {
  margin: 0 0 .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 { font-size: 1.4rem; }
h2 { font-size: .95rem; color: var(--dim); margin-top: 1.8rem;
     border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
h3 { font-size: .8rem; }

a { color: var(--phos); }
.sub { color: var(--dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.hint { color: var(--dim); font-size: .75rem; line-height: 1.6; }
.err { color: var(--red); font-size: .8rem; min-height: 1.2em; }
.ok { color: var(--phos); }

nav { display: flex; gap: .5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
nav a {
  padding: .45rem .8rem; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .08em; text-decoration: none;
  border: 1px solid var(--line); border-radius: 3px;
}
nav a.active { background: var(--phos); color: var(--bg); border-color: var(--phos); }

label { display: block; font-size: .7rem; text-transform: uppercase;
        letter-spacing: .08em; color: var(--dim); margin-top: .7rem; }
input, select {
  width: 100%; margin-top: .25rem; padding: .7rem;
  font: inherit; font-size: 1rem; color: var(--phos);
  background: #0a100d; border: 1px solid var(--line); border-radius: 3px;
}
input:focus, select:focus { outline: none; border-color: var(--phos); }

button, a.button {
  display: inline-block; text-decoration: none; text-align: center;
  padding: .7rem 1rem; font: inherit; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--bg); background: var(--phos);
  border: none; border-radius: 3px; cursor: pointer;
}
button.ghost, a.button.ghost { color: var(--phos); background: transparent; border: 1px solid var(--line); }
button.danger { color: var(--red); background: transparent; border: 1px solid var(--red); }
button.small { padding: .35rem .6rem; font-size: .7rem; }
button:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line);
        border-radius: 4px; padding: 1rem; margin-bottom: .8rem; }

/* leaderboard */
.standings { display: flex; flex-direction: column; gap: .5rem; }
.standing {
  display: grid; grid-template-columns: 2.5rem 1fr auto;
  gap: .8rem; align-items: center;
  padding: .9rem 1rem; border-left: 4px solid; border-radius: 3px;
  background: var(--panel);
}
.standing .pos { font-size: 1.4rem; font-weight: 700; text-align: center; color: var(--dim); }
.standing.first .pos { color: var(--amber); }
.standing .who { min-width: 0; }
.standing .tname { font-weight: 700; letter-spacing: .05em; }
.standing .roster { color: var(--dim); font-size: .7rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing .pts { text-align: right; }
.standing .pts b { font-size: 1.5rem; }
.standing .pts span { display: block; color: var(--dim); font-size: .65rem;
  text-transform: uppercase; letter-spacing: .08em; }

table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: .1rem .45rem; border-radius: 10px;
        font-size: .65rem; border: 1px solid currentColor; }
.pwd { font-family: var(--mono); background: #0a100d; padding: .15rem .4rem;
       border-radius: 3px; border: 1px solid var(--line); user-select: all; }

/* At most three per row: four leaves a result card too narrow for its field,
   unit and button. Fewer on narrow screens. Every row as tall as the tallest
   card, so a link card is the same size as a result card. */
.games { display: grid; gap: .6rem; grid-auto-rows: 1fr;
  grid-template-columns: repeat(auto-fill, minmax(max(14rem, calc((100% - 1.2rem) / 3)), 1fr)); }
.game-card { display: block; padding: 1rem; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.game-card.live { border-color: var(--phos); }
.game-card .gname { font-weight: 700; letter-spacing: .05em; }
.game-card .gmeta { color: var(--dim); font-size: .7rem; margin-top: .2rem; }
.game-card .gmeta.saved { font-size: .85rem; }
/* The same width in every card, wide enough for 12:48 or 1234.5; the unit
   label takes what is left so it never squeezes the field. */
.game-card .score-input { flex: 0 0 6rem; width: 6rem; margin-top: 0;
  padding: .55rem .5rem; text-align: right; }
.game-card .score-unit { flex: 1 0 auto; white-space: nowrap; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--phos); color: var(--bg); padding: .6rem 1rem;
  border-radius: 3px; font-size: .8rem; z-index: 50; max-width: 90vw;
}

/* --- photos --- */

/* A file input dressed as a button: the label is what is tapped. */
label.file-button {
  display: inline-block; margin: 0; text-align: center; cursor: pointer;
  padding: .7rem 1rem; font-size: .85rem; letter-spacing: .08em;
  color: var(--bg); background: var(--phos); border-radius: 3px;
}
label.file-button input { display: none; }
label.file-button.busy { opacity: .45; pointer-events: none; }
.photo-actions { align-items: center; }
.photo-actions > * { flex: 0 0 auto; }

.team-head { display: flex; align-items: baseline; gap: .6rem; }
.team-head .hint { text-transform: none; letter-spacing: 0; }
/* Medium thumbnails: two across on a phone, more on wider screens. */
.photo-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.thumb { margin: 0; background: var(--panel); border-radius: 3px; overflow: hidden; }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.thumb figcaption { padding: .3rem .45rem; font-size: .65rem; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; padding: 1rem; }
.overlay > img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.overlay-actions { flex: 0 0 auto; justify-content: center; align-items: center; }
.overlay-actions > * { flex: 0 0 auto; }

/* The slideshow: two stacked images, crossfading. */
.overlay.show { background: #000; padding: 0; cursor: none; }
.show .slide { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none;
  object-fit: contain; opacity: 0; transition: opacity 1.2s ease; }
.show .slide.on { opacity: 1; }
.show-caption { position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  padding: 1.2rem 1rem max(1rem, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  color: #fff; font-size: .9rem; text-align: center; }

/* Spela: the team card. */
.team-name-form { margin-top: .6rem; }

/* Senaste resultat: one line per team; the explanation opens under the row. */
tr.has-detail { cursor: pointer; }
tr.has-detail.open td { border-bottom: none; }
tr.detail-row td { color: var(--dim); font-size: .75rem; line-height: 1.5; padding-top: 0; }
