/* ============================================================
   THE HOMEWORK MINES — styles
   Dark mine / dungeon / slightly janky game menu.
   ============================================================ */

:root {
  --bg: #11120f;
  --panel: #1b1d17;
  --panel-2: #24271f;
  --text: #f6f3e8;
  --muted: #b7b29f;
  --accent: #d6ff65;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  --warning: #ffb347;
  --ok: #80ed99;
  --line: #34382d;

  /* Fun colours — used for stats, tabs, panels and highlights */
  --pink: #ff6fb5;
  --purple: #b47cff;
  --cyan: #3ee6e6;
  --blue: #4da3ff;
  --yellow: #ffd84d;
  --orange: #ffa94d;
  --green: #5ef08a;
  --rainbow: linear-gradient(90deg, var(--pink), var(--orange), var(--yellow), var(--green), var(--cyan), var(--purple));

  --common: #b7b29f;
  --uncommon: #80ed99;
  --rare: #6cb8ff;
  --legendary: #ffb347;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Glowing gem-coloured light in the corners of the mine */
  background:
    radial-gradient(circle at 10% 0%, rgba(180, 124, 255, .22), transparent 35%),
    radial-gradient(circle at 90% 5%, rgba(62, 230, 230, .16), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(255, 111, 181, .12), transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.app {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

/* ---------- Header ---------- */

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: .8rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 800;
}

h1 {
  margin: 6px 0 6px;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: .95;
}

.subtitle {
  color: var(--muted);
  max-width: 650px;
  margin: 0 0 14px;
}

.goblin {
  font-size: 4.5rem;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .4));
  user-select: none;
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat, .panel {
  border: 1px solid var(--line);
  background: rgba(27, 29, 23, .92);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .18);
}

.stat {
  padding: 16px;
  text-decoration: none;
}

a.stat:hover { border-color: var(--accent-2); }

.stat strong {
  display: block;
  font-size: 1.6rem;
  margin-top: 3px;
}

.stat > span {
  color: var(--muted);
  font-size: .85rem;
}

.level-title {
  color: var(--accent);
  font-weight: 800;
  margin: 2px 0 8px;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tabs a {
  text-decoration: none;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

.tabs a:hover { color: var(--text); }

.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #12150d;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 18px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 18px;
}

.panel { padding: 18px; }

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.board-title {
  font-size: 1.6rem !important;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-top: 4px !important;
}

.goblin-says {
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  margin: 0 0 16px;
}

/* ---------- Dashboard buckets ---------- */

.bucket { margin-bottom: 22px; }

.bucket-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.bucket-title {
  font-size: .9rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0 0 10px;
  color: var(--muted);
}

.bucket-urgent .bucket-title { color: var(--danger); }
.bucket-next .bucket-title { color: var(--accent-2); }
.bucket-completed .bucket-title { color: var(--ok); }

.count {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  font-size: .8rem;
  color: var(--text);
}

.quest-list {
  display: grid;
  gap: 12px;
}

.quest-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  background: var(--panel-2);
  border-radius: 16px;
  padding: 15px;
  transition: border-color .15s ease, transform .15s ease;
}

.quest-card:hover {
  border-color: var(--subject, var(--accent));
  transform: translateY(-1px);
}

.quest-card.status-overdue,
.quest-card.status-panic { border-left-color: var(--danger); }
.quest-card.status-today { border-left-color: var(--warning); }
.quest-card.status-tomorrow { border-left-color: var(--accent-2); }

.quest-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.subject {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
}

.type-tag {
  color: var(--muted);
  font-weight: 700;
}

.quest-card h3 {
  margin: 5px 0 4px;
  font-size: 1.15rem;
}

.due-badge {
  display: inline-block;
  font-size: .8rem;
  font-weight: 900;
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
  background: #11130f;
  border: 1px solid var(--line);
  color: var(--muted);
}

.due-badge.status-overdue,
.due-badge.status-panic {
  color: #1a0b0b;
  background: var(--danger);
  border-color: var(--danger);
}
.due-badge.status-today { color: var(--warning); border-color: var(--warning); }
.due-badge.status-tomorrow { color: var(--accent-2); border-color: rgba(255, 209, 102, .5); }
.due-badge.status-done { color: #0d1a10; background: var(--ok); border-color: var(--ok); }

.quest-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px 14px;
  color: var(--muted);
  font-size: .9rem;
  flex-wrap: wrap;
}

