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

body {
  font-family: 'Nunito', 'Comic Sans MS', cursive;
  background: linear-gradient(135deg, #ffecd2, #fcb69f, #a1c4fd, #c2e9fb);
  background-size: 400% 400%;
  animation: bgShift 10s ease infinite;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 30px;
}

@keyframes bgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── AUTH SCREEN ── */
.auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 20px;
}

.auth-box {
  background: #fff;
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.auth-title {
  font-size: 1.8rem;
  color: #7c3aed;
  margin-bottom: 8px;
  font-weight: 700;
  text-shadow: none;
}

.auth-box h2 {
  font-size: 1.3rem;
  color: #333;
  margin-bottom: 16px;
}

.auth-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .2s;
}

.auth-input:focus {
  outline: none;
  border-color: #7c3aed;
}

.auth-pw-wrap {
  position: relative;
  margin-bottom: 12px;
}
.auth-pw-wrap .auth-input {
  margin-bottom: 0;
  padding-right: 44px;
}
.auth-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.auth-pw-toggle:hover { color: #7c3aed; }
.eye-icon { display: block; }

.auth-btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.auth-btn:active { transform: scale(.97); }

.auth-btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  color: #fff;
  background: #7c3aed;
  margin-top: 4px;
}

.auth-btn-primary:hover { background: #6d28d9; }

.auth-btn-small {
  padding: 10px 18px;
  font-size: 1.2rem;
  color: #fff;
  background: #7c3aed;
  border-radius: 12px;
  flex-shrink: 0;
}

.auth-btn-small:hover { background: #6d28d9; }

.auth-switch {
  margin-top: 14px;
  font-size: .9rem;
  color: #666;
}

.auth-switch a {
  color: #7c3aed;
  font-weight: 700;
  text-decoration: none;
}

.auth-error {
  color: #e53e3e;
  font-weight: 700;
  font-size: .9rem;
  min-height: 1.2em;
  margin-top: 10px;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-player-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 14px 24px;
  border: 3px solid #7c3aed;
  border-radius: 16px;
  background: #f3e8ff;
  color: #7c3aed;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.auth-player-btn:hover {
  background: #7c3aed;
  color: #fff;
}

.auth-player-btn:active { transform: scale(.95); }

.auth-add-player {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.auth-add-player .auth-input {
  margin-bottom: 0;
  flex: 1;
}

.setup-kid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  margin-bottom: 6px;
  background: #f3e8ff;
  border: 2px solid #7c3aed;
  border-radius: 12px;
  font-weight: 700;
  color: #7c3aed;
  font-size: 1.05rem;
}

.setup-kid-remove {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}

/* Nav welcome label + sign-out button */
.welcome-label {
  font-family: inherit;
  font-size: .85rem;
  font-weight: 800;
  color: #4a1a7a;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255,255,255,0.6);
}

.signout-btn {
  width: 46px; height: 46px;
  font-size: 1.2rem;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.signout-btn:hover { transform: translateY(-2px); }
.signout-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.12); }

.stats-btn {
  width: 30px; height: 30px;
  font-size: 0.95rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.stats-btn:hover { transform: scale(1.2); }

/* ── NAV ── */
.top-nav {
  width: 100%;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  gap: 10px;
  position: relative;
  z-index: 500;
  overflow: visible;
}
.nav-spacer  { flex: 1; }
.nav-center  { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
/* Games dropdown */
.games-dropdown { position: relative; }
.games-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  padding: 8px;
  z-index: 9999;
  min-width: 200px;
}
.games-dropdown-menu.open { display: flex; flex-direction: column; gap: 4px; }

.game-drop-btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #555;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.game-drop-btn:hover { background: #f3e8ff; }
.game-drop-btn.active { background: #7c3aed; color: #fff; }

.nav-btn {
  padding: 12px 28px;
  font-size: 1.25rem;
  font-family: inherit;
  font-weight: bold;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  background: rgba(255,255,255,0.5);
  color: #555;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s, color 0.2s,
              font-size 0.25s ease, padding 0.25s ease;
}
.nav-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.nav-btn.active {
  background: white;
  color: #6c5ce7;
  box-shadow: 0 4px 0 #a29bfe;
  transform: translateY(-2px);
}

.cog-btn {
  width: 46px; height: 46px;
  font-size: 1.4rem;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
  transition: transform 0.3s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cog-btn:hover { transform: rotate(45deg); }
.cog-btn:active { transform: rotate(90deg) translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.12); }

/* ── SETTINGS MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: white;
  border-radius: 28px;
  padding: 36px 40px;
  min-width: 300px;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  position: relative;
  animation: modalIn 0.25s ease;
  transition: max-width 0.25s ease, min-width 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,92,231,0.35) transparent;
}
.modal-box::-webkit-scrollbar { width: 6px; }
.modal-box::-webkit-scrollbar-track { background: transparent; margin: 14px 0; }
.modal-box::-webkit-scrollbar-thumb {
  background: rgba(108,92,231,0.35);
  border-radius: 3px;
}
.modal-box::-webkit-scrollbar-thumb:hover { background: rgba(108,92,231,0.55); }
@keyframes modalIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: #aaa;
  line-height: 1;
}
.modal-close:hover { color: #e74c3c; }

.modal-box h2 {
  font-size: 1.7rem;
  color: #6c5ce7;
  margin-bottom: 24px;
  text-shadow: none;
}

/* ── Confirm modal ── */
.confirm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 10001;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }

.confirm-box {
  background: white;
  border-radius: 24px;
  padding: 32px 36px;
  min-width: 260px;
  max-width: 380px;
  width: 85%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  text-align: center;
  animation: modalIn 0.25s ease;
}
.confirm-msg {
  font-size: 1.25rem;
  color: #333;
  margin: 0 0 24px;
  line-height: 1.5;
}
.confirm-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
}
.confirm-btn {
  padding: 10px 32px;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.confirm-btn:hover { transform: scale(1.05); }
.confirm-btn-yes {
  background: #6c5ce7;
  color: white;
  box-shadow: 0 4px 12px rgba(108,92,231,0.35);
}
.confirm-btn-yes:hover { box-shadow: 0 6px 18px rgba(108,92,231,0.45); }
.confirm-btn-no {
  background: #f0f0f0;
  color: #555;
}
.confirm-btn-no:hover { background: #e0e0e0; }

/* ── Stats modal ── */
.stats-modal-box {
  max-width: 520px;
  min-width: 340px;
}
.stats-content {
  text-align: left;
  font-size: 0.95rem;
  color: #333;
}
.stats-loading { text-align: center; padding: 20px; color: #999; }

.stats-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #6c5ce7;
  margin: 20px 0 10px;
  border-bottom: 2px solid #eee;
  padding-bottom: 6px;
}
.stats-section-title:first-child { margin-top: 0; }

.stats-overview {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}
.stats-card {
  background: #f8f7ff;
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}
.stats-card-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #6c5ce7;
  display: block;
}
.stats-card-label {
  font-size: 0.8rem;
  color: #888;
  margin-top: 2px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 0.88rem;
}
.stats-table th {
  background: #f0eeff;
  color: #6c5ce7;
  font-weight: 700;
  padding: 8px 6px;
  text-align: left;
  border-bottom: 2px solid #ddd;
}
.stats-table td {
  padding: 7px 6px;
  border-bottom: 1px solid #eee;
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table .pct-cell {
  font-weight: 700;
  text-align: right;
}
.stats-table .pct-good  { color: #27ae60; }
.stats-table .pct-ok    { color: #f39c12; }
.stats-table .pct-low   { color: #e74c3c; }
.stats-no-data { color: #aaa; font-style: italic; padding: 10px 0; }
.stats-game-tag {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 600;
  padding: 1px 6px;
  margin: 1px 2px;
  border-radius: 10px;
  background: #eee8ff;
  color: #6c5ce7;
  white-space: nowrap;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 2px solid #f0f0f0;
}
.setting-label {
  font-size: 1.1rem;
  font-weight: bold;
  color: #555;
}

.lang-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.lang-btn {
  padding: 8px 18px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: bold;
  border: 3px solid #a29bfe;
  border-radius: 50px;
  cursor: pointer;
  background: #f5f3ff;
  color: #6c5ce7;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lang-btn.active {
  background: #6c5ce7;
  color: white;
  border-color: #6c5ce7;
}

/* ── ADMIN PANEL (inside settings modal) ── */
.admin-pw-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.admin-pw-row .auth-input {
  flex: 1;
  margin-bottom: 0;
}

.admin-player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
  max-height: 180px;
  overflow-y: auto;
}

.admin-player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f5f3ff;
  border-radius: 12px;
  padding: 6px 10px;
}
.admin-player-row .admin-player-name {
  flex: 1;
  font-weight: bold;
  color: #333;
  font-size: 0.95rem;
}
.admin-player-row input.admin-rename-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  padding: 4px 8px;
  border: 2px solid #a29bfe;
  border-radius: 8px;
  outline: none;
}
.admin-player-row button {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.admin-player-row button:hover {
  background: #e8e4ff;
}
.admin-player-row .admin-delete-btn:hover {
  background: #ffe0e0;
}

.admin-add-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.admin-add-row .auth-input {
  flex: 1;
  margin-bottom: 0;
}

#adminPanel h3 {
  font-size: 1.05rem;
  color: #6c5ce7;
  margin: 10px 0 4px;
  text-align: left;
}
.admin-pw-change {
  margin-top: 4px;
}
.admin-pw-change .auth-pw-wrap {
  margin-bottom: 8px;
}
.admin-save-pw-btn {
  width: 100%;
  margin-top: 4px;
}
.admin-pw-success {
  color: #27ae60;
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 4px;
  text-align: center;
}

/* ── SECTION WRAPPER ── */
.section {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 20px;
}
.section.visible { display: flex; }

/* ── SHARED ── */
h1 {
  font-size: 2.8rem;
  color: #fff;
  text-shadow: 3px 3px 0 #ff6b6b, 5px 5px 0 #ffd93d;
  margin-bottom: 10px;
  text-align: center;
}

.score-bar {
  display: flex;
  gap: 24px;
  background: rgba(255,255,255,0.85);
  border-radius: 50px;
  padding: 10px 28px;
  margin-bottom: 20px;
  font-size: 1.15rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  flex-wrap: wrap;
  justify-content: center;
}
.score-bar span { font-weight: bold; }
.diff-badge {
  font-size: 0.75em;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  background: #27ae60;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.3s;
}
.diff-badge.diff-hard {
  background: #e74c3c;
}
.diff-badge-sm {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 12px;
  background: #27ae60;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.diff-badge-sm.diff-hard {
  background: #e74c3c;
}
.correct-count { color: #27ae60; }
.streak-count  { color: #e67e22; }
.total-count   { color: #8e44ad; }

.card {
  background: white;
  border-radius: 30px;
  padding: 35px 45px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  max-width: 520px;
  width: 100%;
}

.question-label {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.feedback {
  font-size: 2rem;
  min-height: 2.5rem;
  margin: 12px 0 4px;
}
.stars {
  font-size: 2rem;
  min-height: 2.5rem;
  margin-bottom: 4px;
}

.progress-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.pip { width: 18px; height: 18px; border-radius: 50%; background: #dfe6e9; transition: background 0.3s; }
.pip.ok  { background: #27ae60; }
.pip.err { background: #e74c3c; }

.next-btn {
  margin-top: 15px;
  padding: 12px 35px;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: bold;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 5px 0 #27ae60;
  transition: transform 0.15s, box-shadow 0.15s;
  display: none;
}
.next-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #27ae60; }
.next-btn.visible { display: inline-block; }

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-10px); }
  40%  { transform: translateX(10px); }
  60%  { transform: translateX(-8px); }
  80%  { transform: translateX(8px); }
}

/* ── MYMATHS ── */
.op-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 25px;
}
.op-btn {
  padding: 12px 22px;
  font-size: 1.3rem;
  font-family: inherit;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s,
              font-size 0.25s ease, padding 0.25s ease;
  font-weight: bold;
  box-shadow: 0 5px 0 rgba(0,0,0,0.2);
}
.op-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.op-btn.active { transform: translateY(4px) scale(1.05); box-shadow: 0 1px 0 rgba(0,0,0,0.2); outline: 4px solid #fff; }
.btn-add { background: #f9ca24; color: #333; }
.btn-sub { background: #6ab04c; color: #fff; }
.btn-mul { background: #e55039; color: #fff; }
.btn-div { background: #2980b9; color: #fff; }
.btn-all { background: #8e44ad; color: #fff; }

.equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 3rem;
  font-weight: bold;
  color: #333;
  margin: 20px 0;
  flex-wrap: wrap;
}
.eq-num { color: #2c3e50; }
.eq-op  { color: #e74c3c; }
.eq-eq  { color: #7f8c8d; }

.answer-input {
  font-size: 3rem;
  font-family: inherit;
  font-weight: bold;
  width: 110px;
  text-align: center;
  border: 4px dashed #a29bfe;
  border-radius: 16px;
  color: #6c5ce7;
  background: #f5f3ff;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  padding: 4px 8px;
}
.answer-input:focus { border-color: #6c5ce7; background: #eae6ff; }
.answer-input.correct-input { border-color: #27ae60; background: #eafaf1; color: #27ae60; animation: pop 0.3s; }
.answer-input.wrong-input   { border-color: #e74c3c; background: #fdedec; color: #e74c3c; animation: shake 0.4s; }

.submit-btn {
  margin-top: 25px;
  padding: 14px 45px;
  font-size: 1.5rem;
  font-family: inherit;
  font-weight: bold;
  background: linear-gradient(135deg, #a18cd1, #fbc2eb);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 5px 0 #9b59b6;
  transition: transform 0.15s, box-shadow 0.15s;
}
.submit-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #9b59b6; }

/* ── TIME INPUT (hard mode) ── */
.time-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 8px;
}
.time-num-input {
  font-size: 2.5rem;
  font-family: inherit;
  font-weight: bold;
  width: 90px;
  text-align: center;
  border: 4px dashed #a29bfe;
  border-radius: 16px;
  color: #6c5ce7;
  background: #f5f3ff;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  padding: 4px 6px;
}
.time-num-input:focus { border-color: #6c5ce7; background: #eae6ff; }
.time-num-input.correct-input { border-color: #27ae60; background: #eafaf1; color: #27ae60; animation: pop 0.3s; }
.time-num-input.wrong-input   { border-color: #e74c3c; background: #fdedec; color: #e74c3c; animation: shake 0.4s; }
.time-colon { font-size: 2.8rem; font-weight: bold; color: #555; line-height: 1; }

/* ── MYTIMES ── */
.clock-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 22px;
}
.clock-wrap svg {
  width: 220px; height: 220px;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.18));
}

.time-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
.time-choice-btn {
  padding: 14px 10px;
  font-size: 1.5rem;
  font-family: inherit;
  font-weight: bold;
  border: 4px solid #a29bfe;
  border-radius: 18px;
  background: #f5f3ff;
  color: #6c5ce7;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s, border-color 0.15s;
  box-shadow: 0 4px 0 #a29bfe;
}
.time-choice-btn:hover:not(:disabled) { background: #eae6ff; transform: translateY(-2px); box-shadow: 0 6px 0 #a29bfe; }
.time-choice-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a29bfe; }
.time-choice-btn.choice-correct { background: #eafaf1; border-color: #27ae60; color: #27ae60; box-shadow: 0 4px 0 #27ae60; animation: pop 0.35s; }
.time-choice-btn.choice-wrong   { background: #fdedec; border-color: #e74c3c; color: #e74c3c; box-shadow: 0 4px 0 #e74c3c; animation: shake 0.4s; }
.time-choice-btn.fifth { grid-column: 1 / -1; max-width: 260px; margin: 0 auto; width: 100%; }

/* ── MYPATTERNS ── */
.pattern-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 18px 0 10px;
  min-height: 64px;
}
.pat-tile {
  width: 54px; height: 54px;
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: #f0f0f0;
  user-select: none;
}
.pat-blank {
  width: 54px; height: 54px;
  border: 3px dashed #a29bfe;
  border-radius: 12px;
  background: #f5f3ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #a29bfe; font-weight: bold;
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
}
.pat-blank.filled   { font-size: 2rem; border-style: solid; }
.pat-blank.active   { border-color: #6c5ce7; background: #eae6ff; color: #6c5ce7; animation: pulse 1s ease-in-out infinite; }
.pat-blank.correct  { border-color: #27ae60; background: #eafaf1; font-size: 2rem; animation: pop 0.3s; }
.pat-blank.wrong    { border-color: #e74c3c; background: #fdedec; font-size: 2rem; animation: shake 0.4s; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(108,92,231,0.4); } 50% { box-shadow: 0 0 0 6px rgba(108,92,231,0); } }

.pat-choices {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap; margin-top: 14px;
}
.pat-choice-btn {
  width: 62px; height: 62px; font-size: 2.2rem;
  border: 3px solid #a29bfe; border-radius: 16px;
  background: #f5f3ff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 #a29bfe;
  transition: transform 0.12s, box-shadow 0.12s;
}
.pat-choice-btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 7px 0 #a29bfe; }
.pat-choice-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a29bfe; }
.pat-choice-btn.choice-correct { border-color: #27ae60; background: #eafaf1; box-shadow: 0 4px 0 #27ae60; animation: pop 0.35s; }
.pat-choice-btn.choice-wrong   { border-color: #e74c3c; background: #fdedec; box-shadow: 0 4px 0 #e74c3c; animation: shake 0.4s; }
.pat-choice-pair { width: auto; min-width: 110px; gap: 6px; padding: 8px 14px; height: 62px; }

.pat-palette-wrap {
  margin-top: 14px;
  background: rgba(162,155,254,0.12);
  border-radius: 18px;
  padding: 12px;
}
.pat-palette-label {
  font-size: 0.85rem; color: #aaa; letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 10px;
}
.pat-palette {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.pat-palette-item {
  width: 62px; height: 62px; font-size: 2.2rem;
  border: 3px solid #a29bfe; border-radius: 16px;
  background: #f5f3ff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 #a29bfe;
  transition: transform 0.12s, box-shadow 0.12s;
}
.pat-palette-item:hover:not(:disabled) { transform: translateY(-3px) scale(1.05); box-shadow: 0 7px 0 #a29bfe; }
.pat-palette-item:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a29bfe; }
.pat-palette-item:disabled { opacity: 0.35; cursor: default; transform: none; }

footer {
  margin-top: 20px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
}

/* ── MYSHAPES ── */
.shape-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 22px;
}
.shape-wrap svg {
  width: 210px; height: 210px;
  filter: drop-shadow(0 5px 14px rgba(0,0,0,0.16));
}

.shape-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
.shape-choice-btn {
  padding: 14px 10px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: bold;
  border: 4px solid #a29bfe;
  border-radius: 18px;
  background: #f5f3ff;
  color: #6c5ce7;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s, border-color 0.15s,
              font-size 0.25s ease, padding 0.25s ease;
  box-shadow: 0 4px 0 #a29bfe;
}
.shape-choice-btn:hover:not(:disabled) { background: #eae6ff; transform: translateY(-2px); box-shadow: 0 6px 0 #a29bfe; }
.shape-choice-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a29bfe; }
.shape-choice-btn.choice-correct { background: #eafaf1; border-color: #27ae60; color: #27ae60; box-shadow: 0 4px 0 #27ae60; animation: pop 0.35s; }
.shape-choice-btn.choice-wrong   { background: #fdedec; border-color: #e74c3c; color: #e74c3c; box-shadow: 0 4px 0 #e74c3c; animation: shake 0.4s; }

/* ── MYCALENDAR ── */
.cal-display {
  font-size: 2.2rem;
  font-weight: 800;
  color: #6c5ce7;
  background: #f5f3ff;
  border: 4px solid #a29bfe;
  border-radius: 18px;
  padding: 16px 28px;
  margin: 10px auto;
  display: inline-block;
}

/* ── MYLANGUAGE ── */
.sub-game-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
}

.sub-game-btn {
  padding: 10px 22px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: bold;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  background: rgba(255,255,255,0.6);
  color: #555;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s, color 0.2s,
              font-size 0.25s ease, padding 0.25s ease;
}
.sub-game-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.sub-game-btn.active {
  background: #a29bfe;
  color: white;
  box-shadow: 0 4px 0 #6c5ce7;
  transform: translateY(-2px);
}

.syllables-word {
  font-size: 3rem;
  font-weight: bold;
  color: #2c3e50;
  margin: 12px 0 4px;
  letter-spacing: 2px;
}

.syllables-hint {
  font-size: 0.85rem;
  color: #a29bfe;
  font-weight: bold;
  min-height: 1.3rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.syllables-input {
  font-size: 1.6rem;
  font-family: inherit;
  font-weight: bold;
  width: 100%;
  max-width: 320px;
  text-align: center;
  border: 4px dashed #a29bfe;
  border-radius: 16px;
  color: #6c5ce7;
  background: #f5f3ff;
  outline: none;
  padding: 10px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.syllables-input:focus { border-color: #6c5ce7; background: #eae6ff; }
.syllables-input.correct-input { border-color: #27ae60; background: #eafaf1; color: #27ae60; animation: pop 0.3s; }
.syllables-input.wrong-input   { border-color: #e74c3c; background: #fdedec; color: #e74c3c; animation: shake 0.4s; }

.syllables-boxes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 12px 0 8px;
}
.syllable-box {
  font-size: 1.6rem;
  font-family: inherit;
  font-weight: bold;
  text-align: center;
  border: 4px dashed #a29bfe;
  border-radius: 12px;
  color: #6c5ce7;
  background: #f5f3ff;
  outline: none;
  padding: 8px 6px;
  transition: border-color 0.2s, background 0.2s;
  min-width: 2ch;
}
.syllable-box:focus { border-color: #6c5ce7; background: #eae6ff; }
.syllable-box.correct-input { border-color: #27ae60; background: #eafaf1; color: #27ae60; animation: pop 0.3s; }
.syllable-box.wrong-input   { border-color: #e74c3c; background: #fdedec; color: #e74c3c; animation: shake 0.4s; }
.syl-hyphen {
  font-size: 2rem;
  font-weight: bold;
  color: #6c5ce7;
  line-height: 1;
  user-select: none;
}


/* ── TEST MODE ── */
body.test-active .top-nav          { display: none; }
body.test-active .section > h1     { display: none; }
body.test-active .score-bar        { display: none; }
body.test-active .op-buttons       { display: none; }
body.test-active .progress-row     { display: none; }

#testBar {
  width: 100%;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 12px 16px;
  margin-bottom: 24px;
}
.test-bar-content {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 620px;
  margin: 0 auto;
}
#testBarText {
  font-weight: bold;
  font-size: 1rem;
  white-space: nowrap;
  color: #6c5ce7;
  min-width: 130px;
}
.test-bar-track {
  flex: 1;
  height: 14px;
  background: rgba(255,255,255,0.5);
  border-radius: 50px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.test-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a29bfe, #6c5ce7);
  border-radius: 50px;
  transition: width 0.4s ease;
}
.test-end-btn {
  padding: 8px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: bold;
  background: #ff7675;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 #c0392b;
  transition: transform 0.15s, box-shadow 0.15s;
}
.test-end-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c0392b; }

.test-num-input {
  width: 72px;
  padding: 8px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: bold;
  text-align: center;
  border: 3px solid #a29bfe;
  border-radius: 12px;
  color: #6c5ce7;
  background: #f5f3ff;
  outline: none;
}
.test-num-input:focus { border-color: #6c5ce7; }

.test-game-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  width: 100%;
  margin-top: 6px;
}
.test-game-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.test-game-check:hover { background: #f0eeff; }
.test-game-check-all {
  grid-column: 1 / -1;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  margin-bottom: 2px;
}
.test-game-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #6c5ce7;
  cursor: pointer;
  flex-shrink: 0;
}

.start-test-btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: bold;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 0 #4a3cb8;
  transition: transform 0.15s, box-shadow 0.15s;
}
.start-test-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4a3cb8; }

.test-result-pct {
  font-size: 4rem;
  font-weight: bold;
  color: #6c5ce7;
  margin: 8px 0 18px;
  text-shadow: 2px 2px 0 #a29bfe;
}
.test-result-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.test-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 1.15rem;
  font-weight: bold;
}
.correct-row { background: #eafaf1; color: #27ae60; }
.wrong-row   { background: #fdedec; color: #e74c3c; }
.total-row   { background: #f0f0ff; color: #6c5ce7; }
.test-result-num { margin-left: auto; font-size: 1.5rem; }
.test-result-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* ── MYSEQUENCES ── */
.sequence-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 4px;
  margin: 18px 0 10px;
  font-size: 2rem;
  font-weight: 800;
}

.seq-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: 6px 10px;
  background: #e8f4fd;
  border-radius: 12px;
  color: #2d3436;
}

.seq-comma {
  color: #999;
  font-weight: 400;
  font-size: 1.6rem;
  align-self: flex-end;
  margin-bottom: 4px;
}

.seq-blank {
  width: 3.4rem;
  font-size: inherit;
  font-family: inherit;
  font-weight: 800;
  text-align: center;
  border: 3px solid #a78bfa;
  border-radius: 12px;
  padding: 6px 4px;
  background: #f3f0ff;
  color: #5b21b6;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  /* hide number spinner arrows */
  -moz-appearance: textfield;
}
.seq-blank::-webkit-outer-spin-button,
.seq-blank::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.seq-blank:focus {
  border-color: #7c3aed;
  background: #ede9fe;
}

.seq-blank.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  color: #b91c1c;
}

/* ── VIEWPORT FIT ── */
/* Scales all vertical spacing and font sizes so content always fits on screen */

html { height: 100%; }

body {
  height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
}

footer { display: none; }

.section.visible {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.top-nav {
  padding: clamp(6px, 1.2vh, 14px) 16px;
  margin-bottom: clamp(8px, 1.5vh, 24px);
}

.nav-btn {
  padding: clamp(8px, 1.2vh, 12px) clamp(12px, 1.5vw, 28px);
  font-size: clamp(0.85rem, 1.8vh, 1.25rem);
}

h1 {
  font-size: clamp(1.4rem, 3.5vh, 2.8rem);
  margin-bottom: clamp(4px, 1vh, 10px);
}

.score-bar {
  font-size: clamp(0.8rem, 1.6vh, 1.15rem);
  padding: clamp(6px, 1vh, 10px) clamp(12px, 2vw, 28px);
  margin-bottom: clamp(8px, 1.5vh, 20px);
}

.op-buttons {
  gap: clamp(6px, 1vw, 12px);
  margin-bottom: clamp(8px, 1.5vh, 25px);
}

.op-btn {
  padding: clamp(8px, 1.2vh, 12px) clamp(10px, 1.5vw, 22px);
  font-size: clamp(0.85rem, 1.8vh, 1.3rem);
}

.card {
  padding: clamp(14px, 2vh, 35px) clamp(20px, 3vw, 45px);
}

.question-label {
  font-size: clamp(0.75rem, 1.5vh, 1rem);
  margin-bottom: clamp(4px, 0.8vh, 8px);
}

.stars {
  font-size: clamp(1.2rem, 2.5vh, 2rem);
  min-height: clamp(1.5rem, 3vh, 2.5rem);
  margin-bottom: clamp(2px, 0.5vh, 4px);
}

.equation {
  font-size: clamp(1.8rem, 4.5vh, 3rem);
  gap: clamp(8px, 1.5vw, 16px);
  margin: clamp(8px, 1.5vh, 20px) 0;
}

.feedback {
  font-size: clamp(1.2rem, 2.5vh, 2rem);
  min-height: clamp(1.5rem, 3vh, 2.5rem);
  margin: clamp(6px, 1vh, 12px) 0 clamp(2px, 0.5vh, 4px);
}

.submit-btn {
  margin-top: clamp(10px, 1.8vh, 25px);
  padding: clamp(10px, 1.5vh, 14px) clamp(24px, 3vw, 45px);
  font-size: clamp(1rem, 2vh, 1.5rem);
}

.next-btn {
  margin-top: clamp(8px, 1.2vh, 15px);
  padding: clamp(8px, 1.2vh, 12px) clamp(18px, 2.5vw, 35px);
  font-size: clamp(0.9rem, 1.8vh, 1.2rem);
}

.progress-row {
  margin-top: clamp(8px, 1.5vh, 22px);
}

.pip {
  width: clamp(10px, 1.8vh, 18px);
  height: clamp(10px, 1.8vh, 18px);
}

.clock-wrap {
  margin: clamp(8px, 1.5vh, 18px) 0 clamp(10px, 2vh, 22px);
}

.clock-wrap svg {
  width: clamp(140px, 22vh, 220px);
  height: clamp(140px, 22vh, 220px);
}

.shape-wrap {
  margin: clamp(8px, 1.5vh, 18px) 0 clamp(10px, 2vh, 22px);
}

.shape-wrap svg {
  width: clamp(140px, 22vh, 210px);
  height: clamp(140px, 22vh, 210px);
}

.sub-game-nav {
  margin-bottom: clamp(8px, 1.5vh, 18px);
}

.sub-game-btn {
  padding: clamp(8px, 1.2vh, 10px) clamp(14px, 2vw, 22px);
  font-size: clamp(0.9rem, 1.8vh, 1.15rem);
}

.syllables-word {
  font-size: clamp(1.8rem, 4.5vh, 3rem);
  margin: clamp(6px, 1vh, 12px) 0 clamp(2px, 0.5vh, 4px);
}

.syllables-hint {
  margin-bottom: clamp(6px, 1vh, 10px);
}

.syllables-input {
  font-size: clamp(1.1rem, 2.5vh, 1.6rem);
  padding: clamp(8px, 1.2vh, 10px) 16px;
}

.syllable-box {
  font-size: clamp(1.1rem, 2.5vh, 1.6rem);
  padding: clamp(6px, 1vh, 8px) 6px;
}

.syl-hyphen {
  font-size: clamp(1.4rem, 3vh, 2rem);
}

.sequence-row {
  font-size: clamp(1.4rem, 3.5vh, 2rem);
  margin: clamp(10px, 1.8vh, 18px) 0 clamp(6px, 1vh, 10px);
}

.seq-blank {
  width: clamp(2.8rem, 5vw, 3.4rem);
  font-size: inherit;
}

/* ── LANGUAGE-ADAPTIVE SIZING ── */
/* applyLang() sets document.documentElement.lang — these selectors fire instantly on switch */

[lang="af"] .nav-btn {
  font-size: 1.05rem;
  padding: 10px 16px;
}

[lang="af"] .op-btn {
  font-size: 1rem;
  padding: 10px 14px;
}

[lang="af"] .modal-box {
  max-width: 480px;
  min-width: 360px;
}

[lang="af"] .setting-label {
  font-size: 0.95rem;
}

[lang="af"] .setting-row {
  gap: 10px;
}

[lang="af"] .shape-choice-btn {
  font-size: 0.92rem;
  padding: 12px 8px;
}

[lang="xh"] .nav-btn {
  font-size: 1.0rem;
  padding: 10px 14px;
}

[lang="xh"] .op-btn {
  font-size: 0.95rem;
  padding: 10px 12px;
}

[lang="xh"] .modal-box {
  max-width: 480px;
  min-width: 360px;
}

[lang="xh"] .setting-label {
  font-size: 0.95rem;
}

[lang="xh"] .setting-row {
  gap: 10px;
}

[lang="xh"] .shape-choice-btn {
  font-size: 0.88rem;
  padding: 12px 6px;
}

[lang="zu"] .nav-btn {
  font-size: 1.0rem;
  padding: 10px 14px;
}

[lang="zu"] .op-btn {
  font-size: 0.95rem;
  padding: 10px 12px;
}

[lang="zu"] .modal-box {
  max-width: 480px;
  min-width: 360px;
}

[lang="zu"] .setting-label {
  font-size: 0.95rem;
}

[lang="zu"] .setting-row {
  gap: 10px;
}

[lang="zu"] .shape-choice-btn {
  font-size: 0.88rem;
  padding: 12px 6px;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  .section.visible { overflow-y: auto; }
  .score-bar {
    gap: 8px 14px;
    padding: 6px 14px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    border-radius: 30px;
  }
  .diff-badge {
    font-size: 0.65em;
    padding: 1px 7px;
  }
}

/* ── MOBILE ── */
@media (max-width: 480px) {
  h1 { font-size: 2rem; }
  .card { padding: 24px 20px; }
  .equation { font-size: 2.4rem; gap: 10px; }
  .answer-input { font-size: 2.4rem; width: 90px; }
  .clock-wrap svg { width: 185px; height: 185px; }
  .time-choice-btn { font-size: 1.25rem; padding: 12px 8px; }
  .nav-btn { padding: 10px 18px; font-size: 1.1rem; }

  [lang="af"] .nav-btn { font-size: 0.88rem; padding: 8px 12px; }
  [lang="af"] .op-btn  { font-size: 0.82rem; padding: 8px 10px; }
  [lang="af"] .modal-box { max-width: 95%; min-width: 0; padding: 28px 20px; }
  [lang="af"] .setting-label { font-size: 0.85rem; }
  [lang="af"] .shape-choice-btn { font-size: 0.78rem; padding: 10px 6px; }
  [lang="xh"] .nav-btn { font-size: 0.82rem; padding: 8px 10px; }
  [lang="xh"] .op-btn  { font-size: 0.78rem; padding: 8px 8px; }
  [lang="xh"] .modal-box { max-width: 95%; min-width: 0; padding: 28px 20px; }
  [lang="xh"] .setting-label { font-size: 0.85rem; }
  [lang="xh"] .shape-choice-btn { font-size: 0.74rem; padding: 10px 4px; }
  [lang="zu"] .nav-btn { font-size: 0.82rem; padding: 8px 10px; }
  [lang="zu"] .op-btn  { font-size: 0.78rem; padding: 8px 8px; }
  [lang="zu"] .modal-box { max-width: 95%; min-width: 0; padding: 28px 20px; }
  [lang="zu"] .setting-label { font-size: 0.85rem; }
  [lang="zu"] .shape-choice-btn { font-size: 0.74rem; padding: 10px 4px; }
  .shape-wrap svg { width: 175px; height: 175px; }
  .score-bar {
    gap: 4px 10px;
    padding: 5px 10px;
    font-size: 0.78rem;
    margin-bottom: 8px;
  }
  .diff-badge {
    font-size: 0.6em;
    padding: 1px 6px;
  }
}
