/* ============================================================
   quest.css, the mission's HTML layer
   ============================================================
   Sits over the console. Takes its four colours from the live palette, which
   main.js writes onto :root as --q-light through --q-ink whenever the palette
   changes, so the shop panel repaints with the world instead of drifting into
   a different-looking app halfway through.

   Sizing rule, applied throughout: nothing tappable is under 44px on its
   shortest side, and nothing depends on a precise drag or a double tap. This is
   the brief's accessibility line (nine-year-olds, shared classroom tablets, no
   rapid motor demands), so it is a constraint rather than a preference.
   ============================================================ */

:root {
  --q-light: #c4cfa1;
  --q-mid: #8b956d;
  --q-dark: #4d5339;
  --q-ink: #1f2412;
}

.quest-layer {
  position: relative;
  z-index: 10;
}

/* --- Intro and consent ------------------------------------------------ */

.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #14140f;
  overflow-y: auto;
  z-index: 40;
}

.intro[hidden] { display: none; }

.intro__card {
  width: min(560px, 100%);
  background: #1e1e18;
  border: 1px solid #33332a;
  border-radius: 14px;
  padding: 26px 24px 28px;
  color: #d8d4c6;
}

.intro__title {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e8e4d8;
}

.intro__lead {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.6;
}

.intro__notice {
  background: #17170f;
  border: 1px solid #2e2e24;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.intro__h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8d8a82;
}

.intro__notice p {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.6;
}

.intro__small {
  font-size: 12px;
  font-style: italic;
  color: #8d8a82;
}

.intro__field {
  display: block;
  margin-bottom: 18px;
  font-size: 13px;
  color: #a8a49a;
}

.intro__field span { display: block; margin-bottom: 6px; }

.intro__field input {
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #3a3a30;
  background: #14140f;
  color: #e8e4d8;
}

.intro__start,
.intro__skip {
  font: inherit;
  font-weight: 700;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.intro__start {
  font-size: 16px;
  background: #8c2f4a;
  color: #ffe9f0;
  box-shadow: 0 3px 0 #5e1e31;
  margin-bottom: 10px;
}

.intro__start:active { transform: translateY(3px); box-shadow: none; }

.intro__skip {
  font-size: 14px;
  background: transparent;
  color: #a8a49a;
  border: 1px solid #3a3a30;
}

.intro__name {
  margin: 16px 0 0;
  font-size: 12px;
  text-align: center;
  color: #6d6a63;
}

/* --- HUD -------------------------------------------------------------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #14140fee;
  border-bottom: 1px solid #2e2e24;
  z-index: 20;
}

.hud[hidden] { display: none; }

.hud__stat {
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: #e8e4d8;
  min-width: 70px;
}

.hud__stat.is-low { color: #e8909f; }

.hud__plate {
  display: flex;
  gap: 14px;
  flex: 0 1 auto;
  min-width: 200px;
  max-width: 420px;
  margin-right: auto;
}

.plate__seg {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #a8a49a;
  flex: 1;
}

.plate__seg.is-met { color: #9fd08f; }

.plate__label { white-space: nowrap; }

.plate__bar {
  flex: 1;
  height: 8px;
  min-width: 24px;
  background: #2e2e24;
  border-radius: 4px;
  overflow: hidden;
}

.plate__fill {
  height: 100%;
  background: var(--q-mid);
  transition: width 180ms ease-out;
}

.plate__seg.is-met .plate__fill { background: #6f9e5f; }

.plate__count { font-variant-numeric: tabular-nums; }

.hud__btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  background: #2e2e24;
  color: #e8e4d8;
  cursor: pointer;
}

.hud__btn:active { transform: translateY(2px); }

/* --- Panels ----------------------------------------------------------- */

.panel-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 0;
  background: #0c0c08cc;
  z-index: 30;
}

.panel-overlay[hidden] { display: none; }

.panel-card {
  width: min(720px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #1c1c16;
  border: 1px solid #33332a;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}

@media (min-width: 720px) {
  .panel-overlay { place-items: center; padding: 20px; }
  .panel-card { border-radius: 14px; }
}

.panel-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #2e2e24;
  background: #17170f;
}

.panel-card__title {
  margin: 0;
  font-size: 16px;
  color: #e8e4d8;
}

.panel-card__close {
  font: inherit;
  font-size: 14px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #3a3a30;
  border-radius: 8px;
  background: transparent;
  color: #c6c2b6;
  cursor: pointer;
}

.panel-card__body {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- The shop --------------------------------------------------------- */

.shop__greeting {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
  color: #c6c2b6;
}

.shop__aid {
  background: #22221a;
  border: 1px solid #3a3a30;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.shop__aid-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 8px;
  background: #3f5b6b;
  color: #dff0f7;
  cursor: pointer;
}

.shop__aid-btn:disabled { opacity: 0.45; cursor: default; }

.shop__aid-note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #8d8a82;
}

.shop__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px;
  background: #22221a;
  border: 1px solid #33332a;
  border-radius: 10px;
  text-align: center;
}

