:root {
  --bg: #fff7f6;
  --card: #ffffff;
  --ink: #2b1d1b;
  --muted: #6f5e5c;
  --primary: #ff7aa2;
  --primary-ink: #3a0b1d;
  --accent: #7ad8ff;
  --accent-ink: #062233;
  --danger: #ff5d5d;
  --ok: #7be495;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Fredoka", system-ui, -apple-system, Segoe UI, Roboto, Emoji, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 10% -10%, #ffe3ec, transparent 50%),
              radial-gradient(1000px 700px at 110% 0%, #e6f7ff, transparent 50%),
              var(--bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: saturate(1.2) blur(6px);
  background: rgba(255, 247, 246, 0.7);
  border-bottom: 1px solid #f0e6e5;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.brand .logo-img { width: 36px; height: 36px; object-fit: contain; }
.brand h1 { font-size: 22px; margin: 0; letter-spacing: 0.5px; }

.tabs { display: flex; gap: 8px; padding: 0 16px 12px; }
.tab {
  border: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.tab.active { background: var(--primary); color: #fff; }
.tab:focus-visible { outline: 3px solid #000; outline-offset: 2px; }

.container { max-width: 1100px; margin: 20px auto; padding: 0 16px 48px; }
.cards.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .cards.two-col { grid-template-columns: 1fr 1fr; }
  .cards.two-col.play-layout { grid-template-columns: 1.55fr 0.45fr; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-header h2 { margin: 0; font-size: 20px; }
.card-actions { display: flex; gap: 8px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.block { display: grid; gap: 6px; }

.add-form input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #f0e6e5;
  background: #fff;
}

.btn { 
  --b: var(--primary);
  --c: var(--primary-ink);
  border: 0;
  background: var(--b);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.btn.ghost { background: #fff; color: var(--c); border: 2px solid var(--b); }
.btn.accent { --b: var(--accent); --c: var(--accent-ink); }
.btn.danger { --b: var(--danger); --c: #3a0b0b; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.file-btn { position: relative; overflow: hidden; }

.list { display: grid; gap: 8px; margin-top: 12px; }
.list .item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 2px dashed #f0e6e5;
}
.participants .name { font-weight: 700; }
.participants .score-controls { display: flex; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff8fb;
  border: 1px solid #ffe1ee;
}

.add-question { display: grid; gap: 12px; margin-top: 8px; }
textarea, input[type="text"] { font: inherit; }
textarea, .opt-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #f0e6e5;
  background: #fff;
}

.code-section { border: 2px dashed #f0e6e5; border-radius: 12px; padding: 8px 10px; }
.code-lang { padding: 8px 10px; border: 2px solid #f0e6e5; border-radius: 10px; background: #fff; }

.options-grid { border: 0; display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 600px) {
  .options-grid { grid-template-columns: 1fr 1fr; }
}
.option-item { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; }
.opt-label {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700;
}

.questions .qtext { font-weight: 700; }
.questions .answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.questions .answer { background: #f9fdff; border: 1px solid #dff3ff; padding: 8px; border-radius: 10px; }
.questions .correct { border-color: #b3f2ca; background: #effff4; }

.play-layout { align-items: start; }
.question-card .question-text { font-size: 20px; font-weight: 700; margin: 14px 0; letter-spacing: 0.2px; }
.code-area { margin: 6px 0 8px; }
.question-card .question-text, .code-area, .options-choices { animation: fadeIn .45s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.timers { display: none; }
.options-choices { display: grid; gap: 10px; }
.choice {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; border: 2px solid #f0e6e5; background: #fff;
}
/* smoother hover/selection transitions */
.choice { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease; }
.choice .badge { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; background: #ffe7f1; color: var(--primary-ink); font-weight: 700; }
.choice.correct { border-color: #b3f2ca; background: #effff4; }
.choice.wrong { border-color: #ffd1d1; background: #fff3f3; }
.choice.selected { transform: scale(1.02); box-shadow: 0 6px 18px rgba(0,0,0,0.08); border-color: var(--accent); }
.choice.revealing { animation: pulse 0.6s ease-in-out infinite alternate; }
.choice .flag { transition: transform .25s ease; visibility: hidden; }
.revealed .choice.correct .flag { visibility: visible; transform: scale(1.2); }
.play-status { min-height: 22px; margin: 6px 0 0; }

/* Code rendering */
.code-block { position: relative; margin: 10px 0; border: 2px solid #f0e6e5; border-radius: 12px; overflow: hidden; background: #0b1021; color: #f4f7ff; }
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: #121939; color: #a7b3ff; font-weight: 700; font-size: 12px; }
.code-pre { margin: 0; padding: 10px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.5; }
.copy-btn { border: 0; padding: 6px 10px; border-radius: 8px; background: #2b3270; color: #fff; cursor: pointer; font-weight: 700; }

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}
.hint { color: var(--muted); font-size: 14px; }

.scoreboard .s-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border: 2px dashed #f0e6e5; border-radius: 10px; background: #fff; }
.scoreboard .name { font-weight: 700; }
.score-btns { display: inline-flex; gap: 6px; }
.score { font-weight: 700; }
.s-row.active { outline: 3px solid var(--accent); box-shadow: 0 0 0 4px rgba(122,216,255,0.25); }
.s-row.bump { animation: bump 250ms ease; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.float-plus1 {
  position: absolute;
  pointer-events: none;
  color: #1a7f3c;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0,0,0,0.1);
  animation: floatUp 900ms ease forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(4px) scale(0.9); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px) scale(1.1); }
}

.leaderboard { display: grid; gap: 8px; }
.leaderboard .lb-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 12px; background: #fff; border-radius: 12px; border: 2px solid #f0e6e5; opacity: 0; transform: translateY(8px) scale(0.98); }
.leaderboard .lb-row.appear { animation: fadeSlideIn 520ms cubic-bezier(.2,.7,.2,1.1) forwards; }
.leaderboard .lb-row.top1 { border-color: #ffe27a; box-shadow: 0 8px 24px rgba(255,226,122,0.28); position: relative; }
.leaderboard .lb-row.top1::after { content: ""; position: absolute; inset: -2px; border-radius: 14px; background: radial-gradient(600px 60px at 20% -20%, rgba(255,239,170,.35), transparent 60%); pointer-events: none; }
.leaderboard .lb-row.top2 { border-color: #d7dee2; }
.leaderboard .lb-row.top3 { border-color: #ffc9ac; }
@keyframes fadeSlideIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.98); }
  60% { opacity: 1; transform: translateY(0) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.medal { font-size: 26px; position: relative; display: inline-block; text-shadow: 0 1px 0 #fff, 0 0 4px rgba(0,0,0,0.15); }
.medal.shimmer::after { content: ""; position: absolute; inset: -6px; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.9), rgba(255,255,255,0)); transform: translateX(-150%); animation: glint 1.6s ease-in-out infinite; pointer-events: none; mix-blend-mode: screen; }
@keyframes glint { to { transform: translateX(150%); } }

.view { display: none; }
.view.active { display: block; }

.app-footer { text-align: center; padding: 18px; color: var(--muted); }

/* Confetti canvas */
#confettiCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

/* Lock overlay for questions (stays below header) */
#questionsCard { position: relative; overflow: hidden; }
.lock-overlay { position: absolute; left: 0; right: 0; bottom: 0; top: 64px; display: none; place-items: center; background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.98)); border-top: 1px solid #f0e6e5; backdrop-filter: blur(2px) saturate(1.05); }
.lock-overlay.active { display: grid; }
.lock-content { text-align: center; display: grid; gap: 6px; justify-items: center; }
.lock-emoji { font-size: 38px; }
.lock-title { font-size: 18px; font-weight: 700; }
.lock-sub { color: var(--muted); }

/* Modal */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 10; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-content { position: relative; max-width: 420px; margin: 10vh auto; background: #fff; padding: 18px; border-radius: 14px; box-shadow: var(--shadow); }

/* Countdown overlay */
.countdown { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.35); z-index: 6; }
.countdown.hidden { display: none; }
.count-num { font-size: 120px; font-weight: 700; color: #fff; text-shadow: 0 12px 24px rgba(0,0,0,0.4); animation: pop 600ms ease; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}


