/* Peelgrim layout. Skin-agnostic: every colour and font comes from a --pg-* token
 * defined by the active skin (skins/<id>/skin.css). Never put a literal colour here.
 *
 * Boxes use a notched 4px pixel border: four hard box-shadows, no radius, no blur,
 * coloured by --edge on each element. The shadows sit OUTSIDE the box, so anything
 * with .px needs 4px of clear space around it.
 */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--pg-ground);
  color: var(--pg-ink);
  font: 17px/1.35 var(--pg-font-body);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

img { image-rendering: pixelated; }

.px {
  --edge: var(--pg-edge-soft);
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), var(--bevel, 0 0 0 0 transparent);
}

.top, main { max-width: 520px; margin: 0 auto; }

/* --- header --- */

.top { display: flex; align-items: center; gap: 12px; padding: 4px 4px 16px; }
.hero { width: 48px; height: 48px; flex: none; }
.hero img { width: 48px; height: 48px; display: block; }
.title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
h1 { margin: 0; font: 15px/1 var(--pg-font-display); letter-spacing: 1px; color: var(--pg-edge); }
.tagline { margin: 0; font-size: 14px; color: var(--pg-ink-dim); }

.xp { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--pg-panel); }
.xp .coin { width: 20px; height: 20px; }
.xp-total { font: 12px/1 var(--pg-font-display); color: var(--pg-xp); font-variant-numeric: tabular-nums; }
.xp-unit { font: 8px/1 var(--pg-font-display); color: var(--pg-ink-dim); }

/* The cheer: a stepped hop, so it moves in whole jumps like a sprite would. */
@keyframes pg-cheer {
  0% { transform: translateY(0); }
  12% { transform: translateY(-8px); }
  25% { transform: translateY(-14px); }
  38% { transform: translateY(-8px); }
  50% { transform: translateY(0); }
  62% { transform: translateY(-6px); }
  75%, 100% { transform: translateY(0); }
}
.hero img.cheering { animation: pg-cheer 0.8s steps(1, end) both; }
@media (prefers-reduced-motion: reduce) {
  .hero img.cheering { animation: none; }
}

/* --- add form --- */

.card {
  --edge: var(--pg-edge);
  --bevel: inset 0 -4px 0 0 var(--pg-shadow);
  margin: 4px 4px 28px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--pg-panel);
}

input[type="text"] {
  width: 100%;
  font: 18px var(--pg-font-body);
  color: var(--pg-ink);
  background: var(--pg-ground);
  border: 0; border-radius: 0;
  padding: 12px;
  box-shadow: inset 4px 4px 0 0 var(--pg-shadow);
  -webkit-appearance: none; appearance: none;
}
input[type="text"]::placeholder { color: var(--pg-ink-faint); }

:focus-visible, label:focus-within { outline: 4px solid var(--pg-xp); outline-offset: 4px; }
input[type="text"]:focus-visible { outline-offset: 2px; }

.tiers { border: 0; padding: 0; margin: 0; min-width: 0; }
.tiers legend { padding: 0; margin-bottom: 10px; font: 9px/1 var(--pg-font-display); color: var(--pg-ink-dim); }
.tier-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 4px; }
.tier {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 64px; padding: 8px 0 6px;
  border: 0; border-radius: 0;
  background: var(--pg-ground);
  cursor: pointer;
}
.tier img { width: 32px; height: 32px; }
.tier-xp { font: 8px/1 var(--pg-font-display); }
.tier[aria-checked="true"] { --edge: var(--pg-xp); --bevel: inset 0 -4px 0 0 var(--pg-shadow); background: var(--pg-panel-raised); }

.hint { margin: 0; min-height: 40px; display: flex; align-items: flex-start; gap: 8px; font-size: 15px; line-height: 1.3; }
.hint img { width: 12px; height: 14px; margin-top: 2px; flex: none; }
.hint strong { font-weight: 600; }
#hint-text, #tears-text { color: var(--pg-ink-dim); }
#tears-name { color: var(--pg-tears); }

.tears-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 4px; }
.tears-picker .tier { min-height: 52px; justify-content: center; gap: 6px; }
.tears-picker .tier-xp { color: var(--pg-tears); }
.drops { display: flex; align-items: center; justify-content: center; gap: 2px; min-height: 18px; }
.drops img { width: 14px; height: 14px; }
.drops.boss img { width: 24px; height: 24px; }
.tears-picker .tier-xp.boss { color: var(--pg-xp); }
.drops .none { font: 10px/1 var(--pg-font-display); color: var(--pg-ink-dim); }

