/*
 * Bloop Arcade - the dashboard (/app/).
 *
 * Built ON site.css, never beside it: every colour, size, radius and shadow
 * below is a token from there, and the components (.btn, .card, .tabs, .purse,
 * .bloop-tile, .empty, .check, .switch, .segmented...) are reused as they are.
 * This file only adds what the dashboard has that no other page does.
 *
 * NO NEW COLOUR TOKENS. If one is ever needed, it goes in site.css in all
 * three blocks (light, the dark media query, [data-theme="dark"]) - that file's
 * tests hold them together, and a token defined only here would break dark
 * mode silently.
 *
 * THE COLOUR RULES STILL HOLD HERE:
 *   - brand blue is the only action colour (buttons, links, focus, "chosen");
 *   - amber is ONLY money: the coin, purses, prices, the Shop's cut line and
 *     the BlooBucks wallet - never a button, never a warning;
 *   - green is owned / ready / right answer;
 *   - red is only errors and destructive actions.
 *
 * LAYOUT MATH AT 320px. The page gutter is 16px, so content is 288px wide. A
 * .card is 16px padded below 640px, leaving 256px inside one. Every grid below
 * uses minmax(min(100%, N), 1fr) or a fixed column count that fits 256px, and
 * nothing sets a width wider than its container. The header is site.css's.
 *
 * MOTION. Everything that moves is declared inside
 * @media (prefers-reduced-motion: no-preference), at the end of this file,
 * and every @keyframes runs FROM a displaced state TO the element's natural
 * one - the game Shop's house rule - so a redraw that lands mid-animation, or
 * no animation at all, always paints the finished screen.
 */

/* ---------------------------------------------------------------------------
 * Icons: the sprite in app/index.html, drawn in currentColor
 * ------------------------------------------------------------------------- */
.app-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

/* ---------------------------------------------------------------------------
 * The welcome band and the tab bar that sits on its bottom edge
 * ------------------------------------------------------------------------- */
.app-hero {
  background: linear-gradient(180deg, var(--stage-top) 0%, var(--stage-bottom) 100%);
  border-bottom: 1px solid var(--line);
  padding-top: var(--sp-4);
}
@media (min-width: 640px) { .app-hero { padding-top: var(--sp-5); } }

.app-hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding-bottom: var(--sp-4);
}
.app-hello { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: 1 1 260px; }
.app-hello-text { min-width: 0; }
.app-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--surface) 0 45%, var(--brand-soft) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.app-avatar .bloop { width: 74%; }
/* The "Change icon" button sits on the avatar's lower right (DESIGN.md s.14):
   a 44px target around a 32px disc, overhanging the 72px circle by 12px so it
   covers as little of the Bloop as it can while staying a full-size tap. */
.app-avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-edit {
  position: absolute;
  right: -12px;
  bottom: -12px;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-brand);
  cursor: pointer;
}
.avatar-edit-dot {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-fill);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1);
}
.avatar-edit:hover .avatar-edit-dot { background: var(--brand-fill-hover); }
.avatar-edit .icon { width: 16px; height: 16px; }
@media (min-width: 640px) {
  .app-avatar { width: 96px; height: 96px; }
}
.app-title { margin-top: 2px; }
.app-sub { color: var(--ink-2); margin-top: var(--sp-half); font-size: var(--fs-sm); max-width: 52ch; }
@media (min-width: 640px) { .app-sub { font-size: var(--fs-md); } }

.app-hero-side { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1); }

/* The BlooBucks pill in the band: money, so its accents are amber. */
.app-wallet {
  display: inline-grid;
  gap: 2px;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--purse-border);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.app-wallet:hover { box-shadow: var(--shadow-2); text-decoration: none; }
