* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--page-bg, #0E1116);
  color: var(--ink, #EDEFF3);
  min-height: 100vh;
}
input, select, button { font-family: inherit; }

/* Display face: the wordmark, titles and section headings */
h1, h2, .card-title, .nav-brand {
  font-family: "Bricolage Grotesque", "Inter", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.01em;
}

#content {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
a { color: var(--accent, #5FD1C9); }
.hint { color: var(--sub, #828B9A); font-size: 0.9rem; }
.error { color: #e46060; }

.kicker {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sub);
}
.card-title { font-size: 1.3rem; font-weight: 600; margin-top: 0.25rem; }

/* Nav */
#mainnav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--card-bg, #171B22);
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
  backdrop-filter: blur(var(--card-blur, 0px));
  flex-wrap: wrap;
}
.nav-items { display: flex; gap: 0.15rem; }
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 4.25rem;
  padding: 0.3rem 0;
  border-radius: 10px;
  text-decoration: none;
  color: var(--sub);
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--accent); }
.nav-label { font-size: 0.6rem; letter-spacing: 0.07em; text-transform: uppercase; }

/* "More" dropdown (Admin / Settings / Log out) */
.nav-more { position: relative; }
.nav-more summary { list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 9rem;
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  background: var(--card-bg, #171B22);
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 30;
}
.nav-menu a { text-decoration: none; color: var(--ink); padding: 0.45rem 0.75rem; border-radius: 8px; }
.nav-menu a:hover { background: rgba(128, 128, 128, 0.15); }
.nav-menu a.active { color: var(--accent); }
.nav-brand { font-weight: 700; color: var(--ink); letter-spacing: 0.02em; }
.brand-or { color: var(--gold, #d9a83e); }
.nav-spacer { flex: 1; }
.coin-widget { color: var(--gold, var(--accent)); font-weight: 600; }

/* Cards & forms */
.card {
  background: var(--card-bg, #171B22);
  border: var(--card-border, 1px solid #262C36);
  border-radius: var(--card-radius, 24px);
  box-shadow: var(--card-shadow, none);
  backdrop-filter: blur(var(--card-blur, 0px));
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
}
.card-list .card { margin: 0.5rem 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.25rem; }
.card-head .stat { text-align: right; }
.card-head .stat b { display: block; font-size: 1.15rem; color: var(--accent); margin-top: 0.25rem; }

label { display: block; margin: 0.5rem 0; }
label.check { display: flex; align-items: center; gap: 0.5rem; }
/* Two-line variant: title with a smaller muted description underneath */
label.check:has(.check-text) { align-items: flex-start; padding: 0.25rem 0; }
label.check:has(.check-text) input { margin-top: 0.25rem; }
.check-text { display: flex; flex-direction: column; line-height: 1.35; }
.check-desc { color: var(--sub); font-size: 0.78rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select {
  background: var(--page-bg, #0E1116);
  color: var(--ink);
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
}
body[data-theme="glass"] input, body[data-theme="glass"] select { background: rgba(0,0,0,0.25); }

button {
  background: var(--card-bg, #171B22);
  color: var(--ink);
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}
button.primary, .auth-card button {
  background: var(--accent, #5FD1C9);
  color: var(--accent-text, #0E1116);
  border: none;
  font-weight: 600;
}
button.primary:disabled { background: var(--accent-disabled); color: var(--sub); opacity: 1; }
button:disabled { opacity: 0.5; cursor: default; }
button.small { font-size: 0.8rem; padding: 0.2rem 0.6rem; }
button.danger { color: #e46060; }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.inline-form input[type="text"] { flex: 1; min-width: 160px; }

/* Auth */
.auth-card {
  max-width: 360px;
  margin: 8vh auto;
  background: var(--card-bg, #171B22);
  border: var(--card-border, 1px solid #262C36);
  border-radius: var(--card-radius, 24px);
  box-shadow: var(--card-shadow, none);
  backdrop-filter: blur(var(--card-blur, 0px));
  padding: 1.5rem;
}
.auth-card input { width: 100%; }
.auth-card button { width: 100%; margin-top: 0.75rem; }

/* Coin progress */
.coin-progress { display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 0; }
.coin-progress-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--card-bg, #171B22);
  border: 1px solid rgba(128, 128, 128, 0.3);
  overflow: hidden;
}
/* The bar tracks gold earned, so it fills in gold — same glow language as
   the lab's element tiles. */
.coin-progress-bar .fill {
  height: 100%;
  width: 0;
  background: var(--gold, var(--accent));
  box-shadow: 0 0 12px color-mix(in srgb, var(--gold, var(--accent)) 55%, transparent);
  transition: width 0.3s;
}
.card-head .stat b.gold-stat { color: var(--gold, var(--accent)); }

/* Daily-use pages (tracker, tasks): one big card like the lab and world */
.page-card { padding: 1.5rem 1.75rem; }
.section-kicker { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid rgba(128, 128, 128, 0.25); }

.project-group { margin-top: 1.25rem; }
.project-group + .project-group { padding-top: 1rem; border-top: 1px solid rgba(128, 128, 128, 0.15); }
.project-name {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sub);
  margin: 0 0 0.25rem;
}

/* Goal line under a project heading on the daily pages */
.project-goal { margin: 0 0 0.35rem; color: var(--sub); font-style: italic; font-size: 0.8rem; }

.achieved-badge {
  margin-left: 0.5rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold, var(--accent));
  border: 1px solid var(--gold, var(--accent));
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}
.manage-row.achieved .manage-name { color: var(--sub); }

.range-input { display: flex; align-items: center; gap: 0.3rem; margin: 0; color: var(--sub); font-size: 0.85rem; }
.range-input input { width: 3.6rem; }
.project-editor-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.3rem 0; }
.project-editor-row input[type="text"] { flex: 1; min-width: 200px; }

.pack-kicker { margin: 0.9rem 0 0.15rem; }
.pack-kicker:first-child { margin-top: 0.25rem; }
/* Pack group headers carry the visual break; skip the row divider after them */
.pack-kicker + .manage-row { border-top: none; }

.manage-link { margin: 1.75rem 0 0.25rem; text-align: right; }
.manage-link a { color: var(--sub); text-decoration: none; }
.manage-link a:hover { color: var(--accent); }

.icon-btn {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: none;
  border: 1px solid transparent;
  color: var(--sub);
  font-size: 0.95rem;
}
.icon-btn:hover { color: var(--ink); background: rgba(128, 128, 128, 0.12); }
.icon-btn.confirming { color: #e46060; border-color: #e46060; }

/* Manage page rows: name (with a muted meta line below) never wraps,
   controls keep a fixed footprint on the right. */
.manage-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; }
.manage-row + .manage-row, .manage-habit + .manage-habit { border-top: 1px solid rgba(128, 128, 128, 0.15); }
.manage-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.manage-name, .manage-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-meta { color: var(--sub); font-size: 0.75rem; }
.manage-row select { max-width: 11rem; min-width: 0; }
.manage-row button { flex-shrink: 0; }

/* Add-habit form: grid keeps every control the same width */
#add-habit { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
#add-habit input[type="text"], #add-habit button { grid-column: 1 / -1; }
#add-habit select, #add-habit input[type="number"] { width: 100%; min-width: 0; }

.habit-row, .task-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.45rem 0; }
.habit-row + .habit-row, .task-row + .task-row { border-top: 1px solid rgba(128, 128, 128, 0.15); }
.row-name { flex: 1; }
.row-done .row-name { color: var(--sub); text-decoration: line-through; }
.pill {
  font-size: 0.72rem;
  color: var(--sub);
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}
.coin-tag { color: var(--gold, var(--accent)); font-size: 0.85rem; white-space: nowrap; }
/* Margin 0 kills the global label margin so the stretched flex item is as
   tall as its siblings; the inner input then stretches to match. */
.coin-input { display: flex; align-items: center; gap: 0.25rem; color: var(--gold, var(--accent)); margin: 0; }
.coin-input input { width: 4rem; align-self: stretch; }

/* Animated checkbox */
.fcheck { display: inline-flex; align-items: center; cursor: pointer; margin: 0; }
.fcheck input { position: absolute; opacity: 0; pointer-events: none; }
.fcheck-box {
  width: 26px; height: 26px;
  border-radius: 9px;
  border: 2px solid var(--sub);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.fcheck:hover .fcheck-box { border-color: var(--accent); transform: scale(1.06); }
.fcheck-box svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
}
.fcheck input:checked + .fcheck-box {
  background: var(--accent);
  border-color: var(--accent);
}
.fcheck input:checked + .fcheck-box svg { stroke-dashoffset: 0; }

/* The dopamine part — only on interaction (.pow), never on initial render */
.fcheck-box.pow { animation: checkPop 0.4s cubic-bezier(0.2, 2.2, 0.4, 1); }
.fcheck-box.pow svg { animation: checkDraw 0.22s 0.06s ease-out backwards; }
.fcheck-burst { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.fcheck-box.pow .fcheck-burst::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: inherit;
  border: 2px solid var(--accent);
  animation: burstRing 0.45s ease-out forwards;
}
.fcheck-box.pow .fcheck-burst::after {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  animation: burstDots 0.5s 0.05s ease-out forwards;
}
@keyframes checkPop {
  0% { transform: scale(0.75); }
  55% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes checkDraw { from { stroke-dashoffset: 22; } to { stroke-dashoffset: 0; } }
@keyframes burstRing {
  0% { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(2); opacity: 0; }
}
@keyframes burstDots {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 var(--accent), 0 0 0 0 var(--accent), 0 0 0 0 var(--accent),
      0 0 0 0 var(--accent), 0 0 0 0 var(--accent), 0 0 0 0 var(--accent);
  }
  100% {
    opacity: 0;
    box-shadow: 0 -22px 0 0 var(--accent), 19px -11px 0 0 var(--accent), 19px 11px 0 0 var(--accent),
      0 22px 0 0 var(--accent), -19px 11px 0 0 var(--accent), -19px -11px 0 0 var(--accent);
  }
}

/* Scaled habits: one anchor button per scale value */
.habit-row.scale-habit { flex-wrap: wrap; }
.scale-row { display: flex; flex-wrap: wrap; gap: 0.35rem; width: 100%; padding: 0.15rem 0 0.2rem; }
.scale-anchor {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 8px;
  padding: 0.15rem 0.6rem 0.15rem 0.2rem;
  font-size: 0.8rem;
  color: var(--sub);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.scale-anchor:hover { border-color: var(--accent); color: var(--text); }
.scale-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.35);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  flex: 0 0 20px;
}
.scale-anchor.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.scale-anchor.selected .scale-num { border-color: var(--accent-text); color: var(--accent-text); }
/* A selected-but-done row keeps the strikethrough on the name only */
.row-done .scale-anchor:not(.selected) { opacity: 0.65; }
/* Wide unlabeled scales log via a compact dropdown */
.scale-select { min-width: 4.5rem; text-align: center; }

/* Scale editor (manage section) */
.scale-editor { margin: 0.25rem 0 0.75rem; padding-left: 0.5rem; border-left: 2px solid rgba(128, 128, 128, 0.25); }
.scale-editor-range { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.4rem; }
.scale-editor-range input { width: 3.5rem; }
.scale-editor-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0; }
.scale-editor-row .scale-edit-label { width: 9rem; }
.scale-editor-row .scale-edit-desc { flex: 1; }
.scale-editor-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }

/* ---------- Lab ---------- */

.lab-card { max-width: 520px; margin: 1.5rem auto; padding: 2rem 2.25rem; }

.inv-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1.4rem 0 2rem;
}
.inv-item {
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--sub);
}
/* One label style for every element tile: inside the tile, uppercase.
   Condensed face so longer names fit before the ellipsis. */
.tile-name {
  font-family: "Barlow Condensed", "Inter", sans-serif;
  font-weight: 500;
  font-size: 9.5px;
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  max-width: 94%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Small uppercase companions share the condensed face */
.cell-panel .cell-label, .inv-item .inv-theme {
  font-family: "Barlow Condensed", "Inter", sans-serif;
  letter-spacing: 0.08em;
}

.inv-item .icon-tile {
  width: 50px; height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border-radius: var(--tile-radius);
  background: var(--element-bg);
  box-shadow: var(--element-shadow);
  border: var(--element-border);
  color: var(--element-icon);
  transition: transform 0.15s;
}
.inv-item .inv-theme {
  font-size: 9px;
  color: var(--sub);
  max-width: 62px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-item:hover .icon-tile { transform: translateY(-2px); }
/* Dedication: category free to place today (all linked dailies done) */
.inv-item .inv-theme.free-today { color: var(--gold, var(--accent)); }
/* Still clickable while on the bench — self-combos (Water + Water) need
   a second click on the same element. */
.inv-item.on-bench { opacity: 0.5; }
.inv-item.on-bench.fully-benched { opacity: 0.35; pointer-events: none; }
.inv-item.known { opacity: 0.25; }
.inv-item.known .icon-tile { box-shadow: none; border-style: dashed; }
.inv-item.spent { opacity: 0.55; }
.inv-item .icon-tile { position: relative; }
.inv-badge {
  position: absolute;
  bottom: -5px; right: -5px;
  min-width: 17px; height: 17px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.inv-item.base .icon-tile { outline: 1px solid var(--ring-color); outline-offset: 2px; }

.bench {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 1.5rem 0;
}
.bench-op { color: var(--sub); font-size: 1.1rem; user-select: none; }
.bench-slot {
  width: 74px; height: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  border-radius: var(--tile-radius);
  background: var(--slot-bg);
  box-shadow: var(--slot-shadow);
  border: var(--slot-border);
  color: var(--slot-icon);
  cursor: default;
}
.bench-slot.filled {
  background: var(--element-bg);
  box-shadow: var(--element-shadow);
  border: var(--element-border);
  color: var(--element-icon);
  cursor: pointer;
}
.bench-slot .flask { display: flex; opacity: 0.8; }

.bench-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.bench-actions button { padding: 0.6rem 1.4rem; white-space: nowrap; }

.lab-message { text-align: center; min-height: 1.4rem; margin-top: 1rem; font-size: 0.95rem; }
.lab-message.success { color: var(--accent); font-weight: 600; }
.lab-message.failure, .lab-message.known_failure { color: var(--sub); }
.lab-costs { text-align: center; margin-top: 1.25rem; }

@keyframes labPulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.lab-pulse { animation: labPulse 1.1s ease-in-out infinite; }
@keyframes revealPop { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: scale(1); } }
.reveal-pop { animation: revealPop 0.35s ease-out; }
@keyframes shakeNo {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.shake { animation: shakeNo 0.3s ease-in-out 2; }

/* ---------- World ---------- */

.world-card { padding: 1.75rem 2rem; }

#unplaced-list { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.75rem 0 1.25rem; }
#unplaced-list .inv-item { cursor: pointer; pointer-events: auto; }
#unplaced-list .inv-item.selected .icon-tile {
  outline: 2px solid var(--ring-color);
  outline-offset: 3px;
  transform: translateY(-2px);
}

#world-viewport {
  overflow: auto;
  border-radius: 12px;
  max-height: 70vh;
}
#world-field { position: relative; margin: 0 auto; }

#blob-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.25rem 0 0.75rem;
}
.blob-chip {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--sub);
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 8px;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
}
.blob-chip.earned { color: var(--accent); border-color: var(--accent); }

.wtile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tile-radius);
  transition: background 0.3s, box-shadow 0.3s;
}
.wtile.fog {
  background: var(--fog-bg);
  box-shadow: var(--fog-shadow);
  border: var(--fog-border);
  color: var(--fog-icon);
}
.wtile.found {
  background: var(--found-bg);
  box-shadow: var(--found-shadow);
  border: var(--found-border);
  color: var(--found-icon);
  flex-direction: column;
  gap: 1px;
}
.wtile.found .wtile-icon { display: flex; line-height: 1; }
.wtile.target { cursor: pointer; }
.wtile.new-pop { animation: revealPop 0.35s ease-out; }

.frontier-ring {
  position: absolute;
  inset: -4px;
  border-radius: var(--tile-radius);
  border: 2px solid var(--ring-color);
  pointer-events: none;
  animation: frontierPulse 2.2s ease-in-out infinite;
}
@keyframes frontierPulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.07); }
}

