:root {
  color-scheme: light;
  --site-font: system-ui, sans-serif;
  --paper: #f6ecd5;
  --paper-light: #fff8e8;
  --ink: #19352c;
  --muted: #525e4c;
  --gold: #d7b45d;
  --line: #bda06a;
  --teal: #0b3d42;
  --green: #0d482e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: clamp(8px, 2vw, 24px);
  background: radial-gradient(ellipse at top, #155058, #061f22 76%) fixed;
  color: var(--ink);
  font: clamp(15px, .8vw, 18px)/1.5 var(--site-font);
}
.scanner-shell {
  width: 100%;
  margin: auto;
  padding: clamp(8px, 1.2vw, 14px);
  border: 1px solid #a38a52;
  border-radius: 16px;
  background: linear-gradient(135deg, #062326, #0b3c43 55%, #062326);
  box-shadow: 0 16px 48px #001619a8, inset 0 0 0 4px #0a282b;
}
header {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  border: 1px solid #a38a52;
  border-radius: 9px;
  background: linear-gradient(90deg, #061f20, #0b3b40);
  color: var(--paper);
  padding: 9px;
}
.brand { display: flex; flex: 1 1 245px; align-items: center; gap: 12px; padding: 5px 10px; }
.brand img { width: 51px; height: 51px; }
.brand h1 { margin: 0; font: bold clamp(25px, 4vw, 36px)/1 var(--site-font); letter-spacing: .12em; }
small, .badge, .readout dt, .mode-strip, footer { font: 750 11px/1.4 var(--site-font); letter-spacing: .1em; }
.brand small { display: block; margin-top: 4px; color: #e0c989; }
.readout { flex: 0 1 135px; margin: 0; min-width: 0; border: 1px solid #57776c; border-radius: 6px; background: #062a2c; padding: 7px 11px; }
.readout.explorer { flex: 1 1 160px; }
.readout dt { color: #e0c989; text-transform: uppercase; }
.readout dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.mode-strip { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 7px 10px; color: #e5e9ce; }
nav { display: flex; flex-wrap: wrap; gap: 7px; margin: 3px 0 13px; }
nav button { flex: 1 1 auto; text-transform: uppercase; letter-spacing: .07em; border-radius: 6px; }
nav button[aria-current=true] { background: linear-gradient(#e7d3a1,#bc9650); color: #162b22; border-color: #f4d998; box-shadow: inset 0 0 0 1px #fff3c568; }
button, input, select {
  font: inherit;
  border: 1px solid #a08754;
  border-radius: 5px;
  padding: 7px 10px;
  color: var(--ink);
}
input, select { background: var(--paper-light); min-width: 0; max-width: 100%; }
input[type=number] { width: 7ch; }
button { cursor: pointer; font-weight: 700; background: linear-gradient(#fff8e9,#e5d3a7); }
button:hover { background: #fff1c4; }
button:disabled { opacity: .58; cursor: default; }
.primary, nav button { background: linear-gradient(#205748,#103b32); color: #fff4d6; border-color: #b69a61; }
.primary:hover, nav button:hover { background: #286552; }
#layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(210px, min(25%, 30rem)); gap: 12px; align-items: start; }
.panel, aside {
  background: linear-gradient(135deg,#fff6e1,var(--paper));
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: clamp(11px, 2vw, 19px);
  box-shadow: 0 3px 8px #00161952;
}
h2,h3,p { margin: 0; }
h2 {
  background: linear-gradient(90deg,#123f35,#21584a);
  border-bottom: 2px solid #c5a451;
  border-radius: 5px;
  color: #fff1c7;
  padding: 7px 11px;
  font: bold 20px var(--site-font);
}
h3 { font: bold 20px var(--site-font); }
small, .muted, .grid label { color: var(--muted); }
.badge { display: inline-block; border: 1px solid #ba9a5d; border-radius: 5px; padding: 5px 8px; background: #f3e2b9; }
.log-entries { max-height: 540px; overflow: auto; }
.log-entries p { border: 1px solid #cfbb8e; border-left: 3px solid #2e6654; background: #fff7e3; border-radius: 4px; padding: 8px; margin-top: 8px; font-size: 13px; overflow-wrap: anywhere; }
.stack > * + * { margin-top: 11px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,145px),1fr)); gap: 9px; }
.grid label { display: grid; gap: 3px; font-size: 13px; font-weight: 650; }
details { border: 1px solid #cfbb8e; border-radius: 5px; padding: 6px 9px; }
details summary { cursor: pointer; color: #14493a; font-weight: 700; }
details form { margin-top: 10px; }
.party-slots { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,150px),1fr)); gap: 7px; }
.party-slot { text-align: left; overflow-wrap: anywhere; }
.party-slot[aria-current=true] { background: #d8e7df; border-color: #366e5c; box-shadow: inset 0 0 0 1px #366e5c; }
.party-slot small { display: block; letter-spacing: .025em; }
.kin-sheet { border: 1px solid #b9a471; border-radius: 7px; padding: 11px; background: #f3e6c8; }
.resonance-icon { width: 25px; height: 25px; object-fit: contain; vertical-align: middle; }
.resonances { margin: 4px 0; }
.meter { margin: 10px 0; }
.meter button { min-width: 36px; padding: 4px 7px; }
progress { display: block; width: 100%; height: 11px; margin: 5px 0; accent-color: #28714f; }
progress.stamina { accent-color: #127397; }
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,195px),1fr)); gap: 9px; }
.card { background: var(--paper-light); border: 1px solid #c3aa75; border-radius: 6px; padding: 10px; }
.card p { font-size: 13px; margin: 4px 0; }
.card small { color: #65501e; }
li[aria-current=step] { font-weight: 750; color: #104a3a; }
footer { margin: 13px 2px 1px; color: #e0c989; }
:focus-visible { outline: 2px solid #1269a0; outline-offset: 2px; }
@media (max-width: 740px) { #layout { grid-template-columns: 1fr; } .readout { flex: 1 1 90px; } }
.license { display: grid; grid-template-columns: minmax(0, 142px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ranger-portrait { margin: 0; min-width: 0; }
.portrait-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 3px double #bf9b50;
  border-radius: 7px;
  background: radial-gradient(ellipse at center, #21584a, #0b302f);
}
.portrait-frame.has-portrait { background: transparent; }
.portrait-frame > img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.portrait-empty { text-align: center; }
.portrait-empty img { width: 44px; height: 44px; }
.portrait-empty small { display: block; color: #eadcae; }
.portrait-tools { display: grid; gap: 5px; margin-top: 6px; }
.portrait-tools button, .portrait-upload { font-size: 12px; }
.portrait-upload {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid #a08754;
  border-radius: 5px;
  padding: 7px 4px;
  background: linear-gradient(#fff8e9,#e5d3a7);
  font-weight: 700;
  text-align: center;
}
.portrait-upload:hover { background: #fff1c4; }
.portrait-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.portrait-upload:focus-within { outline: 2px solid #1269a0; outline-offset: 2px; }
@media (max-width: 450px) { .license { grid-template-columns: minmax(0, 108px) minmax(0,1fr); gap: 9px; } }
#remove-kin-dialog { width: min(400px, calc(100% - 24px)); color: var(--ink); }
#remove-kin-dialog::backdrop { background: #061f22b3; }
.profile-editor { padding: 0; background: #f7ecd1; }
.profile-editor summary { padding: 9px 12px; }
.profile-editor[open] summary { border-bottom: 1px solid #cfbb8e; background: #efe0bd; }
.profile-editor form { margin: 0; padding: 12px; }
.editor-sections { display: grid; gap: 12px; }
.edit-section { min-width: 0; margin: 0; padding: 8px 10px 10px; border: 1px solid #c6b185; border-radius: 6px; background: #fff7e3; }
.edit-section legend { padding: 0 5px; font: bold 16px var(--site-font); color: #14493a; }
.edit-section .grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,115px),1fr)); }
.edit-section input, .edit-section select { width: 100%; }
.edit-actions { padding-top: 9px; border-top: 1px solid #cfbb8e; }
.edit-actions .danger { margin-inline-start: auto; color: #7a241b; border-color: #a86756; background: #fae8dc; }
.edit-actions .danger:hover { background: #f4d4c3; }
.edit-error { color: #7a241b; background: #fae8dc; border-left: 3px solid #a86756; padding: 7px 10px; }
.compass-motto { text-align: center; color: #65501e; font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.compass-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border-radius: 5px;
  background: repeating-radial-gradient(circle at center,#e8d7ad 0 1px,transparent 2px 23px), #f1e4c5;
}
.compass-point {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: center;
  gap: 4px 6px;
  padding: 6px 8px;
  border: 1px solid #b4975e;
  border-radius: 5px;
  background: #fff7e3;
  font-weight: 700;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.compass-letter { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: #174d40; color: #f4d998; font: bold 15px var(--site-font); }
.compass-point input { grid-column: 1 / -1; text-align: center; font-weight: 750; }
.compass-seal { grid-column: 1 / -1; grid-row: 2; justify-self: center; display: flex; align-items: center; gap: 6px; border: 1px solid #b4975e; border-radius: 24px; padding: 3px 12px; background: #123f35; color: #f4d998; font: bold 13px var(--site-font); letter-spacing: .12em; }
.compass-seal img { width: 22px; height: 22px; }
@media (max-width: 480px) { .compass-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .compass-seal { grid-row: 1; } }
.compass-point { display: block; }
.compass-point-heading { display: flex; gap: 6px; align-items: center; }
.compass-point-heading [data-total] { margin-inline-start: auto; color: #14493a; font-size: 18px; }
.compass-fields { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; margin-top: 6px; font-size: 12px; }
.compass-fields > div { grid-column: span 1; color: #525e4c; }
.compass-fields > div:nth-child(2) { grid-column: span 2; }
.compass-fields label { display: grid; gap: 3px; }
.compass-fields input { min-width: 0; padding: 5px 2px; }
@media (max-width: 420px) { .compass-grid { grid-template-columns: 1fr; } }

progress.focus { accent-color: #79519c; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,120px),1fr)); gap: 7px; }
.check-grid button { display: flex; justify-content: space-between; align-items: center; gap: 5px; text-align: left; overflow-wrap: anywhere; }
.check-grid strong { color: #14493a; }

.quick-rose {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 3px clamp(3px,2vw,20px);
  max-width: 620px;
  margin-inline: auto;
  padding: 4px clamp(2px,2vw,16px);
}
.quick-rose::after {
  content: '';
  position: absolute;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  background: repeating-radial-gradient(circle,#9e7c432e 0 1px,transparent 2px 24px);
  mask-image: radial-gradient(ellipse at center,#000 10%,#000a 38%,transparent 73%);
}
.quick-rose::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 8% 12%;
  pointer-events: none;
  background: conic-gradient(from 0deg,#28574e 0 12.5%,#b38a44 0 25%,#28574e 0 37.5%,#b38a44 0 50%,#28574e 0 62.5%,#b38a44 0 75%,#28574e 0 87.5%,#b38a44 0);
  opacity: .23;
  clip-path: polygon(50% 0,56% 38%,84% 14%,64% 44%,100% 50%,64% 56%,84% 86%,56% 62%,50% 100%,44% 62%,16% 86%,36% 56%,0 50%,36% 44%,16% 14%,44% 38%);
}
.quick-rose button {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 76px;
  padding: 6px 3px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: radial-gradient(ellipse,#fbf1d8 20%,#fbf1d8c9 46%,transparent 72%);
  box-shadow: none;
  font-size: clamp(10px,2vw,14px);
  overflow-wrap: anywhere;
}
.quick-rose button:hover, .quick-rose button:focus-visible {
  border-color: #a7854a;
  background: radial-gradient(ellipse,#fff8e7,#ead9ad9c);
}
.quick-rose button strong { font: bold 1.65em/1 var(--site-font); color: #14493a; }
.quick-rose button small { font-size: 9px; letter-spacing: .12em; }
.quick-rose-center {
  grid-area: 2 / 1 / 3 / -1;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 5px 12px;
  border: 3px double #d7b45d;
  border-radius: 50%;
  background: #123f35;
  color: #f4d998;
  font: bold 12px var(--site-font);
}
.quick-rose-center img { width: 30px; height: 30px; }

.log-die.die-success { color: #17603b; }
.log-die.die-failure { color: #a12a2a; }

.backup-download { display: inline-block; padding: 7px 11px; border: 1px solid #b69a61; border-radius: 6px; text-decoration: none; font-weight: 700; }
.backup-json { box-sizing: border-box; width: 100%; margin-top: 6px; }

.cards.loadout-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 480px) {
  .cards.loadout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.rank-display { display: grid; justify-items: center; gap: 6px; }
.rank-insignia { display: block; width: 86px; height: 108px; }