.quest-meta strong { color: var(--text); }

.diff { font-weight: 800; text-transform: uppercase; font-size: .78rem; }
.diff-easy { color: var(--ok); }
.diff-normal { color: var(--accent-2); }
.diff-pain { color: var(--danger); }

.card-cta {
  margin-top: 10px;
  font-weight: 800;
  font-size: .85rem;
  color: var(--accent);
}

.done-list {
  display: grid;
  gap: 6px;
}

.done-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(128, 237, 153, .05);
}

.done-row:hover { border-color: var(--ok); }

/* ---------- Progress bars ---------- */

.progress {
  height: 10px;
  background: #11130f;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 7px;
  border: 1px solid #303429;
}

.progress > div {
  height: 100%;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .18) 0 8px, transparent 8px 16px),
    linear-gradient(90deg, var(--cyan), var(--accent), var(--yellow), var(--orange));
  background-size: auto, 100% 100%;
  border-radius: 999px;
  width: 0%;
}

.progress.mini { height: 6px; margin: 0 0 4px; }
.progress.big { height: 22px; margin: 14px 0 10px; }

/* ---------- Quest detail / work screen ---------- */

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

.quest-focus { border-top: 6px solid var(--line); }
.quest-focus.status-overdue, .quest-focus.status-panic { border-top-color: var(--danger); }
.quest-focus.status-today { border-top-color: var(--warning); }
.quest-focus.status-tomorrow { border-top-color: var(--accent-2); }
.quest-focus.status-done { border-top-color: var(--ok); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.quest-title {
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  margin: 12px 0 10px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.quest-due {
  color: var(--muted);
  font-weight: 700;
}

.quest-due .tiny { margin-top: 4px; }

.focus-progress {
  margin: 22px 0 18px;
  padding: 18px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.big-count {
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1;
}

.big-count span {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0;
}

.remaining {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.work-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.finish-btn { width: 100%; }

.victory, .lost {
  text-align: center;
  padding: 18px;
}

.victory strong {
  display: block;
  font-size: 1.6rem;
  color: var(--ok);
  letter-spacing: .06em;
}

.victory-icon { font-size: 3.4rem; }

.sessions { margin-top: 16px; }

.danger-zone h2 { color: var(--danger); font-size: 1rem; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  background: var(--accent);
  color: #12150d;
  text-decoration: none;
  text-align: center;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  filter: none;
}

.btn.secondary {
  background: #303429;
  color: var(--text);
  border: 1px solid #3e4335;
}

.btn.danger-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, .35);
}

.btn.small {
  padding: 6px 10px;
  font-size: .85rem;
  border-radius: 10px;
}

.btn.huge {
  font-size: 1.25rem;
  padding: 16px 22px;
  flex: 1 1 140px;
}

/* ---------- Timer ---------- */

.timer-panel { border-top: 6px solid var(--accent); }
.timer-panel[data-mode="break"] { border-top-color: var(--purple); }

.timer-box {
  text-align: center;
  padding: 6px 0;
}

.timer-mode {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .85rem;
}

.timer-panel[data-mode="break"] .timer-mode { color: var(--purple); }

.timer {
  font-size: clamp(3.2rem, 8vw, 5.5rem);
  font-weight: 900;
  letter-spacing: -.05em;
  margin: 6px 0 8px;
  font-variant-numeric: tabular-nums;
}

.timer-note {
  color: var(--muted);
  min-height: 44px;
}

.timer-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.timer-settings {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

/* ---------- Forms ---------- */

form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .85rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #11130f;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
  color-scheme: dark;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------- Shop ---------- */

.shop {
  display: grid;
  gap: 10px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 12px;
  background: var(--panel-2);
}

.shop-icon { font-size: 2rem; }
.shop-text { flex: 1; }
.shop-item.too-poor .shop-text { opacity: .65; }

.bank-amount {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent-2);
  line-height: 1;
}

.bank-amount span { font-size: 1.2rem; color: var(--muted); }

/* ---------- Inventory / loot ---------- */

.rarity-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.rarity-tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.rarity-common { color: var(--common); }
.rarity-uncommon { color: var(--uncommon); }
.rarity-rare { color: var(--rare); }
.rarity-legendary { color: var(--legendary); }

.loot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.loot-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 16px 12px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 2px solid currentColor;
}

.loot-card strong, .loot-card .tiny { color: var(--text); }
.loot-card .tiny { color: var(--muted); }
.loot-card.unfound { border-style: dashed; opacity: .55; }
.loot-card.rarity-legendary:not(.unfound) { box-shadow: 0 0 24px rgba(255, 179, 71, .25); }

.loot-icon { font-size: 2.6rem; line-height: 1.1; }

.loot-qty {
  position: absolute;
  top: 8px;
  right: 10px;
  font-weight: 900;
  color: var(--text);
}

/* ---------- Toast & alert popup ---------- */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #eefdb9;
  color: #18200a;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 800;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
  max-width: min(340px, calc(100% - 36px));
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.alert-dialog {
  width: min(460px, calc(100% - 32px));
  border: 2px solid var(--accent);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}

.alert-dialog::backdrop { background: rgba(5, 6, 4, .75); }

.alert-dialog h2 {
  margin: 6px 0 10px;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: .02em;
}

.alert-icon { font-size: 3.4rem; }

.alert-body {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 18px;
}

.alert-body strong { color: var(--text); }

.reward-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  font-weight: 800;
  color: var(--accent-2);
}

