/*
 * game.css — styles for games built with game.js. Load after theme.css.
 *
 * .level-list > button.level (level menu), .hud, .timer > .timer-fill,
 * .stage (.locked after answering; with a picture in it, its answers
 * show characters without Jyutping), .game-feedback, .game-end
 * (.perfect: the stars pop in), canvas.celebrate (Game.celebrate),
 * .stars, .btn.small, .speech (a speech bubble), .tray (labelled box
 * of answer buttons), .prompt-pic (big picture to answer about),
 * .prompt-pic.far (the same, small and faded: "over there"),
 * .prompt-num (big numeral to answer about), .pic-row (a group of small
 * pictures to count, in rows of five; smaller inside .choice-grid.groups answers), .tile-line / .tile-bank >
 * button.tile (word tiles, tiles.js; .tile-line.right / .wrong),
 * .stall (a .prompt-pic with an optional .price-tag), .till (a box that
 * collects tapped .pic-btn money; .right / .wrong) and .till-total,
 * .pic-grid.cols-4, .pic-grid.pics (square picture answers on
 * .choice buttons, from Game.choose: clocks, family trees), .stepper (◀ label ▶ row),
 * .prompt-pic.right / .wrong, .ticket (an order pad: .ticket-row >
 * .ticket-label + .ticket-opts of small .pic-btn / .choice buttons), and
 * .map (a 5 × 5 street map: .road, .block, .road.you, and .pic-btn.spot
 * places), .dress (a .figure with img.layer clothes placed on it by
 * the game, beside a .rack of clothes to pick), .choice-grid.forecast
 * (a row of days, each a .choice with the day, a weather picture and a
 * .temp), and .chart (a patient's chart, a survey sheet: .chart-item
 * pictures, each with a .mark.yes ✓ or .mark.no ✗, from Game.chart; a
 * .mark can sit on a .pic-grid.pics answer too), .planner (a day planner: .plan-item
 * cards, each a clock over a picture) with .now (the time now), and
 * .pic-grid.order (pictures tapped in order, numbered by .order-num),
 * .pic-grid.pair / .three (two or three big picture answers), and
 * .versus (things side by side to compare: .versus-item pictures, or a
 * .pic-word for a word without one, each with an optional .tag, a price,
 * an age or a height; a .tag can sit on a .pic-grid.pics answer too).
 */

.btn.small { padding: 6px 12px; font-size: 14px; }

/* Level menu */
.level-list { display: grid; gap: 12px; margin-top: 16px; }
.level {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .level:hover:not(:disabled) { border-color: var(--ink-soft); } }
.level:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.level:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.level-num {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}
.level-text { flex: 1; display: flex; flex-direction: column; }
.level-text span { color: var(--ink-soft); font-size: 15px; }
.level-best { flex: none; text-align: right; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; }
.stars { color: var(--gold); letter-spacing: 2px; }
.stars.big { font-size: 40px; margin: 0; }

/* Play screen */
.hud { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.hud-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.streak { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); color: var(--ink); }
.timer { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 16px; }
.timer-fill { height: 100%; background: var(--jade); transform-origin: left; transition: background 0.3s; }
.timer-fill.low { background: var(--bad); }
.stage.locked { pointer-events: none; }
/* A round with a picture is about reading the characters: its answers
   (choices, tiles, picture labels) show no Jyutping. The answer line after
   the round still gives it. */
.stage:has(img) :is(.choice, .tile, .pic-label) .zh :is(.jp, rt) { display: none; }
.stage:has(img) :is(.choice, .tile) .zh ruby { margin: 0; }
.game-feedback { min-height: 3.5em; }
.game-feedback .btn { margin-left: 8px; vertical-align: middle; }

/* Speech bubble */
.speech {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-width: 520px;
}
.speech::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: -10px;
  width: 18px;
  height: 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
.speech .who {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 22px;
  font-weight: 700;
}
.speech p { margin: 0; flex: 1; }