.app-wallet-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.app-wallet .purse { background: transparent; border: 0; padding: 0; }
.app-wallet-off { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
/* Before the locker answers: a quiet blank rather than a misleading 0. */
.purse.is-pending .purse-amount {
  color: transparent;
  background: var(--surface-3);
  border-radius: 6px;
  min-width: 3ch;
}
.app-guest-cta { display: grid; gap: var(--sp-half); justify-items: start; max-width: 280px; }

/* Tabs: site.css .tabs, lifted onto the band's edge. The negative margin
   lets it straddle the border; .app-body makes the room back. */
.app-tabs {
  position: relative;
  z-index: 2;
  margin-bottom: -26px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  width: 100%;
}
@media (min-width: 560px) { .app-tabs { width: max-content; min-width: 420px; } }
.app-tabs .tab { min-height: var(--tap); gap: var(--sp-1); padding: 0 var(--sp-3); }
/* 320px: three equal tabs in 280px, ~93px each; "Shop" with its icon is ~62. */
@media (max-width: 479px) {
  .app-tabs .tab { flex: 1 1 0; min-width: 0; padding: 0 var(--sp-1); gap: 6px; }
}
.app-tabs .tab[aria-current="page"] { background: var(--brand-soft); box-shadow: none; }
.app-tabs .icon { width: 18px; height: 18px; }
/* The play triangle reads better filled. fill set on <use> inherits into the symbol. */
.icon use[href="#i-play"] { fill: currentColor; }

.app-body { padding-top: calc(26px + var(--sp-4)); }
@media (min-width: 640px) { .app-body { padding-top: calc(26px + var(--sp-5)); } }
.app-notice { margin-bottom: var(--sp-3); }

/* Headings and messages the dashboard moves focus TO (after a tab change, a
   save, a purchase) are not controls, so they get no focus ring: the ring
   would look like something to press. Screen readers still land on them. */
[data-panel-title]:focus, .step-title:focus, [data-shop-msg]:focus,
.form-error:focus, .shelf-arm[tabindex="-1"]:focus { outline: none; }

/* Panel headings, shared by every tab */
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.panel-head-text { min-width: 0; flex: 1 1 260px; }
.panel-sub { color: var(--ink-2); margin-top: var(--sp-half); max-width: 62ch; font-size: var(--fs-sm); }
@media (min-width: 640px) { .panel-sub { font-size: var(--fs-md); } }
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
@media (max-width: 479px) { .panel-actions, .panel-actions .btn { flex: 1 1 auto; } }
.field-optional { font-weight: 400; color: var(--muted); }

/* ---------------------------------------------------------------------------
 * PLAY
 * ------------------------------------------------------------------------- */
.play-grid { display: grid; gap: var(--sp-3); align-items: start; }
@media (min-width: 880px) { .play-grid { grid-template-columns: 1.1fr 0.9fr; gap: var(--sp-4); } }
@media (max-width: 639px) { .play-card.card-pad-lg { padding: var(--sp-3) var(--sp-2); } }

.play-card-head { display: flex; gap: var(--sp-2); align-items: flex-start; margin-bottom: var(--sp-3); }
.play-badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--r-card);
  background: var(--brand-fill);
  color: var(--on-brand);
  box-shadow: 0 1px 0 var(--btn-shine) inset, 0 4px 12px var(--btn-glow);
}
.play-badge .icon { width: 26px; height: 26px; }
.play-badge-alt { background: var(--brand-soft); color: var(--brand-ink); box-shadow: none; }

.join-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); }
.join-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--sp-2); align-items: start; }
.join-num, .step-num, .tip-num {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: var(--fs-sm);
  line-height: 1;
}
.join-num { margin-top: -2px; }
.join-code {
  min-height: 64px;
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  /* The letter-spacing adds a gap after the last letter too; this evens it. */
  padding-left: calc(var(--sp-2) + 0.35em);
}
.join-code::placeholder { color: var(--line-strong); }
.join-form > .btn { margin-top: var(--sp-4); }

/* Host: the set picker is a list of big radio rows. */
.host-choices > legend { margin-bottom: var(--sp-1); }
.choice-list { display: grid; gap: var(--sp-1); }
.choice-list.is-long {
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 2px 2px;
}
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 56px;
  padding: 10px var(--sp-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-input);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.choice:hover { border-color: var(--line-strong); }