.loot-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid currentColor;
  background: var(--panel-2);
}

.loot-drop strong { display: block; font-size: 1.15rem; }
.loot-drop .tiny { color: var(--muted); font-weight: 800; }

/* ---------- Misc ---------- */

.tiny {
  color: var(--muted);
  font-size: .8rem;
}

.empty {
  color: var(--muted);
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  margin-bottom: 16px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: .9rem;
}

/* ============================================================
   COLOUR — gem colours everywhere, but text stays readable.
   Most pieces set --c (their colour) and tint themselves with it.
   ============================================================ */

.hero h1 {
  background: linear-gradient(90deg, var(--yellow), var(--pink) 50%, var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Stat cards: each one its own colour */
.stat[data-color="purple"] { --c: var(--purple); }
.stat[data-color="cyan"] { --c: var(--cyan); }
.stat[data-color="yellow"] { --c: var(--yellow); }
.stat[data-color="pink"] { --c: var(--pink); }

.stat[data-color] {
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
  border-top: 5px solid var(--c);
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 20%, var(--panel)), var(--panel) 75%);
}

.stat[data-color] > span {
  color: var(--c);
  font-weight: 800;
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.stat[data-color] strong { color: var(--c); }
a.stat[data-color]:hover { border-color: var(--c); }
.stat-level .level-title { color: var(--text); }

/* Tabs: each one its own colour */
.tabs a[data-nav="dashboard"] { --c: var(--accent); }
.tabs a[data-nav="shop"] { --c: var(--yellow); }
.tabs a[data-nav="inventory"] { --c: var(--pink); }

.tabs a {
  color: var(--c);
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
}

.tabs a.active {
  background: var(--c);
  border-color: var(--c);
  color: #12150d;
}

/* Panels with a coloured strip across the top */
.theme-cyan { --c: var(--cyan); }
.theme-yellow { --c: var(--yellow); }
.theme-pink { --c: var(--pink); }
.theme-purple { --c: var(--purple); }
.theme-rainbow { --c: var(--accent); --bar: var(--rainbow); }

.panel[class*="theme-"] {
  position: relative;
  overflow: hidden;
  padding-top: 24px;
}

.panel[class*="theme-"]::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--bar, var(--c));
}

.panel[class*="theme-"] > h2 { color: var(--c); }

/* Goblin speech bubble */
.goblin-says {
  background: color-mix(in srgb, var(--pink) 14%, var(--panel-2));
  border-color: color-mix(in srgb, var(--pink) 55%, transparent);
}

/* Dashboard buckets */
.bucket-urgent { --c: var(--danger); }
.bucket-next { --c: var(--yellow); }
.bucket-later { --c: var(--blue); }
.bucket-completed { --c: var(--green); }

.bucket .bucket-title { color: var(--c); }

.bucket .count {
  background: var(--c);
  border-color: var(--c);
  color: #12150d;
  font-weight: 900;
}

/* Quest cards are tinted with their subject colour */
.quest-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--subject, var(--panel-2)) 16%, var(--panel-2)), var(--panel-2) 65%);
}

.quest-card .subject { color: var(--subject, var(--accent)); }
.quest-card.status-later { border-left-color: var(--blue); }

