/* =============================================
   RekenRegen.nl – Global Styles
   Theme: Rainy-day playful, bold, child-friendly
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --sky:        #1a1f5e;
  --sky-mid:    #2b3490;
  --cloud:      #e8f4fd;
  --rain:       #4fc3f7;
  --rain-dark:  #0288d1;
  --sun:        #FFD600;
  --sun-dark:   #F9A825;
  --green:      #00C853;
  --green-dark: #009624;
  --red:        #FF3D00;
  --red-dark:   #BF360C;
  --white:      #ffffff;
  --text-dark:  #1a1a2e;
  --card-bg:    rgba(255,255,255,0.12);
  --card-border:rgba(255,255,255,0.25);
  --shadow:     0 8px 32px rgba(0,0,0,0.35);
  --radius:     20px;
  --radius-sm:  12px;
  --font-head:  'Fredoka One', cursive;
  --font-body:  'Nunito', sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: linear-gradient(160deg, var(--sky) 0%, var(--sky-mid) 60%, #1565c0 100%);
  min-height: 100dvh;
  color: var(--white);
  overflow-x: hidden;
  position: relative;
}

/* ─── Rain canvas background ─── */
#rain-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0.18;
  z-index: 0;
}

/* ─── Page wrapper ─── */
.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 40px;
}

/* ─── Logo ─── */
.logo {
  font-family: var(--font-head);
  font-size: clamp(2rem, 8vw, 3.5rem);
  color: var(--sun);
  text-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 40px rgba(255,214,0,0.3);
  letter-spacing: 1px;
  margin-top: 40px;
  text-align: center;
  line-height: 1.1;
}

.logo span {
  color: var(--rain);
  text-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 40px rgba(79,195,247,0.4);
}

.logo-sub {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  text-align: center;
  margin-top: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ─── Cards ─── */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  margin-top: 24px;
}

.card-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  color: var(--sun);
  margin-bottom: 18px;
  text-align: center;
}

/* ─── Buttons ─── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  text-decoration: none;
  color: var(--text-dark);
  letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.96); filter: brightness(0.92); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-dark) 100%);
  box-shadow: 0 6px 20px rgba(255,214,0,0.4);
}
.btn-primary:not(:disabled):hover { box-shadow: 0 8px 28px rgba(255,214,0,0.55); transform: translateY(-2px); }

.btn-blue {
  background: linear-gradient(135deg, var(--rain) 0%, var(--rain-dark) 100%);
  color: var(--white);
  box-shadow: 0 6px 20px rgba(2,136,209,0.4);
}
.btn-blue:not(:disabled):hover { box-shadow: 0 8px 28px rgba(2,136,209,0.55); transform: translateY(-2px); }

.btn-green {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--white);
  box-shadow: 0 6px 20px rgba(0,200,83,0.4);
}
.btn-green:not(:disabled):hover { box-shadow: 0 8px 28px rgba(0,200,83,0.55); transform: translateY(-2px); }

.btn-red {
  background: linear-gradient(135deg, #FF6B6B 0%, var(--red) 100%);
  color: var(--white);
  box-shadow: 0 6px 20px rgba(255,61,0,0.35);
}

.btn-ghost {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  color: var(--white);
  backdrop-filter: blur(8px);
}

.btn + .btn { margin-top: 14px; }

/* ─── Inputs ─── */
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--card-border);
  background: rgba(255,255,255,0.1);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder { color: rgba(255,255,255,0.4); }

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--sun);
  background: rgba(255,255,255,0.18);
}

/* ─── Checkbox / Toggle ─── */
.check-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
/* Last item alone on a row gets full width */
.check-group .check-item:last-child:nth-child(odd) { grid-column: 1 / -1; max-width: 50%; }

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.check-item:has(input:checked) {
  background: rgba(255,214,0,0.2);
  border-color: var(--sun);
}

.check-item input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--sun);
  cursor: pointer;
  flex-shrink: 0;
}

