/* ==========================================================================
   Game — foundation styles. Prefix gm-; a module's own sheet uses gm-<mod>-.
   ==========================================================================
   Tokens only — surfaces, text, accent, warning, critical, the card radius
   and shadow, and the typography variables Settings → Appearance swaps — so
   every palette, type and surface preset applies here unchanged. LiFE RPG is
   light and monochrome; what is kept from it is the vocabulary: ten-square
   bars, hearts for HP, mono reward chips, tagged objectives, line-icon tiles.

   Colour carries meaning and nothing else: EXP is the accent, coins are
   gold (--warning), a loss is --critical, HP restored is --good-text.      */

.gm-eyebrow {
  font-family: var(--s-eyebrow-f, var(--s-mono));
  font-size: var(--s-eyebrow-size, 11px);
  font-weight: var(--s-eyebrow-w, 500);
  letter-spacing: var(--s-eyebrow-track, 0.14em);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- hub layout ----------------------------------------------------------- */

.gm-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gm-top-sp { flex: 1; }

.gm-cols { display: grid; gap: 22px; }
.gm-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
@media (min-width: 1000px) {
  .gm-cols { grid-template-columns: 320px minmax(0, 1fr) 320px; align-items: start; }
}

.section-head .gm-link { margin-left: auto; }
.gm-link {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer;
}

/* --- the character card ---------------------------------------------------- */

.gm-char { display: flex; flex-direction: column; gap: 13px; cursor: pointer; }
.gm-char:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gm-char-head { display: flex; align-items: center; gap: 14px; }
.gm-char-head > .btn { margin-left: auto; }
.gm-char-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gm-char-name {
  font-family: var(--s-display); font-size: 21px; font-weight: 600;
  letter-spacing: var(--s-h-track, -0.01em); line-height: 1.15;
  overflow-wrap: anywhere;
}
.gm-char-name.big { font-size: 25px; }
.gm-char-level {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px;
  font-size: 13.5px; color: var(--text-secondary);
}
.gm-char-level span { white-space: nowrap; }

.gm-avatar {
  width: var(--s); height: var(--s); flex: none;
  border-radius: 50%; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center;
}
.gm-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gm-avatar-init {
  font-family: var(--s-display); font-size: calc(var(--s) * 0.38);
  color: var(--text-secondary);
}

.gm-stat {
  display: grid; grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center; gap: 10px;
}
.gm-stat-v {
  font-family: var(--s-value-f); font-variant-numeric: tabular-nums;
  font-size: 13px; color: var(--text-secondary); white-space: nowrap;
}
.gm-debt-note { font-family: var(--s-body); font-size: 11.5px; color: var(--critical); white-space: normal; }

/* Ten squares, LiFE RPG's bar. */
.gm-squares { display: inline-flex; gap: 3px; }
.gm-squares i { width: 9px; height: 9px; border-radius: 2px; background: var(--surface-2); }
.gm-squares i.on { background: var(--accent); }

/* Ten hearts; the fill is clipped to the heart's share of HP. Each heart
   gives way before the row does — ten 15px hearts and "1,000 / 1,000" do not
   fit a 375px phone's card side by side, and the number matters more. */
.gm-hearts { display: flex; gap: 2px; min-width: 0; }
.gm-heart { position: relative; flex: 0 1 15px; min-width: 8px; aspect-ratio: 1; display: block; }
.gm-heart svg { display: block; width: 100%; height: 100%; }
.gm-heart .gm-heart-bg { color: color-mix(in srgb, var(--critical) 16%, var(--surface-2)); }
.gm-heart-fill {
  position: absolute; inset: 0; color: var(--critical);
  clip-path: inset(0 calc((1 - var(--f)) * 100%) 0 0);
}

.gm-coins {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--warning);
  font-family: var(--s-value-f); font-weight: var(--s-value-w, 600);
  font-variant-numeric: tabular-nums;
}
.gm-coins.debt { color: var(--critical); }
.gm-coins.big { font-size: 26px; }

.gm-objectives { display: grid; gap: 6px; }
.gm-obj {
  display: grid; grid-template-columns: 124px minmax(0, 1fr);
  gap: 10px; align-items: baseline; font-size: 13.5px;
}
.gm-tag {
  justify-self: start; white-space: nowrap;
  font-family: var(--s-mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-2);
  border-radius: 4px; padding: 2px 6px;
}

/* A module's slider on the card ("Habit goal completion — 25%"). */
.gm-slider {
  display: grid; grid-template-columns: minmax(0, 1fr) 90px auto;
  gap: 10px; align-items: center; font-size: 13px;
}
.gm-slider-label { color: var(--text-secondary); }
.gm-slider-track { position: relative; border-top: 1px dashed var(--border-strong); }
.gm-slider-dot {
  position: absolute; top: -6px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-primary); transform: translateX(-50%);
}