.add {
  --edge: var(--pg-shadow);
  --bevel: inset 0 -4px 0 0 var(--pg-xp-deep);
  min-height: 44px; padding: 14px;
  font: 11px/1 var(--pg-font-display);
  color: var(--pg-ground); background: var(--pg-xp);
  border: 0; border-radius: 0;
  cursor: pointer;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), var(--bevel);
}
.add:active { --bevel: inset 0 4px 0 0 var(--pg-shadow); background: var(--pg-xp-deep); padding: 16px 14px 12px; }

/* --- quest lists --- */

section { padding: 0 4px; }
h2 { display: flex; justify-content: space-between; margin: 0 0 14px; font: 10px/1 var(--pg-font-display); color: var(--pg-edge); }
.count { color: var(--pg-ink-dim); }

.chores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.chore { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 12px; background: var(--pg-panel); }
.chore .check-hit { flex: none; width: 44px; height: 44px; margin-left: -10px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chore .check { width: 24px; height: 24px; flex: none; }
.chore-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chip { flex: none; display: flex; align-items: center; gap: 4px; }
.chip img { width: 20px; height: 20px; }
.chip .drops { min-height: 0; gap: 1px; margin-right: 2px; }
.chip .drops img { width: 12px; height: 12px; }
.chip .drops.boss img { width: 20px; height: 20px; }
.chip span { font: 8px/1 var(--pg-font-display); }
.delete {
  width: 44px; height: 44px; flex: none;
  border: 0; background: transparent; cursor: pointer;
  font: 10px/1 var(--pg-font-display); color: var(--pg-ink-dim);
}
.delete:hover { color: var(--pg-danger); }

.chore.done { --edge: var(--pg-panel); background: var(--pg-ground); }
.chore.done .chore-title { color: var(--pg-ink-dim); text-decoration: line-through; }
.chore.done .chip { opacity: 0.7; }

.empty { margin: 0; font-size: 15px; color: var(--pg-ink-dim); }

/* --- dailies --- */

.repeat-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 4px; }
.repeat {
  min-height: 44px; padding: 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 10px/1 var(--pg-font-display); color: var(--pg-ink-dim);
  border: 0; border-radius: 0; background: var(--pg-ground); cursor: pointer;
}
.repeat img { width: 12px; height: 16px; }
.repeat[aria-checked="true"] { --edge: var(--pg-xp); --bevel: inset 0 -4px 0 0 var(--pg-shadow); color: var(--pg-edge); background: var(--pg-panel-raised); }

.daily-section { margin-bottom: 28px; }
.streak { flex: none; display: flex; align-items: center; gap: 3px; min-width: 36px; min-height: 44px; padding: 0 4px; border: 0; background: transparent; cursor: pointer; font: 8px/1 var(--pg-font-display); color: var(--pg-xp); }
.streak img { width: 12px; height: 16px; }
/* A daily done for today stays in the list, dimmed, until midnight resets it. */
.chore.daily.done .streak { opacity: 1; }

/* --- stickers --- */

/* A never-unlocked sticker: its shape in black, traced in the soft edge colour so it reads on dark rows. */
.silhouette { filter: brightness(0) drop-shadow(1px 0 0 var(--pg-edge-soft)) drop-shadow(-1px 0 0 var(--pg-edge-soft)) drop-shadow(0 1px 0 var(--pg-edge-soft)) drop-shadow(0 -1px 0 var(--pg-edge-soft)); }
.sticker-summary { margin: 0 4px 16px; font-size: 15px; color: var(--pg-ink-dim); }
.sticker-grid { list-style: none; margin: 0; padding: 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sticker-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px 12px; background: var(--pg-panel); text-align: center;
}
.sticker-card.locked { --edge: var(--pg-panel); background: var(--pg-ground); }
.sticker-art { width: 96px; height: 96px; }
.sticker-name { font-size: 16px; font-weight: 600; }
.sticker-card.locked .sticker-name { font: 12px/1.4 var(--pg-font-display); color: var(--pg-ink-faint); }
.sticker-meta { font-size: 13px; color: var(--pg-ink-dim); }
.sticker-count { position: absolute; top: 8px; right: 10px; font: 10px/1 var(--pg-font-display); color: var(--pg-xp); }