/* Tray of answers */
.tray {
  border: 3px solid var(--gold);
  border-radius: 18px;
  padding: 12px;
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
  max-width: 664px;
}
.tray-label { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.prompt-pic { display: block; width: 160px; height: 160px; margin: 0 0 16px; }
.prompt-pic.far { width: 64px; height: 64px; margin: 48px 0 64px 96px; opacity: 0.75; }
.pic-row { display: grid; grid-template-columns: repeat(5, auto); justify-content: start; gap: 4px; margin: 0 0 16px; }
.pic-row img { width: 64px; height: 64px; }
.choice-grid.groups .choice { padding: 10px; display: grid; place-items: center; min-height: 96px; }
.choice-grid.groups .pic-row { margin: 0; justify-content: center; }
@media (max-width: 420px) { .pic-row img { width: 52px; height: 52px; } }
.choice-grid.groups .pic-row img { width: 40px; height: 40px; }
.prompt-num { margin: 0 0 16px; font-size: 56px; font-weight: 800; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }

/* Word tiles (tiles.js) */
.tile-line, .tile-bank, .till { display: flex; flex-wrap: wrap; gap: 8px; max-width: 664px; }
.tile-line, .till {
  min-height: 76px;
  margin-bottom: 14px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  align-content: flex-start;
}
:is(.tile-line, .till):empty::before { content: attr(data-empty); color: var(--ink-soft); align-self: center; padding: 0 6px; }
:is(.tile-line, .till).right { border-style: solid; border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
:is(.tile-line, .till).wrong { border-style: solid; border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.tile-bank { margin-bottom: 16px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .tile:hover { border-color: var(--ink-soft); } }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tile .hanzi { font-size: 24px; font-weight: 700; line-height: 1.2; }
.tile .jp { font-size: 13px; }
.tile-line .tile { border-color: var(--accent); }

/* Market stall: a thing with a price tag, and money on the counter */
.stall { position: relative; display: inline-block; margin: 0 0 16px; }
.stall .prompt-pic { margin: 0; }
.price-tag {
  position: absolute;
  right: -12px;
  bottom: 8px;
  padding: 4px 12px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  transform: rotate(-6deg);
}
.till { margin-bottom: 6px; }
.till .pic-btn { width: 56px; height: 56px; padding: 2px; }
.till-total { margin: 0 0 10px; min-height: 1.5em; font-weight: 700; color: var(--ink-soft); }
.pic-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.purse { margin-top: 16px; max-width: 520px; }

/* Square picture answers (clocks, family trees), and setting a clock with steppers */
.pic-grid.pics .choice { aspect-ratio: 1; padding: 8px; }
.pic-grid.pics img { display: block; width: 100%; height: 100%; }
.prompt-pic.right, .prompt-pic.wrong { border-radius: 50%; outline: 4px solid var(--good); outline-offset: 2px; }
.prompt-pic.wrong { outline-color: var(--bad); }
.stepper { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.stepper span { min-width: 5.5em; text-align: center; font-weight: 700; color: var(--ink-soft); }

/* Order ticket: a row of options per thing to choose */
.ticket {
  max-width: 520px;
  margin: 0 0 16px;
  padding: 12px 14px 4px;
  border: 2px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 6px 6px 14px 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ticket-row { margin: 0 0 12px; }
.ticket-label { margin: 0 0 6px; color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.ticket-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-opts .pic-btn { width: 72px; padding: 4px; }
.ticket-opts .choice { padding: 6px 14px; font-size: 17px; }
.ticket-opts .choice .hanzi { font-size: 20px; }

/* Street map: roads, blocks, places to tap, and where you are */
.map {
  display: grid;
  grid-template: repeat(5, minmax(0, 1fr)) / repeat(5, minmax(0, 1fr));
  max-width: 400px;
  aspect-ratio: 1;
  margin: 0 0 16px;
  border-radius: 14px;
  overflow: hidden;
  background: color-mix(in srgb, var(--jade) 12%, var(--surface));
}
.map .road { background: #8a9aa5; }
.map .block { margin: 5px; border-radius: 8px; background: color-mix(in srgb, var(--ink-soft) 16%, transparent); }
.map .spot { margin: 3px; padding: 3px; aspect-ratio: auto; min-height: 0; }
.map .spot img { object-fit: contain; }
.map .you { display: grid; place-items: center; align-content: center; color: #ffffff; font-size: 22px; font-weight: 800; line-height: 1; }
.map .you span { font-size: 14px; }

/* Dressing a figure: layers are placed on it in % by the game */
.dress { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin: 0 0 16px; }
.figure { position: relative; flex: none; width: 240px; aspect-ratio: 1; }
.figure img { position: absolute; left: 0; top: 0; width: 100%; }
.dress .rack { flex: 1 1 260px; max-width: 400px; }
@media (max-width: 560px) { .figure { width: 160px; margin: 0 auto; } }

/* A weather forecast: a day per column (two rows of two on phones) */
.choice-grid.forecast { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.forecast .choice { display: grid; justify-items: center; gap: 4px; padding: 10px 6px; }
.forecast .choice .hanzi { font-size: 18px; }
.forecast img { width: 100%; max-width: 88px; aspect-ratio: 1; }
.forecast .temp { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .choice-grid.forecast { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* A chart (a patient's, a survey sheet): pictures ticked or crossed */
.chart { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; padding: 12px; border: 2px dashed var(--line); border-radius: var(--radius); max-width: 400px; }
.chart-item { position: relative; width: 104px; }
.chart-item img { display: block; width: 100%; aspect-ratio: 1; }
.pic-grid.pics .choice { position: relative; }
:is(.chart, .pic-grid.pics) .mark { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--surface); font-size: 20px; font-weight: 800; }
.mark.yes { background: var(--good); }
.mark.no { background: var(--bad); }
@media (max-width: 560px) { .chart-item { width: calc((100% - 24px) / 3); } }

/* End screen */
.game-end { text-align: center; padding: 16px 0; }
.end-score { margin: 0; font-size: 56px; font-weight: 800; color: var(--accent); }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
/* A perfect level: the stars pop in one by one (fade, for reduced motion),
   under Game.celebrate's canvas */
.game-end.perfect .stars.big span { display: inline-block; animation: star-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) backwards; animation-delay: calc(var(--i) * 0.15s + 0.1s); }
@keyframes star-pop { from { transform: scale(0); opacity: 0; } }
@keyframes star-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .game-end.perfect .stars.big span { animation-name: star-fade; } }
.celebrate { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

/* A day planner: a clock over each thing to do, and the time now */
.planner { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 16px; max-width: 440px; }
.plan-item { display: grid; justify-items: center; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.plan-item img { display: block; width: 100%; aspect-ratio: 1; }
.plan-item img.clock { width: 70%; }
.now { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; font-weight: 700; }
.now img { width: 88px; height: 88px; }
@media (max-width: 560px) {
  .planner { grid-template-columns: repeat(2, 1fr); }
  .plan-item { grid-template-columns: 1fr 1fr; align-items: center; }
  .plan-item img.clock { width: 100%; }
}

/* Pictures tapped in order: 1, 2 */
.pic-grid.order .pic-btn { position: relative; }
.order-num { position: absolute; top: 6px; left: 6px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #26323c; font-weight: 800; }

/* Two or three picture answers, and things side by side to compare, with tags */
.pic-grid.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 400px; }
.pic-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 540px; }
.versus { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; }
.versus-item { position: relative; width: 136px; aspect-ratio: 1; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.versus-item img { display: block; width: 100%; height: 100%; }
.pic-word { display: grid; place-items: center; width: 100%; height: 100%; font-size: 56px; font-weight: 700; color: var(--ink); }
:is(.versus-item, .pic-grid.pics .choice) .tag { position: absolute; top: 4px; right: 4px; padding: 1px 6px; border: 2px solid var(--gold); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); font-size: 16px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