/* --- reward chips ---------------------------------------------------------- */

.gm-chip {
  display: inline-block; white-space: nowrap;
  font-family: var(--s-mono); font-size: 11.5px; font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 5px;
}
.gm-chip.exp  { color: var(--accent); background: var(--accent-quiet); }
.gm-chip.coin { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.gm-chip.hp   { color: var(--good-text); background: color-mix(in srgb, var(--good-text) 14%, transparent); }
.gm-chip.neg  { color: var(--critical); background: color-mix(in srgb, var(--critical) 14%, transparent); }

/* --- today, the grid, the feed ------------------------------------------- */

.gm-empty .sub { line-height: 1.55; margin-top: 4px; }

.gm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) and (max-width: 999px) {
  .gm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.gm-tile {
  appearance: none; font: inherit; color: var(--text-primary); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 6px; min-height: 108px; padding: 13px 6px 10px; text-align: center;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.gm-tile:hover { border-color: var(--border-strong); }
.gm-tile:active { transform: scale(0.97); }
.gm-tile-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
}
.gm-tile-title { font-size: 13px; font-weight: 600; line-height: 1.2; }
.gm-tile-sub {
  font-family: var(--s-mono); font-size: 9.5px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted); line-height: 1.3;
}
.gm-tile.soon { box-shadow: none; background: transparent; }
.gm-tile.soon .gm-tile-ico { color: var(--text-muted); }
.gm-tile.soon .gm-tile-title { color: var(--text-secondary); }

.gm-feed { padding-top: 4px; padding-bottom: 4px; }
.gm-feed-row { display: grid; gap: 4px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.gm-feed-row:last-child { border-bottom: 0; }
.gm-feed-when { font-family: var(--s-mono); font-size: 11px; color: var(--text-muted); }
.gm-feed-text { font-size: 13.5px; line-height: 1.4; }
.gm-feed-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.gm-feed-chips:empty { display: none; }
.gm-k-level .gm-feed-text { color: var(--accent); font-weight: 600; }
.gm-k-faint .gm-feed-text, .gm-k-overdraft .gm-feed-text { color: var(--critical); }
.gm-feed-day { margin-top: 14px; }

/* --- rank badges ------------------------------------------------------------ */

.gm-badge { position: relative; display: inline-grid; place-items: center; color: var(--warning); flex: none; }
.gm-badge-glyph { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 2px; }
.gm-badge.locked { color: var(--text-muted); opacity: 0.5; }

/* --- feedback: reward toast and level-up --------------------------------- */

.gm-toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 300;
  bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.gm-toast {
  display: flex; gap: 6px; padding: 7px 11px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  animation: gm-rise 0.28s ease-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.gm-toast.out { opacity: 0; transform: translateY(8px); }

.gm-lvl-scrim {
  position: fixed; inset: 0; z-index: 320; padding: 24px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface-0) 74%, transparent);
  backdrop-filter: blur(6px);
}
.gm-lvl {
  min-width: 260px; padding: 26px 30px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: var(--shadow);
  animation: gm-pop 0.36s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.gm-lvl-n {
  font-family: var(--s-value-f); font-weight: var(--s-value-w, 600);
  font-size: 76px; line-height: 1; color: var(--accent);
}
.gm-lvl-rank { display: flex; align-items: center; gap: 12px; text-align: left; }
.gm-lvl-rank-name { font-size: 18px; font-weight: 600; }

@keyframes gm-rise { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes gm-pop { from { opacity: 0; transform: scale(0.86); } }
@keyframes gm-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.gm-shake { animation: gm-shake 0.3s ease; }
@media (prefers-reduced-motion: reduce) {
  .gm-toast, .gm-lvl, .gm-shake { animation: none; }
  .gm-tile { transition: none; }
}

/* --- sheets and panels ------------------------------------------------------ */

.gm-seg { display: flex; }
.gm-seg button { flex: 1; }
.gm-panel {
  display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-s);
}
.gm-panel-title {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-secondary);
}
.gm-panel .form-row { margin-top: 2px; }
.gm-errors .hint { color: var(--critical); }
.gm-grant-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gm-num { width: 100%; }

.gm-iconpick { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.gm-iconpick button {
  appearance: none; aspect-ratio: 1; cursor: pointer;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 8px;
}
.gm-iconpick button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.gm-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.gm-table th, .gm-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); }
.gm-table th:first-child, .gm-table td:first-child { text-align: left; }
.gm-table th {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
}
.gm-table .gm-rank-row td { color: var(--warning); }