.track-dialog {
  --edge: var(--pg-edge);
  --bevel: inset 0 -4px 0 0 var(--pg-shadow);
  width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 16px; border: 0; border-radius: 0;
  background: var(--pg-panel); color: var(--pg-ink); font-family: var(--pg-font-body);
}
.track-dialog::backdrop { background: rgb(14 8 20 / 0.75); }
.track-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.track-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; font: 11px/1 var(--pg-font-display); color: var(--pg-xp); }
.track-head h2 img { width: 12px; height: 16px; }
.track-close { width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; font: 11px/1 var(--pg-font-display); color: var(--pg-ink-dim); }
.track-quest { margin: 4px 0 12px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.track-list { list-style: none; margin: 0; padding: 4px; display: flex; flex-direction: column; gap: 8px; }
.track-step {
  display: grid; grid-template-columns: 64px 36px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 8px; background: var(--pg-ground); color: var(--pg-ink-dim);
}
.track-step.reached { background: var(--pg-panel-raised); color: var(--pg-ink); }
.track-step.next { --edge: var(--pg-xp); background: var(--pg-panel-raised); color: var(--pg-ink); }
.track-day { font: 8px/1.3 var(--pg-font-display); color: var(--pg-ink-faint); }
.track-step.reached .track-day, .track-step.next .track-day { color: var(--pg-edge); }
.track-icon { width: 28px; height: 28px; justify-self: center; }
.track-icon.sticker { width: 36px; height: 36px; }
.track-what { font-size: 15px; }
.track-what.bonus { color: var(--pg-xp); font-weight: 600; }
.track-dialog:focus { outline: none; }
.track-status { font: 8px/1 var(--pg-font-display); color: var(--pg-xp); white-space: nowrap; }
.track-check { width: 18px; height: 18px; }
.track-end { margin: 12px 4px 0; font-size: 13px; color: var(--pg-ink-faint); text-align: center; }

/* --- streak freezes --- */

.daily-meta { display: flex; align-items: center; gap: 12px; }
.freeze-stock { display: flex; align-items: center; gap: 4px; color: var(--pg-tears); }
.freeze-stock img, .freeze-icon { width: 13px; height: 13px; }
.freeze-stock.empty { opacity: 0.45; }
.track-what.freeze { color: var(--pg-tears); font-weight: 600; }
.track-meta { margin: 10px 4px 0; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--pg-ink-dim); }
.track-meta strong { color: var(--pg-tears); }
#freeze-heading { color: var(--pg-tears); }
#freeze-heading img { width: 14px; height: 14px; }
.freeze-intro { margin: 8px 0 12px; font-size: 16px; }
.freeze-choices { list-style: none; margin: 0 0 4px; padding: 4px; display: flex; flex-direction: column; gap: 10px; }
.freeze-choice { --edge: var(--pg-edge-soft); background: var(--pg-ground); }
.freeze-choice label { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 10px; cursor: pointer; }
.freeze-choice input { width: 22px; height: 22px; flex: none; accent-color: var(--pg-tears); }
.freeze-choice-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.freeze-choice-text span { font-size: 13px; color: var(--pg-ink-dim); }
#freeze-form .add { width: 100%; margin-top: 12px; }

/* --- sign-in gate, sync banner, account --- */

.gate { max-width: 420px; margin: 0 auto; padding: 48px 4px 0; display: flex; flex-direction: column; gap: 28px; }
.gate h1 { font-size: 20px; text-align: center; }
.gate-card { margin-bottom: 0; }
.gate-card p { margin: 0; font-size: 16px; }
.gate-card a:not(.add) { color: var(--pg-xp); }
.gate-button { display: block; text-align: center; text-decoration: none; margin-top: 4px; }
.gate-note { font-size: 14px !important; color: var(--pg-ink-dim); }
.move-code { font: 22px/1.4 var(--pg-font-display) !important; color: var(--pg-xp); text-align: center; letter-spacing: 2px; padding: 8px 0; }

.sync-banner { max-width: 520px; margin: 0 auto 12px; padding: 8px 12px; font: 8px/1.5 var(--pg-font-display); color: var(--pg-ground); background: var(--pg-tears); text-align: center; }
.pending-tag { flex: none; font: 7px/1 var(--pg-font-display); color: var(--pg-tears); }
.chore.pending { --edge: var(--pg-tears); }

.claim-card { margin-top: 28px; }
.claim-card label { font-size: 15px; color: var(--pg-ink-dim); }
.claim-card input { text-transform: uppercase; letter-spacing: 2px; }

.account { max-width: 520px; margin: 36px auto 0; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--pg-ink-dim); }
.account-out { min-height: 44px; padding: 0 8px; border: 0; background: transparent; cursor: pointer; font: 8px/1 var(--pg-font-display); color: var(--pg-ink-dim); text-decoration: underline; text-underline-offset: 3px; }