.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice-body { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.choice-title { font-weight: 700; }
.choice-meta { font-size: var(--fs-xs); color: var(--muted); }
.choice-tick {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: transparent;
}
.choice-tick .icon { width: 16px; height: 16px; stroke-width: 3; }
.choice:has(input:checked) .choice-tick { background: var(--brand-fill); border-color: var(--brand-fill); color: var(--on-brand); }
.choice-plain .choice-title { color: var(--ink-2); }
.host-none { margin-top: var(--sp-2); }
.host-go { margin-top: var(--sp-3); }
/* "You'll play as ..." - the Join box's name, which hosting uses too. */
.host-as { margin-top: var(--sp-3); overflow-wrap: anywhere; }
.host-as + .host-go { margin-top: var(--sp-2); }

.play-tips {
  list-style: none;
  padding: 0;
  margin: var(--sp-5) 0 0;
  display: grid;
  gap: var(--sp-2);
}
@media (min-width: 720px) { .play-tips { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .play-tips { grid-template-columns: repeat(4, 1fr); } }
.play-tips li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: var(--sp-2);
  border-radius: var(--r-card);
  background: var(--bg-tint);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.play-tips strong { display: block; color: var(--ink); }

/* ---------------------------------------------------------------------------
 * SETS: the list
 * ------------------------------------------------------------------------- */
.draft-notice { margin-bottom: var(--sp-3); }
.draft-notice .cluster { margin-top: var(--sp-1); }
.set-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
@media (min-width: 640px) { .set-grid { gap: var(--sp-3); } }
.set-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  overflow: hidden;
  padding-top: var(--sp-4);
}
/* A strip of brand along the top: the card reads as "a set" at a glance, and
   it is decoration, so it carries no meaning a colour-blind reader misses. */
.set-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--brand-soft-2));
}
.set-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-1); flex-wrap: wrap; }
.set-count {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 12px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.set-count strong { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; }
.set-title { font-size: var(--fs-md); margin-top: var(--sp-half); }
@media (min-width: 640px) { .set-title { font-size: var(--fs-md); } }
.set-title a { color: var(--ink); text-decoration: none; }
.set-title a:hover { color: var(--brand-ink); text-decoration: underline; }
.set-meta { font-size: var(--fs-xs); color: var(--muted); }
.set-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: auto; padding-top: var(--sp-1); }
.set-delete { margin-left: auto; color: var(--danger-ink); }
.set-confirm {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--r-input);
  background: var(--danger-soft);
  border: 1.5px solid var(--danger);
}
.set-confirm-text { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.set-card.is-asking, .coll-item.is-asking { border-color: var(--danger); }

/* ---------------------------------------------------------------------------
 * SETS: the editor
 * ------------------------------------------------------------------------- */
.editor, .importer { max-width: 800px; margin-inline: auto; }
.editor-top { margin-bottom: var(--sp-1); margin-left: calc(-1 * var(--sp-1)); }
.editor > .panel-title { margin-bottom: var(--sp-3); }
.editor > .form-error { margin-bottom: var(--sp-3); }
/* A save that did not happen and was undone (a set or Maker Bloop back in its
   list, a Wear taken off): said above the list it happened in. */
.sets-error, .maker-saved-error { margin-bottom: var(--sp-3); }
.editor-details .field + .field { margin-top: var(--sp-2); }

/* The Share card (DESIGN.md s.7): a switch, then the link and its options. */
.editor-share { margin-top: var(--sp-3); }
.editor-share-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-1) var(--sp-2); }
.editor-share-title { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-md); }
.editor-share-title .icon { width: 20px; height: 20px; color: var(--brand-ink); }
.editor-share > .field-hint { margin-top: var(--sp-half); }
.editor-share .field, .editor-share .check { margin-top: var(--sp-2); }
.editor-share-renew { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-1); margin-top: var(--sp-1); margin-left: calc(-1 * var(--sp-1)); }
.set-shared .icon { width: 14px; height: 14px; }
.field-foot { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-1); min-height: 0; }
.counter { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.editor-items-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-half) var(--sp-2);
  margin: var(--sp-5) 0 var(--sp-2);
}
.editor-items-title { display: inline-flex; align-items: center; gap: var(--sp-1); }
.undo-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--sp-2);
  padding: 0 var(--sp-2);
  margin-bottom: var(--sp-2);
  border-radius: var(--r-input);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.undo-bar .link-btn { color: var(--bg); }