.world-legend {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
  font-size: 0.8rem;
  color: var(--sub);
  flex-wrap: wrap;
}
.legend-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 999px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .lab-pulse, .frontier-ring, .reveal-pop, .wtile.new-pop, .shake,
  .fcheck-box.pow, .fcheck-box.pow svg,
  .fcheck-box.pow .fcheck-burst::before, .fcheck-box.pow .fcheck-burst::after { animation: none; }
}

/* ---------- Admin ---------- */
.admin-form { display: flex; flex-direction: column; gap: 0.25rem; max-width: 420px; }
.admin-form label { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.admin-form input, .admin-form select { flex: 1; max-width: 280px; }
.admin-form button { align-self: flex-start; margin-top: 0.5rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { text-align: left; color: var(--sub); font-weight: 500; padding: 0.25rem 0.5rem; }
.admin-table td { padding: 0.25rem 0.5rem; border-top: 1px solid rgba(128, 128, 128, 0.15); }
.admin-table .ok { color: var(--accent); }
.admin-table .warn { color: #e4a960; }

/* ---------- Phone layout ---------- */
@media (max-width: 640px) {
  /* Nav becomes a fixed bottom bar */
  #mainnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    border-bottom: none;
    border-top: 1px solid rgba(128, 128, 128, 0.25);
    flex-wrap: nowrap;
    justify-content: space-around;
    gap: 0.15rem;
    padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom));
  }
  .nav-brand, .nav-spacer { display: none; }
  .nav-items { flex: 1; justify-content: space-around; gap: 0; }
  .nav-item { width: auto; flex: 1; padding: 0.2rem 0; }
  .nav-more { flex: 0 0 auto; }
  .nav-more .nav-item { padding: 0.2rem 0.5rem; }
  /* Dropdown opens upward from the bottom bar */
  .nav-menu { top: auto; bottom: calc(100% + 0.5rem); }
  .coin-widget { font-size: 0.85rem; }

  #content { padding: 0.75rem 0.6rem 5rem; }
  .card, .auth-card { padding: 0.85rem 0.8rem; border-radius: 16px; }
  .card-head { margin-bottom: 0.75rem; }
  h1, .card-title { font-size: 1.15rem; }

  .lab-card { margin: 0.25rem auto; padding: 1rem 0.9rem; }
  .inv-grid { gap: 0.5rem; margin: 1rem 0 1.25rem; justify-content: center; }
  .bench { gap: 0.5rem; margin: 1rem 0; }
  .bench-slot { width: 64px; height: 64px; }
  /* Equal-width buttons fill the row symmetrically */
  .bench-actions { gap: 0.5rem; }
  .bench-actions button { flex: 1; max-width: 48%; padding: 0.6rem 0.5rem; }

  /* World board bleeds to the card edge and gets most of the screen */
  .world-card { padding: 0.85rem 0.6rem; }
  #world-viewport {
    margin: 0 -0.6rem;
    border-radius: 0;
    max-height: calc(100vh - 260px);
  }
  .world-legend { gap: 0.6rem; font-size: 0.72rem; padding-top: 0.75rem; margin-top: 0.75rem; }
  .world-legend > span:last-child { margin-left: 0 !important; }

  /* Smaller board tiles (world.js also shrinks its metrics) */
  .wtile.found .wtile-icon svg { width: 15px; height: 15px; }
  .wtile .tile-name { font-size: 8.5px; }

  /* Tracker & tasks: compact single card */
  .page-card { padding: 0.85rem 0.8rem; }
  .habit-row, .task-row { padding: 0.25rem 0; gap: 0.5rem; }
  .section-kicker { margin-top: 1rem; padding-top: 0.85rem; }
  .project-group { margin-top: 0.9rem; }
  /* Add-task: title, gold value and button all on one row */
  #add-task { flex-wrap: nowrap; gap: 0.4rem; }
  #add-task input[type="text"] { flex: 1; min-width: 0; }
  #add-task .coin-input input { width: 2.9rem; }
  #add-task button { padding: 0.45rem 0.8rem; }

  /* Manage page: narrower select, scale editor inputs share the row */
  .manage-row select { max-width: 8rem; }
  .scale-editor-row .scale-edit-label { width: 6.5rem; min-width: 0; }
  .scale-editor-row .scale-edit-desc { flex: 1; min-width: 0; }

  /* Scaled habits: number circles only, labels via title */
  .scale-anchor { padding: 0.15rem; }
  .scale-anchor .scale-label { display: none; }

  /* Toast must clear the bottom nav */
  #toast { bottom: 4.75rem; max-width: 92vw; text-align: center; }
}

/* Toast */
#toast {
  position: fixed;
  bottom: 1.25rem; left: 50%;
  transform: translateX(-50%);
  background: var(--accent, #5FD1C9);
  color: var(--accent-text, #0E1116);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 10;
}
#toast.error { background: #e46060; color: #fff; }
