﻿/* Galaxy theme: deep space, purple and blue nebulae */
:root {
  --bg: #0b0a24;
  --surface: rgba(28, 24, 76, .78);
  --text: #eef0ff;
  --muted: #a9acdf;
  --primary: #8b6cff;
  --primary-dark: #6d4de6;
  --good: #22c9a0;
  --bad: #ff5d7a;
  --border: rgba(139, 108, 255, .35);
  --shadow: 0 8px 30px rgba(60, 40, 200, .35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(139, 108, 255, .35), transparent 50%),
    radial-gradient(ellipse at 85% 30%, rgba(50, 140, 255, .28), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(190, 80, 255, .22), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
/* twinkling stars */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 120px, #cfd6ff, transparent),
    radial-gradient(1.5px 1.5px at 160px 70px, #fff, transparent),
    radial-gradient(1px 1px at 230px 180px, #b9a8ff, transparent),
    radial-gradient(1.5px 1.5px at 300px 40px, #a8d0ff, transparent);
  background-size: 320px 220px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .45; } to { opacity: 1; } }
main, .topbar { position: relative; z-index: 1; }
.topbar { position: sticky; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.screen > h1, .card h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 8px 0; }
.screen > h2 { margin: 24px 0 12px; font-size: 1.5rem; }
.sub { color: var(--muted); margin-top: 0; }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(90deg, #4a2bc4, #2f7dff);
  color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.logo { font-weight: 800; font-size: 1.3rem; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 999px; font-size: .9rem; }

/* screens */
.screen { display: none; }
.screen.active { display: block; animation: pop .35s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* subject grid */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.subject {
  border: 2px solid transparent; border-radius: 18px; padding: 18px; text-align: left;
  background: var(--surface); color: var(--text); cursor: pointer; box-shadow: var(--shadow);
  font: inherit; transition: transform .15s, border-color .15s;
}
.subject:hover, .subject:focus-visible { transform: translateY(-4px) rotate(-1deg); border-color: var(--c); outline: none; }
.subject .emoji { font-size: 2.2rem; display: block; }
.subject .name { font-weight: 700; font-size: 1.1rem; margin-top: 6px; display: block; }
.subject .best { color: var(--muted); font-size: .85rem; }

/* badges */
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  background: var(--surface); border: 2px dashed var(--border); border-radius: 14px;
  padding: 10px 14px; font-size: .9rem; opacity: .5; filter: grayscale(1);
}
.badge.on { opacity: 1; filter: none; border-style: solid; border-color: var(--primary); }

/* game */
.game-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.subject-name { font-weight: 800; font-size: 1.2rem; }
.lives { font-size: 1.3rem; letter-spacing: 2px; }
.progress { height: 12px; background: var(--border); border-radius: 99px; margin: 12px 0; overflow: hidden; }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, #8b6cff, #38bdf8); transition: width .4s; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .95rem; margin-bottom: 8px; }
.timer.low { color: var(--bad); font-weight: 700; animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }

.card { background: var(--surface); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: clamp(1.2rem, 3vw, 1.6rem); }
.center { text-align: center; }
.big { font-size: 4rem; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
@media (max-width: 560px) { .answers { grid-template-columns: 1fr; } }
.answer {
  padding: 14px; border-radius: 14px; border: 2px solid var(--border); background: transparent;
  color: var(--text); font: inherit; font-size: 1.05rem; cursor: pointer; text-align: left;
  transition: transform .12s, background .12s, border-color .12s;
}
.answer:hover:not(:disabled) { border-color: var(--primary); transform: scale(1.02); }
.answer:disabled { cursor: default; }
.answer.correct { background: var(--good); border-color: var(--good); color: #fff; animation: pop .3s; }
.answer.wrong { background: var(--bad); border-color: var(--bad); color: #fff; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { min-height: 3em; color: var(--muted); }
.feedback b { color: var(--text); }

/* buttons */
button.primary, button.ghost {
  font: inherit; font-weight: 700; border-radius: 12px; padding: 10px 20px; cursor: pointer; border: 2px solid var(--primary);
}
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.ghost { background: transparent; color: var(--primary); }
button.ghost:hover { background: var(--border); }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.hidden { display: none; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px);
  background: #1c184c; color: #fff; padding: 12px 22px; border-radius: 99px;
  transition: transform .4s; z-index: 10; box-shadow: var(--shadow);
}
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* white buttons */
.subject, .answer, button.primary, button.ghost { background: #fff; color: #1b1650; border-color: #fff; }
.subject .best { color: #5d5c86; }
.answer:hover:not(:disabled), button.primary:hover, button.ghost:hover { background: #ece8ff; }
.answer:hover:not(:disabled) { border-color: var(--primary); }
.answer.correct { background: var(--good); border-color: var(--good); color: #fff; }
.answer.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }

/* sign in */
.login { max-width: 420px; margin: 40px auto; text-align: center; }
.login input {
  width: 100%; padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; font: inherit;
  border: 2px solid var(--border); background: rgba(255,255,255,.08); color: var(--text);
}
.login input:focus { outline: none; border-color: var(--primary); }
.wide { width: 100%; }
.or { color: var(--muted); margin: 16px 0; font-size: .9rem; }
.auth-msg { min-height: 1.4em; color: var(--bad); font-size: .9rem; }
.linkbtn { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* Tailwind (Learnathon) shares the page: keep our headings and widths stable */
.card h1 { margin: 8px 0; }
#game, #result { max-width: 820px; margin: 0 auto; }

/* shared nav */
.navbtn {
  padding: 6px 14px; border-radius: 12px; border: 0; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600;
  color: rgba(255,255,255,.85); background: transparent; transition: background .15s;
}
.navbtn:hover { background: rgba(255,255,255,.15); }
.navbtn.active { background: rgba(255,255,255,.25); color: #fff; }

/* Learnathon glass panels in galaxy colours */
.glass-panel { background: rgba(18, 14, 60, .85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(139, 108, 255, .25); }
.glass-card { background: rgba(28, 24, 76, .75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(139, 108, 255, .22); }
.perspective-1000 { perspective: 1000px; }
.transform-style-3d { transform-style: preserve-3d; }
.backface-hidden { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.rotate-y-180 { transform: rotateY(180deg); }
/* our white-button rule must not repaint Learnathon's Tailwind-styled buttons */
.screen select { color-scheme: dark; }


/* hidden coordinator access: a nearly invisible dot, bottom-left */
#secretHit { position: fixed; left: 6px; bottom: 6px; width: 20px; height: 20px; opacity: .02; border: 0; border-radius: 50%; background: #000; z-index: 99; cursor: default; padding: 0; }

/* coordinator room */
.room { display: none; position: fixed; inset: 0; z-index: 90; overflow: auto; background: #0b0a24; color: #eef0ff; }
.room.open { display: block; }
.room-inner { max-width: 900px; margin: 0 auto; padding: 24px 16px 56px; }
.room-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.room-top h2 { margin: 0; font-size: 1.5rem; }
.room-sub { color: #a9acdf; font-size: .9rem; margin-top: 4px; }
.room-card { background: rgba(28, 24, 76, .8); border: 1px solid rgba(139, 108, 255, .3); border-radius: 18px; padding: 20px; margin-bottom: 16px; }
.room-card h3 { margin: 0 0 12px; font-size: 1.15rem; }
.room label { display: block; margin: 12px 0 4px; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #a9acdf; }
.room input, .room textarea, .room select {
  width: 100%; padding: 10px 12px; border-radius: 10px; font: inherit; color: #eef0ff;
  background: rgba(255,255,255,.07); border: 1px solid rgba(139, 108, 255, .35);
}
.room select option { color: #111; }
.room textarea { min-height: 96px; resize: vertical; }
.room input:focus, .room textarea:focus, .room select:focus { outline: none; border-color: #8b6cff; }
.room input[type=file] { padding: 8px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.room-parser { margin-top: 16px; padding: 14px; border: 1px dashed rgba(139, 108, 255, .5); border-radius: 14px; }
.room-note { color: #a9acdf; font-size: .85rem; margin: 6px 0; }
.room-note code { background: rgba(255,255,255,.12); padding: 1px 6px; border-radius: 6px; }
.room-sep { text-align: center; color: #a9acdf; margin: 20px 0 4px; font-size: .85rem; }
.room-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.room-btn { font: inherit; font-weight: 700; padding: 9px 18px; border-radius: 12px; border: 2px solid #8b6cff; cursor: pointer; }
.room-btn.primary { background: #8b6cff; color: #fff; }
.room-btn.primary:hover { background: #7556f0; }
.room-btn.secondary { background: transparent; color: #cfc6ff; }
.room-btn.danger { background: transparent; color: #ff8aa0; border-color: #ff5d7a; }
.room-btn.small { padding: 4px 10px; font-size: .8rem; border-radius: 8px; }
.room-status { margin-top: 10px; font-size: .9rem; color: #a9acdf; }
.room-status.ok { color: #22c9a0; }
.room-status.err { color: #ff8aa0; }
.room-table { width: 100%; border-collapse: collapse; font-size: .88rem; color: #eef0ff; }
.room-table th, .room-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid rgba(139, 108, 255, .2); vertical-align: middle; }
.room-table th { color: #a9acdf; font-size: .75rem; text-transform: uppercase; }
.room-table input { padding: 5px 8px; width: 90px; }

/* player leaderboard on the home page */
.lb { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 8px 14px; box-shadow: var(--shadow); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.lb-row:last-child { border-bottom: 0; }
.lb-row.me { background: rgba(139, 108, 255, .18); border-radius: 10px; }
.lb-rank { width: 2rem; text-align: center; font-weight: 800; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: #c4b5fd; }
.lb-empty { color: var(--muted); padding: 14px 4px; }

/* coordinator login overlay */
.room-login { display: none; position: fixed; inset: 0; z-index: 95; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 4, 20, .92); color: #eef0ff; }
.room-login.open { display: flex; }
.room-login-card { width: 100%; max-width: 380px; background: rgba(28, 24, 76, .95); border: 1px solid rgba(139, 108, 255, .4); border-radius: 18px; padding: 24px; }
.room-login-card h3 { margin: 0 0 4px; font-size: 1.3rem; }
.room-login label { display: block; margin: 12px 0 4px; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #a9acdf; }
.room-login input { width: 100%; padding: 10px 12px; border-radius: 10px; font: inherit; color: #eef0ff; background: rgba(255,255,255,.07); border: 1px solid rgba(139, 108, 255, .35); }
.room-login input:focus { outline: none; border-color: #8b6cff; }
.room-btn.wide { width: 100%; margin-top: 8px; }


/* ===== Polish: header ===== */
.topbar { background: linear-gradient(90deg, #3b1fb8, #5b3df0 45%, #2f7dff); box-shadow: 0 6px 24px rgba(30, 20, 120, .45); }
.logo { background: none; border: 0; color: #fff; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.35rem; letter-spacing: .01em; padding: 0; display: inline-flex; align-items: center; gap: 8px; }
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.2); font-size: 1.2rem; }
.chip.lvl { display: inline-flex; align-items: center; gap: 8px; }
.lvlbar { display: inline-block; width: 46px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.3); overflow: hidden; }
.lvlbar i { display: block; height: 100%; width: 0; background: #fff; border-radius: 99px; transition: width .5s; }

/* ===== Hero ===== */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 34px 28px; margin: 6px 0 18px;
  background: linear-gradient(135deg, rgba(91, 61, 240, .55), rgba(47, 125, 255, .35) 60%, rgba(190, 80, 255, .35));
  border: 1px solid rgba(160, 140, 255, .35); box-shadow: 0 18px 50px rgba(40, 20, 160, .45);
}
.hero::after { content: "✨"; position: absolute; right: 22px; top: 8px; font-size: 5rem; opacity: .18; }
.hero-pill { display: inline-block; padding: 5px 14px; border-radius: 99px; background: rgba(255,255,255,.16); font-size: .85rem; font-weight: 700; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); line-height: 1.15; margin: 12px 0 8px; background: linear-gradient(90deg, #fff, #cfd6ff 60%, #8fd3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 640px; color: #dcd9ff; font-size: 1.05rem; margin: 0 0 16px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-stats span { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); border-radius: 99px; padding: 6px 14px; font-size: .88rem; font-weight: 600; }

/* ===== Space switcher, Prepvel track picker, login mode picker ===== */
.spacebar { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.space-pill { font: inherit; font-weight: 700; padding: 9px 18px; border-radius: 99px; cursor: pointer; color: #dcd9ff; background: rgba(255,255,255,.08); border: 1px solid rgba(160, 140, 255, .35); transition: transform .15s, background .15s; }
.space-pill:hover { transform: translateY(-2px); background: rgba(255,255,255,.16); }
.space-pill.on { color: #fff; background: linear-gradient(90deg, #6d4de6, #2f7dff); border-color: transparent; box-shadow: 0 6px 18px rgba(80, 60, 230, .45); }
.track-picker { margin: 10px 0 8px; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.track { text-align: left; cursor: pointer; font: inherit; color: var(--text); padding: 22px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; transition: transform .18s, border-color .18s; }
.track:hover { transform: translateY(-5px); border-color: #8b6cff; }
.track b { font-size: 1.25rem; }
.track span { color: var(--muted); font-size: .92rem; }
.track .track-emoji { font-size: 2.4rem; }
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 18px; }
.mode { font: inherit; text-align: left; cursor: pointer; color: var(--text); padding: 12px; border-radius: 14px; background: rgba(255,255,255,.06); border: 2px solid var(--border); display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, background .15s; }
.mode span { color: var(--muted); font-size: .78rem; }
.mode.on { border-color: #8b6cff; background: rgba(139, 108, 255, .22); }
@media (max-width: 480px) { .mode-pick { grid-template-columns: 1fr; } }

/* ===== Subject cards ===== */
.subject-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.subject { position: relative; overflow: hidden; padding: 20px; border-radius: 20px; }
.subject::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--c); }
.subject .emoji { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-size: 1.8rem; background: color-mix(in srgb, var(--c) 18%, white); margin-bottom: 4px; }
.subject:hover, .subject:focus-visible { transform: translateY(-6px); box-shadow: 0 16px 34px rgba(0,0,0,.35), 0 0 0 2px var(--c); border-color: transparent; }
.screen > h2 { display: flex; align-items: center; gap: 10px; }
.screen > h2::after { content: ""; flex: 1; height: 2px; background: linear-gradient(90deg, rgba(139,108,255,.6), transparent); border-radius: 2px; }

/* ===== Subject bar and hub ===== */
.subbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: 18px; background: rgba(20, 16, 70, .8); border: 1px solid rgba(139, 108, 255, .35); backdrop-filter: blur(10px); }
.subbar.hidden { display: none; }
.subbar-title { flex: 1; font-weight: 800; min-width: 160px; }
.subbar-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 700; cursor: pointer; padding: 8px 16px; border-radius: 12px; color: #cfc6ff; background: rgba(255,255,255,.07); border: 1px solid transparent; }
.tab:hover { background: rgba(255,255,255,.15); }
.tab.on { color: #fff; background: linear-gradient(90deg, #6d4de6, #2f7dff); }
.hub-card { max-width: 640px; margin: 10px auto; padding: 34px 26px; }
.hub-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
.hub-meta span { background: rgba(139, 108, 255, .2); border-radius: 99px; padding: 6px 14px; font-size: .88rem; font-weight: 600; }
.big-btn { font-size: 1.1rem; padding: 14px 34px !important; margin-top: 8px; }
.combo { color: #ffb347; font-weight: 700; }
.muted { color: var(--muted); }

/* ===== Footer ===== */
.site-foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 26px 16px 34px; position: relative; z-index: 1; }

/* ===== Coordinator room additions ===== */
.room-dim { color: #a9acdf; font-size: .78rem; }
.room-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.room-chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(139, 108, 255, .22); border-radius: 99px; padding: 5px 6px 5px 14px; font-size: .85rem; }
.room-chip button { background: rgba(255,255,255,.18); border: 0; color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
#rmFilter { margin-bottom: 8px; }
.room .hidden { display: none; }


/* Google sign-in button slot */
.g-slot { display: flex; justify-content: center; margin: 8px 0; min-height: 44px; }
.g-slot.hidden { display: none; }