.q-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); counter-reset: none; }
.q-card { scroll-margin-top: calc(var(--header-h) + var(--sp-2)); }
.q-card.has-problem { border-color: var(--danger); }
.q-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-2); }
.q-num {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-weight: 800;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.select-sm { min-height: var(--tap); }
.q-kind { width: auto; flex: 1 1 160px; max-width: 220px; }
.q-tools { display: flex; gap: 2px; margin-left: auto; }
.q-tools .btn[disabled] { opacity: 0.3; }
.q-body .field + .field, .q-body .field + fieldset.field { margin-top: var(--sp-2); }
.q-text { min-height: 72px; }
.opt-set > legend { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.opt-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-1); }
.opt-row { display: flex; align-items: center; gap: var(--sp-half); min-width: 0; }
.opt-row .input { flex: 1; min-width: 0; }
.opt-row.is-correct .input { border-color: var(--success); background: var(--success-soft); }
.opt-tick { position: relative; display: grid; place-items: center; flex-shrink: 0; width: var(--tap); height: var(--tap); cursor: pointer; }
.opt-tick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.opt-tick-box {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--input-border);
  background: var(--surface);
  color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.opt-tick-box .icon { width: 18px; height: 18px; stroke-width: 3; }
.opt-tick:hover .opt-tick-box { border-color: var(--success); }
.opt-tick input:checked + .opt-tick-box { background: var(--success); border-color: var(--success); color: var(--mark-ink); }
.opt-tick input:focus-visible + .opt-tick-box { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt-add { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--sp-half); text-decoration: none; }
.opt-add .icon { width: 18px; height: 18px; }
.q-problem { margin-top: var(--sp-2); }

.q-add {
  display: grid;
  justify-items: center;
  gap: var(--sp-1);
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-card);
  text-align: center;
}
.q-add-label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.q-add-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-1); }

