/* the tokens (colours, radii, line width, shadow) live in tokens.css, linked before this file */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(61, 51, 64, .07) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #5aa9e6; outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 900px; margin: 0 auto; padding: 14px 16px 30px; }

.top { display: flex; align-items: baseline; gap: 10px; padding: 4px 2px 12px; }
.home { font-weight: 600; font-size: 20px; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.home span { color: #e2674f; }
.toy { color: var(--soft); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 14px; padding: 12px 16px;
  background: var(--butter); border: 2.5px solid var(--ink); border-radius: 18px;
}
.banner p { margin: 0; flex: 1 1 240px; }

main { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: 22px; align-items: start; }

/* ---------- left column ---------- */
.id-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
#name {
  width: 9.5ch; min-width: 4ch; max-width: 100%;
  padding: 0 4px; margin-left: -4px;
  font-weight: 600; font-size: 28px; line-height: 1.15;
  background: transparent; border: 0; border-bottom: 2.5px dashed transparent; border-radius: 4px;
  field-sizing: content;
}
#name:hover, #name:focus { border-bottom-color: var(--line); outline: none; }
#name:focus { border-bottom-color: var(--ink); }
#name:disabled { opacity: 1; -webkit-text-fill-color: var(--ink); }
#sub { color: var(--soft); font-size: 14px; white-space: nowrap; }

.chip, .btn {
  padding: 6px 14px;
  background: var(--card);
  border: var(--line-w) solid var(--ink); border-radius: var(--r-pill);
  box-shadow: var(--shadow-hard);
  font-size: 14px; font-weight: 500;
  transition: transform .06s, box-shadow .06s;
  text-decoration: none; color: var(--ink);
}
.chip:active, .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip[aria-expanded="true"] { background: var(--butter); }
.chip.warn { background: var(--coral); }
.chip:disabled { cursor: default; transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn { background: var(--butter); }
.btn.plain { background: var(--card); }

.menu {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px; padding: 12px;
  background: var(--card); border: 2.5px solid var(--ink); border-radius: 18px;
}
.menu > button, .menu > a, .danger button, .danger a {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 13px;
  background: #fff; color: var(--ink); text-decoration: none;
  border: 2px solid var(--ink); border-radius: var(--r-pill);
  font-size: 14px;
}
.menu > button:hover, .menu > a:hover, .danger button:hover, .danger a:hover { background: var(--butter); }
.menu > button.warn, .danger button.warn { background: var(--coral); }
.menu > .wide { flex-basis: 100%; text-align: center; }
/* the file picker behind "Load save": out of sight, but still clickable from script everywhere */
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.danger {
  flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin-top: 2px; padding-top: 10px; border-top: 2px dashed var(--coral);
}
.danger b { flex-basis: 100%; font-size: 14px; font-weight: 600; }
/* the button gets a line of its own, so its longer "Tap again" label grows rightwards and stays under the finger */
.danger p { flex-basis: 100%; margin: 0 0 2px; font-size: 13.5px; color: var(--soft); }
@media (pointer: coarse) {
  .menu > button, .menu > a, .danger button, .danger a { min-height: 44px; }
}
.walls { display: flex; align-items: center; gap: 7px; flex-basis: 100%; font-size: 14px; color: var(--soft); }
.walls button { width: 28px; height: 28px; padding: 0; border: 2px solid var(--ink); border-radius: 50%; }
.walls button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--butter), 0 0 0 5px var(--ink); }

