:root {
  --bg: #0a0014;
  --bg2: #1a0033;
  --pink: #ff2bd6;
  --cyan: #00f0ff;
  --yellow: #ffe600;
  --green: #39ff14;
  --red: #ff3355;
  --text: #f4f0ff;
  --dim: #8a7fb0;
  /* Pixelify Sans draws Æ Ø Å clearly; Press Start 2P (logo only) renders Å like A. */
  --pixel: 'Pixelify Sans', monospace;
  --logo: 'Press Start 2P', monospace;
  --term: 'VT323', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, var(--bg2), var(--bg) 70%) fixed;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--term);
  font-size: 22px;
  -webkit-tap-highlight-color: transparent;
}

/* CRT scanlines + vignette over everything */
.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.28) 2px 4px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.6) 100%);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.screen { display: none; flex-direction: column; align-items: center; gap: 18px; text-align: center; min-height: calc(100dvh - 48px); justify-content: center; }
.screen.active { display: flex; animation: boot .35s steps(6); }
#screen-select.active { justify-content: flex-start; }

@keyframes boot { from { opacity: 0; transform: scaleY(.02); } to { opacity: 1; transform: none; } }

.hiscore { display: flex; justify-content: space-between; width: 100%; font-family: var(--pixel); font-size: 15px; color: var(--red); }

.logo { font-family: var(--logo); margin: 12px 0 0; line-height: 1.2; display: flex; flex-direction: column; gap: 10px; }
.logo-top {
  font-size: 56px;
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 #5a00a0;
  letter-spacing: 4px;
}
.logo-bottom {
  font-size: 30px;
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan), 0 0 18px var(--cyan);
  letter-spacing: 6px;
}

.subtitle { font-family: var(--pixel); font-size: 15px; color: var(--pink); letter-spacing: 2px; margin: 0; }
.invaders { font-size: 28px; letter-spacing: 12px; animation: march 1s steps(2) infinite; }
@keyframes march { 50% { transform: translateX(16px); } }

.heading {
  font-family: var(--pixel);
  font-size: 28px;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--pink);
  margin: 8px 0 0;
  line-height: 1.5;
}
.heading.done { font-size: 44px; color: var(--green); text-shadow: 4px 4px 0 #006b2e, 0 0 20px var(--green); }

.hint { font-family: var(--pixel); font-size: 15px; color: var(--cyan); margin: 0; letter-spacing: 1px; line-height: 1.8; }
.hint.small { color: var(--dim); }
.credit { font-family: var(--pixel); font-size: 15px; color: var(--dim); margin-top: 24px; }
.msg { font-family: var(--pixel); font-size: 15px; color: var(--red); min-height: 1em; line-height: 1.8; margin: 0; }

.team-name { font-family: var(--pixel); font-size: 24px; text-transform: uppercase; color: var(--text); text-shadow: 0 0 8px var(--cyan); word-break: break-word; line-height: 1.5; margin: 0; }

.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Buttons */
.btn {
  font-family: var(--pixel);
  font-size: 17px;
  color: var(--text);
  background: var(--bg2);
  border: 3px solid var(--cyan);
  box-shadow: 4px 4px 0 var(--pink);
  padding: 14px 18px;
  cursor: pointer;
  text-transform: uppercase;
  line-height: 1.4;
  display: inline-block;
  user-select: none;
  touch-action: manipulation;
}
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-big { font-size: 22px; padding: 20px 24px; width: 100%; }
.btn-small { font-size: 15px; border-color: var(--dim); box-shadow: 3px 3px 0 #3a2a60; padding: 10px 14px; }
.btn-go { border-color: var(--green); box-shadow: 4px 4px 0 #006b2e; color: var(--green); }
#btn-start { border-color: var(--yellow); color: var(--yellow); margin-top: 16px; }

/* Team search (sticky so it stays reachable in a long list) */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 3px solid var(--yellow);
  box-shadow: 4px 4px 0 var(--pink);
}
.search-bar[hidden] { display: none; }
.search-icon { color: var(--yellow); font-family: var(--pixel); font-size: 16px; animation: blink 1s steps(1) infinite; }
.search-bar input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--yellow);
  font-family: var(--pixel);
  font-size: 20px; /* 16px+ stops iOS zooming in on focus */
  text-transform: uppercase;
  caret-color: var(--pink);
}
.search-bar input::placeholder { color: var(--dim); font-size: 16px; }
.search-bar input::-webkit-search-cancel-button { filter: hue-rotate(200deg) saturate(3); }

/* Team list */
.team-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.team-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; width: 100%; font-size: 19px; }
.team-btn .name { flex: 1; word-break: break-word; }
.team-btn .tag { font-size: 13px; color: var(--green); flex: none; }
.team-btn.done { border-color: var(--dim); box-shadow: 3px 3px 0 #3a2a60; }

/* Photo preview */
.preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 4px solid var(--pink);
  box-shadow: 0 0 20px rgba(255, 43, 214, .5), inset 0 0 30px rgba(0,0,0,.8);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.preview img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.preview-empty { display: flex; flex-direction: column; gap: 12px; font-family: var(--pixel); font-size: 17px; color: var(--dim); }
.big-icon { font-size: 48px; }

/* Upload bar */
.bar { width: 100%; height: 28px; border: 3px solid var(--cyan); padding: 3px; }
.bar-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--green) 0 14px, transparent 14px 18px);
  transition: width .15s steps(4);
}

.stars { font-size: 36px; color: var(--yellow); letter-spacing: 10px; text-shadow: 0 0 12px var(--yellow); animation: pulse .6s steps(2) infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* Confirm dialog */
.dialog {
  background: var(--bg);
  color: var(--text);
  border: 4px solid var(--yellow);
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--pink);
  padding: 24px 18px;
  max-width: min(400px, calc(100vw - 32px));
  text-align: center;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.5;
}
.dialog::backdrop { background: rgba(5, 0, 15, .85); }
.dialog h3 { color: var(--yellow); font-size: 22px; font-weight: 700; margin: 0 0 12px; }
.dialog em { color: var(--red); font-style: normal; }
.dialog strong { color: var(--cyan); word-break: break-word; }
.dialog .verify-team { font-size: 22px; margin: 16px 0; text-transform: uppercase; }
.dialog-buttons { display: flex; gap: 16px; justify-content: center; margin-top: 18px; }
.dialog-buttons .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  .blink, .invaders, .stars, .screen.active { animation: none; }
}
