/* The two pixel faces are served from this site, not from Google. No third party
   sees your students, nothing breaks if Google is unreachable, and it works offline. */

@font-face {
  font-family: "Pixelify";
  src: url("/font/pixelify.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("/font/silkscreen.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* Robot Lab - all the styling and all the movement. */

:root {
  --ink: #EEF3FF;
  --dim: #9AA6C2;
  --panel: #1B2138;
  --panel-2: #232B48;
  --line: #333D63;
  --accent: #6FE3C4;
  --warn: #FFB44A;
  --radius: 18px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --title: "Pixelify", "Courier New", monospace;
  --label: "Silkscreen", "Courier New", monospace;
}

* { box-sizing: border-box; }

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

body { min-height: 100vh; }

h1, h2, h3 {
  margin: 0 0 .4em;
  font-family: var(--title);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.05;
  text-wrap: balance;
}
h1 { font-size: clamp(30px, 7vw, 44px); }
button { font-family: inherit; }

.wrap { max-width: 780px; margin: 0 auto; padding: 18px 16px 60px; }

/* ---------------------------------------------------------- sign in page */

.signin {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, #2A3566 0%, transparent 60%),
    #10142A;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 26px 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}

.card h1 { font-size: clamp(30px, 9vw, 40px); text-align: center; }
.card .sub { text-align: center; color: var(--dim); margin: 0 0 22px; font-size: 15px; }

label { display: block; font-size: 13px; color: var(--dim); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 1px;   font-family: var(--label);
}

select, input[type=text], input[type=password], input[type=number], input[type=tel] {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); }

.pin { letter-spacing: 10px; text-align: center; font-size: 26px; }

.btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px;
  font-size: 18px;
  font-weight: bold;
  color: #10142A;
  background: var(--accent);
  border: none;
  border-radius: 14px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--dim); border: 2px solid var(--line); font-weight: normal; font-size: 15px; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; margin: 0; }

.err { color: #FF8E8E; text-align: center; min-height: 20px; margin-top: 12px; font-size: 15px; }
.tiny { color: var(--dim); font-size: 12px; text-align: center; margin-top: 16px; }

/* ------------------------------------------------------------- the scene */
/* The background and the dragon are two canvases at the same pixel size, laid
   one on top of the other, so the whole picture reads as a single image. */

.scene {
  position: relative;
  width: -moz-fit-content;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  line-height: 0;
}
.scene .bg canvas, .scene .stagearea canvas {
  display: block; image-rendering: pixelated;
  max-width: none; width: auto; height: auto;
}
.scene .stagearea { position: absolute; left: 50%; top: 0; transform: translateX(-50%); }
.tapnote {
  position: absolute; right: 6px; bottom: 6px;
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase;
  color: rgba(255,255,255,.6); background: rgba(0,0,0,.4);
  padding: 3px 7px; border-radius: 6px; line-height: 1.5;
  pointer-events: none;
  font-family: var(--label);
}

/* -------------------------------------------------------- dragon drawing */
/* The dragons are canvases full of square pixels. Never let the browser smooth
   them, and never let CSS stretch them to a fraction of their real size. */

canvas.dg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

@keyframes twinkle { 0%,100% { filter: none; } 50% { filter: brightness(1.7); } }

/* ----------------------------------------------------------- kid app bits */

.topline { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.topline .who { color: var(--dim); font-size: 14px; }
.robotname { font-family: var(--title); font-size: clamp(26px, 7vw, 34px); font-weight: 700; }
.stagetag {
  display: inline-block; margin-left: 8px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent);
  font-family: var(--label);
}

.blurb { color: var(--dim); font-size: 15px; margin: 14px 0 4px; text-align: center; }

.meter { margin: 16px 0 6px; }
.meter .bar {
  height: 20px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); overflow: hidden;
}
.meter .fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #8FB4FF);
  border-radius: 999px;
  transition: width 900ms cubic-bezier(.2,.9,.2,1);
}
.meter .nums {
  display: flex; justify-content: space-between;
  font-size: 14px; color: var(--dim); margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.track { display: flex; gap: 6px; margin: 18px 0 4px; }
.track .pip {
  flex: 1; text-align: center; padding: 8px 2px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 11px; letter-spacing: .5px; color: #5C6789;
}
.track .pip.done { color: var(--ink); }
.track .pip.done { border-color: #4A5A8C; background: var(--panel-2); }
.track .pip.now { color: #10142A; background: var(--accent); border-color: var(--accent); font-weight: bold; }

.list { margin-top: 22px; }
.list h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--dim);   font-family: var(--label);
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--line); margin-bottom: 8px;
}
.row .grow { flex: 1; min-width: 0; }
.row .lab { font-size: 15px; }
.row .meta { font-size: 12px; color: var(--dim); }
.row .xp { font-weight: bold; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 16px; }
.empty { color: var(--dim); font-size: 14px; padding: 14px 2px; }

