@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  src: url('/static/fonts/PressStart2P.ttf') format('truetype');
}

/* ── SNES palette ──────────────────────────────────────── */
:root {
  --bg:      #0a0e23;
  --panel:   #141836;
  --panel2:  #1e2450;
  --border:  #4848b0;
  --bright:  #8888ff;
  --gold:    #ffdd00;
  --green:   #00dd44;
  --red:     #ff3030;
  --blue:    #40a0ff;
  --purple:  #cc44ff;
  --white:   #eeeeff;
  --muted:   #5858a0;
  --font:    'Press Start 2P', monospace;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body / scanlines ──────────────────────────────────── */
html { font-size: 16px; }
body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      0deg, transparent, transparent 3px,
      rgba(0,0,0,.10) 3px, rgba(0,0,0,.10) 4px
    ),
    radial-gradient(ellipse at 50% -5%, rgba(80,50,180,.45) 0%, transparent 65%);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.8;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────── */
header {
  background: var(--panel2);
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--border);
  box-shadow: 0 3px 0 rgba(0,0,0,.6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: .55rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 rgba(0,0,0,.9);
  letter-spacing: 1px;
}

nav a { font-size: .42rem; color: var(--green); letter-spacing: .5px; }

/* ── Main ──────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

footer {
  text-align: center;
  padding: 1.2rem 1rem;
  color: var(--muted);
  font-size: .38rem;
  border-top: 2px solid var(--border);
  line-height: 2.5;
}

/* ── Pixel window card ─────────────────────────────────── */
.card {
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,.12),
    inset -1px -1px 0 rgba(0,0,0,.5),
    4px 4px 0 rgba(0,0,0,.7);
  padding: 1rem;
  margin-bottom: 1.2rem;
}

.card.center { text-align: center; }

/* ── Titles ────────────────────────────────────────────── */
h1 {
  font-size: .85rem;
  color: var(--gold);
  text-shadow: 3px 3px 0 rgba(0,0,0,.9);
  margin-bottom: .6rem;
  line-height: 1.7;
  letter-spacing: 1px;
}

h2 {
  font-size: .65rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 rgba(0,0,0,.9);
  margin-bottom: .5rem;
  line-height: 1.7;
}

h3 {
  font-size: .5rem;
  color: var(--bright);
  margin-bottom: .6rem;
  letter-spacing: 1px;
  line-height: 1.8;
}

.subtitle { font-size: .42rem; color: var(--muted); margin-bottom: 1rem; line-height: 2.2; }
.count    { font-size: .42rem; color: var(--muted); margin-bottom: 1rem; line-height: 2; }

/* ── Alerts ────────────────────────────────────────────── */
.alert {
  background: #1e1400;
  border: 2px solid var(--gold);
  box-shadow: 3px 3px 0 rgba(0,0,0,.7);
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .42rem;
  line-height: 2.2;
}
.alert.success { background: #001308; border-color: var(--green); }
.alert.center  { text-align: center; }

/* ── Forms ─────────────────────────────────────────────── */
.join-form { display: flex; flex-direction: column; gap: .9rem; }

label {
  font-size: .42rem;
  color: var(--muted);
  display: block;
  margin-bottom: .25rem;
  letter-spacing: .5px;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: .6rem .8rem;
  background: var(--panel2);
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.5);
  color: var(--white);
  font-family: var(--font);
  font-size: .5rem;
  appearance: none;
  line-height: 1.6;
}

input:focus, select:focus { outline: none; border-color: var(--gold); }

/* ── ★ PLAYER SELECT ★ ────────────────────────────────── */
.player-select-title {
  font-size: .55rem;
  color: var(--gold);
  text-align: center;
  margin: .5rem 0 .8rem;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.8);
}

.player-select-title::before { content: "★ "; }
.player-select-title::after  { content: " ★"; }

.player-group-section { margin-bottom: .8rem; }

.player-group-label {
  font-size: .38rem;
  color: var(--bright);
  padding: .2rem .4rem;
  margin-bottom: .3rem;
  background: var(--panel2);
  border-left: 3px solid var(--bright);
  letter-spacing: 1px;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .45rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .8rem;
  margin-top: .5rem;
}
.legend-card .jc-top { height: 110px; }
.legend-card .jc-photo { width: 100%; height: 110px; object-fit: cover; object-position: top center; }
.legend-card .jc-name { font-size: .55rem; }
.legend-card .jc-flag { font-size: 1.1rem; }

/* ── Jersey card ───────────────────────────────────────── */
.player-opt input { display: none; }

.jersey-card {
  display: flex;
  flex-direction: column;
  border: 2px solid rgba(0,0,0,.5);
  box-shadow: 3px 3px 0 rgba(0,0,0,.7);
  cursor: pointer;
  overflow: hidden;
  transition: transform .08s;
}

