/* EnglishTutor - classroom frontend, the pupils' look (and the login screen): the demo's playful, chunky,
   colourful design. The teachers get the calmer css/teacher.css instead, see js/theme.js. */

:root {
  --ink: #2b2350;
  --ink-soft: #5b5380;
  --paper: #ffffff;
  --purple: #8a5cf6; --purple-d: #6a3fd6;
  --pink: #ff5fa2;   --pink-d: #d93a80;
  --blue: #2db7ff;   --blue-d: #1790d1;
  --green: #2ed573;  --green-d: #1fa855;
  --yellow: #ffd23f; --yellow-d: #e0a800;
  --orange: #ff8a3d; --orange-d: #d96a1f;
  --red: #ff5a5f;    --red-d: #d93a40;
  --radius: 26px;
  --lift: 0 7px 0 rgba(43, 35, 80, .16);
  font-family: "Comic Sans MS", "Chalkboard SE", "Comic Neue", "Trebuchet MS", "Segoe UI", system-ui, sans-serif,
    "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji";
  color: var(--ink);
  font-size: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #8fe3ff 0%, #c9b8ff 55%, #ffc9e6 100%) fixed;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: .4em 0; }
code { background: rgba(0,0,0,.08); padding: 1px 6px; border-radius: 6px; }
.hidden { display: none !important; }
.center { text-align: center; }
.small { font-size: .8rem; color: var(--ink-soft); }
.lead { font-size: 1.1rem; margin: 6px 4px 14px; }
.empty { text-align: center; font-size: 1.2rem; padding: 40px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------------------------------------ background */
#bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-item { position: absolute; opacity: .55; animation: drift linear infinite; filter: saturate(1.1); }
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(-6deg); }
  50%  { transform: translate(28px, -36px) rotate(8deg); }
  100% { transform: translate(0, 0) rotate(-6deg); }
}