/* --- creation ------------------------------------------------------------- */

.gm-ob { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.gm-ob-dots { display: flex; gap: 5px; }
.gm-ob-dots i { width: 26px; height: 4px; border-radius: 2px; background: var(--surface-2); }
.gm-ob-dots i.on { background: var(--accent); }
.gm-ob-title { font-family: var(--s-display); font-size: 23px; margin-bottom: 4px; }
.gm-ob-body { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.gm-ob-body .ap-field { margin-bottom: 0; }
.gm-ob-nav { display: flex; justify-content: space-between; gap: 10px; }
.gm-ob-avatar { display: flex; align-items: center; gap: 16px; }
.gm-ob-note { margin-top: -4px; }
.gm-ob-skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gm-ob-skill {
  appearance: none; font: inherit; font-size: 14px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-s);
}
.gm-ob-skill[aria-pressed="true"] {
  background: var(--accent-quiet); color: var(--text-primary); border-color: var(--accent);
}
.gm-ob-skill[aria-pressed="true"] svg { color: var(--accent); }

/* --- the Character screen --------------------------------------------------- */

.gm-idcard { display: flex; flex-direction: column; gap: 14px; }
.gm-tile-coins .gm-coins.big { font-size: inherit; }

.gm-skill-row {
  appearance: none; width: 100%; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto 40px 12px;
  align-items: center; gap: 10px; padding: 10px 0;
  background: none; border: 0; border-bottom: 1px solid var(--grid);
  color: var(--text-primary); font: inherit; font-size: 14px;
}
.gm-skill-row:last-of-type { border-bottom: 0; }
.gm-skill-ico { color: var(--accent); display: grid; }
.gm-skill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-skill-v {
  font-family: var(--s-value-f); font-size: 12.5px;
  color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gm-skill-lv { font-family: var(--s-mono); font-size: 11.5px; color: var(--text-muted); text-align: right; }
.gm-dom-count { color: var(--text-muted); font-size: 12.5px; }
.gm-dom-chev { color: var(--text-muted); font-size: 18px; line-height: 1; text-align: right; }
.gm-dom-ico { color: var(--accent); display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, transparent); flex: none; }
.gm-dom-actions { display: flex; gap: 16px; align-items: baseline; margin-left: auto; }
.gm-dom-edit {
  display: grid; grid-template-columns: minmax(0, 1fr) 36px 36px 36px; gap: 6px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--grid);
}
.gm-dom-edit:last-of-type { border-bottom: 0; }
.gm-dom-edit-name {
  appearance: none; background: none; border: 0; color: var(--text-primary); font: inherit; font-size: 14px;
  display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; cursor: pointer; padding: 6px 0;
}
.gm-dom-edit-name > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-dom-edit-hint { font-size: 12px; margin-left: auto; }
.gm-dom-tool {
  appearance: none; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 15px; display: grid; place-items: center;
}
.gm-dom-tool:disabled { opacity: .3; cursor: default; }
.gm-dom-tool:last-child { color: var(--critical); }
.gm-danger { color: var(--critical); }
.gm-archived-item { white-space: nowrap; }
.gm-crumbs { font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px; align-items: baseline; }
.gm-archived { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
@media (max-width: 440px) {
  .gm-skill-row { grid-template-columns: 22px minmax(0, 1fr) auto 36px 12px; }
  .gm-skill-v { display: none; }
  .gm-skill-row .gm-squares i { width: 7px; height: 7px; }
  .gm-obj { grid-template-columns: 1fr; gap: 3px; }
}

.gm-radar { display: block; width: 100%; max-width: 440px; margin: 0 auto; }
.gm-radar-ring { fill: none; stroke: var(--grid); }
.gm-radar-spoke { stroke: var(--grid); }
.gm-radar-label { fill: var(--text-secondary); font-size: 11px; font-family: var(--s-body); }
.gm-radar-shape {
  fill: color-mix(in srgb, var(--accent) 22%, transparent);
  stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round;
}

.gm-ranks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 8px; }
.gm-rank { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.gm-rank-name { font-size: 12.5px; font-weight: 600; }
.gm-rank.locked .gm-rank-name { color: var(--text-muted); }
.gm-rank-lv { font-family: var(--s-mono); font-size: 10.5px; color: var(--text-muted); }

.gm-vision { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; }
.gm-vision-cell {
  appearance: none; border: 0; padding: 0; background: none; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  color: var(--text-secondary); font: inherit; font-size: 12px;
}
.gm-vision-img {
  display: block; aspect-ratio: 1; overflow: hidden;
  border-radius: var(--radius-s); background: var(--surface-2);
}
.gm-vision-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