.check-item span { font-size: 0.85rem; font-weight: 700; color: var(--white); }

/* ─── Slider ─── */
.slider-group { margin-bottom: 16px; }
.slider-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.slider-label { font-size: 0.85rem; font-weight: 700; color: rgba(255,255,255,0.8); }
.slider-value { font-family: var(--font-head); font-size: 1rem; color: var(--sun); min-width: 50px; text-align: right; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.2);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.2); }

/* ─── Toggle switch ─── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row label { font-size: 0.9rem; font-weight: 700; color: rgba(255,255,255,0.85); cursor: pointer; }

.toggle {
  position: relative;
  width: 52px; height: 28px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 28px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 4px; top: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.toggle input:checked + .toggle-slider { background: var(--sun); }
.toggle input:checked + .toggle-slider::before { transform: translateX(24px); }

/* ─── Section headers in settings ─── */
.section-heading {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--rain);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(79,195,247,0.3);
}

/* ─── Error / info messages ─── */
.msg-error {
  background: rgba(255,61,0,0.2);
  border: 1px solid rgba(255,61,0,0.5);
  color: #ff8a65;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
  display: none;
}
.msg-error.show { display: block; }

.msg-info {
  background: rgba(79,195,247,0.15);
  border: 1px solid rgba(79,195,247,0.4);
  color: var(--rain);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
}

/* ─── Room code display ─── */
.room-code {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 12vw, 4rem);
  letter-spacing: 10px;
  color: var(--sun);
  text-align: center;
  text-shadow: 0 4px 20px rgba(255,214,0,0.5);
  padding: 10px 0;
}

/* ─── Player list ─── */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.2s;
}
.player-item.eliminated {
  opacity: 0.45;
  text-decoration: line-through;
}
.player-item .p-score {
  font-family: var(--font-head);
  font-size: 1.1rem;
  color: var(--sun);
}
.player-item .p-status {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 700;
}
.p-status.active  { background: rgba(0,200,83,0.3);  color: var(--green); }
.p-status.out     { background: rgba(255,61,0,0.3);   color: #ff8a65; }

/* ─── Timer bar ─── */
.timer-bar-wrap {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green) 0%, var(--sun) 60%, var(--red) 100%);
  border-radius: 10px;
  transition: width 0.9s linear;
}

.timer-text {
  font-family: var(--font-head);
  font-size: 1.8rem;
  color: var(--sun);
  text-align: center;
}

/* ─── Game arena (falling sum) ─── */
#game-arena {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 55dvh;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  border: 2px solid var(--card-border);
  overflow: hidden;
  flex-shrink: 0;
  margin: 16px 0;
}

.falling-question {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--rain) 0%, var(--rain-dark) 100%);
  color: var(--white);
  font-family: var(--font-head);
  font-size: clamp(1.3rem, 5vw, 2rem);
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: fallDown linear forwards;
  min-width: 80px;
  text-align: center;
  z-index: 5;
}

@keyframes fallDown {
  from { top: -80px; }
  to   { top: 100%;  }
}

/* ─── Answer buttons ─── */
.answer-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 400px;
  flex-shrink: 0;
}

.btn-answer {
  padding: 20px 12px;
  font-family: var(--font-head);
  font-size: clamp(1.2rem, 5vw, 1.7rem);
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.08) 100%);
  border: 2px solid var(--card-border);
  color: var(--white);
  cursor: pointer;
  transition: transform 0.1s, background 0.1s, border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-answer:active { transform: scale(0.94); }
.btn-answer.correct { background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%); border-color: var(--green); animation: correctPulse 0.4s ease; }
.btn-answer.wrong   { background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);   border-color: var(--red);   animation: shake 0.35s ease; }
.btn-answer.disabled, .btn-answer:disabled { opacity: 0.5; cursor: not-allowed; }

@keyframes correctPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ─── HUD (score / lives / streak) ─── */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 400px;
  gap: 12px;
  flex-shrink: 0;
}

