:root {
  --bg-0: #160033;
  --bg-1: #2a0a5e;
  --pink: #ff2d95;
  --cyan: #00f0ff;
  --yellow: #ffe600;
  --lime: #9dff00;
  --purple: #b14dff;
  --ink: #11002b;
  --good: #19ff7a;
  --bad: #ff3860;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(177, 77, 255, 0.45), transparent 45%),
    radial-gradient(circle at 90% 20%, rgba(0, 240, 255, 0.30), transparent 40%),
    radial-gradient(circle at 50% 120%, rgba(255, 45, 149, 0.40), transparent 50%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* subtle CRT scanlines */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 28px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- screens ---------- */
.screen { display: none; animation: pop 0.35s ease both; }
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex: 1;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* ---------- attract ---------- */
.logo {
  font-family: "Bungee", sans-serif;
  font-size: clamp(48px, 16vw, 86px);
  line-height: 0.82;
  text-align: center;
  letter-spacing: 1px;
  color: var(--yellow);
  text-shadow:
    3px 3px 0 var(--pink),
    6px 6px 0 var(--purple),
    0 0 26px rgba(255, 230, 0, 0.55);
}
.logo span {
  display: block;
  color: var(--cyan);
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--purple), 0 0 26px rgba(0, 240, 255, 0.6);
}

.julie-pic {
  width: clamp(200px, 60vw, 260px);
  height: auto;
  border: 4px solid var(--cyan);
  border-radius: 20px;
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.5), 0 0 40px rgba(255, 45, 149, 0.3);
  display: block;
}

/* one-word treatment: keep EYECONIC on a single line, two-tone */
.logo-oneword {
  font-size: clamp(34px, 11vw, 58px);
  letter-spacing: 2px;
  white-space: nowrap;
}
.logo-oneword span { display: inline; margin-left: 0.12em; }

.tagline {
  text-align: center;
  font-weight: 800;
  font-size: clamp(15px, 4.2vw, 18px);
  color: var(--cyan);
  max-width: 26em;
  margin-top: 14px;
  line-height: 1.3;
}

#start-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

#name-input {
  width: 100%;
  font-family: "Bungee", sans-serif;
  font-size: 20px;
  text-align: center;
  text-transform: uppercase;
  padding: 16px 14px;
  border: 4px solid var(--cyan);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  letter-spacing: 2px;
  outline: none;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35), inset 0 0 12px rgba(0, 0, 0, 0.4);
}
#name-input::placeholder { color: rgba(255, 255, 255, 0.45); letter-spacing: 1px; }
#name-input:focus { border-color: var(--yellow); box-shadow: 0 0 22px rgba(255, 230, 0, 0.5); }

/* ---------- buttons ---------- */
.btn {
  font-family: "Bungee", sans-serif;
  font-size: 18px;
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  color: var(--ink);
  letter-spacing: 1px;
  transition: transform 0.08s ease, filter 0.15s ease;
  user-select: none;
}
.btn:active { transform: translateY(3px) scale(0.99); }

.btn-primary {
  background: linear-gradient(120deg, var(--yellow), var(--pink));
  box-shadow: 0 6px 0 #a01060, 0 10px 24px rgba(255, 45, 149, 0.45);
  width: 100%;
  max-width: 360px;
}
.btn-primary:active { box-shadow: 0 3px 0 #a01060, 0 6px 14px rgba(255, 45, 149, 0.4); }

.btn-ghost {
  background: transparent;
  color: #fff;
  border: 3px solid var(--cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.25);
  font-size: 15px;
  width: 100%;
  max-width: 360px;
}
.btn-ghost:active { transform: translateY(2px) scale(0.99); }

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  align-items: center;
  margin-top: 8px;
}

#save-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.board-title-lg {
  font-family: "Bungee", sans-serif;
  font-size: clamp(26px, 8vw, 40px);
  color: var(--yellow);
  text-align: center;
  margin-top: 4vh;
  text-shadow: 2px 2px 0 var(--pink), 0 0 20px rgba(255, 230, 0, 0.5);
}
#screen-board .board-list {
  width: 100%;
  max-width: 420px;
  max-height: 56vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--purple) transparent;
}
#screen-board .board-list::-webkit-scrollbar { width: 8px; }
#screen-board .board-list::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 8px; }