.chip-subject {
  color: var(--subject);
  border-color: color-mix(in srgb, var(--subject) 55%, transparent);
  background: color-mix(in srgb, var(--subject) 16%, var(--panel-2));
}

.done-row { border-left: 5px solid var(--subject, var(--ok)); }

/* Big numbers */
.big-count {
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.big-count span { -webkit-text-fill-color: var(--muted); }

.timer {
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.timer-panel[data-mode="break"] .timer { background-image: linear-gradient(90deg, var(--purple), var(--pink)); }

/* Extra button colours */
.btn.cyan { background: var(--cyan); color: #0b1a1a; }
.btn.yellow { background: var(--yellow); color: #1a1505; }
.btn.pink { background: var(--pink); color: #1f0a14; }
.btn.red { background: var(--danger); color: #1a0b0b; }

/* Big coin price in the "Buy ...?" popup */
.price-tag {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 1.6rem;
  font-weight: 900;
  color: #1a1505;
  background: var(--yellow);
}

.alert-dialog { box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 35%, transparent), 0 30px 80px rgba(0, 0, 0, .6); }

/* ============================================================
   TODAY PANEL, CHESTS & POPUP ANIMATIONS
   ============================================================ */

.theme-orange { --c: var(--orange); }

.today-block {
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.today-label {
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 4px;
}

.streak-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 1.2rem;
}

.streak-fires { font-size: 1.4rem; letter-spacing: -.1em; }
.streak-wounded { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--panel-2)); }
.streak-lost { border-color: var(--danger); }
.streak-healthy { border-color: color-mix(in srgb, var(--orange) 60%, transparent); }

.bounty-text { font-weight: 800; }
.bounty-done { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--panel-2)); }

.chest-cta { width: 100%; }

.tab-badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--pink);
  color: #1f0a14;
  font-size: .8rem;
  text-align: center;
}

.tabs a.active .tab-badge { background: #1f0a14; color: var(--pink); }

.inventory-panel { margin-top: 18px; }

.chest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.chest-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 16px 12px;
  border-radius: 16px;
  border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--panel-2));
  color: var(--text);
  text-align: center;
}

.chest-card:hover .chest-icon { animation: shake .5s ease; }
.chest-icon { font-size: 2.8rem; }
.chest-open { margin-top: 6px; font-weight: 900; color: var(--c); }

.chest-wooden { --c: var(--orange); }
.chest-iron { --c: var(--cyan); }
.chest-golden { --c: var(--yellow); }
.loot-drop.chest-wooden, .loot-drop.chest-iron, .loot-drop.chest-golden { color: var(--c); }

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.alert-icon.shake { animation: shake .6s ease-in-out infinite; }
.alert-icon.pop { animation: pop .45s ease-out; }

@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}

@keyframes pop {
  0% { transform: scale(.3); opacity: 0; }
  70% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .alert-icon.shake, .alert-icon.pop, .chest-card:hover .chest-icon { animation: none; }
}

/* ============================================================
   AVATAR
   Built from emoji: coloured orb + face, hat on top, sidekick
   in the corner. Size is set with --size; everything scales.
   ============================================================ */

.avatar {
  --size: 80px;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: calc(var(--size) * .58);
  line-height: 1;
  background: radial-gradient(circle at 35% 30%,
    color-mix(in srgb, var(--avatar) 70%, white),
    var(--avatar) 55%,
    color-mix(in srgb, var(--avatar) 55%, black));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--avatar) 35%, transparent), 0 8px 20px rgba(0, 0, 0, .35);
}

.avatar-sm { --size: 58px; }
.avatar-xl { --size: 170px; margin: 26px auto 16px; }

.avatar-face { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3)); }