.hud-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  flex: 1;
}
.hud-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,0.6); }
.hud-value { font-family: var(--font-head); font-size: 1.4rem; color: var(--sun); line-height: 1.1; }

/* ─── Lives display ─── */
.lives { display: flex; gap: 4px; justify-content: center; }
.life { font-size: 1.1rem; transition: opacity 0.2s; }
.life.lost { opacity: 0.2; }

/* ─── Leaderboard ─── */
.leaderboard { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.lb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}
.lb-rank { font-family: var(--font-head); font-size: 1.2rem; width: 32px; text-align: center; }
.lb-rank.gold   { color: var(--sun); }
.lb-rank.silver { color: #B0BEC5; }
.lb-rank.bronze { color: #BCAAA4; }
.lb-nick { flex: 1; font-size: 0.95rem; }
.lb-score { font-family: var(--font-head); font-size: 1.1rem; color: var(--sun); }
.lb-item.eliminated { opacity: 0.5; }

/* ─── Overlay / modal ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,14,60,0.92);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.show { opacity: 1; pointer-events: all; }

.overlay-box {
  background: linear-gradient(160deg, #1e2560, #2b3490);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.35s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.overlay-title { font-family: var(--font-head); font-size: 2rem; color: var(--sun); margin-bottom: 10px; }
.overlay-sub   { font-size: 0.95rem; color: rgba(255,255,255,0.7); margin-bottom: 24px; }

/* ─── Countdown ─── */
.countdown-number {
  font-family: var(--font-head);
  font-size: clamp(5rem, 25vw, 9rem);
  color: var(--sun);
  text-shadow: 0 0 60px rgba(255,214,0,0.5);
  text-align: center;
  animation: pulse 0.8s ease infinite;
}

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ─── Eliminated banner ─── */
.eliminated-banner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,61,0,0.92);
  z-index: 300;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  animation: fadeIn 0.4s ease;
}
.eliminated-banner.show { display: flex; }
.elim-emoji { font-size: 5rem; margin-bottom: 16px; }
.elim-title { font-family: var(--font-head); font-size: 2.5rem; margin-bottom: 10px; }
.elim-reason { font-size: 1rem; opacity: 0.85; margin-bottom: 24px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Waiting room ─── */
.waiting-dots::after {
  content: '';
  animation: dots 1.5s steps(3, end) infinite;
}
@keyframes dots {
  0%   { content: '.'; }
  33%  { content: '..'; }
  66%  { content: '...'; }
  100% { content: ''; }
}

/* ─── Stats badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ─── QR area ─── */
.qr-area {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px;
  width: fit-content;
  margin: 12px auto;
}

/* ─── Responsive ─── */
@media (min-width: 640px) {
  .page { padding: 0 24px 60px; }
  .card { padding: 36px 32px; }
  #game-arena { height: 50vh; }
}

@media (min-width: 1024px) {
  .check-group { grid-template-columns: 1fr 1fr 1fr; }
  .teacher-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1000px;
    width: 100%;
  }
}

/* ─── Teacher screen wide layout ─── */
.teacher-grid {
  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 900px) {
  .teacher-grid {
    grid-template-columns: 340px 1fr;
    grid-template-rows: auto auto;
  }
  .teacher-header { grid-column: 1 / -1; }
}

/* ─── Score pop animation ─── */
@keyframes scorePop {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; transform: translateY(-30px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-50px) scale(0.8); }
}
.score-pop {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-head);
  font-size: 1.5rem;
  color: var(--sun);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  animation: scorePop 0.8s ease forwards;
  z-index: 100;
}

/* ─── Utility ─── */
.text-center { text-align: center; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.w100  { width: 100%; }
.hidden { display: none !important; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.opacity-60 { opacity: 0.6; }
.divider { border: none; border-top: 1px solid rgba(255,255,255,0.12); margin: 16px 0; }