/* The save bar floats at the bottom of the screen while the editor scrolls. */
.editor-bar {
  position: sticky;
  bottom: var(--sp-2);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  box-shadow: var(--shadow-3);
}
.editor-status { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.editor-status.is-dirty { color: var(--ink); }
.editor-status.is-dirty::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.editor-bar-actions { display: flex; gap: var(--sp-1); margin-left: auto; }
/* One row at 320px: status and Save. "Your sets" at the top of the editor is
   the same link as Close, so nothing is lost. */
@media (max-width: 419px) { .editor-bar-close { display: none; } }
.save-check { flex: 1; }
.save-check .cluster { margin-top: var(--sp-1); }

/* ---------------------------------------------------------------------------
 * SETS: Bring a set
 * ------------------------------------------------------------------------- */
.panel-head-stack { margin-bottom: var(--sp-3); }
.import-step + .import-step { margin-top: var(--sp-3); }
.step-title { display: flex; align-items: center; gap: 12px; margin-bottom: var(--sp-2); font-size: var(--fs-md); }
@media (min-width: 640px) { .step-title { font-size: var(--fs-lg); } }
.import-source { max-width: 520px; margin-bottom: var(--sp-3); }
.import-source span { flex-direction: row; gap: var(--sp-1); }
.import-source .icon { width: 18px; height: 18px; flex-shrink: 0; }
/* Three choices in 256px (a card at 320px): icon above the words, and the
   words may take two lines. Each is still 44px or more tall. */
@media (max-width: 519px) {
  .import-source span { flex-direction: column; gap: 2px; padding-inline: var(--sp-half); font-size: var(--fs-xs); }
}
/* Paste a link: the box and its button share a line when there is room. */
.import-link-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.import-link-row .input { flex: 1 1 220px; min-width: 0; }
.import-link-row .btn { flex: 0 0 auto; }
.import-source-body .field + .field { margin-top: var(--sp-2); }
.import-paste { font-family: var(--font-mono); font-size: var(--fs-sm); min-height: 180px; }
.import-sep { max-width: 340px; }

.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--sp-half);
  padding: var(--sp-4) var(--sp-2);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-card);
  background: var(--bg-tint);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--sp-1);
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand-ink);
  box-shadow: var(--shadow-1);
}
.dropzone-icon .icon { width: 26px; height: 26px; }
.dropzone-title { font-weight: 800; color: var(--brand-ink); }
.dropzone-text { font-size: var(--fs-sm); color: var(--ink-2); }
.dropzone-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-top: var(--sp-1);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.dropzone + .field-hint, .import-reading + .field-hint { margin-top: var(--sp-2); }
.import-reading { display: flex; align-items: center; gap: var(--sp-1); margin-top: var(--sp-2); font-size: var(--fs-sm); font-weight: 600; }
.import-reading .spinner, .shelf-unlocking .spinner { width: 18px; height: 18px; border-width: 2.5px; }
.import-template {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-half) var(--sp-1);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
}
.import-template .btn { margin-left: calc(-1 * var(--sp-1)); }

.import-summary { margin-bottom: var(--sp-2); }
.import-count { font-size: var(--fs-md); }
.import-flip { margin: var(--sp-2) 0; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-input); background: var(--surface-2); }
.import-flip .switch > span:last-child { display: inline-flex; align-items: center; gap: 6px; }
.import-flip .field-hint { padding-bottom: var(--sp-1); }
.import-unreadable {
  margin: var(--sp-2) 0;
  padding: 0 var(--sp-2);
  border: 1.5px solid var(--danger);
  border-radius: var(--r-input);
  background: var(--danger-soft);
  font-size: var(--fs-sm);
}
.import-unreadable summary { display: flex; align-items: center; gap: var(--sp-1); min-height: var(--tap); font-weight: 700; cursor: pointer; list-style: none; }
.import-unreadable summary::-webkit-details-marker { display: none; }
/* A flex summary loses its triangle in some browsers, so it says what it does. */
.import-unreadable summary::after { content: "Show"; margin-left: auto; color: var(--brand-ink); font-weight: 700; }
.import-unreadable[open] summary::after { content: "Hide"; }
.import-unreadable ul { margin: 0 0 var(--sp-2); }
.import-table-wrap { max-height: 560px; overflow: auto; margin-top: var(--sp-2); }
.import-table thead th { position: sticky; top: 0; z-index: 1; }
.import-row-n { width: 1%; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.import-kind { display: block; font-size: var(--fs-xs); }
.import-problem { display: block; margin-top: var(--sp-half); color: var(--danger-ink); font-size: var(--fs-xs); font-weight: 700; }
.import-wrong { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-xs); }
.import-act { width: 1%; white-space: nowrap; text-align: right; }
.import-table tr.is-dropped td:not(.import-act),
.import-table tr.is-blocked td:not(.import-act) { opacity: 0.55; }
.import-table tr.is-dropped .import-q, .import-table tr.is-dropped .import-a { text-decoration: line-through; }
/* Below 640px the table becomes stacked rows: row number and question on the
   left, the Drop button on the right, the answer underneath. Still a <table>
   to a screen reader; only the boxes change. */