/* --- tabs --- */

.tabs { max-width: 520px; margin: 0 auto 24px; padding: 4px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
/* Four tabs on a 390px phone: the count goes under the label so ABANDONED fits. */
.tab {
  min-height: 48px; padding: 8px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font: 8px/1.2 var(--pg-font-display); text-align: center; text-decoration: none;
  color: var(--pg-ink-dim); background: var(--pg-ground);
}
.tab[aria-current="page"] { --edge: var(--pg-xp); --bevel: inset 0 -4px 0 0 var(--pg-shadow); color: var(--pg-edge); background: var(--pg-panel-raised); }
.tab-count { color: var(--pg-xp); }
.tab-count:empty { display: none; }

/* --- abandoned history --- */

.chore.abandoned { --edge: var(--pg-panel); background: var(--pg-ground); align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
.flag-icon { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.abandoned-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chore.abandoned .chore-title { color: var(--pg-ink-dim); }
.abandoned-note { font-size: 15px; color: var(--pg-ink); }
.abandoned-note::before { content: '“'; }
.abandoned-note::after { content: '”'; }
.abandoned-when { font: 8px/1 var(--pg-font-display); color: var(--pg-ink-faint); margin-top: 2px; }
.chore.abandoned .chip { opacity: 0.6; margin-top: 2px; }
.chore.abandoned .delete { margin-top: -10px; }

/* --- abandon dialog --- */

.abandon-dialog {
  --edge: var(--pg-edge);
  --bevel: inset 0 -4px 0 0 var(--pg-shadow);
  width: min(340px, calc(100vw - 40px));
  padding: 20px;
  border: 0; border-radius: 0;
  background: var(--pg-panel); color: var(--pg-ink);
  font-family: var(--pg-font-body);
}
.abandon-dialog::backdrop { background: rgb(14 8 20 / 0.75); }
.abandon-dialog form { display: flex; flex-direction: column; gap: 12px; }
.abandon-dialog h2 { margin: 0; }
.abandon-title { display: flex; align-items: center; gap: 10px; color: var(--pg-edge); }
.abandon-title img { width: 20px; height: 20px; }
.abandon-quest { margin: 0; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.abandon-label { font: 9px/1.4 var(--pg-font-display); color: var(--pg-ink-dim); }
.abandon-dialog textarea {
  width: 100%; resize: none;
  font: 17px/1.3 var(--pg-font-body);
  color: var(--pg-ink); background: var(--pg-ground);
  border: 0; border-radius: 0; padding: 10px 12px;
  box-shadow: inset 4px 4px 0 0 var(--pg-shadow);
}
.abandon-dialog textarea::placeholder { color: var(--pg-ink-faint); }
.abandon-help { margin: 0; font-size: 14px; color: var(--pg-ink-dim); }
.abandon-error { margin: 0; font-size: 15px; color: var(--pg-danger); }
.abandon-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 4px; margin-top: 4px; }
.secondary {
  --edge: var(--pg-edge-soft);
  min-height: 44px; padding: 14px;
  font: 11px/1 var(--pg-font-display);
  color: var(--pg-ink); background: var(--pg-ground);
  border: 0; border-radius: 0; cursor: pointer;
}
.abandon-delete {
  align-self: center; min-height: 44px; padding: 0 8px;
  border: 0; background: transparent; cursor: pointer;
  font: 15px var(--pg-font-body); color: var(--pg-danger);
  text-decoration: underline; text-underline-offset: 3px;
}

/* --- toast --- */

.toast {
  --edge: var(--pg-shadow);
  --bevel: inset 0 -4px 0 0 var(--pg-xp-deep);
  position: fixed; left: 50%; bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--pg-xp); color: var(--pg-ground);
  font: 12px/1 var(--pg-font-display);
  /* left: 50% leaves only half the viewport to shrink into, so size to the content
     and cap at the screen; long streak toasts then wrap instead of running off it. */
  width: max-content; max-width: calc(100vw - 32px); line-height: 1.4;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s steps(2, end), transform 0.15s steps(2, end);
}
.toast .coin { width: 20px; height: 20px; }
.toast-tears { color: var(--pg-shadow); font-size: 9px; }
.toast-tears:empty { display: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sr-only, .chore input[type="checkbox"] {
  position: absolute; width: 1px; height: 1px; margin: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0;
}
[hidden] { display: none !important; }