.board-msg {
  max-width: 24em;
  text-align: center;
  font-weight: 800;
  font-size: clamp(14px, 4vw, 17px);
  line-height: 1.3;
  color: var(--pink);
  text-shadow: 0 0 12px rgba(255, 45, 149, 0.5);
}
.board-msg:empty { display: none; }
.board-msg.sad { color: var(--pink); }

/* ---------- leaderboard ---------- */
.board {
  width: 100%;
  max-width: 400px;
  background: rgba(0, 0, 0, 0.30);
  border: 3px solid var(--purple);
  border-radius: 18px;
  padding: 14px 16px 16px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4), 0 0 18px rgba(177, 77, 255, 0.3);
}
.board-title {
  font-family: "Bungee", sans-serif;
  font-size: 16px;
  text-align: center;
  color: var(--yellow);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.board-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.board-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}
.board-list li .rank { font-family: "Bungee", sans-serif; font-size: 14px; color: var(--cyan); }
.board-list li .pname { text-transform: uppercase; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .pscore { font-family: "Bungee", sans-serif; color: var(--lime); }
.board-list li.me { background: linear-gradient(90deg, rgba(255,230,0,0.25), rgba(255,45,149,0.25)); outline: 2px solid var(--yellow); }
.board-list li:nth-child(1) .rank { color: var(--yellow); }
.board-loading, .board-empty { text-align: center; opacity: 0.7; font-weight: 700; display: block !important; }

/* ---------- play HUD ---------- */
.hud {
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: space-between;
  font-family: "Bungee", sans-serif;
  font-size: 18px;
  padding: 4px 6px;
  margin-top: 6px;
}
.hud-player span { color: var(--cyan); }
.hud-streak span { color: var(--lime); }

.timer-track {
  width: 100%;
  max-width: 460px;
  height: 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lime), var(--yellow), var(--pink));
  transform-origin: left center;
}
.timer-bar.danger { background: var(--bad); animation: pulse 0.4s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

/* ---------- eyes ---------- */
.eyes-frame {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 3 / 1;
  border: 5px solid var(--cyan);
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 26px rgba(0, 240, 255, 0.45);
}
/* crops are wide eye-strips of varying ratio — contain guarantees both eyes stay visible */
.eyes-img { width: 100%; height: 100%; object-fit: contain; display: block; }

.flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.flash.good { background: rgba(25, 255, 122, 0.55); animation: flash 0.5s ease; }
.flash.bad  { background: rgba(255, 56, 96, 0.6); animation: flash 0.5s ease; }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

.prompt {
  font-family: "Bungee", sans-serif;
  font-size: clamp(15px, 4.5vw, 19px);
  color: var(--yellow);
  text-align: center;
  letter-spacing: 1px;
}

/* ---------- options ---------- */
.options {
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.opt {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 3.8vw, 17px);
  padding: 16px 10px;
  border: 3px solid var(--purple);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  min-height: 60px;
  transition: transform 0.07s ease, background 0.15s ease;
}
.opt:active { transform: scale(0.97); }
.opt.correct { background: var(--good); color: var(--ink); border-color: #0a8; }
.opt.wrong { background: var(--bad); color: #fff; border-color: #a00; }
.opt.dim { opacity: 0.4; }
.opt:disabled { cursor: default; }

/* ---------- game over ---------- */
.gameover-title {
  font-family: "Bungee", sans-serif;
  font-size: clamp(40px, 13vw, 70px);
  color: var(--pink);
  text-shadow: 3px 3px 0 var(--purple), 0 0 24px rgba(255, 45, 149, 0.6);
  margin-top: 4vh;
  transform: rotate(-2deg);
}
.over-reason { font-weight: 700; opacity: 0.9; text-align: center; }

.score-pop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.score-label { font-family: "Bungee", sans-serif; font-size: 14px; color: var(--cyan); letter-spacing: 2px; }
.score-value {
  font-family: "Bungee", sans-serif;
  font-size: clamp(56px, 20vw, 96px);
  color: var(--lime);
  text-shadow: 0 0 26px rgba(157, 255, 0, 0.6);
  line-height: 1;
}
.rank-line { font-family: "Bungee", sans-serif; font-size: 18px; color: var(--yellow); text-align: center; }

@media (max-width: 360px) {
  .options { grid-template-columns: 1fr; }
}