@media (max-width: 639px) {
  .import-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .import-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px var(--sp-1);
    padding: 12px var(--sp-2);
    border-bottom: 1px solid var(--line);
  }
  .import-table tr:last-child { border-bottom: 0; }
  .import-table td { display: block; padding: 0; border: 0; }
  .import-table .import-row-n { grid-column: 1; width: auto; font-size: var(--fs-xs); }
  .import-table .import-kind { display: inline; margin-left: 6px; }
  .import-table .import-q { grid-column: 1; font-weight: 600; }
  .import-table .import-a { grid-column: 1; }
  .import-table .import-act { grid-column: 2; grid-row: 1 / span 3; align-self: center; width: auto; }
}

/* ---------------------------------------------------------------------------
 * SHOP
 * ------------------------------------------------------------------------- */
.shop-tabs { margin-bottom: var(--sp-3); }
@media (min-width: 480px) { .shop-tabs { width: max-content; } }
.shop-tabs .tab { min-height: var(--tap); }
.shop-tabs .icon { width: 18px; height: 18px; }

.wallet-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  background: linear-gradient(135deg, var(--money-soft) 0%, var(--surface) 75%);
  border-color: var(--purse-border);
}
.wallet-main { display: grid; gap: var(--sp-half); }
.wallet-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.wallet-purse { position: relative; display: inline-flex; align-items: center; gap: var(--sp-1); }
.spent-chip { font-size: var(--fs-sm); }
.wallet-earn { font-size: var(--fs-sm); color: var(--ink-2); max-width: 46ch; }

.shop-msg { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); font-weight: 700; }
.shop-msg:empty { display: none; }
.shop-msg.is-success { color: var(--success-ink); }
.shop-msg.is-error { color: var(--danger-ink); }

.drop { margin-top: var(--sp-5); }
.drop-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-half) var(--sp-2);
  margin-bottom: var(--sp-2);
}
.drop-title { font-size: var(--fs-lg); }
.drop-count { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The two Bloops each drop gives away for playing */
.earn-grid { display: grid; gap: var(--sp-1); }
@media (min-width: 560px) { .earn-grid { grid-template-columns: 1fr 1fr; } }
.earn-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1.5px solid var(--line);
}
.earn-card.is-got { border-color: var(--success); background: var(--success-soft); }
.earn-art .bloop { width: 56px; }
.earn-text { min-width: 0; display: grid; }
.earn-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.earn-sub { font-size: var(--fs-xs); color: var(--muted); }
.earn-card.is-got .earn-sub { color: var(--success-ink); font-weight: 700; }
.pips { display: flex; gap: 4px; }
.pip { display: block; width: 14px; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); box-shadow: inset 0 1px 2px var(--knob-shadow); }
.pip.is-on { background: var(--success); box-shadow: none; }
.earn-note { margin: var(--sp-1) 0 var(--sp-3); font-size: var(--fs-xs); color: var(--muted); }
.drop-done { display: flex; align-items: center; gap: var(--sp-1); margin-bottom: var(--sp-2); font-size: var(--fs-sm); font-weight: 700; color: var(--success-ink); }
.shelf-hint { margin-bottom: 12px; font-size: var(--fs-sm); color: var(--ink-2); }

/* THE SHELF. One column on a phone, a grid wider up. The sort is by price in
   reading order, and the cut line spans the whole grid row, so "above the
   line" keeps meaning "cheaper than where your money runs out". */
.shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* TWO FIXED BANDS (see js/app/shop.js). .shelf-arm is the top band and the
   only thing that arms; .shelf-band is the bottom band and the only thing that
   spends. The band is the SAME height in every state - it is sized to its
   tallest occupant, the Spend/Keep pair - so arming moves nothing and a second
   tap never lands on a control the first one uncovered. */