/* -------------------------------------------------------------------- HUD */
#hud {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  max-width: 1080px; margin: 0 auto 8px; padding: 10px 16px;
  background: rgba(150, 190, 255, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 0 0 26px 26px;
}
.hud-home {
  width: 52px; height: 52px; border-radius: 18px; border: 0; font-size: 1.6rem;
  background: #fff; box-shadow: var(--lift); transition: transform .12s;
}
.hud-home:hover { transform: translateY(-2px) rotate(-6deg); }
.hud-title {
  font-weight: 700; font-size: 1.25rem; color: #fff; flex: 1;
  text-shadow: 2px 2px 0 rgba(43,35,80,.35), -1px -1px 0 rgba(43,35,80,.2);
}
.hud-chips { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.chip {
  display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 999px;
  padding: 7px 14px; font-weight: 700; box-shadow: 0 4px 0 rgba(43,35,80,.14); white-space: nowrap;
}
.chip-level { gap: 8px; }
.lv-emoji { font-size: 1.3rem; }
.mini-bar { width: 54px; height: 10px; border-radius: 99px; background: #e6e0ff; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); border-radius: 99px; transition: width .6s; }
.chip-stars { background: #fff8d6; }
.chip-streak { background: #ffe6d6; }
/* the pupil's name; a click logs out (js/account.js) */
.chip-user { max-width: 11em; border: 0; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; transition: transform .12s; }
.chip-user:hover { transform: translateY(-2px); }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { display: inline-grid; place-items: center; flex: none; color: var(--ink-soft); }
.save-warn { font-size: 1.3rem; background: #fff; border-radius: 12px; padding: 4px 8px; }
.save-warn[hidden] { display: none; }
.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.3) rotate(-4deg); } 60% { transform: scale(.95); } }

/* ------------------------------------------------------------------ layout */
#app { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 4px 16px 70px; }
.loading { text-align: center; font-size: 2rem; padding: 80px 0; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.25); }
.screen > * { animation: popIn .35s both; }
.screen > *:nth-child(2) { animation-delay: .06s; }
.screen > *:nth-child(3) { animation-delay: .12s; }
.screen > *:nth-child(4) { animation-delay: .18s; }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

.card { background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: var(--lift); border: 4px solid rgba(255,255,255,.7); }
.title { font-size: 2.3rem; color: var(--purple-d); text-shadow: 3px 3px 0 #ffe0f0; }
.screen-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.screen-title { font-size: 1.8rem; color: #fff; text-shadow: 3px 3px 0 rgba(43,35,80,.35); }
.error-card { text-align: center; margin-top: 60px; }
.big-emoji { font-size: 5rem; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none;
  background: var(--purple); border: 0; border-bottom: 6px solid var(--purple-d);
  border-radius: 20px; padding: .65em 1.2em; transition: transform .1s, filter .15s;
  text-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(4px); border-bottom-width: 2px; margin-bottom: 4px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-small { font-size: .95rem; padding: .45em .9em; border-bottom-width: 4px; }
.btn-big { font-size: 1.4rem; padding: .7em 1.5em; }
.btn-green  { background: var(--green);  border-color: var(--green-d); }
.btn-blue   { background: var(--blue);   border-color: var(--blue-d); }
.btn-pink   { background: var(--pink);   border-color: var(--pink-d); }
.btn-red    { background: var(--red);    border-color: var(--red-d); }
.btn-yellow { background: var(--yellow); border-color: var(--yellow-d); color: var(--ink); text-shadow: none; }
.btn-ghost  { background: #fff; border-color: #d8d2f0; color: var(--ink); text-shadow: none; }

.btn-speak {
  width: 64px; height: 64px; border-radius: 50%; border: 0; border-bottom: 6px solid var(--blue-d);
  background: var(--blue); font-size: 1.9rem; display: inline-grid; place-items: center; transition: transform .1s;
}
.btn-speak:hover { transform: scale(1.08) rotate(-6deg); }
.btn-speak:active { transform: translateY(3px); border-bottom-width: 3px; }
.btn-speak.slow { background: var(--green); border-color: var(--green-d); }
.btn-speak.big { width: 84px; height: 84px; font-size: 2.6rem; }
.btn-speak.speaking { animation: pulse .7s infinite; }
@keyframes pulse { 50% { transform: scale(1.14); box-shadow: 0 0 0 12px rgba(45,183,255,.25); } }

/* ----------------------------------------------------------------- mascot */
.mascot { --ms: 4rem; position: relative; display: inline-block; font-size: var(--ms); line-height: 1; animation: bob 3s ease-in-out infinite; }
.mascot-sm { --ms: 3.2rem; } .mascot-md { --ms: 5rem; } .mascot-lg { --ms: 7rem; } .mascot-xl { --ms: 9rem; }
.mascot-body { display: inline-block; filter: drop-shadow(0 6px 0 rgba(43,35,80,.12)); }
.mascot-hat  { position: absolute; top: -.32em; left: 50%; transform: translateX(-50%) rotate(-10deg); font-size: .62em; }
.mascot-face { position: absolute; top: .27em; left: 50%; transform: translateX(-50%); font-size: .62em; }
.mascot.happy { animation: hop .6s; }
.mascot.sad { animation: droop .7s; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes hop { 30% { transform: translateY(-26px) rotate(-8deg); } 60% { transform: translateY(0) rotate(6deg); } 80% { transform: translateY(-8px); } }
@keyframes droop { 25% { transform: rotate(-8deg) translateY(4px); } 75% { transform: rotate(8deg) translateY(4px); } }

.coach { display: flex; align-items: center; gap: 14px; margin-top: 22px; max-width: 760px; margin-inline: auto; }
.bubble {
  position: relative; background: #fff; border-radius: 22px; padding: 12px 18px; font-weight: 700;
  box-shadow: var(--lift); border: 3px solid #efeaff; flex: 1;
}
.bubble::before {
  content: ""; position: absolute; left: -14px; top: 50%; width: 22px; height: 22px; background: #fff;
  border-left: 3px solid #efeaff; border-bottom: 3px solid #efeaff; transform: translateY(-50%) rotate(45deg); border-radius: 0 0 0 6px;
}
.bubble.big { font-size: 1.25rem; padding: 16px 22px; }
.bubble.pop { animation: popIn .3s; }

/* ---------------------------------------------------------------- picture */
.emoji { font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; line-height: 1; display: inline-block; }
.swatch { display: inline-block; width: .85em; height: .85em; border-radius: 50%; border: .05em solid rgba(43,35,80,.25); box-shadow: inset 0 -.08em 0 rgba(0,0,0,.12); vertical-align: middle; }
.pic { height: 1em; width: auto; vertical-align: middle; }
/* Stand-in for a word without a picture: a tile with the first letter (data-letter). */
span.nopic {
  display: flex; align-items: center; justify-content: center; width: .85em; height: .85em; border-radius: .25em; vertical-align: middle;
  background: linear-gradient(145deg, #f1ebff, #d9ceff); border: .05em solid #cfc8ea; box-shadow: inset 0 -.06em 0 rgba(43,35,80,.12); color: var(--purple-d);
}
.nopic::before { content: attr(data-letter); font-size: .55em; font-weight: 700; line-height: 1; }
.prompt-visual, .learn-visual, .pv-visual { margin-inline: auto; }

/* -------------------------------------------------------------- modal etc */
.modal-back { position: fixed; inset: 0; background: rgba(43,35,80,.55); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); padding: 26px; max-width: 420px; text-align: center; box-shadow: var(--lift); animation: popIn .25s; }
.modal-icon { font-size: 3.5rem; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 20px; padding: 12px 20px;
  font-weight: 700; box-shadow: var(--lift), 0 0 0 4px var(--yellow); animation: toastIn .4s; max-width: 90vw;
}
.toast.out { opacity: 0; transform: translateY(-14px); transition: .4s; }
.toast-emoji { font-size: 2rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(.9); } }

.float-text {
  position: fixed; z-index: 80; font-weight: 700; font-size: 1.5rem; color: #fff; pointer-events: none;
  text-shadow: 2px 2px 0 var(--purple-d), -1px -1px 0 var(--purple-d); transform: translate(-50%, -50%);
  animation: floatUp 1.4s ease-out forwards; white-space: nowrap;
}
@keyframes floatUp { to { opacity: 0; transform: translate(-50%, -140px) scale(1.2); } }
canvas.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 95; }

/* ------------------------------------------------------------------- home */
.hero { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 24px; align-items: center; }
.hero-left { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.hero-mascot { background: none; border: 0; padding: 0; }
.hero-mascot.jump .mascot { animation: hop .6s; }
.hero-left .bubble::before { left: 50%; top: -12px; transform: translateX(-50%) rotate(135deg); border: 3px solid #efeaff; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.hero-info { display: flex; flex-direction: column; gap: 16px; }
.level-row { display: flex; align-items: center; gap: 14px; }
.level-emoji { font-size: 3rem; }
.level-text { flex: 1; }
.level-title { font-weight: 700; font-size: 1.15rem; }
.xp-bar { height: 18px; border-radius: 99px; background: #e9e3ff; overflow: hidden; margin: 6px 0 2px; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); }
.xp-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff8fc4, var(--purple)); transition: width .8s; }
.xp-label { font-size: .85rem; color: var(--ink-soft); }
.goal-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ring-wrap { position: relative; width: 78px; height: 78px; }
.ring { width: 100%; height: 100%; }
.ring-bg, .ring-fg { fill: none; stroke-width: 9; }
.ring-bg { stroke: #ece7ff; }
.ring-fg { stroke: var(--orange); stroke-linecap: round; transition: stroke-dashoffset 1s; }
.ring-icon { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.8rem; }
.goal-title { font-weight: 700; }
.streak-box { margin-left: auto; background: #fff0e0; border-radius: 20px; padding: 8px 16px; text-align: center; line-height: 1.2; }
.streak-fire { font-size: 1.8rem; display: block; animation: bob 1.4s infinite; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin: 22px 0; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 22px 14px 18px; border: 0; border-bottom: 9px solid rgba(0,0,0,.2); border-radius: 30px; color: #fff;
  background: linear-gradient(145deg, var(--c1), var(--c2)); transition: transform .15s;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.tile:hover { transform: translateY(-5px) rotate(-1.5deg) scale(1.02); }
.tile:active { transform: translateY(4px); border-bottom-width: 4px; }
.tile-icon { font-size: 4.4rem; line-height: 1.1; filter: drop-shadow(0 5px 0 rgba(0,0,0,.18)); transition: transform .3s; }
.tile:hover .tile-icon { transform: scale(1.15) rotate(8deg); }
.tile-title { font-size: 1.4rem; font-weight: 700; }
.tile-sub { font-size: .95rem; opacity: .95; }
.pills { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.pill { border: 0; border-bottom: 5px solid rgba(0,0,0,.18); border-radius: 999px; padding: .6em 1.3em; font-weight: 700; font-size: 1.05rem; color: var(--ink); transition: transform .12s; }
.pill:hover { transform: translateY(-3px); }
.pill-gold { background: #ffe58a; } .pill-pink { background: #ffc2dd; } .pill-blue { background: #bfe8ff; } .pill-grey { background: #e4e0f0; }

/* ----------------------------------------------------------------- topics */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.topic-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 12px 14px;
  background: #fff; border: 0; border-bottom: 8px solid var(--c); border-top: 8px solid var(--c);
  border-radius: 26px; box-shadow: var(--lift); transition: transform .15s;
}
.topic-card:hover { transform: translateY(-5px) rotate(1.5deg); }
.topic-emoji { font-size: 3.4rem; line-height: 1.1; }
.topic-name { font-weight: 700; font-size: 1.2rem; }
.topic-bar { width: 100%; height: 12px; border-radius: 99px; background: #eee9fb; overflow: hidden; }
.topic-bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.topic-count { font-size: .85rem; color: var(--ink-soft); }

/* ------------------------------------------------------------------ learn */
.learn { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.learn-card { background: #fff; border-radius: 34px; padding: 26px 40px; text-align: center; box-shadow: var(--lift); min-width: min(100%, 460px); border: 5px solid #fff3b0; }
.learn-visual { font-size: 9rem; line-height: 1.1; display: block; filter: drop-shadow(0 8px 0 rgba(43,35,80,.1)); animation: wobble 2.5s ease-in-out infinite; }
.learn-en { font-size: 3.4rem; font-weight: 700; color: var(--purple-d); text-shadow: 3px 3px 0 #ffe0f0; }
.learn-hu { font-size: 1.8rem; color: var(--ink-soft); margin-bottom: 10px; }
.learn-tools, .prompt-tools, .pv-actions { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.learn-nav { display: flex; align-items: center; gap: 18px; }
.learn-nav .btn { min-width: 84px; font-size: 1.6rem; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; max-width: 320px; justify-content: center; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #fff; opacity: .6; }
.dots i.done { background: var(--green); opacity: 1; }
.dots i.on { background: var(--pink); opacity: 1; transform: scale(1.5); }
.learn-done-emoji { font-size: 6rem; }
.learn-play { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
@keyframes wobble { 50% { transform: rotate(4deg) scale(1.04); } 25% { transform: rotate(-4deg); } }
.pop { animation: popIn .3s both; }

/* ------------------------------------------------------------------ games */
.game-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; background: rgba(255,255,255,.75); border-radius: 22px; padding: 8px 14px; }
.game-title { font-weight: 700; white-space: nowrap; }
.bar { flex: 1; height: 18px; border-radius: 99px; background: #e9e3ff; overflow: hidden; box-shadow: inset 0 3px 0 rgba(0,0,0,.08); }
.bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); border-radius: 99px; transition: width .5s; }
.combo { font-weight: 700; color: var(--orange-d); min-width: 3.2em; text-align: center; opacity: 0; }
.combo.on { opacity: 1; animation: bump .4s; }
.game-count { font-weight: 700; min-width: 3em; text-align: right; }

.stage { display: flex; flex-direction: column; align-items: center; }
.prompt { background: #fff; border-radius: 30px; padding: 20px 34px; text-align: center; box-shadow: var(--lift); min-width: min(100%, 440px); border: 5px solid #d9f0ff; }
.prompt-label { font-weight: 700; font-size: 1.3rem; color: var(--ink-soft); margin-bottom: 8px; }
.prompt-word { font-size: 3.4rem; font-weight: 700; color: var(--purple-d); text-shadow: 3px 3px 0 #ffe0f0; margin-bottom: 8px; }
.prompt-visual { font-size: 7rem; display: block; }
.prompt-hu { font-size: 2.2rem; font-weight: 700; color: var(--purple-d); margin: 4px 0 12px; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 20px; width: min(100%, 640px); }
.option {
  background: #fff; border: 0; border-bottom: 8px solid #d8d2f0; border-radius: 26px; min-height: 130px;
  display: grid; place-items: center; box-shadow: var(--lift); transition: transform .12s; padding: 8px;
}
.option:hover:not(:disabled) { transform: translateY(-4px) rotate(-1deg); }
.option:active:not(:disabled) { transform: translateY(3px); }
.opt-visual { font-size: 4.8rem; }
.opt-text { font-size: 2.2rem; font-weight: 700; color: var(--purple-d); }
.option.right { background: #c9f7d8; border-color: var(--green-d); animation: hop .6s; }
.option.wrong { background: #ffd9d9; border-color: var(--red-d); animation: shake .5s; }
.option.reveal { box-shadow: 0 0 0 6px rgba(46,213,115,.4); }
.option:disabled { cursor: default; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

.feedback { min-height: 2.2em; margin-top: 14px; font-weight: 700; font-size: 1.4rem; padding: 4px 18px; border-radius: 16px; opacity: 0; text-align: center; }
.feedback.show { opacity: 1; animation: popIn .25s; }
.feedback.ok { background: #d5f8e0; color: #15803d; }
.feedback.no { background: #ffe3e3; color: #b91c1c; }

/* --------------------------------------------------------------- preview */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; width: 100%; margin: 16px 0; }
.pv-card { background: #fff; border: 0; border-bottom: 7px solid #d8d2f0; border-radius: 24px; padding: 12px 8px; box-shadow: var(--lift); text-align: center; transition: transform .12s; }
.pv-card:hover { transform: translateY(-4px) rotate(-1deg); }
.pv-card.hl { background: #fff3b0; transform: scale(1.06); }
.pv-visual { font-size: 3.6rem; display: block; }
.pv-en { font-weight: 700; font-size: 1.4rem; color: var(--purple-d); }
.pv-hu { color: var(--ink-soft); }
/* The teacher's hint on when a word or phrase is used, small under its Hungarian meaning. */
.word-note { font-size: 1rem; font-style: italic; color: var(--ink-soft); margin: -6px 0 12px; }
.pv-card .word-note { font-size: .85rem; margin: 2px 0 0; }

/* --------------------------------------------------------------- memory */
.memory-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 12px; width: min(100%, 720px); }
.mcard { aspect-ratio: 1 / 1.05; background: none; border: 0; padding: 0; perspective: 800px; }
.mcard-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .45s; }
.mcard.open .mcard-inner { transform: rotateY(180deg); }
.mface { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--lift); padding: 4px; }
.mback { background: repeating-linear-gradient(45deg, #8a5cf6 0 12px, #9d77ff 12px 24px); font-size: 2.8rem; color: #fff; border: 4px solid #fff; }
.mfront { transform: rotateY(180deg); background: #fff; border: 4px solid var(--blue); }
.mcard:hover:not(.open) .mcard-inner { transform: rotate(-3deg) translateY(-3px); }
.mc-visual { font-size: 3.6rem; }
.mc-word { font-size: 1.6rem; font-weight: 700; color: var(--purple-d); text-align: center; word-break: break-word; }
.mc-hu { display: none; font-size: .95rem; color: var(--ink-soft); }
.mcard.show-hu .mc-hu { display: block; }
.mcard.matched .mfront { background: #d5f8e0; border-color: var(--green); }
.mcard.matched { animation: hop .6s; }
.moves { margin-top: 14px; font-weight: 700; font-size: 1.2rem; background: #fff; border-radius: 99px; padding: 6px 18px; }

/* --------------------------------------------------------------- typing */
.answer-show { font-size: 2.6rem; font-weight: 700; color: var(--green-d); text-shadow: 2px 2px 0 #fff; min-height: 0; height: 0; overflow: hidden; opacity: 0; letter-spacing: .1em; }
.answer-show.show { height: auto; min-height: 1.3em; opacity: 1; margin-top: 10px; animation: popIn .3s; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.slots.shake { animation: shake .45s; }
.slot, .slot-fixed {
  width: 58px; height: 70px; border-radius: 16px; display: grid; place-items: center; background: #fff;
  border: 4px solid #d8d2f0; border-bottom-width: 8px; font-size: 2.5rem; font-weight: 700; text-transform: uppercase; color: var(--purple-d);
}
.slot-fixed { background: transparent; border: 0; width: 24px; }
.slot-gap { width: 22px; }
.slot.filled { border-color: var(--purple); animation: popIn .15s; }
.slot.locked { background: #fff3b0; border-color: var(--yellow-d); }
.slot.good { background: #c9f7d8; border-color: var(--green-d); color: #15803d; }
.slot.bad { background: #ffd9d9; border-color: var(--red-d); color: #b91c1c; }
.type-actions { display: flex; gap: 16px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

/* -------------------------------------------------------------- results */
.results { text-align: center; max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.big-stars { display: flex; gap: 10px; font-size: 4rem; }
.big-star { filter: grayscale(1) opacity(.35); transform: scale(.6); }
.big-star.on { filter: none; animation: starPop .6s var(--d) both; }
@keyframes starPop { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.35) rotate(12deg); } 100% { transform: scale(1) rotate(0); } }
.result-line { font-size: 1.3rem; font-weight: 700; }
.result-stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.stat { background: #f3efff; border-radius: 22px; padding: 10px 22px; display: flex; flex-direction: column; align-items: center; min-width: 110px; }
.stat span { font-size: 1.8rem; } .stat b { font-size: 1.8rem; color: var(--purple-d); }
.banner { border-radius: 20px; padding: 10px 20px; font-weight: 700; width: 100%; animation: popIn .4s .5s both; }
.banner.gold { background: #fff0b3; } .banner.pink { background: #ffd6ea; } .banner.purple { background: #e5d9ff; }
.result-block { width: 100%; text-align: left; }
.result-block h3 { margin-bottom: 8px; }
.chip-sticker { background: linear-gradient(135deg, #fff1a8, #ffc933); border-radius: 99px; padding: 6px 16px; font-weight: 700; box-shadow: 0 3px 0 #e0a800; }
.mini-badge { display: flex; align-items: center; gap: 10px; background: #f3efff; border-radius: 18px; padding: 8px 14px; }
.mini-badge > span { font-size: 2.2rem; } .mini-badge small { display: block; color: var(--ink-soft); }
.rwords { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.rword { display: flex; align-items: center; gap: 8px; background: #f8f6ff; border-radius: 16px; padding: 6px 10px; }
.rword .btn-speak { width: 38px; height: 38px; font-size: 1.1rem; border-bottom-width: 3px; margin-left: auto; }
.rhu { color: var(--ink-soft); font-size: .9rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }

/* -------------------------------------------------------- album / trophies */
.album-topic { background: rgba(255,255,255,.8); border-radius: 26px; padding: 14px 16px 18px; margin-bottom: 16px; border-left: 10px solid var(--c); }
.album-topic h3 { display: flex; justify-content: space-between; margin-bottom: 10px; }
.album-topic small { font-weight: 400; color: var(--ink-soft); }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.sticker { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 118px; background: #fff; border: 4px dashed #d8d2f0; border-radius: 20px; padding: 8px 4px; transition: transform .12s; }
.sticker:hover { transform: rotate(-3deg) scale(1.05); }
.st-visual { font-size: 3.2rem; } .sticker .emoji { font-size: 3.2rem; }
.st-word { font-weight: 700; font-size: .95rem; }
.sticker.locked { background: #efecf7; color: #aaa4c4; } .sticker.locked .emoji { filter: grayscale(1); opacity: .6; }
.sticker.learning { border-style: solid; border-color: #b7e4c7; } .sticker.learning .st-visual, .sticker.learning .emoji { filter: grayscale(.7) opacity(.75); }
.sticker.good { border-style: solid; border-color: #9ad0ff; }
.sticker.gold { border: 4px solid #ffc933; background: linear-gradient(145deg, #fffbe0, #fff0a0); box-shadow: 0 0 0 3px #fff, 0 6px 0 #e0a800; position: relative; overflow: hidden; }
.sticker.gold::after { content: ""; position: absolute; top: -30%; left: -60%; width: 40%; height: 160%; background: rgba(255,255,255,.7); transform: rotate(25deg); animation: shine 3.2s infinite; }
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 140%; } }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sticker.mini { flex-direction: row; min-height: 0; padding: 4px 12px; font-weight: 700; border-width: 3px; }
.sticker.mini:hover { transform: none; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.badge { background: rgba(255,255,255,.6); border-radius: 24px; padding: 16px 12px; text-align: center; border: 4px dashed #cfc8ea; }
.badge-emoji { font-size: 3.4rem; filter: grayscale(1) opacity(.55); }
.badge-name { font-weight: 700; margin-top: 4px; } .badge-desc { font-size: .85rem; color: var(--ink-soft); }
.badge-date { font-size: .75rem; color: var(--ink-soft); margin-top: 4px; }
.badge.earned { background: #fff; border: 4px solid var(--yellow); box-shadow: var(--lift); }
.badge.earned .badge-emoji { filter: none; animation: wobble 3s infinite; }

/* ------------------------------------------------------------------ shop */
.shop { display: flex; flex-direction: column; gap: 14px; }
.shop-top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.shop-top .mascot { padding-top: 26px; }
.shop-stars { font-size: 2.2rem; font-weight: 700; }
.shop-h { color: #fff; text-shadow: 2px 2px 0 rgba(43,35,80,.35); margin: 8px 0; font-size: 1.5rem; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 0; border-bottom: 7px solid #d8d2f0; border-radius: 22px; padding: 12px 8px; box-shadow: var(--lift); transition: transform .12s; }
.shop-item:hover { transform: translateY(-4px) rotate(-1.5deg); }
.shop-emoji { font-size: 3.2rem; line-height: 1.1; }
.shop-name { font-weight: 700; }
.shop-price { background: #fff3b0; border-radius: 99px; padding: 2px 12px; font-weight: 700; font-size: .95rem; }
.shop-item.on { border-color: var(--green); background: #e5fbec; } .shop-item.on .shop-price { background: #b7f0c9; }
.shop-item.poor { opacity: .7; } .shop-item.poor .shop-price { background: #eee; }

/* ---------------------------------------------------------------- parents */
.parent { display: flex; flex-direction: column; gap: 16px; }
.gate { max-width: 420px; margin: 20px auto; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.gate-icon { font-size: 3.4rem; }
.gate-input, .field input[type=text], .field select { font: inherit; padding: 8px 12px; border-radius: 14px; border: 3px solid #d8d2f0; min-width: 0; }
.gate-input { font-size: 1.6rem; width: 140px; text-align: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: #f3efff; border-radius: 18px; padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.kpi span { font-size: 1.6rem; } .kpi b { font-size: 1.5rem; color: var(--purple-d); } .kpi small { color: var(--ink-soft); }
.day-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 8px; }
.day-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.day-bar i { width: 100%; background: linear-gradient(180deg, var(--blue), var(--purple)); border-radius: 8px 8px 2px 2px; display: block; }
.day-bar small { font-size: .7rem; color: var(--ink-soft); }
.hard-word { background: #fff0f0; border-radius: 14px; padding: 6px 12px; }
.settings .field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 2px dashed #eee9fb; }
.settings input[type=checkbox] { width: 26px; height: 26px; }
.settings input[type=range] { width: 200px; }
.voice-ok { margin-top: 12px; color: #15803d; font-weight: 700; }
.warn-box { background: #fff3cd; border-radius: 16px; padding: 10px 14px; margin: 10px 0; }
.warn-box ul { margin: 4px 0 0; padding-left: 20px; }
.chip-topic { background: #f3efff; border-left: 6px solid var(--c); border-radius: 12px; padding: 4px 10px; font-size: .9rem; }
.danger { border-color: #ffd0d0; }

/* ----------------------------------------------------------------- splash */
/* Shown until a valid access code was entered (js/splash.js, art in js/school-wireframe.js).
   Timeline: the building is drawn from .45s to ~2.4s and its windows light up until ~3.5s, title
   letters drop from 1s to ~3s, the code box opens at 3.7s (class .is-ready). A tap skips ahead
   (.is-skipped). */
.splash {
  position: fixed; inset: 0; z-index: 70; display: flex; overflow: hidden auto; padding: 18px 16px;
  background: linear-gradient(160deg, #8fe3ff 0%, #c9b8ff 55%, #ffc9e6 100%);
  transition: opacity .6s ease, transform .7s cubic-bezier(.5, 0, .8, .5);
}
.splash.is-leaving { opacity: 0; transform: translateY(-5%) scale(1.08); pointer-events: none; }
.sp-stage { position: relative; margin: 2vh auto auto; width: 100%; display: flex; flex-direction: column; align-items: center; }
.sp-intro { display: flex; flex-direction: column; align-items: center; margin-bottom: clamp(6px, 1.5vh, 14px); }

.sp-sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.sp-cloud {
  position: absolute; left: 0; top: calc(5% + var(--i) * 19%); width: 150px; height: 44px; border-radius: 99px;
  background: rgba(255, 255, 255, .85); transform: translateX(calc(var(--i) * 24vw + 4vw));
}
.sp-cloud::before, .sp-cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.sp-cloud::before { width: 62px; height: 62px; left: 20px; top: -30px; }
.sp-cloud::after { width: 80px; height: 80px; right: 16px; top: -40px; }
.sp-spark { position: absolute; font-size: 1.7rem; opacity: 0; animation: spTwinkle 2.6s calc(2.4s + var(--i) * .35s) ease-in-out infinite; }
@media (prefers-reduced-motion: no-preference) {
  .sp-cloud { animation: spCloud calc(46s + var(--i) * 13s) linear calc(var(--i) * -17s) infinite; }
}

/* title: every letter drops in (.sp-ch) and then wiggles for ever (.sp-jig) */
.sp-title {
  margin: 0; text-align: center; font-weight: 700; line-height: 1.05; user-select: none;
  font-size: clamp(2.1rem, min(7.4vw, 9.5vh), 4.4rem);
}
.sp-line { display: block; white-space: nowrap; }
.sp-line + .sp-line { margin-top: .04em; }
.sp-word { display: inline-block; white-space: nowrap; }
.sp-word + .sp-word { margin-left: .26em; }
.sp-for { font-size: .5em; }
.sp-erkel { font-size: 1.3em; }
.sp-ch { display: inline-block; animation: spDrop .85s calc(1s + var(--i) * 75ms) cubic-bezier(.3, 1.5, .5, 1) both; }
.sp-jig {
  display: inline-block; color: var(--c);
  text-shadow: .035em .035em 0 var(--ink), .07em .07em 0 var(--ink), .105em .105em 0 var(--ink), .14em .14em 0 rgba(43, 35, 80, .3);
  animation: spJig 2.6s calc(3.1s + var(--i) * 110ms) ease-in-out infinite;
}

/* the school: black lines as wide as the window, drawn over the sky and the clouds (js/school-wireframe.js);
   the title and the code box lie on top of it and hide parts of it. It is drawn line by line, then its
   windows light up. The drawing's own groups time the animation. */
.sp-wire { position: fixed; inset: 0; pointer-events: none; display: flex; align-items: flex-end; justify-content: center; }
.sp-wire .wf { flex: none; width: min(100vw, 200vh); height: auto; }
.wf { display: block; overflow: visible; fill: none; stroke: #111; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.wf path { stroke-dasharray: 1; animation: wfDraw 1.2s ease-out both; }
.wf-frame path { animation-delay: .45s; }
.wf-roofs > path { animation-delay: .85s; }
.wf-tower > path { animation-delay: 1.15s; }
.wf-fine path { stroke-width: .7; opacity: .6; animation-delay: 1.9s; }
.wf-red { fill: #ff4d5a; }
.wf-white { fill: #fff; }
.wf-green { fill: #2ed573; }
.wf-flag { transform-box: fill-box; transform-origin: 0 50%; animation: spWave 1.6s ease-in-out infinite; }
.wf-flag path { animation: wfDraw 1.2s 2.5s ease-out both, wfFill .6s 2.5s ease-out both; }
/* windows: drawn in a scattered order (eleven delays, repeating), the glass lights up after its frame */
.wf-win { --k: 0; }
.wf-win:nth-child(11n+1) { --k: 3; }  .wf-win:nth-child(11n+2) { --k: 8; }  .wf-win:nth-child(11n+3) { --k: 1; }
.wf-win:nth-child(11n+4) { --k: 6; }  .wf-win:nth-child(11n+5) { --k: 10; } .wf-win:nth-child(11n+6) { --k: 0; }
.wf-win:nth-child(11n+7) { --k: 5; }  .wf-win:nth-child(11n+8) { --k: 9; }  .wf-win:nth-child(11n+9) { --k: 2; }
.wf-win:nth-child(11n+10) { --k: 7; } .wf-win:nth-child(11n+11) { --k: 4; }
.wf-wins > path { animation-delay: 1.6s; }
.wf-win path { animation-duration: .7s; animation-delay: calc(1.5s + var(--k) * .075s); }
.wf-win .wf-glass {
  fill: rgba(255, 221, 87, .6);
  animation: wfDraw .7s calc(1.5s + var(--k) * .075s) ease-out both, wfLight .6s calc(2.2s + var(--k) * .075s) ease-out both;
}

/* the code box slides open when the animation is done */
.sp-login {
  width: min(100%, 460px); display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .8s cubic-bezier(.2, .9, .3, 1), opacity .5s;
}
.sp-login-in { min-height: 0; overflow: hidden; padding: 4px 8px 14px; }
.is-ready .sp-login { grid-template-rows: 1fr; opacity: 1; visibility: visible; }
.sp-card { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; }
.sp-coach { margin: 0; max-width: none; }
/* the password: dots, or the letters as typed (the show / hide button beside it) */
.sp-row { display: flex; align-items: center; gap: 10px; }
.sp-input {
  font: inherit; font-size: 1.7rem; font-weight: 700; text-align: center; letter-spacing: .1em;
  color: var(--purple-d); flex: 1; min-width: 0; width: 100%; padding: 10px 14px; border: 4px solid #d8d2f0; border-radius: 20px;
  background: #fbfaff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.sp-input::placeholder { font-size: 1.2rem; font-weight: 400; letter-spacing: 0; color: #b1abd0; }
.sp-input:focus { border-color: var(--purple); box-shadow: 0 0 0 5px rgba(138, 92, 246, .22); }
.sp-input:disabled { opacity: .7; }
.sp-card.is-done .sp-input:disabled { opacity: 1; background: #e5fbec; border-color: var(--green); }
.sp-toggle { flex: none; white-space: nowrap; }
.sp-card .btn-big { width: 100%; }
.sp-card.shake { animation: shake .45s; }

.is-skipped .intro, .is-skipped .wf path { animation-delay: 0s !important; animation-duration: .01ms !important; }
.is-skipped .sp-login { transition-duration: .01ms !important; }
@media (prefers-reduced-motion: reduce) {
  .splash *, .splash *::before, .splash *::after { animation-delay: 0s !important; }
  .wf path { animation: none !important; }
}

/* wide screens: the title is top left, above the roof, and the code box opens top right, over the right wing.
   Narrower or taller windows keep the single column (title, then the code box). */
@media (min-width: 700px) and (min-aspect-ratio: 4/3) {
  .splash { --sp-card-w: min(440px, 46vw); }
  .sp-stage { flex-direction: row; justify-content: space-between; align-items: stretch; margin: 0 auto; }
  .sp-intro { align-self: flex-start; }
  .sp-title { font-size: clamp(2.1rem, min(4.6vw, 9.5vh), 4.4rem); }
  .sp-login {
    align-self: flex-start; grid-template-rows: 1fr; flex: none; width: 0; margin-left: 0;
    transition: width .8s cubic-bezier(.2, .9, .3, 1), margin-left .8s cubic-bezier(.2, .9, .3, 1), opacity .5s;
  }
  .sp-login-in { width: var(--sp-card-w); }
  .is-ready .sp-login { width: var(--sp-card-w); margin-left: 28px; }
}
/* short screens (phones on their side): tighter code box */
@media (max-height: 700px) {
  .sp-card { gap: 10px; padding: 12px 16px 14px; }
  .sp-input { font-size: 1.4rem; padding: 6px 12px; }
}
/* narrow screens: the drawing is smaller than the window, so its lines get thicker to stay visible */
@media (max-width: 700px) {
  .wf { stroke-width: 1.8; }
  .wf-fine path { stroke-width: 1.1; }
}

@keyframes spCloud { from { transform: translateX(-220px); } to { transform: translateX(calc(100vw + 220px)); } }
@keyframes spTwinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1.15) rotate(20deg); } }
@keyframes spDrop { 0% { opacity: 0; transform: translateY(-1.3em) scale(.5) rotate(-24deg); } 100% { opacity: 1; transform: none; } }
@keyframes spJig { 0%, 100% { transform: none; } 50% { transform: translateY(-.07em) rotate(-2deg); } }
@keyframes wfDraw { from { stroke-dashoffset: 1; } }
@keyframes wfLight { from { fill: rgba(255, 221, 87, 0); } }
@keyframes wfFill { from { fill-opacity: 0; } }
@keyframes spWave { 0%, 100% { transform: skewY(-3deg) scaleX(1); } 50% { transform: skewY(3deg) scaleX(.94); } }

/* ----------------------------------------------------------- responsive */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hud-title { display: none; }
  .hud-chips { margin-left: auto; }
  .learn-card { padding: 18px 22px; }
  .learn-visual { font-size: 6.5rem; }
  .learn-en { font-size: 2.6rem; }
}
@media (max-width: 520px) {
  :root { font-size: 16px; }
  .slot { width: 42px; height: 56px; font-size: 1.9rem; }
  .mini-bar { display: none; }
  #hud { gap: 8px; padding: 8px 10px; }
  .hud-home { width: 46px; height: 46px; }
  .hud-chips { gap: 6px; }
  .chip { padding: 6px 10px; }
  .chip-user { max-width: 6.5em; }
  .opt-visual { font-size: 3.6rem; }
  .game-title { display: none; }
}
@media (max-width: 400px) {
  .lv-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
