: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 {
  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 { 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; }

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; }
#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;
}


/* --- heroes --- */
.big { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.admin-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }

/* The team's two photo slots. */
.slots { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
/* A large photo must never stretch the card past the screen: phones then
   zoom out and every text gets tiny. */
.slot { background: var(--panel); border: 1px dashed var(--line); border-radius: 4px;
  padding: .8rem; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.slot.approved { border: 1px solid var(--phos); }
.slot.rejected { border: 1px solid var(--red); }
.slot.pending { border: 1px solid var(--dim); }
.slot .frame { position: relative; aspect-ratio: 4 / 3; background: #0a100d; border-radius: 3px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: var(--dim); font-size: .8rem; min-width: 0; }
/* Absolute, so the photo's own size (often 4000 px) never sizes the frame. */
.slot .frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in; }
/* Shown over the photo while it is sent and judged. */
.slot .frame .overlay { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .6rem; padding: .5rem; text-align: center;
  background: rgba(6, 11, 8, .7); color: var(--phos); font-size: .85rem; }
.slot .frame .overlay .spinner { width: 2.2rem; height: 2.2rem; border-width: 3px; margin: 0; }
.slot .meta { font-size: .7rem; color: var(--dim); }
.status { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.status.approved { color: var(--phos); }
.status.pending { color: var(--dim); }
.status.rejected { color: var(--red); }
.rejected-box { border: 1px solid var(--red); color: var(--red); background: #2a0d0d;
  border-radius: 3px; padding: .6rem .7rem; font-size: .85rem; }
.rejected-box b { display: block; text-transform: uppercase; letter-spacing: .08em; }

/* A file input styled as a button: the label is what is tapped. */
.pick { display: block; margin: 0; text-align: center; cursor: pointer;
  padding: .7rem 1rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--bg); background: var(--phos); border-radius: 3px; }
.pick.ghost { color: var(--phos); background: transparent; border: 1px solid var(--line); }
.pick input { display: none; }
.pick.busy { opacity: .7; pointer-events: none; }

.spinner { display: inline-block; width: 1em; height: 1em; margin-right: .5em;
  vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
button.busy:disabled { opacity: .8; }

/* The photo page. */
.gallery { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.tile { position: relative; margin: 0; background: var(--panel); border-radius: 3px;
  overflow: hidden; border-bottom: 3px solid var(--line); }
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.tile figcaption { padding: .3rem .45rem; font-size: .65rem; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .del { position: absolute; top: .3rem; right: .3rem; }
.tile .flag { position: absolute; top: .3rem; left: .3rem; font-size: .6rem;
  padding: .1rem .35rem; border-radius: 2px; background: var(--bg); }

#viewer { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; padding: 1rem; }
#viewer img { max-width: 100%; max-height: 85vh; object-fit: contain; }
#viewer .hint { margin: 0; }
#viewer .row { flex: 0 0 auto; }

/* Admin: every team's slots side by side. */
.team-card { background: var(--panel); border-left: 4px solid; border-radius: 3px;
  padding: .8rem; margin-bottom: .8rem; }
.team-card .head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .5rem; }
.team-card .tname { font-weight: 700; }
.team-card .slots { grid-template-columns: repeat(2, 1fr); }
.score-row { display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; align-items: center;
  padding: .5rem .8rem; border-left: 4px solid; background: var(--panel);
  border-radius: 3px; margin-bottom: .3rem; }
.score-row .pos { font-weight: 700; color: var(--dim); }
.score-row.first .pos { color: var(--phos); }