.shelf-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.shelf-arm {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 12px var(--sp-half);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
span.shelf-arm { cursor: default; }
/* Hover promises no more than the press delivers: a tint, no lift. */
button.shelf-arm:hover { background: var(--surface-2); }
.shelf-arm:focus-visible { outline-offset: -3px; border-radius: var(--r-card) var(--r-card) 0 0; }
.shelf-art .bloop { width: 64px; }
/* One column on a phone: a slimmer row, so a drop is not a mile of scrolling. */
@media (max-width: 559px) {
  .shelf-arm, .shelf-item.is-armed .shelf-arm { grid-template-columns: 48px minmax(0, 1fr); }
  .shelf-item.is-armed .shelf-arm { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .shelf-art .bloop { width: 48px; }
  .shelf-arm { padding-top: var(--sp-1); }
}
.shelf-name { min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
  min-height: 56px;
  padding: var(--sp-half) 12px 12px;
}
.shelf-gap { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.shelf-item.is-far { background: transparent; box-shadow: none; }
.shelf-item.is-far .shelf-art { opacity: 0.8; }

/* Armed: brand, because it is chosen; the price inside Spend is still a coin. */
.shelf-item.is-armed { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2); }
.shelf-item.is-armed .shelf-arm { grid-template-columns: 64px minmax(0, 1fr) auto; }
.shelf-item.is-armed .shelf-band { justify-content: flex-start; }
.shelf-note {
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.shelf-spend { flex: 1 1 auto; font-variant-numeric: tabular-nums; }
.shelf-spend .coin { width: 16px; height: 16px; }
.shelf-keep { flex: none; }
.shelf-unlocking { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }

.shelf-item.is-have { border-color: var(--success-soft); }
.shelf-have { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 800; color: var(--success-ink); }
.shelf-have .icon { width: 18px; height: 18px; stroke-width: 3; }
/* Bought a moment ago: the price paid, with a green ribbon wiped across it. */
.shelf-paid { position: relative; display: inline-flex; overflow: hidden; padding: 2px 8px; border-radius: 6px; }
.shelf-ribbon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--success);
  color: var(--mark-ink);
  font-size: var(--fs-xs);
  font-weight: 800;
}
.shelf-ribbon .icon { width: 14px; height: 14px; stroke-width: 3; }

/* THE CUT LINE: one amber rule where the balance runs out. Money, so amber. */
.shelf-cut { grid-column: 1 / -1; list-style: none; padding: var(--sp-half) 0; }
.cut-rule { display: block; height: 3px; border-radius: 3px; background: var(--money); transform-origin: left center; }
.cut-label { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--sp-1); font-size: var(--fs-sm); font-weight: 700; color: var(--money-ink); }
.cut-short { margin-top: var(--sp-half); font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
.cut-short b { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 330px) { .cut-words { display: none; } }

/* The collection, and saved Maker Bloops */
.collection { margin-top: var(--sp-6); }
.coll-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr));
}
.coll-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  padding: 12px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}
.coll-item .bloop-tile { width: 100%; }
.coll-name { font-size: var(--fs-sm); font-weight: 700; line-height: 1.3; }
.coll-dl, .coll-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.coll-dl .btn, .coll-actions .btn { padding: 0 10px; }
.coll-dl .icon, .coll-actions .icon { width: 16px; height: 16px; }
.coll-pro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  color: var(--muted);
  text-decoration: none;
}
.coll-pro:hover { color: var(--brand-ink); text-decoration: none; }
.coll-pro .icon { width: 16px; height: 16px; }
.coll-item .set-confirm { width: 100%; margin-top: 0; }

/* ---------------------------------------------------------------------------
 * BLOOP MAKER
 * ------------------------------------------------------------------------- */
.maker-grid { display: grid; gap: var(--sp-3); align-items: start; }
@media (min-width: 880px) {
  .maker-grid { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .maker-stage-card { position: sticky; top: calc(var(--header-h) + var(--sp-2)); }
}
.maker-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 5 / 4;
  margin-bottom: var(--sp-3);
  overflow: hidden;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 30%, var(--surface) 0 22%, var(--stage-top) 100%);
}
/* The ground the Bloop stands on. */
.maker-stage::after {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  bottom: 9%;
  height: 7%;
  border-radius: 50%;
  background: var(--bloop-shadow);
}
.maker-preview { position: relative; z-index: 1; width: 56%; margin-bottom: 6%; }
.maker-preview .bloop { width: 100%; }
.maker-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-3); }
.maker-actions .btn { flex: 1 1 130px; }
.maker-count { margin-top: 12px; text-align: center; }