.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.meter {
  --c: var(--mint);
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 6px;
  background: var(--card); border: 2.5px solid var(--ink); border-radius: 99px;
}
.meter[data-k="tummy"] { --c: #f58aa0; }
.meter[data-k="energy"] { --c: #ffd166; }
.meter[data-k="fun"] { --c: #8ecbf2; }
.meter[data-k="clean"] { --c: #8fdcc4; }
.meter svg { flex: none; width: 19px; height: 19px; fill: var(--c); stroke: var(--ink); stroke-width: 1.800; stroke-linejoin: round; }
.bar { flex: 1; height: 10px; background: #efe3cf; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 50%; background: var(--c); border-radius: 99px; transition: width .5s; }
.meter.low { animation: low 1.1s ease-in-out infinite; }
.meter.low .bar i { background: var(--coral); }
@keyframes low { 50% { background: #ffe1d9; } }

.stage {
  position: relative;
  border: 3px solid var(--ink); border-radius: 30px;
  box-shadow: 0 7px 0 rgba(61, 51, 64, .16);
  overflow: hidden;
  background: #f6ead6;
  aspect-ratio: 360 / 430;
}
.stage[data-mode="bouts"] { aspect-ratio: 360 / 250; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
#cv.washing { cursor: none; }

.tray {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 12px; padding: 10px;
  background: var(--card); border: 2.5px solid var(--ink); border-radius: 22px;
}
.tray button {
  position: relative;
  width: 62px; padding: 5px 2px 4px;
  display: grid; justify-items: center; gap: 0;
  background: #fff; border: 2px solid var(--ink); border-radius: 16px;
  font-size: 12px;
  transition: transform .08s;
}
.tray button:hover { transform: translateY(-2px); background: #fff7e3; }
.tray button canvas { width: 40px; height: 40px; }
.tray button.locked { background: #f1e8d8; color: var(--soft); border-style: dashed; }
.tray button.locked canvas { filter: grayscale(1) opacity(.35); }
.tray button[aria-pressed="true"] { background: var(--butter); }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.tools button {
  display: grid; justify-items: center; gap: 2px;
  padding: 9px 4px 7px;
  background: var(--tc, var(--card));
  border: 2.5px solid var(--ink); border-radius: 22px;
  box-shadow: 0 5px 0 var(--ink);
  font-weight: 500; font-size: 15px;
  transition: transform .06s, box-shadow .06s;
}
.tools button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
#t-feed { --tc: #ffd0d8; }
#t-play { --tc: var(--sky); }
#t-wash { --tc: var(--mint); }
#t-light { --tc: var(--butter); }
#t-light[aria-pressed="false"] { --tc: var(--lilac); }
.tools button[aria-expanded="true"], #t-wash[aria-pressed="true"] { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); filter: saturate(1.3) brightness(.96); }
.tools svg { width: 30px; height: 30px; fill: #fff; stroke: var(--ink); stroke-width: 2.200; stroke-linejoin: round; stroke-linecap: round; }
.tools svg .cut { fill: none; }
.tools svg .leaf { fill: #8fd16f; }
#t-feed svg circle { fill: #f58aa0; }
#t-play svg circle { fill: var(--coral); }
#t-light svg path:first-child { fill: #fff3b8; }
#t-light[aria-pressed="false"] svg path:first-child { fill: #b9add6; }
.tools button.need { animation: need 1s ease-in-out infinite; }
@keyframes need { 50% { transform: translateY(-4px) rotate(-2deg); } }

/* the one status line: directly under the stage in every mode, and the bout caption while fighting */
.status { margin: 10px 4px 0; min-height: calc(2 * 1.3em + 4px); padding: 2px 6px; text-align: center; color: var(--soft); font-size: 15px; line-height: 1.3; }
.bout .status { color: var(--ink); font-weight: 500; }

/* ---------- side column ---------- */
.side { display: grid; gap: 14px; }
.card { padding: 14px 16px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-card); }
.card h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; display: flex; justify-content: space-between; }
.card h2 span { color: var(--soft); font-weight: 500; }
.small { margin: 0; font-size: 14.5px; color: var(--soft); }
.small b { color: var(--ink); font-weight: 500; }
.bond-bar { height: 14px; background: #efe3cf; border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.bond-bar i { display: block; height: 100%; width: 0; background: var(--coral); transition: width .6s; }
.diary ol { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow: auto; display: grid; gap: 9px; }
.diary li { font-size: 14.5px; line-height: 1.35; }
.diary time { display: block; font-size: 12px; color: var(--soft); letter-spacing: .04em; text-transform: uppercase; }
.diary li.new { animation: newnote .9s ease-out; }
@keyframes newnote { from { background: var(--butter); } to { background: transparent; } }

footer { margin-top: 26px; text-align: center; color: var(--soft); font-size: 13.5px; }
footer p { margin: 0; }

@media (max-width: 780px) {
  main { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .stage-col, .side { width: 100%; max-width: 470px; }
  #log-card { display: none !important; } /* the inline Log expander under the moves takes over */
}
@media (min-width: 781px) { .logbox { display: none; } }
@media (max-width: 420px) {
  .wrap { padding: 10px 10px 24px; }
  #name { font-size: 24px; }
  .meters { gap: 5px; }
  .meter { padding: 4px 6px 4px 4px; gap: 4px; }
  .meter svg { width: 16px; height: 16px; }
  .tools { gap: 7px; }
  .tools button { font-size: 14px; border-radius: 18px; }
  .stage { border-radius: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .meter.low, .tools button.need, .diary li.new { animation: none; }
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; padding: 4px; background: #efe3cf; border-radius: 99px; }
.tabs button {
  flex: 1; padding: 7px 4px;
  background: transparent; border: 2.5px solid transparent; border-radius: 99px;
  font-weight: 600; font-size: 15px; color: var(--soft);
  transition: background .15s, color .15s;
}
.tabs button[aria-pressed="true"] { background: var(--card); color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }

/* ---------- bouts ---------- */
/* the slim bar that stands in for the name row and tabs while a bout runs */
.bout-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; margin-bottom: 10px; padding: 0 2px; }
.bout-bar b { font-size: 18px; font-weight: 600; }
.bout .top { padding-bottom: 6px; }

/* pep plates, laid over the top of the arena */
.plates { position: absolute; inset: 8px 8px auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.plate { width: 47%; padding: 5px 9px 7px; background: rgba(255, 250, 242, .94); border: var(--line-w) solid var(--ink); border-radius: 14px; font-size: 13px; }
.plate.foe { text-align: right; }
.plate .who { display: flex; align-items: baseline; gap: 5px; line-height: 1.25; white-space: nowrap; }
.plate.foe .who { flex-direction: row-reverse; }
.plate .who b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; font-weight: 600; }
.plate .who span { color: var(--soft); font-size: 12.5px; }
.plate .who em { margin-left: auto; font-style: normal; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plate.foe .who em { margin: 0 auto 0 0; }
.pep { position: relative; height: 16px; margin-top: 3px; background: #efe3cf; border: 2px solid var(--ink); border-radius: var(--r-pill); overflow: hidden; }
.pep i { display: block; height: 100%; width: 100%; background: #f58aa0; transition: width .35s; }
.plate.foe .pep i { margin-left: auto; }
.pep::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(61, 51, 64, .35) calc(25% - 1px) 25%); }
.pep em { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.sprow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 3px; }
.plate.foe .sprow { flex-direction: row-reverse; }
.spk { flex: 1 1 36px; height: 7px; background: #efe3cf; border: 1.5px solid var(--ink); border-radius: var(--r-pill); overflow: hidden; }
.spk span { display: block; height: 100%; width: 100%; background: var(--lilac); transition: width .35s; }
.plate.foe .spk span { margin-left: auto; }
.fx { display: flex; flex-wrap: wrap; gap: 4px; }
.fx:empty { display: none; }
.plate.foe .fx { justify-content: flex-end; }
.fx span { padding: 1px 7px; font-size: 12px; white-space: nowrap; border-radius: var(--r-pill); border: 1.5px solid var(--ink); background: #fff; }
.fx span.good { background: var(--butter); }
.fx span.bad { background: var(--lilac); }

.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.moves button {
  position: relative;
  display: grid; justify-items: center; align-content: center; gap: 1px;
  min-height: 64px; padding: 8px 6px 7px;
  background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile);
  box-shadow: 0 5px 0 var(--ink);
  font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: transform .06s, box-shadow .06s;
}
.moves button .ic { font-size: 22px; line-height: 1; }
.moves button small { font-size: 12px; color: var(--soft); }
.moves button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.moves button:disabled { opacity: .45; cursor: default; transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
@media (hover: hover) {
  .moves button::after { content: attr(data-key); position: absolute; top: 5px; left: 7px; min-width: 18px; padding: 1px 4px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; font-size: 12px; font-weight: 600; line-height: 1.2; color: var(--soft); }
}
.result { margin-top: 10px; padding: 14px; text-align: center; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-card); }
.result h3 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.result p { margin: 0 0 12px; color: var(--soft); }
.result .btn { margin: 4px; }

/* the full log, folded away under the moves on narrow screens */
.logbox { margin-top: 10px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.logbox summary { padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; }
.logbox summary::-webkit-details-marker { display: none; }
.logbox summary::after { content: ' \25BE'; color: var(--soft); }
.logbox[open] summary::after { content: ' \25B4'; }
.logbox .blog { max-height: 220px; padding: 0 14px 12px; }

@media (pointer: coarse) {
  #b-forfeit, .result .btn, .logbox summary, .league .btn, .lhead .btn { min-height: 44px; }
  .logbox summary { display: flex; align-items: center; }
}

.league { margin-top: 12px; }
.lhead { display: grid; gap: 4px; margin-bottom: 10px; padding: 12px 14px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.lhead b { font-size: 17px; font-weight: 600; }
.lhead span { font-size: 13.5px; color: var(--soft); }
.league > * + .lhead { margin-top: 12px; }
.league > .btn { width: 100%; margin-bottom: 10px; }
.rivals { display: grid; gap: 8px; }
.rival { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px 6px 6px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.rival canvas { width: 56px; height: 56px; }
.rival b { display: block; font-weight: 600; }
.rival small { color: var(--soft); font-size: 13px; }
.rival.locked { opacity: .55; }
.rival.locked canvas { filter: grayscale(1); }
.rival.beaten canvas { filter: saturate(.7); }
.rival.next { border-color: #e2674f; box-shadow: 0 0 0 3px var(--butter); }
.blog { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; display: grid; gap: 6px; font-size: 14px; }
.blog li.new { font-weight: 600; }
/* each round opens with a small heading; the log is newest first, so the rule sits above it, between rounds */
.blog li.round { margin-top: 4px; padding-top: 6px; border-top: 2px dashed var(--line); color: var(--soft); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.blog li.round:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14.5px; }
.stats dt { color: var(--soft); }
.stats dd { margin: 0; font-weight: 600; }
.stats p { grid-column: 1 / -1; margin: 8px 0 0; }

@media (max-width: 420px) { .moves button { border-radius: 14px; } .plates { inset: 6px 6px auto; } .plate { padding: 4px 8px 6px; } }

/* ---------- bouts page: our fighter, next up, last bout, gauntlet ---------- */
.league section { margin-top: 12px; }
.league > .fighter { margin-top: 0; }
.fighter { padding: 10px 12px 12px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.fhead { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.fhead canvas { width: 56px; height: 56px; }
.fhead > .btn { align-self: start; }
.ftitle { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.ftitle b { font-size: 17px; font-weight: 600; }
.ftitle span { font-size: 14px; color: var(--soft); }
.xpbar { position: relative; height: 18px; margin: 3px 0 2px; }
.xpbar i { background: #8ecbf2; }
.xpbar em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.frec { display: block; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.kit { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 0; padding: 0; }
.kit li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 8px; padding: 3px 10px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; line-height: 1.2; }
.kit .ic { grid-row: span 2; font-size: 20px; line-height: 1; }
.kit b { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.kit small { font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.rival.opp { grid-template-columns: 72px minmax(0, 1fr); padding: 8px 10px 10px 8px; }
.rival .go { grid-column: 1 / -1; display: grid; gap: 6px; }
.rival .go .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.rival .go .btn.big { flex: 1 1 140px; padding: 9px 18px; font-size: 18px; font-weight: 600; }
.rival .go .btn.plain { flex: 0 1 auto; }
.league h3 { margin: 0 0 8px 4px; font-size: 16px; font-weight: 600; }
.league h3 small { display: block; font-weight: 400; font-size: 13px; color: var(--soft); }
.rival .acts { display: grid; gap: 6px; }
.rival .acts .btn { font-size: 13px; padding: 5px 10px; white-space: nowrap; }
.rival.opp canvas { width: 72px; height: 72px; }
.rival.lost { border-style: dashed; }
.mini { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mini span { padding: 1px 7px; font-size: 12px; border: 1.5px solid var(--line); border-radius: 99px; background: #fff; color: var(--soft); }
.strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.gslot { width: 48px; height: 48px; padding: 0; background: #fff; border: var(--line-w) solid var(--ink); border-radius: 14px; overflow: hidden; }
.gslot canvas { width: 44px; height: 44px; display: block; }
.gslot.beaten { border-color: var(--mint); background: #f1fbf7; }
.gslot.next { border-color: #e2674f; box-shadow: 0 0 0 3px var(--butter); }
.gslot.locked { opacity: .45; cursor: default; }
.gslot.locked canvas { filter: grayscale(1); }

/* ---------- skills: classes and talent trees ----------
   Phones: header, loadout chips, a tree switcher, one tree, and the detail bar (pinned to the bottom once a talent is picked).
   900px and up: the side column goes away; a sticky left panel (loadout, detail) sits beside all three trees */
.ic { font-style: normal; }
.skills { display: grid; gap: 12px; }
.skills .lhead { margin: 0; }
.lrow { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; }
.lhead .pts { padding: 1px 10px; background: var(--butter); border-radius: var(--r-pill); color: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lhead .pts.none { background: transparent; padding: 0; color: var(--soft); font-weight: 500; }
.skside { display: contents; }

.loadout { padding: 10px 12px 12px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.loadout h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slots button { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 6px 4px; background: #fff; border: var(--line-w) dashed var(--ink); border-radius: var(--r-chip); font-size: 13px; font-weight: 500; line-height: 1.2; overflow-wrap: break-word; }
.slots button .ic { font-size: 20px; line-height: 1; }
.slots button[aria-pressed="true"] { background: var(--butter); border-style: solid; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 2px dashed var(--line); }
.picker span { width: 100%; font-size: 13px; color: var(--soft); }
.picker button { padding: 5px 11px; background: #fff; border: 2px solid var(--ink); border-radius: var(--r-pill); font-size: 13.5px; }
.picker button[aria-pressed="true"] { background: var(--butter); }

/* the tree switcher: the same pill strip as the tabs, with each tree's points in a badge */
.seg { display: flex; gap: 8px; padding: 4px; background: #efe3cf; border-radius: var(--r-pill); }
.seg button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; padding: 6px 4px; background: transparent; border: var(--line-w) solid transparent; border-radius: var(--r-pill); font-size: 15px; font-weight: 600; color: var(--soft); transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); border-color: var(--ink); box-shadow: var(--shadow-hard); }
.seg button b { min-width: 22px; padding: 0 6px; border: 1.5px solid currentColor; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; line-height: 1.35; font-variant-numeric: tabular-nums; }

.trees { display: grid; gap: 10px; }
.ttree { padding: 10px 10px 12px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); }
.ttree h3 { margin: 0 0 8px 2px; font-size: 16px; font-weight: 600; }
.ttree h3 small { display: block; font-weight: 400; font-size: 13px; color: var(--soft); }
.tier { padding-top: 6px; }
.tier + .tier { margin-top: 6px; border-top: 2px dashed var(--line); }
.tlabel { display: block; margin: 2px 0 5px 2px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--soft); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.talent {
  position: relative;
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 84px; padding: 8px 6px 6px;
  background: #fff; border: 2px solid var(--line); border-radius: var(--r-chip);
  font-size: 13.5px; line-height: 1.2; text-align: center;
  transition: transform .08s, box-shadow .08s;
}
.talent .ic { font-size: 22px; line-height: 1; }
.talent .tn { font-weight: 500; }
.talent .rk { font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.talent.can { border-color: var(--ink); box-shadow: var(--shadow-hard); }
.talent.part { border-color: #e2674f; background: #fff2ea; }
.talent.full { border-color: var(--mint); background: #f1fbf7; }
.talent.full .rk { color: #1f7a6f; font-weight: 600; }
.talent[aria-pressed="true"] { background: var(--butter); border: var(--line-w) solid var(--ink); box-shadow: var(--shadow-hard); }
.talent:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tier.shut .talent:not([aria-pressed="true"]) { opacity: .55; }
.tier.shut .talent .ic { filter: grayscale(1); }
@media (hover: hover) {
  .talent:hover { background: #fff7e3; }
  .talent.can:hover { transform: translateY(-2px); }
  .talent[aria-pressed="true"]:hover { background: var(--butter); }
}

/* the detail bar: what the selected talent does, what one more rank changes, and the only button that spends */
.tdetail { display: grid; gap: 3px; padding: 10px 14px 12px; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-tile); box-shadow: var(--shadow-hard); font-size: 14.5px; line-height: 1.3; }
.tdetail p { margin: 0; }
.dhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 10px; }
.dhead b { font-size: 17px; font-weight: 600; }
.dmeta { font-size: 13px; color: var(--soft); }
.dtext { color: var(--soft); }
.dfx, .ddelta { font-weight: 500; font-variant-numeric: tabular-nums; }
.ddelta { font-weight: 600; }
.dmsg { min-height: calc(1.3em + 4px); padding: 2px 10px; background: #fff2ea; border-radius: var(--r-chip); font-weight: 500; }
/* the message line is the live region, so it is always rendered: an empty one keeps its line (Learn doesn't jump when a message arrives) */
.dmsg:empty { background: transparent; }
.tdetail.empty .dmsg:empty { min-height: 0; padding: 0; }
.dacts .btn.off { visibility: hidden; }
.dacts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.dacts .btn { font-size: 14px; }
.dacts .btn:not(.plain) { font-weight: 600; }
.dacts .btn:disabled { background: var(--card); border-style: dashed; box-shadow: none; transform: translateY(3px); color: var(--soft); cursor: default; }
.dleft { margin-left: auto; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.tdetail.peek { border-style: dashed; }
.tfoot { display: flex; flex-wrap: wrap; gap: 8px; }
.tfoot .btn { font-size: 13px; }

@media (max-width: 899px) {
  .skills.picked .ttree:not(.on) { display: none; }
  /* once a talent is picked the bar is pinned to the bottom of the screen while the tree scrolls under it;
     a tile given keyboard focus scrolls clear of it (--skbar is the bar's height, set from app.js). Only tiles:
     a page-wide scroll-padding would count the bar's own buttons as covered and scroll on every Learn */
  .skills.picked .tdetail:not(.empty) { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 3; }
  .skills.picked:has(> .tdetail:not(.empty)) .talent { scroll-margin-bottom: calc(var(--skbar, 200px) + 20px); }
}
/* between the phone layout and the wide one, Skills keeps the phone column, centred as it is below 781px */
@media (min-width: 781px) and (max-width: 899px) {
  body[data-mode="skills"] main { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  body[data-mode="skills"] .stage-col { width: 100%; max-width: 470px; }
}
@media (min-width: 900px) {
  body[data-mode="skills"] main { grid-template-columns: minmax(0, 1fr); }
  body[data-mode="skills"] .stage-col > :not(#skills) { max-width: 470px; }
  .skills.picked { grid-template-columns: 220px minmax(0, 1fr); column-gap: 14px; align-items: start; }
  .skills.picked > .lhead { grid-column: 1 / -1; }
  .skside { display: grid; gap: 12px; grid-column: 1; grid-row: 2 / span 2; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; margin: -6px; padding: 6px; }
  .skills.picked > .seg { display: none; }
  .skills.picked > .trees { grid-column: 2; grid-row: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .skills.picked > .tfoot { grid-column: 2; grid-row: 3; }
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* a tree is about 200px wide here, so its tiles stack one per row, icon beside the name */
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .talent { grid-template-columns: auto minmax(0, 1fr) auto; justify-items: start; align-items: center; gap: 8px; min-height: 52px; padding: 7px 10px; text-align: left; }
  .dacts .btn { flex: 1 1 auto; }
}
@media (pointer: coarse) {
  .slots button, .picker button, .seg button, .dacts .btn, .tfoot .btn, .class .btn { min-height: 44px; }
}

.ctitle { margin: 4px 0 10px; font-size: 20px; font-weight: 600; text-align: center; }
.classes { display: grid; gap: 10px; }
.class { display: grid; justify-items: center; gap: 4px; padding: 14px; text-align: center; background: var(--card); border: var(--line-w) solid var(--ink); border-radius: var(--r-card); }
.class .cicon { font-size: 34px; line-height: 1; }
.class b { font-size: 19px; font-weight: 600; }
.class p { margin: 0; color: var(--soft); font-size: 14px; }
.class .mini { justify-content: center; }
.class small { color: var(--soft); font-size: 13px; }
.class .btn { margin-top: 6px; }
@media (min-width: 560px) { .classes { grid-template-columns: repeat(3, 1fr); } }
body[data-mode="skills"] .side { display: none; }
body[data-mode="skills"] .status:empty { display: none; }