/* ------------------------------------------------------------- setup page */

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.sw {
  width: 46px; height: 46px; border-radius: 14px; cursor: pointer;
  border: 3px solid transparent; box-shadow: inset 0 -8px 14px rgba(0,0,0,.25);
}
.sw.on { border-color: #fff; transform: scale(1.06); }
.sw.eye { width: 38px; height: 38px; border-radius: 999px; }

.preview {
  background: linear-gradient(#20264A, #3A2C4E);
  border-radius: var(--radius); border: 1px solid var(--line);
  padding: 10px; margin: 14px 0; text-align: center;
}
.preview .scene { margin: 0 auto; }

/* -------------------------------------------------------------- level up */

.celebrate {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,11,26,.97);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  animation: fadein 400ms ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes popin { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.celebrate .big { font-size: 15px; letter-spacing: 6px; color: var(--accent); text-transform: uppercase; }
.celebrate h2 { font-size: 34px; margin: 6px 0 0; }
.celebrate .art { width: min(70vw, 300px); animation: popin 700ms cubic-bezier(.2,.9,.2,1); }
.celebrate p { color: var(--dim); max-width: 300px; }

.burst { position: absolute; width: 10px; height: 10px; border-radius: 999px; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

/* -------------------------------------------------------------- teacher */

.tbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--dim); }

.kidgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.kidcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 10px; align-items: center; }
.kidcard .art { width: 96px; flex: none; background: #171C33; border-radius: 12px; padding: 4px; }
.kidcard .nm { font-weight: bold; }
.kidcard .sm { font-size: 12px; color: var(--dim); }
.kidcard .bar { height: 8px; margin-top: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.kidcard .fill { height: 100%; background: var(--accent); }

.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: 999px; cursor: pointer; font-size: 15px;
  background: var(--panel); border: 2px solid var(--line); color: var(--ink);
}
.chip.on { background: var(--accent); color: #10142A; border-color: var(--accent); font-weight: bold; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note { font-size: 13px; color: var(--dim); margin-top: 8px; }
.flash { background: #16351F; border: 1px solid #2C6B3E; color: #B6F3C6; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: 15px; }
.flash.bad { background: #3A1A20; border-color: #7A2B36; color: #FFC2C6; }

/* ------------------------------------------------------- species picker */

.species { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin-top: 8px; }
.spc {
  background: var(--panel); border: 3px solid var(--line); border-radius: 16px;
  padding: 6px 6px 10px; text-align: center; cursor: pointer;
}
.spc.on { border-color: var(--accent); background: var(--panel-2); }
.spc canvas.dg { width: 100%; height: auto; }
.spc .n { font-weight: bold; font-size: 15px; }
.spc .t { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .9px;   font-family: var(--label);
}

/* --------------------------------------------------------- where it lives */

.places { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.plc {
  background: var(--panel); border: 3px solid var(--line); border-radius: 16px;
  padding: 6px 6px 10px; text-align: center; cursor: pointer; line-height: 1.3;
}
.plc.on { border-color: var(--accent); background: var(--panel-2); }
.plc canvas { width: 100%; height: auto; border-radius: 8px; image-rendering: pixelated; }
.plc .n { font-weight: bold; font-size: 15px; margin-top: 4px; }
.plc .t { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .9px;   font-family: var(--label);
}

/* ------------------------------------------------------------- the purse */

.purse { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.coins {
  display: flex; align-items: center; gap: 7px;
  font-size: 22px; font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.coins .pip {
  width: 20px; height: 20px; border-radius: 999px;
  background: linear-gradient(#FFE07A, #D9A020);
  color: #6B4A00; font-size: 12px; font-weight: bold;
  display: grid; place-items: center; border: 2px solid #B8850F;
}
.fed { flex: 1; }
.fed .lab { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--dim);   font-family: var(--label);
}
.bar.sm { height: 10px; margin-top: 3px; }
.bar.sm .fill { background: linear-gradient(90deg, #8FD455, #57B03C); }
.bar.sm .fill.low { background: linear-gradient(90deg, #FFB44A, #E2504E); }

/* ------------------------------------------------------- the care menu */

.acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 10px 0 12px; }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px 10px; cursor: pointer;
  background: var(--panel-2); border: 2px solid var(--line); border-radius: 14px;
  color: var(--ink); font-family: inherit;
}
.act:hover:not(:disabled) { border-color: var(--accent); }
.act:disabled { opacity: .38; cursor: not-allowed; }
.act canvas { image-rendering: pixelated; }
.act .n { font-size: 13px; }
.act .c { font-size: 13px; color: var(--accent); font-weight: bold; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 120%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 18px; border-radius: 14px; font-size: 15px; max-width: 90vw;
  text-align: center; z-index: 60; transition: transform 320ms cubic-bezier(.2,.9,.2,1);
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.toast.up { transform: translate(-50%, 0); }
.toast.bad { border-color: #7A2B36; color: #FFC2C6; }

/* ------------------------------------------------- hoard and weather layers */

.scene .weather { position: absolute; left: 0; top: 0; pointer-events: none; }
.scene .weather canvas {
  display: block; image-rendering: pixelated; max-width: none; width: auto; height: auto;
}
.wxnote {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase;
  color: rgba(255,255,255,.7); background: rgba(0,0,0,.4);
  padding: 3px 7px; border-radius: 6px; line-height: 1.5; pointer-events: none;
  font-family: var(--label);
}
.wxnote:empty { display: none; }

/* ------------------------------------------------------- notes and practice */

.note-panel { border-left: 4px solid var(--accent); }
.note-line { padding: 8px 0; border-bottom: 1px solid var(--line); }
.note-line:last-child { border-bottom: 0; }
.note-line .t { font-size: 15px; }
.note-line.first .t { font-size: 17px; color: var(--ink); }
.note-line .w { font-size: 11px; color: var(--dim); margin-top: 2px; }
.note-line:not(.first) .t { color: var(--dim); font-size: 14px; }

.quizhead { display: flex; align-items: center; justify-content: space-between; }
.clock {
  font-size: 24px; font-weight: bold; font-variant-numeric: tabular-nums;
  color: var(--accent); background: var(--panel-2); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 10px;
}
.clock.low { color: #FF8E8E; border-color: #7A2B36; }
.qrow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.qrow .qq { flex: 1; font-size: 17px; font-variant-numeric: tabular-nums; }
.qrow input { width: 110px; text-align: center; font-size: 19px; font-variant-numeric: tabular-nums; }
.qrow.mark { font-size: 14px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); }
.qrow.mark .qa { font-weight: bold; }
.qrow.mark.ok .qa { color: var(--accent); }
.qrow.mark.no .qa { color: #FF8E8E; }

/* ---------------------------------------------------- the egg being given */

.intro {
  position: fixed; inset: 0; z-index: 80;
  background: #05060F;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 20px; text-align: center;
  opacity: 0; transition: opacity 900ms ease;
}
.intro.up { opacity: 1; }
.intro.out { opacity: 0; }

.intro .stage {
  position: relative;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  line-height: 0; opacity: 0; transition: opacity 1600ms ease;
}
.intro .stage.lit { opacity: 1; }
.intro .stage canvas { display: block; image-rendering: pixelated; max-width: none; }
.intro .egghold {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  opacity: 0;
}
.intro .egghold.drop { animation: eggArrive 1700ms cubic-bezier(.18,.9,.3,1) forwards; }
@keyframes eggArrive {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-46%) scale(.35); }
  55%  { opacity: 1; transform: translateX(-50%) translateY(4%) scale(1.06); }
  72%  { transform: translateX(-50%) translateY(-2%) scale(.97); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.intro .ring {
  position: absolute; left: 50%; top: 58%; width: 10px; height: 10px;
  margin: -5px 0 0 -5px; border-radius: 999px;
  border: 3px solid var(--accent); opacity: 0;
}
.intro .ring.go { animation: ringOut 1400ms ease-out 900ms forwards; }
@keyframes ringOut {
  0%   { opacity: .9; transform: scale(.3); }
  100% { opacity: 0; transform: scale(22); }
}

.intro .where {
  font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--dim);
  opacity: 0; transition: opacity 1200ms ease;
}
.intro .where.lit { opacity: 1; }

.intro .say {
  min-height: 2.6em; display: flex; align-items: center; justify-content: center;
  max-width: 22ch;
}
.intro .say span {
  font-size: clamp(22px, 6vw, 34px); line-height: 1.25; color: var(--ink);
  opacity: 0; transform: translateY(10px);
  transition: opacity 800ms ease, transform 800ms ease;
  text-wrap: balance;
}
.intro .say span.lit { opacity: 1; transform: translateY(0); }
.intro .say span.big { font-size: clamp(34px, 10vw, 58px); font-weight: bold; color: var(--accent); }

.intro .skip {
  position: absolute; right: 14px; top: 14px;
  background: none; border: 1px solid var(--line); color: var(--dim);
  padding: 8px 14px; border-radius: 999px; font-family: inherit; font-size: 13px;
  cursor: pointer;
}
.intro .skip:hover { color: var(--ink); border-color: var(--dim); }

@media (prefers-reduced-motion: reduce) {
  .intro, .intro .stage, .intro .say span { transition: none; }
  .intro .egghold.drop { animation: none; opacity: 1; }
  .intro .ring.go { animation: none; }
}

/* ------------------------------------------------- what gets said, two ways */

.saybox { margin: 16px auto 6px; max-width: 36ch; }

/* A notice ABOUT the dragon. Narrator voice. */
.announce {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px 12px;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.35);
}
.announce .tag {
  position: absolute; top: -9px; left: 12px;
  background: var(--panel-2); border: 2px solid var(--line);
  font-family: var(--label); font-size: 9px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--dim);
  padding: 2px 7px; border-radius: 3px; line-height: 1.4;
}
.announce .line { font-size: 16px; color: var(--dim); line-height: 1.45; }

/* The dragon speaking TO the student. */
.bubble {
  position: relative;
  background: var(--panel-2);
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 15px 16px 12px;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.35);
}
.bubble::before, .bubble::after {
  content: ""; position: absolute; left: 50%; width: 0; height: 0;
}
.bubble::before {
  top: -14px; margin-left: -8px;
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 12px solid var(--accent);
}
.bubble::after {
  top: -10px; margin-left: -6px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 9px solid var(--panel-2);
}
.bubble .who {
  font-family: var(--label); font-size: 9px; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 5px;
}
.bubble .line { font-size: 18px; color: var(--ink); line-height: 1.4; }
.bubble.hurt { border-color: #C4566A; }
.bubble.hurt::before { border-bottom-color: #C4566A; }
.bubble.hurt .who { color: #FFB2B8; }

/* ------------------------------------------------------------- asking first */

.ask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6,8,18,.88);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.ask .box {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 4px;
  padding: 20px;
  box-shadow: 6px 6px 0 rgba(0,0,0,.5);
}
.ask h3 { font-family: var(--title); font-size: 26px; margin: 0 0 12px; color: var(--ink); }
.ask dl { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.ask dt {
  font-family: var(--label); font-size: 10px; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--dim); padding-top: 3px;
}
.ask dd { margin: 0; font-size: 17px; color: var(--ink); }
.ask .warn { font-size: 14px; color: var(--dim); margin: 0 0 16px; line-height: 1.45; }
.ask .row { display: flex; gap: 8px; }
.ask .row .btn { margin-top: 0; }

/* ------------------------------------------- something thrown to the dragon */

.thrown {
  position: absolute; z-index: 3; pointer-events: none;
  opacity: 0; line-height: 0;
}
.thrown canvas { display: block; image-rendering: pixelated; max-width: none; }
.thrown.go { animation: tossIn 760ms cubic-bezier(.3,.1,.4,1) forwards; }
@keyframes tossIn {
  0%   { opacity: 0; transform: translate(340%, 90%) scale(.5) rotate(-40deg); }
  12%  { opacity: 1; }
  55%  { transform: translate(90%, -120%) scale(1.3) rotate(20deg); }
  88%  { transform: translate(0, 8%) scale(1) rotate(0deg); }
  100% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .thrown.go { animation: none; opacity: 1; }
}

/* a button that has been asked once and is waiting to be sure */
.btn.armed, .btn.ghost.armed {
  background: #6B2430;
  border-color: #A8394A;
  color: #FFD9DE;
  font-weight: bold;
}