.player-opt input:checked + .jersey-card {
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 3px 3px 0 rgba(0,0,0,.7);
}

.player-opt:active .jersey-card {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(0,0,0,.7);
}

/* photo section — team color bg */
.jc-top {
  background: var(--c1);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 52px;
  position: relative;
  overflow: hidden;
}

.jc-photo {
  width: 48px;
  height: 52px;
  object-fit: cover;
  object-position: top center;
  display: block;
  image-rendering: auto;
}

/* fallback number shown when photo hidden */
.jc-num-fb {
  display: none;
  font-size: 1.6rem;
  font-weight: 900;
  color: rgba(255,255,255,.85);
  font-family: Arial, sans-serif;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* name strip — second team color */
.jc-bottom {
  background: var(--c2);
  padding: 2px 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  min-height: 20px;
}

.jc-name {
  font-size: .35rem;
  font-family: var(--font);
  color: var(--tc);
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.jc-flag { font-size: .6rem; flex-shrink: 0; }

/* ── Jersey in player header (sm) ──────────────────────── */
.jersey-card.jersey-sm {
  width: 58px;
  flex-shrink: 0;
  cursor: default;
  box-shadow: 3px 3px 0 rgba(0,0,0,.7);
}

.jersey-sm .jc-top { height: 46px; }
.jersey-sm .jc-photo { width: 44px; height: 46px; }

/* ── Jersey in leaderboard (mini) ──────────────────────── */
.jersey-mini {
  width: 34px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 2px solid rgba(0,0,0,.4);
  box-shadow: 2px 2px 0 rgba(0,0,0,.6);
  overflow: hidden;
}

.jersey-mini-photo {
  flex: 1;
  background: var(--c1);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.jersey-mini-photo img {
  width: 32px;
  height: 30px;
  object-fit: cover;
  object-position: top center;
}

.jersey-mini-num-fb {
  display: none;
  font-size: .75rem;
  font-weight: 900;
  font-family: Arial, sans-serif;
  color: rgba(255,255,255,.9);
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.jersey-mini-strip {
  background: var(--c2);
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.jersey-mini-strip span {
  font-size: .55rem;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: #001a0a;
  border: 2px solid #009930;
  box-shadow: 0 4px 0 #004a18, 4px 4px 0 rgba(0,0,0,.5);
  padding: .75rem 1.5rem;
  font-family: var(--font);
  font-size: .48rem;
  cursor: pointer;
  width: 100%;
  letter-spacing: 1px;
  transition: transform .08s, box-shadow .08s;
}

.btn-primary:hover { background: #00ff55; }

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #004a18, 0 0 0 rgba(0,0,0,.5);
}

.btn-primary.btn-big { padding: .9rem; font-size: .52rem; }

/* ── Rules ─────────────────────────────────────────────── */
.rules ul { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.rules li { font-size: .42rem; line-height: 2; }
.rules strong { color: var(--gold); }

/* ── Player header ─────────────────────────────────────── */
.player-header {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: 4px 4px 0 rgba(0,0,0,.7);
  padding: .8rem 1rem;
  margin-bottom: 1rem;
}

.player-emoji { font-size: 2rem; }
.player-header h2 { margin: 0; font-size: .6rem; }
.player-link-hint { font-size: .36rem; color: var(--muted); margin-top: .3rem; line-height: 2.2; }

/* ── Section titles ────────────────────────────────────── */
.section-title {
  font-size: .48rem;
  color: var(--gold);
  margin: 1.2rem 0 .3rem;
  letter-spacing: 1px;
}

.section-hint {
  font-size: .38rem;
  color: var(--muted);
  margin-bottom: .8rem;
  line-height: 2.2;
}

/* ── Progress bar (pixel blocks) ───────────────────────── */
.progress-bar-wrap { margin-bottom: 1rem; }

.progress-label {
  font-size: .38rem;
  color: var(--muted);
  margin-bottom: .4rem;
  letter-spacing: .5px;
}

.progress-track {
  height: 14px;
  background: var(--panel2);
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.4);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--green) 0px, var(--green) 10px,
    #009930 10px, #009930 12px
  );
  transition: width .3s;
}

/* ── Group blocks ──────────────────────────────────────── */
.group-block {
  background: var(--panel);
  border: 3px solid var(--border);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.08), 4px 4px 0 rgba(0,0,0,.7);
  margin-bottom: 1rem;
  overflow: hidden;
}

.group-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .8rem;
  cursor: pointer;
  border-bottom: 2px solid var(--border);
  background: var(--panel2);
  font-size: .48rem;
  color: var(--gold);
  letter-spacing: 1px;
  user-select: none;
}

.group-count {
  font-size: .36rem;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: .12rem .4rem;
  color: var(--muted);
  margin-left: auto;
  margin-right: .5rem;
}

.toggle-icon { color: var(--muted); font-size: .7rem; }
.group-matches.collapsed { display: none; }
.group-matches { padding: .2rem 0; }

/* ── Match rows ────────────────────────────────────────── */
.match-row {
  display: flex;
  align-items: center;
  padding: .4rem .6rem;
  gap: .3rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.match-row:nth-child(even) { background: var(--panel2); }
.match-row.has-pred        { background: rgba(0,180,50,.13); }
.match-row:nth-child(even).has-pred { background: rgba(0,180,50,.2); }
.match-row:last-child      { border-bottom: none; }

.match-team {
  flex: 1;
  font-size: .6rem;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.match-team.home-team { justify-content: flex-end; }
.match-team.away-team { justify-content: flex-start; }
.match-flag { font-size: 1.6rem; line-height: 1; }

.home-team { text-align: right; }
.away-team { text-align: left; }

.score-inputs {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}

.score-input {
  width: 3.6rem;
  height: 3rem;
  padding: .4rem .2rem;
  text-align: center;
  background: var(--panel2);
  border: 3px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.5);
  color: var(--gold);
  font-family: var(--font);
  font-size: 1.1rem;
  -moz-appearance: textfield;
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.score-input:focus { outline: none; border-color: var(--gold); }

.score-sep { color: var(--muted); font-size: .55rem; font-family: var(--font); }

/* ── Champion block ────────────────────────────────────── */
.champion-block { border-color: var(--gold); }
.champion-block .group-block-header {
  background: #1e1600;
  border-bottom-color: var(--gold);
  cursor: default;
}

.champion-select { padding: .8rem; }

/* ── Save bar ──────────────────────────────────────────── */
.save-bar {
  position: sticky;
  bottom: 0;
  padding: .7rem 0;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  z-index: 10;
}

/* ── Leaderboard ───────────────────────────────────────── */
.leaderboard { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.lb-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 rgba(0,0,0,.6);
  padding: .6rem .8rem;
}

.lb-row.first  { border-color: var(--gold);  background: #1a1200; }
.lb-row.second { border-color: #c0c0c0;      background: #121214; }
.lb-row.third  { border-color: #cd7f32;      background: #120c06; }

.lb-rank { font-size: 1rem; min-width: 2rem; text-align: center; flex-shrink: 0; }
.lb-player { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; }
.lb-emoji { font-size: 1.3rem; }
.lb-name { font-size: .42rem; color: var(--white); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { text-align: right; flex-shrink: 0; }
.lb-pts strong { font-size: .6rem; color: var(--gold); display: block; }
.lb-detail { font-size: .34rem; color: var(--muted); margin-top: .2rem; white-space: nowrap; }

/* ── Results section ───────────────────────────────────── */
.result-group { margin-bottom: .8rem; }

.result-group-title {
  display: block;
  font-size: .38rem;
  color: var(--gold);
  margin-bottom: .3rem;
  letter-spacing: 1px;
}

.result-match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .28rem .4rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  gap: .5rem;
  font-family: Arial, sans-serif;
  font-size: .36rem;
}

.result-match strong {
  min-width: 3rem;
  text-align: center;
  color: var(--gold);
  font-family: var(--font);
  font-size: .44rem;
}

/* ── Admin ─────────────────────────────────────────────── */
.admin-controls { margin-bottom: 1rem; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  font-size: .42rem;
  color: var(--white);
  line-height: 2;
}

.toggle-label input { width: 1.1rem; height: 1.1rem; }

.pts-badge {
  font-size: .36rem;
  background: #1e1600;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: .12rem .35rem;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 380px) {
  .player-grid { grid-template-columns: repeat(3, 1fr); }
  .match-team { font-size: .5rem; }
  .match-flag { font-size: 1.3rem; }
  .score-input { width: 3rem; height: 2.6rem; font-size: .9rem; }
  h1 { font-size: .7rem; }
}

/* ── Easter egg ────────────────────────────────────────── */
#easter, #easter2 {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-block;
  user-select: none;
}
#egg-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 9999;
  flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1rem;
  animation: eggIn .25s ease-out;
}
#egg-overlay img { max-width: 92vw; max-height: 70vh; border: 3px solid var(--gold); box-shadow: 6px 6px 0 rgba(0,0,0,.7); image-rendering: pixelated; }
.egg-fallback {
  display: none;
  color: var(--gold);
  font-family: var(--font);
  font-size: 1.2rem;
  text-align: center;
  padding: 2rem;
  border: 3px solid var(--gold);
  background: var(--panel);
}
.egg-fallback small { font-size: .55rem; color: var(--white); display: block; margin-top: 1rem; }
.egg-caption {
  margin-top: 1rem;
  font-family: var(--font);
  font-size: .55rem;
  color: var(--bright);
  text-shadow: 1px 1px 0 #000;
}
@keyframes eggIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
