:root {
  --font: "Baloo 2", "Comic Sans MS", "Segoe UI Rounded", "Nunito", system-ui, sans-serif;
  --ink: #2b2350;
  --panel: #ffffff;
  --shadow: 0 14px 30px rgba(60, 30, 120, .18);
  --radius: 26px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, #eef2ff 0%, #fdf0ff 50%, #fff5e6 100%);
}

h1 { font-size: clamp(1.5rem, 4vw, 2.4rem); margin: 0 0 .4em; }
.lead { font-size: clamp(1rem, 2.4vw, 1.25rem); opacity: .82; margin: 0; }

/* ---------- Buttons ---------- */
.big-btn {
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: .8em 1.6em;
  cursor: pointer;
  background: linear-gradient(135deg, #ff7eb3, #ff758c 40%, #ff6a88);
  box-shadow: 0 10px 0 #d8355f, var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4em;
  line-height: 1.1;
}
.big-btn:hover { filter: brightness(1.05); }
.big-btn:active { transform: translateY(6px); box-shadow: 0 4px 0 #d8355f, var(--shadow); }
.big-btn.reward {
  background: linear-gradient(135deg, #7b2ff7, #f107a3);
  box-shadow: 0 10px 0 #5a1fb8, var(--shadow);
  font-size: clamp(1.3rem, 4vw, 2rem);
  padding: 1em 2em;
  animation: bob 2.4s ease-in-out infinite;
}
.big-btn.reward:active { box-shadow: 0 4px 0 #5a1fb8, var(--shadow); }
.big-btn.ghost {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 0 #d7d0f0, var(--shadow);
}
.big-btn.ghost:active { box-shadow: 0 3px 0 #d7d0f0, var(--shadow); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.spark { animation: twinkle 1.4s ease-in-out infinite; }
.spark:last-child { animation-delay: .7s; }
@keyframes twinkle { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }

/* ---------- Login ---------- */
.login-page {
  display: grid; justify-items: center; align-items: safe center;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  position: relative;
}
.blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.blobs span {
  position: absolute; border-radius: 50%; filter: blur(8px); opacity: .5;
  animation: float 9s ease-in-out infinite;
}
.blobs span:nth-child(1) { width: 180px; height: 180px; background: #ffd166; top: 8%; left: 8%; }
.blobs span:nth-child(2) { width: 140px; height: 140px; background: #06d6a0; top: 70%; left: 12%; animation-delay: 1.5s; }
.blobs span:nth-child(3) { width: 160px; height: 160px; background: #ff8fab; top: 15%; right: 10%; animation-delay: 3s; }
.blobs span:nth-child(4) { width: 120px; height: 120px; background: #4cc9f0; bottom: 10%; right: 14%; animation-delay: 4.5s; }
@keyframes float { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-24px) scale(1.08); } }

.login-card {
  position: relative; z-index: 1;
  background: var(--panel);
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 44px);
  width: min(520px, 100%);
  text-align: center;
  border: 4px solid #fff;
}
.login-emoji { font-size: 4rem; line-height: 1; margin-bottom: .2em; }
.field { display: block; text-align: left; margin: 22px 0 10px; }
.field > span, .field-label { display: block; font-weight: 700; margin-bottom: 8px; }
.field-label { text-align: left; }
.field input {
  width: 100%; font-family: var(--font); font-size: 1.25rem;
  padding: .7em .9em; border: 3px solid #e6e0ff; border-radius: 18px; outline: none;
}
.field input:focus { border-color: #7b2ff7; }

/* ---------- Auth tabs (login / register) ---------- */
.auth-tabs {
  display: flex; gap: 6px; background: #f3f0ff; border-radius: 999px;
  padding: 5px; margin: 20px 0 6px;
}
.auth-tab {
  flex: 1; font-family: var(--font); font-weight: 800; font-size: 1.05rem;
  color: var(--ink); background: transparent; border: none; cursor: pointer;
  padding: .6em 1em; border-radius: 999px; transition: background .15s ease, color .15s ease;
}
.auth-tab.active { background: #fff; color: #7b2ff7; box-shadow: 0 4px 12px rgba(123,47,247,.18); }

.auth-form[hidden] { display: none; }

.auth-error {
  background: #fff0f3; color: #c81d4a; border: 2px solid #ffc2d1;
  border-radius: 16px; padding: .7em 1em; margin: 14px 0 0; font-weight: 700;
}

/* Resend-confirmation button under the login form. */
.auth-resend { display: flex; justify-content: center; margin: 12px 0 0; }

.auth-back { text-align: center; margin: 14px 0 22px; }
.auth-back a { color: #7b2ff7; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.auth-back a:hover { text-decoration-thickness: 2px; }

/* ---------- Photo picker (registration) ---------- */
.photo-picker {
  display: grid; place-items: center; width: 140px; height: 140px; margin: 6px auto 22px;
  border-radius: 24px; border: 3px dashed #cdbcff; background: #f7f4ff;
  cursor: pointer; overflow: hidden; position: relative; transition: border-color .15s ease;
}
.photo-picker:hover { border-color: #7b2ff7; }
.photo-picker img { width: 100%; height: 100%; object-fit: cover; }
.photo-hint { display: grid; gap: 4px; text-align: center; color: #8a7fb0; padding: 8px; }
.photo-hint b { font-size: 2rem; line-height: 1; }
.photo-hint small { font-weight: 700; font-size: .82rem; line-height: 1.25; }
.optional { font-style: normal; font-weight: 700; color: #8a7fb0; font-size: .85em; }

.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 26px; }
.avatar input { position: absolute; opacity: 0; pointer-events: none; }
.avatar span {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 1.7rem;
  background: #f3f0ff; border-radius: 16px; cursor: pointer;
  border: 3px solid transparent; transition: transform .1s ease;
}
.avatar span:hover { transform: scale(1.08); }
.avatar input:checked + span { border-color: #7b2ff7; background: #efe6ff; transform: scale(1.12); }
@media (max-width: 460px) { .avatars { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px); flex-wrap: wrap;
  background: rgba(255,255,255,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 1.3rem; font-weight: 800; text-decoration: none; color: var(--ink); }
.brand span { display: none; }
@media (min-width: 560px) { .brand span { display: inline; } }
.topbar nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--font); font-weight: 700; font-size: .95rem;
  text-decoration: none; color: var(--ink); background: #fff;
  padding: .5em .9em; border-radius: 999px; border: 2px solid #ece7ff; cursor: pointer;
}
.chip.ghost { background: transparent; }
.chip:hover { border-color: #7b2ff7; }
.chip.danger { color: #c81d4a; }
.chip.danger:hover { border-color: #c81d4a; background: #fff0f3; }
.who { font-weight: 800; padding: .3em .6em; display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; border-radius: 999px; transition: background .15s; }
.who:hover { background: rgba(123, 47, 247, .12); }
.who-photo {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(60,30,120,.25);
}
.who-emoji { font-size: 1.3rem; }
.inline { display: inline; margin: 0; }

/* ---------- App stage ---------- */
.stage {
  max-width: 1040px; margin: 0 auto;
  padding: clamp(16px, 4vw, 36px);
  padding-bottom: calc(clamp(16px, 4vw, 36px) + env(safe-area-inset-bottom) + 24px);
}
.hero { text-align: center; margin-bottom: 22px; }

/* ---------- Teacher panel ---------- */
.teacher-panel {
  background: #fff; border: 3px dashed #cdbcff; border-radius: var(--radius);
  padding: 16px clamp(14px, 3vw, 24px); margin-bottom: 22px; box-shadow: var(--shadow);
}
.tp-title { font-weight: 800; font-size: 1.1rem; margin-bottom: 12px; }
.tp-note { font-weight: 600; font-size: .85rem; opacity: .55; }
.grades { display: flex; gap: 12px; flex-wrap: wrap; }
.grade-btn {
  font-family: var(--font); cursor: pointer; color: #fff; border: none;
  border-radius: 18px; padding: 10px 18px; min-width: 118px; text-align: center;
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
  box-shadow: 0 6px 0 rgba(0,0,0,.18); transition: transform .08s ease;
}
.grade-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.grade-btn b { font-size: 1.5rem; }
.grade-btn span { font-weight: 700; }
.grade-btn small { font-size: .78rem; opacity: .9; margin-top: 2px; }
.grade-btn.g5 { background: linear-gradient(135deg, #06d6a0, #1b9e77); }
.grade-btn.g4 { background: linear-gradient(135deg, #4cc9f0, #4361ee); }
.grade-btn.g3 { background: linear-gradient(135deg, #ffb703, #fb8500); }

/* ---------- Pulls badge ---------- */
.pulls {
  display: inline-block; margin-top: 14px; font-weight: 800; font-size: 1.1rem;
  background: #fff; padding: .5em 1.1em; border-radius: 999px; box-shadow: var(--shadow);
  border: 3px solid #ffd166;
}
.pulls.empty { border-color: #e6e0ff; opacity: .7; }
.pulls b { color: #7b2ff7; }

/* ---------- Disabled buttons ---------- */
.big-btn:disabled {
  filter: grayscale(.6); opacity: .5; cursor: not-allowed;
  animation: none; transform: none;
}

.themes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 30px;
}
.theme-card {
  font-family: var(--font); text-align: center; cursor: pointer; color: #fff;
  border: none; border-radius: var(--radius); padding: 18px 12px;
  background: linear-gradient(150deg, var(--from), var(--to));
  box-shadow: var(--shadow); position: relative;
  transition: transform .12s ease, outline-color .12s ease;
  outline: 4px solid transparent; outline-offset: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.theme-card:hover { transform: translateY(-4px) scale(1.02); }
.theme-card[aria-pressed="true"] { outline-color: #ffd166; transform: translateY(-2px) scale(1.03); }
.theme-card[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 8px; right: 12px;
  background: #fff; color: #7b2ff7; font-weight: 900; border-radius: 999px;
  width: 26px; height: 26px; display: grid; place-items: center; font-size: .9rem;
}
.theme-icon { font-size: 2.6rem; line-height: 1; }
.theme-icon img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); vertical-align: middle;
}
.theme-title { font-weight: 800; font-size: 1.15rem; }
.theme-sub { font-size: .82rem; opacity: .9; }
.theme-count {
  margin-top: 6px; font-weight: 800; font-size: .82rem; color: #fff;
  background: rgba(0,0,0,.22); border-radius: 999px; padding: .25em .7em;
}
.theme-card.done { filter: saturate(.8); }
.theme-card.done .theme-count { background: rgba(255,255,255,.9); color: #1b9e77; }

.cta { text-align: center; margin: 10px 0 40px; }
.hint { margin-top: 14px; opacity: .8; }

/* ---------- Reveal overlay ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at center, rgba(40,10,80,.72), rgba(20,5,45,.92));
  backdrop-filter: blur(3px); padding: 20px;
}
.reveal[hidden] { display: none; }
.reveal canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.reveal-inner { position: relative; text-align: center; z-index: 1; }
.card-holder { display: inline-block; }
.card-holder svg {
  width: min(78vw, 300px); height: auto; filter: drop-shadow(0 20px 40px rgba(0,0,0,.45));
  animation: pop .7s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes pop {
  0% { transform: scale(.1) rotate(-30deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* uploaded picture shown in the reveal */
.custom-card {
  width: min(78vw, 300px); background: #fff; border-radius: 26px; padding: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,.45); border: 6px solid #ffd166;
  animation: pop .7s cubic-bezier(.2,1.5,.4,1) both;
}
.custom-card img {
  width: 100%; max-height: 60vh; object-fit: contain; border-radius: 16px; display: block;
}
.cc-name { margin-top: 10px; font-weight: 800; color: var(--ink); font-size: 1.1rem; }

.rarity-line { color: #fff; font-size: 1.4rem; font-weight: 800; margin: 16px 0 6px; min-height: 1.4em; }
.reveal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.saved-note { color: #d7ffe6; font-weight: 700; margin-top: 14px; }

/* ---------- Cabinet ---------- */
.cabinet-head {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: #fff; border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow); margin-bottom: 24px;
}
.cabinet-head h1 { margin: 0; }
.cabinet-head > .big-btn { margin-left: auto; }
.cabinet-actions {
  margin-left: auto; display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.photo-upload { margin: 0; }
.photo-upload .big-btn { display: inline-flex; align-items: center; cursor: pointer; }
.big-avatar {
  font-size: 3rem; width: 84px; height: 84px; display: grid; place-items: center;
  background: linear-gradient(150deg, #a18cd1, #fbc2eb); border-radius: 24px;
  overflow: hidden; flex: none;
}
.big-avatar img { width: 100%; height: 100%; object-fit: cover; }

.collection { margin-bottom: 30px; }
.collection-head {
  display: flex; align-items: center; gap: 12px; margin: 0 0 14px;
}
.collection-head h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.6rem); }
.collection-count {
  font-weight: 800; font-size: .95rem; color: #7b2ff7;
  background: #fff; padding: .35em .9em; border-radius: 999px;
  box-shadow: var(--shadow); border: 2px solid #ece7ff;
}

.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px;
}
.card-cell { display: flex; flex-direction: column; gap: 6px; }
.card-meta {
  margin: 0; text-align: center; line-height: 1.35;
  display: flex; flex-direction: column; gap: 1px;
}
.card-meta .cm-from { font-weight: 700; font-size: .85rem; color: var(--ink); }
.card-meta .cm-when { font-size: .78rem; font-weight: 600; opacity: .6; }
.collected {
  margin: 0; border-radius: 22px; overflow: hidden; background: #fff;
  box-shadow: var(--shadow); transition: transform .12s ease;
}
.collected:hover { transform: translateY(-5px) rotate(-1deg); }
.collected img { display: block; width: 100%; height: auto; }
.rarity-legendary { box-shadow: 0 0 0 3px #ffd700, var(--shadow); }
.rarity-rare { box-shadow: 0 0 0 3px #7cc4ff, var(--shadow); }
.collected.custom { box-shadow: 0 0 0 3px #ffd166, var(--shadow); }
.collected.custom img { aspect-ratio: 3 / 4; object-fit: cover; }
.collected figcaption {
  padding: 8px 12px; font-weight: 700; font-size: .9rem; text-align: center;
  color: var(--ink); background: #fff;
}

/* A collected picture doubling as an "use as avatar" button. */
.collected-form { margin: 0; }
button.collected.as-avatar {
  display: block; width: 100%; padding: 0; border: none; font: inherit;
  color: inherit; text-align: inherit; cursor: pointer;
}
button.collected.as-avatar:focus-visible { outline: 3px solid #7b2ff7; outline-offset: 2px; }
.avatar-hint { margin: 6px 0 0; font-weight: 700; color: #7b2ff7; }
.reset-avatar { margin: 0; }

.empty { text-align: center; background: #fff; border-radius: var(--radius); padding: 50px 24px; box-shadow: var(--shadow); }
.empty-emoji { font-size: 4rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #2b2350; color: #fff; padding: .8em 1.4em; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow); opacity: 0; transition: all .3s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Role picker (registration) ---------- */
.role-picker { display: flex; gap: 10px; margin: 6px 0 4px; }
.role-option { flex: 1; cursor: pointer; }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }
.role-option span {
  display: block; text-align: center; font-weight: 800; font-size: 1.05rem;
  padding: .8em .5em; border-radius: 18px; background: #f3f0ff;
  border: 3px solid transparent; transition: transform .1s ease, border-color .12s ease;
}
.role-option span:hover { transform: scale(1.03); }
.role-option input:checked + span {
  border-color: #7b2ff7; background: #efe6ff; color: #7b2ff7;
}

.role-badge {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: #7b2ff7; background: #efe6ff; border-radius: 999px; padding: .2em .6em;
}

/* ---------- Flash messages (teacher dashboard) ---------- */
.flash {
  font-weight: 700; border-radius: 16px; padding: .8em 1.1em; margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.flash.ok { background: #e6fff4; color: #0a7d55; border: 2px solid #9be9c9; }
.flash.bad { background: #fff0f3; color: #c81d4a; border: 2px solid #ffc2d1; }

/* ---------- Premium ---------- */
.premium {
  background: linear-gradient(135deg, #fff9e6, #fff);
  border: 2px solid #ffe4a3; border-radius: var(--radius);
  padding: 20px clamp(16px, 3vw, 26px); box-shadow: var(--shadow); margin-bottom: 24px;
}
.premium-plans { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Teacher roster ---------- */
.roster {
  background: #fff; border-radius: var(--radius); padding: 20px clamp(16px, 3vw, 26px);
  box-shadow: var(--shadow); margin-bottom: 24px;
}
.add-student { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.add-student input {
  flex: 1 1 240px; min-width: 0; font-family: var(--font); font-size: 1.15rem;
  padding: .7em .9em; border: 3px solid #e6e0ff; border-radius: 18px; outline: none;
}
.add-student input:focus { border-color: #7b2ff7; }
.add-student .big-btn { flex: none; }

/* ---------- Class invite (code + link) ---------- */
.invite-box {
  background: linear-gradient(135deg, #f3ecff, #eafff6);
  border: 2px dashed #cdbcff; border-radius: 20px;
  padding: 14px 16px; margin: 4px 0 8px;
}
.invite-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.invite-label { font-weight: 700; opacity: .7; }
.invite-code {
  font-size: 1.7rem; letter-spacing: .14em; font-weight: 800; color: #7b2ff7;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.invite-hint { margin: 6px 0 12px; font-weight: 600; opacity: .75; }
.invite-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.invite-link {
  flex: 1 1 260px; min-width: 0; font-size: .95rem; padding: .55em .7em;
  border: 2px solid #e6e0ff; border-radius: 14px; background: #fff; color: var(--ink);
}
.invite-link:focus { outline: none; border-color: #7b2ff7; }
.or-manual { margin: 12px 0 8px; font-weight: 700; opacity: .55; }

/* ---------- Student's classes ---------- */
.my-classes {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px;
}
.mc-label { font-weight: 800; }
.mc-chip {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700;
  background: #fff; border: 2px solid #e6e0ff; border-radius: 999px;
  padding: 5px 14px 5px 6px; box-shadow: var(--shadow);
}
.mc-chip img {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block;
}
.mc-chip .mc-emoji {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #f3ecff; font-size: 1.1rem;
}

/* ---------- Join a class by code (student cabinet) ---------- */
.join-class {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: #fff; border-radius: 20px; padding: 14px 16px;
  box-shadow: var(--shadow); margin: 0 0 22px;
}
.join-class .jc-label { font-weight: 700; flex: 1 1 100%; }
.join-class input {
  flex: 0 1 220px; min-width: 0; font-family: var(--font); font-size: 1.1rem;
  padding: .6em .8em; border: 3px solid #e6e0ff; border-radius: 16px; outline: none;
  text-transform: uppercase; letter-spacing: .08em;
}
.join-class input:focus { border-color: #7b2ff7; }

.auth-note {
  background: #eef7ff; color: #22456b; border: 2px solid #bfe0ff;
  border-radius: 14px; padding: .7em 1em; font-weight: 700; margin: 0 0 14px;
}

.muted { opacity: .7; font-weight: 600; }

.student-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.student-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #f7f4ff; border-radius: 20px; padding: 10px 14px;
}
.student-link {
  flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--ink);
}
.student-ava {
  width: 48px; height: 48px; flex: none; border-radius: 14px; overflow: hidden;
  display: grid; place-items: center; font-size: 1.6rem;
  background: linear-gradient(150deg, #a18cd1, #fbc2eb);
}
.student-ava img { width: 100%; height: 100%; object-fit: cover; }
.student-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.student-info b { font-size: 1.1rem; }
.student-info small { opacity: .6; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.student-link:hover b { color: #7b2ff7; }
.student-cards {
  font-weight: 800; font-size: .9rem; color: #7b2ff7;
  background: #fff; padding: .3em .8em; border-radius: 999px; border: 2px solid #ece7ff;
}
.reward-student {
  flex: none; font-weight: 800; color: #fff; border: none;
  background: linear-gradient(135deg, #7b2ff7, #f107a3);
}
.reward-student:hover { filter: brightness(1.06); }

/* ---------- Teacher's own collections ---------- */
.collections-manage {
  background: #fff; border-radius: var(--radius); padding: 20px clamp(16px, 3vw, 26px);
  box-shadow: var(--shadow); margin-bottom: 24px;
}
.new-collection {
  display: grid; gap: 12px; margin: 14px 0 20px;
  background: #f7f4ff; border-radius: 20px; padding: 16px;
}
.nc-row { display: flex; gap: 12px; flex-wrap: wrap; }
.nc-icon, .nc-title {
  font-family: var(--font); font-size: 1.1rem; padding: .6em .8em;
  border: 3px solid #e6e0ff; border-radius: 16px; outline: none; background: #fff;
}
.nc-icon { flex: none; width: 74px; text-align: center; }
.nc-title { flex: 1 1 240px; min-width: 0; }
.nc-icon:focus, .nc-title:focus { border-color: #7b2ff7; }

/* Emoji picker (collection icon) */
.emoji-picker { position: relative; flex: none; }
.nc-icon.emoji-trigger {
  width: 74px; font-size: 1.8rem; line-height: 1.1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.nc-icon.emoji-trigger:hover { border-color: #7b2ff7; }
.emoji-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  width: 288px; max-width: 80vw; background: #fff; border: 3px solid #e6e0ff;
  border-radius: 16px; padding: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18);
  display: grid; gap: 8px;
}
.emoji-pop[hidden] { display: none; }
.emoji-custom {
  font-family: var(--font); font-size: 1.1rem; padding: .45em .7em;
  border: 2px solid #e6e0ff; border-radius: 12px; outline: none; background: #fff;
}
.emoji-custom:focus { border-color: #7b2ff7; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  max-height: 220px; overflow-y: auto;
}
.emoji-cell {
  border: none; background: none; cursor: pointer; padding: 0;
  aspect-ratio: 1; font-size: 1.4rem; line-height: 1; border-radius: 10px;
  display: grid; place-items: center;
}
.emoji-cell:hover { background: #f0ebff; }
.emoji-cell:focus-visible { outline: 2px solid #7b2ff7; outline-offset: -2px; }
.emoji-cell[aria-selected="true"] { background: #ece2ff; box-shadow: inset 0 0 0 2px #7b2ff7; }

.file-drop {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer;
  border: 3px dashed #cdbcff; border-radius: 16px; padding: 12px 14px; background: #fff;
}
.file-drop:hover { border-color: #7b2ff7; }
.file-drop .col-file, .file-drop .cover-file { flex: none; max-width: 220px; }
.fd-btn { font-weight: 800; color: #7b2ff7; }
.fd-hint { opacity: .65; font-weight: 600; }
.fd-preview { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.fd-preview:empty { display: none; }
.fd-preview figure { margin: 0; }
.fd-preview img {
  display: block; width: 64px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.fd-preview.ratio-square img { aspect-ratio: 1 / 1; object-fit: cover; }
.fd-preview.ratio-portrait img { aspect-ratio: 3 / 4; object-fit: cover; }
.new-collection .big-btn { justify-self: start; }

.collection-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.collection-item { background: #f7f4ff; border-radius: 20px; padding: 12px 14px; }
.ci-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ci-icon { font-size: 1.5rem; }
.ci-icon img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.14); vertical-align: middle;
}
.ci-title { font-size: 1.1rem; }
.ci-count {
  font-weight: 800; font-size: .85rem; color: #7b2ff7;
  background: #fff; padding: .3em .7em; border-radius: 999px; border: 2px solid #ece7ff;
}
.ci-delete { margin-left: auto; }
.ci-thumbs {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0;
}
.ci-thumbs img {
  width: 60px; height: 60px; object-fit: contain; border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.ci-add .chip { cursor: pointer; }
.theme-card.custom-theme[aria-pressed="true"] { outline-color: #ffd166; }

.new-puzzle { margin-top: -6px; }
.new-puzzle .nc-icon {
  font-size: 1.8rem; display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Puzzle collection ----------
   Each piece is a jigsaw-shaped (transparent-PNG) cutout sized a bit bigger
   than its grid cell, so its tab can bulge into the neighbouring cell; every
   cell carries an inline left/top/width/height (in %) that places it
   pixel-perfectly. In a student's own cabinet the pieces start in a tray
   below the board (puzzle.js) and the student drags each one onto the board
   themselves; a "slot" tile marks every grid cell (empty or not) so the
   board always shows the full picture's shape, faintly, through the cover
   background-image peeking past the semi-transparent fog stripes. */
.puzzle-wrap { max-width: 480px; }
.puzzle-board {
  position: relative; max-width: 480px; border-radius: 18px;
  overflow: hidden; box-shadow: var(--shadow); background: #ece2ff no-repeat center/cover;
}
.puzzle-slot {
  position: absolute; z-index: 0; box-sizing: border-box;
  border: 1px dashed rgba(123, 47, 247, .2);
  background: repeating-linear-gradient(45deg,
    rgba(236, 226, 255, .82), rgba(236, 226, 255, .82) 10px,
    rgba(226, 216, 251, .82) 10px, rgba(226, 216, 251, .82) 20px);
}
.puzzle-piece {
  margin: 0; padding: 0; border: none; background: none;
  opacity: 0; transition: opacity .15s ease;
  cursor: grab; touch-action: none;
}
.puzzle-piece.ready { opacity: 1; }
.puzzle-piece img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  pointer-events: none; -webkit-user-drag: none; user-select: none;
}
.puzzle-piece.in-tray { position: relative; width: 92px; height: 92px; }
.puzzle-piece.on-board { position: absolute; z-index: 1; }
.puzzle-piece.dragging {
  cursor: grabbing; z-index: 1000 !important;
  filter: drop-shadow(0 10px 16px rgba(43, 35, 80, .4));
}
.puzzle-hint { margin: 10px 0 0; font-weight: 700; color: #7b2ff7; text-align: center; }
.puzzle-tray {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; min-height: 10px;
}
.puzzle-solved {
  margin: 14px 0 0; max-width: 320px; background: #fff; border-radius: 999px;
  padding: 10px 20px; box-shadow: var(--shadow); border: 3px solid #ffd166;
  text-align: center; font-weight: 800; color: #7b2ff7;
}

/* ---------- Award panel (teacher) ---------- */
.award-panel {
  background: #fff; border: 3px dashed #cdbcff; border-radius: var(--radius);
  padding: 18px clamp(14px, 3vw, 24px); margin-bottom: 24px; box-shadow: var(--shadow);
}
.award-panel[hidden] { display: none; }
.award-panel .tp-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.award-panel .tp-title .chip { margin-left: auto; }
.award-panel .themes { margin-top: 14px; }

.gift-count { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.gift-count-label { font-weight: 800; }
.count-chip {
  font-family: var(--font); font-weight: 800; font-size: 1.05rem;
  color: var(--ink); background: #fff; cursor: pointer;
  padding: .45em 1em; border-radius: 999px; border: 3px solid #ece7ff;
}
.count-chip:hover { border-color: #7b2ff7; }
.count-chip[aria-pressed="true"] {
  border-color: #7b2ff7; background: #f3ecff; box-shadow: 0 3px 0 #d7c9ff;
}
.count-chip:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* ---------- Welcome gift (student's first cabinet visit) ---------- */
.welcome-gift {
  border-color: #ffd166; background: linear-gradient(180deg, #fffaf0, #fff);
}
.welcome-gift .tp-title { font-size: 1.3rem; }

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

/* ---------- Admin panel ---------- */
.admin-premium-badge {
  font-weight: 800; font-size: .9rem; color: #b8860b;
  background: #fff9e6; padding: .3em .8em; border-radius: 999px; border: 2px solid #ffe4a3;
}
.admin-premium-form { display: flex; align-items: center; gap: 6px; }
.admin-premium-form input {
  width: 4.5em; font-family: var(--font); font-size: .95rem; text-align: center;
  padding: .5em .3em; border: 2px solid #ece7ff; border-radius: 12px; outline: none;
}
.admin-premium-form input:focus { border-color: #7b2ff7; }