.maker-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-half);
  padding: var(--sp-half);
  margin-bottom: var(--sp-3);
  border-radius: var(--r-card);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
@media (min-width: 560px) { .maker-slots { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.maker-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--r-input);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.maker-slot:hover { background: var(--surface); color: var(--ink); }
.maker-slot[aria-selected="true"] { background: var(--surface); color: var(--brand-ink); box-shadow: var(--shadow-1); }
.maker-slot:focus-visible { border-radius: var(--r-input); }
.maker-slot-pick {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
}
.maker-choice-grid {
  display: grid;
  gap: var(--sp-1);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 96px), 1fr));
}
.maker-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-half);
  min-width: 0;
  padding: var(--sp-1) 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.maker-choice:hover { border-color: var(--line-strong); }
.maker-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.maker-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.maker-choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.maker-choice-art { width: 76%; }
.maker-choice-art .bloop { width: 100%; }
.maker-choice-name { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); line-height: 1.25; }
.maker-choice:has(input:checked) .maker-choice-name { color: var(--brand-ink); }
.maker-swatch { width: 12px; height: 12px; flex-shrink: 0; }
.maker-swatch circle { stroke: var(--line-strong); stroke-width: 1; }

.maker-saved { margin-top: var(--sp-6); }
.maker-saved-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 156px), 1fr)); }
.maker-empty {
  padding: var(--sp-3);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-card);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  text-align: center;
}
.maker-teaser { display: flex; justify-content: center; align-items: flex-end; gap: var(--sp-1); margin-bottom: var(--sp-1); }
.maker-teaser .bloop { width: 72px; }
.maker-teaser .bloop:nth-child(2) { width: 88px; }

/* ---------------------------------------------------------------------------
 * Motion - only for people who have not asked for less of it. Every keyframe
 * runs FROM a displaced state TO the natural one (no `to`), so stopping it
 * anywhere is the finished screen.
 * ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .app-panel:not([hidden]) { animation: app-in 220ms var(--ease); }
  .set-card, .coll-item, .earn-card { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
  .set-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
  .maker-choice:active { transform: scale(0.97); }
  .maker-preview.is-pop .bloop { animation: app-pop 260ms var(--ease); transform-origin: 50% 100%; }
  .shelf-item.is-won .shelf-ribbon { animation: app-wipe 260ms cubic-bezier(.22, 1, .36, 1) both; }
  .shelf-cut.is-moved .cut-rule { animation: app-rule 300ms cubic-bezier(.22, 1, .36, 1) both; }
  .wallet-purse.is-ticking .purse-amount, .drop-count.is-ticking { display: inline-block; animation: app-tick 220ms var(--ease) both; }
  .spent-chip { animation: app-chip 260ms var(--ease) both; }
  .app-tabs .tab, .maker-slot { transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
}
@keyframes app-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes app-pop { from { transform: scale(0.9, 1.08); } }
@keyframes app-wipe { from { transform: translateX(-101%); } }
@keyframes app-rule { from { transform: scaleX(0); } }
@keyframes app-tick { from { transform: translateY(-4px); opacity: 0.35; } }
@keyframes app-chip { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .app-panel, .maker-preview .bloop, .shelf-ribbon, .cut-rule, .purse-amount, .drop-count, .spent-chip { animation: none; }
  .set-card:hover { transform: none; }
}

@media (forced-colors: active) {
  .choice:has(input:checked), .maker-choice:has(input:checked), .shelf-item.is-armed { outline: 3px solid Highlight; }
  .opt-tick input:checked + .opt-tick-box { background: Highlight; color: HighlightText; }
  .cut-rule { background: CanvasText; }
}