.item.is-held { border-color: #6f9e5f; background: #1f2a1b; }
.item.is-unaffordable { opacity: 0.5; }

.item__iconwrap {
  display: grid;
  place-items: center;
  min-height: 64px;
  /* The lightest palette shade, so an icon drawn in the other three reads with
     the same contrast it has on the game screen. On the dark card it did not:
     the artwork is authored against shade 0, and putting it on a near-black
     panel left the darkest two shades indistinguishable from the background,
     which is exactly the legibility the language design depends on. */
  background: var(--q-light);
  border-radius: 8px;
  padding: 4px;
  width: 100%;
}

.item__icon { image-rendering: pixelated; display: block; }

.item__name {
  font-size: 14px;
  line-height: 1.35;
  color: #e8e4d8;
  /* The label may be Tamil, Mandarin, Malay or English in the same grid, so the
     row height has to survive scripts with taller glyphs without clipping. */
  min-height: 2.7em;
  display: flex;
  align-items: center;
}

.item__price {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #d9c98a;
}

.item__btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: #8c2f4a;
  color: #ffe9f0;
  cursor: pointer;
}

.item.is-held .item__btn { background: #4a5c42; color: #dcecd4; }
.item.is-unaffordable .item__btn { background: #3a3a30; color: #8d8a82; }

.shop__hint {
  margin: 16px 0 0;
  font-size: 13px;
  color: #a8a49a;
  text-align: center;
}

/* --- The basket ------------------------------------------------------- */

.basket__empty { margin: 0 0 16px; color: #8d8a82; font-size: 14px; line-height: 1.6; }

.basket__list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.basket__row .item__iconwrap {
  min-height: 0;
  padding: 3px;
}

.basket__row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #22221a;
  border-radius: 8px;
}

.basket__name { font-size: 14px; color: #e8e4d8; }
.basket__price { font-size: 14px; font-variant-numeric: tabular-nums; color: #d9c98a; }

.basket__remove {
  font: inherit;
  font-size: 13px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #4a4a3e;
  border-radius: 8px;
  background: transparent;
  color: #c6c2b6;
  cursor: pointer;
}

.basket__shortfall { margin: 0 0 14px; font-size: 14px; color: #a8a49a; }

.basket__submit {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 10px;
  background: #4a7a3a;
  color: #e6f5df;
  cursor: pointer;
}

.basket__submit.is-warn { background: #8a6a2a; color: #f7ecd2; }

/* --- Mission ---------------------------------------------------------- */

.mission__line { margin: 0 0 12px; font-size: 15px; line-height: 1.6; color: #d8d4c6; }
.mission__list { margin: 0 0 14px; padding-left: 20px; color: #d8d4c6; font-size: 15px; line-height: 1.8; }

/* --- Tutorial --------------------------------------------------------- */

.tutorial {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  background: #17170fee;
  border: 1px solid #3a3a30;
  border-radius: 12px;
  padding: 14px 16px;
  color: #d8d4c6;
  font-size: 13.5px;
  z-index: 25;
}

.tutorial strong {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d9c98a;
}

.tutorial ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }

.tutorial__done {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: #3f5b6b;
  color: #dff0f7;
  cursor: pointer;
}

/* --- The report ------------------------------------------------------- */

.report {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 24px 18px 60px;
  background: #14140f;
  color: #d8d4c6;
  z-index: 45;
}

.report[hidden] { display: none; }

.report__head { max-width: 640px; margin: 0 auto 22px; text-align: center; }

.report__title {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e8e4d8;
}

.report__sub { margin: 0; font-size: 15px; color: #a8a49a; }

.report__section {
  max-width: 640px;
  margin: 0 auto 26px;
  background: #1c1c16;
  border: 1px solid #2e2e24;
  border-radius: 12px;
  padding: 18px;
}

.report__h3 {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8d8a82;
}

.report__plate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.report__plateseg {
  background: #22221a;
  border: 1px solid #33332a;
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
}

.report__plateseg.is-met { border-color: #6f9e5f; background: #1f2a1b; }

.report__platecount { font-size: 20px; font-weight: 700; color: #e8e4d8; }
.report__platelabel { margin-top: 4px; font-size: 11px; color: #8d8a82; }

.bar {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) 2fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bar__label { font-size: 12.5px; color: #c6c2b6; line-height: 1.3; }

.bar__track { height: 12px; background: #2e2e24; border-radius: 6px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--q-mid); }

/* Confidence is shown beside every bar, never omitted. A score from two
   observations and a score from twenty look identical otherwise, and the whole
   method depends on not letting them. */
.bar__conf {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.bar__conf--low { background: #3a2f2f; color: #c9a0a0; }
.bar__conf--moderate { background: #3a382a; color: #cfc496; }
.bar__conf--good { background: #2b3a2b; color: #a8cfa0; }

.radar { display: block; width: 100%; max-width: 300px; margin: 20px auto 0; }
.radar__label { font-size: 9px; fill: #8d8a82; }

.report__evidence { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.75; }
.report__evidence li { margin-bottom: 6px; }
.report__evidence li.is-next { color: #cfc496; }

.report__disclaimer {
  max-width: 640px;
  margin: 0 auto 22px;
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.6;
  color: #8d8a82;
  text-align: center;
}

.report__again {
  display: block;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  width: min(320px, 100%);
  min-height: 52px;
  margin: 0 auto;
  border: none;
  border-radius: 10px;
  background: #8c2f4a;
  color: #ffe9f0;
  cursor: pointer;
}

/* The player picker. A dropdown rather than a text box: a nine-year-old typing
   their own name produces "Jonh", "john tan" and "JOHN" across three sessions,
   which fragments one child's data into three children's. */
.intro__select {
  font: inherit;
  font-size: 16px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #3a3a30;
  background: #14140f;
  color: #e8e4d8;
}

.intro__start:disabled,
.intro__skip:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
  transform: none;
}