.avatar-hat {
  position: absolute;
  top: -.38em;
  left: 50%;
  transform: translateX(-50%) rotate(-10deg);
  font-size: .6em;
  z-index: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

.avatar-sidekick {
  position: absolute;
  right: -.2em;
  bottom: -.15em;
  font-size: .42em;
  padding: .14em;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}

/* Player card (top-left stat) */
.player {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 10px;
}

.player-info { min-width: 0; }

.player-name {
  font-weight: 900;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.player-level { color: var(--purple); font-weight: 800; font-size: .85rem; }
.player-level b { font-size: 1.05rem; }
.stat-level .level-title { margin: 0; font-size: .85rem; }

.tabs a[data-nav="avatar"] { --c: var(--purple); }

/* ---------- Avatar page ---------- */

.welcome {
  background: color-mix(in srgb, var(--yellow) 14%, var(--panel-2));
  border: 2px dashed var(--yellow);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.welcome strong { font-size: 1.15rem; }
.welcome p { margin: 4px 0 0; }

.picker { margin-top: 20px; }
.picker-title { font-size: 1.05rem; margin: 0 0 10px; }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.pick-colors { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }

.pick-tile {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 4px;
  padding: 12px 6px 10px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.pick-tile:hover { border-color: var(--purple); }

.pick-tile.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-2));
}

.pick-icon { font-size: 2.2rem; line-height: 1.15; }
.pick-name { font-size: .78rem; }
.pick-lock { font-size: .72rem; color: var(--muted); }

.pick-tile.lock-level .pick-icon,
.pick-tile.lock-loot .pick-icon { filter: grayscale(1); opacity: .45; }
.pick-tile.lock-level, .pick-tile.lock-loot { border-style: dashed; }
.pick-tile.lock-cost .pick-lock { color: var(--yellow); font-weight: 900; font-size: .8rem; }

.pick-check {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #12150d;
  font-size: .8rem;
}

.swatch {
  display: block;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25);
}

.preview-panel {
  text-align: center;
  position: sticky;
  top: 16px;
}

.preview-panel .field { text-align: left; }
.preview-panel input { font-size: 1.1rem; font-weight: 800; }
.preview-title { color: var(--purple); font-weight: 800; margin: 12px 0 14px; }
.preview-actions { display: grid; gap: 8px; }

/* ---------- Kid-friendly form ---------- */

.kid-form { gap: 16px; }

.kid-form fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.kid-form .field { display: grid; gap: 8px; }

.kid-form label.field,
.kid-form legend,
.kid-form #totalLabel {
  color: var(--text);
  font-weight: 800;
  font-size: .95rem;
}

.kid-form legend { padding: 0; margin-bottom: 8px; }

.tile-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tile-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.tile {
  display: block;
  position: relative;
  cursor: pointer;
}

/* The real radio stays in the page (keyboard + screen readers) but is invisible. */
.tile input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.tile span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #11130f;
  color: var(--text);
  font-weight: 800;
  font-size: .85rem;
  text-align: center;
  line-height: 1.15;
}

.tile span:hover { border-color: #5a604c; }
.tile-icon { font-size: 1.5rem; font-weight: normal; }
.small-tiles .tile span { min-height: 58px; font-size: .7rem; }
.small-tiles .tile-icon { font-size: 1.3rem; }

.tile input:checked + span {
  --pick: var(--subject, var(--cyan));
  border-color: var(--pick);
  background: color-mix(in srgb, var(--pick) 20%, #11130f);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--pick) 35%, transparent);
}

.tile input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.stepper {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  gap: 8px;
}

.stepper .btn { font-size: 1.5rem; padding: 4px; }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 800; }

#dueDatePick { margin-top: 8px; }

.due-time summary {
  cursor: pointer;
  color: var(--muted);
  font-size: .85rem;
  margin-top: 8px;
}

.due-time input { margin-top: 8px; }

/* Big "do this next" button on the dashboard */
.next-quest {
  display: block;
  width: 100%;
  margin-bottom: 18px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

.next-quest-name {
  display: block;
  margin-top: 2px;
  font-size: .9rem;
  font-weight: 700;
  opacity: .8;
  overflow-wrap: anywhere;
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .hero { align-items: center; }
  .goblin { font-size: 3.2rem; }
  .stat-level { grid-column: 1 / -1; } /* player card gets the full row */
  .avatar-layout .sidebar { order: -1; } /* show the preview above the pickers */
  .preview-panel { position: static; }
  .avatar-xl { --size: 130px; }
}

@media (max-width: 520px) {
  .app { width: calc(100% - 24px); padding-top: 18px; }
  .goblin { display: none; }
  .stat { padding: 12px; }
  .stat strong { font-size: 1.3rem; }
  .row { grid-template-columns: 1fr; }
  .quest-top { flex-direction: column; gap: 6px; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .tabs a { text-align: center; padding: 10px 4px; font-size: .9rem; white-space: nowrap; }
  .pick-grid { grid-template-columns: repeat(3, 1fr); }
  .pick-colors { grid-template-columns: repeat(4, 1fr); }
}
