:root {
  --bg: #171512;
  --panel: rgba(35, 31, 26, .96);
  --line: rgba(213, 184, 126, .28);
  --text: #f4efe4;
  --muted: #c3b9a5;
  --gold: #ffce70;
  --accent: #ffb019;
  --blue: #82b7ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(rgba(18,16,13,.68), rgba(18,16,13,.9)), url("assets/ror.jpg") center / cover fixed;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--gold); }
a:hover { color: #ffe6b4; }
button, a, input, select, textarea, summary, [tabindex] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.app-shell { width: min(1220px, 100%); margin: auto; }
.hero { display: flex; gap: 24px; align-items: center; justify-content: space-between; margin: 18px 0 22px; }
.hero h1 { flex: 1; min-width: 0; }
.rules-control { flex: 0 0 240px; }
h1 { font-size: clamp(1.55rem, 2.8vw, 2.15rem); margin: 0; letter-spacing: -.025em; line-height: 1.25; }
h1 a { text-decoration: none; color: var(--accent); }
h1 span { color: #d6c9b2; font-weight: 500; }
.controls {
  display: grid;
  grid-template-columns: 150px minmax(150px, 1fr) auto;
  gap: 16px;
  align-items: end;
  min-width: 0;
  margin: 0;
  padding: 17px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 7px 20px #0004;
}
label { display: grid; gap: 7px; color: var(--muted); font-size: .77rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #76654a;
  border-radius: 5px;
  color: var(--text);
  background: #15130f;
}
textarea { resize: vertical; font: .82rem/1.6 ui-monospace, monospace; overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.budget-note { display: grid; gap: 4px; align-self: center; padding: 16px 0 0 8px; }
.budget-note strong { color: var(--gold); font-size: .95rem; }
.budget-note span { color: var(--muted); font-size: .73rem; }
.comparison-layout { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 850px) minmax(270px, 1fr); gap: 20px; align-items: start; }
.trainer {
  min-width: 0;
  border: 3px ridge #696660;
  background: #080808;
  box-shadow: inset 0 0 0 2px #151210, 0 12px 38px #0009, 0 0 0 1px #0c0b09;
}
.trainer-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 43px;
  padding: 0 14px;
  border-bottom: 3px ridge #7c6848;
  background: linear-gradient(110deg, #22211f55, #0a0a0be8 42%, #25232155), repeating-linear-gradient(9deg, #1e1d1b, #131211 3px, #171717 4px);
}
.trainer-title h2 { margin: 0; font: bold clamp(1.1rem, 2vw, 1.45rem)/1 Georgia, "Times New Roman", serif; letter-spacing: .025em; text-shadow: 0 2px 2px #000; }
.title-ornament { position: absolute; left: 18px; color: #b9aa8c; font-size: 25px; text-shadow: -1px -1px #fff7, 2px 2px #000; }
.trainer-tag { position: absolute; right: 13px; font: 700 .55rem/1.5 sans-serif; letter-spacing: .1em; color: #baae96; padding: 2px 5px; border: 1px solid #7d6b4677; border-radius: 2px; }
.trainer-tag.is-pts { color: #ffd690; border-color: #cb9743; }
.trainer-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px 5px 0; background: #100d0a; border-bottom: 1px solid #9b7845; }
.trainer-tabs button {
  position: relative;
  height: 40px;
  margin-bottom: -1px;
  padding: 3px 5px 5px;
  border: 2px ridge #b18856;
  border-radius: 10px 10px 0 0;
  color: #ebd168;
  background: linear-gradient(#353432, #171412);
  font: bold clamp(.82rem, 1.5vw, 1.05rem)/1 Georgia, "Times New Roman", serif;
  text-shadow: 1px 2px 1px #000;
  box-shadow: inset 0 0 0 2px #391c14;
}
.trainer-tabs button[aria-selected="true"] { color: #fff6df; background: #080808; border-bottom-color: #080808; box-shadow: inset 0 2px #5d321d; }
.trainer-tabs button:hover { color: #fff3ba; }
.trainer-tabs button:focus-visible { outline-offset: -5px; }
.board-scroll { overflow-x: auto; scrollbar-color: #7c6949 #100e0b; background: radial-gradient(ellipse at 50% 0%, #1f1b1333, transparent 55%), #070707; }
.skill-grid {
  display: grid;
  grid-template-columns: repeat(var(--desktop-cols, 8), minmax(66px, 1fr)) 24px;
  gap: 9px;
  min-width: 704px;
  min-height: 395px;
  padding: 17px 15px 17px;
  background: repeating-linear-gradient(138deg, transparent, transparent 67px, #b0996204 68px, transparent 69px);
}
.skill-column { min-width: 0; }
.skill-heading { display: flex; align-items: center; justify-content: center; min-height: 37px; margin: 0 0 7px; color: #bcaf94; font: 600 .66rem/1.25 Georgia, serif; text-align: center; }
.skill-heading.has-changes::after { content: "•"; margin-left: 3px; color: #d4b76e; }
.rank-list { display: grid; grid-template-rows: repeat(5, 58px); gap: 10px; margin: 0; padding: 0; list-style: none; }
.rank-list li { display: flex; justify-content: center; min-width: 0; }
.rank-button {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  padding: 0;
  border: 2px solid #655d4c;
  border-radius: 5px;
  background: #17110d;
  box-shadow: 0 0 0 1px #18110a, inset 0 0 5px #000, 0 3px 6px #000a;
  overflow: visible;
}
.rank-button img { display: block; width: 100%; height: 100%; border-radius: 3px; object-fit: cover; }
.rank-button.needs-prerequisite img, .rank-button.unaffordable img { filter: sepia(1) saturate(7) hue-rotate(318deg) brightness(.53); }
.rank-button.unavailable img { filter: grayscale(1) brightness(.28); }
.rank-button[aria-pressed="true"] { border-color: #8bbdff; box-shadow: 0 0 0 1px #3165a0, 0 0 10px #448cea66; }
.rank-button[aria-pressed="true"] img { filter: none; }
.rank-button[aria-pressed="true"]::before { content: ""; position: absolute; inset: 0; background: #518feb33; z-index: 1; }
.rank-button:hover, .rank-button:focus-visible { border-color: #f4d597; transform: translateY(-1px); }
.rank-button:focus-visible { outline-offset: 3px; }
.rank-cost { position: absolute; bottom: -3px; right: -4px; z-index: 2; min-width: 20px; padding: 2px 4px; border: 1px solid #8b7147; border-radius: 3px; background: #13110f; color: #edd493; font: 700 .67rem/1 sans-serif; box-shadow: 0 1px 3px #000; }
.rank-check { position: absolute; top: 0; left: 2px; z-index: 2; color: #fff; font: 900 .75rem/1.2 sans-serif; text-shadow: 0 1px 3px #000; }
.rank-scale { grid-column: var(--scale-column, 9); padding-top: 44px; display: grid; grid-template-rows: repeat(5, 58px); gap: 10px; color: #dfd9c9; font: bold 1rem Georgia, serif; text-align: center; }
.rank-scale span { align-self: center; }
.points-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: 43px;
  padding: 10px 15px;
  border-top: 3px ridge #74716a;
  border-bottom: 3px ridge #69665e;
  background: linear-gradient(130deg, #191714, #0b0a09 65%, #201c14);
  font: bold 1rem/1.2 Georgia, serif;
  color: #d7d0bf;
}
.points-bar strong { color: #fff3d2; font-variant-numeric: tabular-nums; }
.points-meter { width: 95px; height: 6px; border: 1px solid #796445; background: #080808; }
.points-meter > span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #8c591e, #dec181); transition: width .15s; }
.trainer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 15px; padding: 13px 17px; background: repeating-linear-gradient(166deg, #171511, #0d0c0a 3px, #0b0a09 5px); }
.trainer-actions button { min-width: 165px; }
.game-button {
  min-height: 33px;
  padding: 5px 8px;
  border: 2px ridge #b08c57;
  border-radius: 2px;
  background: linear-gradient(#6a492d, #342821 44%, #453125 57%, #251910);
  color: #f1d778;
  font: bold .94rem/1.1 Georgia, "Times New Roman", serif;
  text-shadow: 1px 2px #000;
  box-shadow: inset 0 0 0 2px #28150c, 0 2px 4px #000;
}
.game-button:hover { color: #fff3b3; background: linear-gradient(#805837, #403124 48%, #4d3926); }
.game-button:active { transform: translateY(1px); }
.side-panel { display: grid; gap: 16px; }
.rank-details { padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: 0 4px 16px #0004; }
.quiet, .rank-details p { font-size: .8rem; line-height: 1.55; color: var(--muted); margin: 0; }
.rank-details h2 { margin: 0; font: 600 1.05rem Georgia, serif; color: #edd6a8; }
.rank-details { border-top-color: #a08145; }
.detail-title { display: flex; gap: 10px; align-items: center; margin-bottom: 11px; }
.detail-title img { width: 37px; height: 37px; border: 1px solid #796548; border-radius: 3px; }
.detail-title h2 { line-height: 1.3; font-size: 1rem; }
.detail-cost { color: #d7bb7d; font-size: .72rem; margin-top: 3px; }
.rank-details .detail-description { white-space: pre-line; }
.rank-details .detail-requirement { margin-top: 9px; color: #e0a69b; font-size: .75rem; }
.detail-comparison { display: grid; gap: 8px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.detail-version { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; font-size: .72rem; line-height: 1.45; color: #d3caba; }
.detail-version b { color: #dcb873; font-size: .66rem; padding-top: 2px; }
.below-trainer { max-width: 850px; padding: 12px 3px 0; }
.state-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; font-size: .67rem; color: #b6ab97; }
.state-legend > span { display: flex; align-items: center; gap: 5px; }
.state-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; border: 1px solid; }
.legend-available { background: #c0ae79; border-color: #e6d5ae !important; }
.legend-selected { background: #416c9d; border-color: #8bbdff !important; }
.legend-locked { background: #6d211b; border-color: #a95747 !important; }
.status { min-height: 20px; font-size: .78rem; line-height: 1.5; color: #ccdca9; margin: 10px 3px 18px; }
.status.is-error { color: #ffb2a3; }
.status:empty { display: none; }
.changes { margin-top: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.changes > summary { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 17px 20px; cursor: pointer; color: #eed7ae; font-size: .94rem; font-weight: 650; list-style: none; }
.changes > summary::before { content: "+"; font-size: 1.2rem; color: #d5b87e; }
.changes > summary > span:first-child { margin-right: auto; }
.changes[open] > summary::before { content: "−"; }
.change-count { color: var(--muted); font-size: .75rem; font-weight: 400; }
.comparison-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 570px; font-size: .78rem; }
th, td { padding: 12px 20px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.5; }
thead th { background: #15130fb0; color: #d5bc8b; font-size: .68rem; letter-spacing: .035em; text-transform: uppercase; }
tbody th { color: #e6dbc5; width: 24%; font-weight: 600; }
td { width: 38%; color: var(--muted); }
td strong { color: #e2d5b7; font-weight: 550; }
td p { margin: 5px 0 0; font-size: .73rem; }
td .cost-sequence { color: #a99d87; font-size: .66rem; }
.row-icon { display: inline-block; width: 23px; height: 23px; margin: 0 9px 0 0; vertical-align: middle; border: 1px solid #887148; border-radius: 3px; }
.page-footer { margin: 22px 2px 12px; color: #a59b88; font-size: .69rem; line-height: 1.6; }
.page-footer p { margin: 5px 0; }
.page-footer a { color: #c7b78e; }
.loading { color: var(--muted); grid-column: 1 / -1; }
.load-error { padding: 15px; border: 1px solid #a7644c; border-radius: 6px; margin-bottom: 15px; color: #ffcbba; background: #2d1814; font-size: .9rem; }
.rank-tooltip { position: fixed; z-index: 1000; max-width: 295px; padding: 13px 15px; border: 1px solid #bba06c; border-radius: 4px; background: #0c0b09f5; box-shadow: 0 7px 26px #000a; pointer-events: none; font-size: .78rem; line-height: 1.5; color: #dfd6c5; white-space: pre-line; }
.rank-tooltip strong { color: #f2d189; display: block; margin-bottom: 5px; font: 600 .96rem/1.2 Georgia, serif; }
.load-error button { border: 1px solid #92713d; border-radius: 5px; padding: 9px 13px; background: #513b20; color: #f1dca9; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.downloads > span { color: var(--muted); font-size: .72rem; margin-right: 3px; }
.downloads a { text-decoration: none; font-size: .74rem; padding: 9px 11px; border: 1px solid #76654a; border-radius: 4px; background: #19150f; white-space: nowrap; }
.downloads a:hover { border-color: var(--gold); }
@media (max-width: 1050px) {
  .downloads { grid-column: 1 / -1; justify-content: flex-start; }
  .controls { grid-template-columns: 150px 1fr; }
  .comparison-layout { grid-template-columns: minmax(0, 1fr); }
  .side-panel { grid-template-columns: 1fr; }
  .trainer { max-width: 850px; }
}
@media (max-width: 620px) {
  body { padding: 14px 10px; background-attachment: scroll; }
  .hero { display: grid; grid-template-columns: 1fr; gap: 15px; margin: 14px 2px 18px; }
  h1 span { display: block; margin-top: 3px; }
  .controls { grid-template-columns: 1fr 1fr; padding: 14px; gap: 12px; }
  .rules-control { justify-self: end; width: min(240px, 100%); }
  .budget-note { display: grid; gap: 3px; padding: 0; }
  .trainer-title h2 { font-size: 1.05rem; }
  .title-ornament { left: 10px; font-size: 18px; }
  .trainer-tag { right: 7px; font-size: .48rem; }
  .trainer-tabs { gap: 2px; padding: 5px 3px 0; }
  .trainer-tabs button { height: 39px; font-size: .78rem; }
  .skill-grid { min-width: max(100%, calc(var(--mobile-cols, 8) * 74px + 38px)); grid-template-columns: repeat(var(--mobile-cols, 8), minmax(62px, 1fr)) 20px; padding: 13px 11px 17px; gap: 10px; }
  .rank-scale { grid-column: var(--mobile-scale-column, 9); }
  .points-bar { gap: 17px; font-size: .91rem; }
  .points-meter { width: 55px; }
  .trainer-actions { gap: 12px; padding: 11px; }
  .trainer-actions button { min-width: 140px; }
  .game-button { min-height: 39px; font-size: 1rem; }
  .side-panel { grid-template-columns: 1fr; gap: 12px; }
  .comparison-layout { gap: 14px; }
  .rank-details { padding: 15px; }
  .state-legend { gap: 8px; font-size: .6rem; }
  .changes > summary { padding: 15px 13px; font-size: .85rem; }
  .change-count { font-size: .65rem; }
  th, td { padding: 10px 13px; }
  .rank-tooltip { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
