/* Character Forge - parchment & leather look (same art as the desktop app). */
@font-face { font-family: "Cinzel Decorative"; font-weight: 700; src: url(../assets/fonts/cinzel-decorative-700-normal.ttf); }
@font-face { font-family: "Cinzel"; font-weight: 400; src: url(../assets/fonts/cinzel-400-normal.ttf); }
@font-face { font-family: "Cinzel"; font-weight: 700; src: url(../assets/fonts/cinzel-700-normal.ttf); }
@font-face { font-family: "Alegreya"; font-weight: 400; src: url(../assets/fonts/alegreya-400-normal.ttf); }
@font-face { font-family: "Alegreya"; font-weight: 400; font-style: italic; src: url(../assets/fonts/alegreya-400-italic.ttf); }
@font-face { font-family: "Alegreya"; font-weight: 700; src: url(../assets/fonts/alegreya-700-normal.ttf); }

:root {
  --ink: #2b1a0e; --ink-soft: #6b4a2c; --brown: #5c3a1e; --gold: #c9a24a; --gold-hi: #f3dc8a; --gold-lo: #7a5a1c;
  --crimson: #7d1d1d; --crimson-hi: #a83232; --parch: #f1e4c6; --cream: #f3e6c8; --ok: #3f6b2a;
  --head: "Cinzel", serif; --title: "Cinzel Decorative", serif; --body: "Alegreya", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #2a1a10; }
body { font: 15px/1.35 var(--body); color: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0; }
.h1 { font: 700 26px var(--head); color: #4a1010; }
.h2 { font: 700 18px var(--head); color: #4a2a12; }
.h3 { font: 700 14px var(--head); color: var(--brown); }
.muted { color: var(--ink-soft); font-style: italic; }
.hint { color: #7a2a1a; font-size: 14px; }
.num { font: 700 16px var(--body); color: #4a2a12; font-variant-numeric: lining-nums; }
.bignum { font: 700 30px var(--body); color: var(--crimson); font-variant-numeric: lining-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* ------------------------------------------------------------- controls */
button {
  font: 700 13px var(--head); color: #3b2412; cursor: pointer; background: none; min-height: 38px;
  border-style: solid; border-width: 8px 14px; padding: 2px 8px;
  border-image: url(../assets/ui/btn_secondary.png) 16 16 16 16 fill / 8px 14px stretch;
}
button:hover { border-image-source: url(../assets/ui/btn_secondary_hover.png); }
button:active { border-image-source: url(../assets/ui/btn_secondary_pressed.png); }
button.on { border-image: url(../assets/ui/btn_toggle_on.png) 14 14 14 14 fill / 8px 14px stretch; color: #f8e7b0; }
button:disabled { border-image-source: url(../assets/ui/btn_secondary_disabled.png); color: #8d7e6a; cursor: default; }
button.primary { border-image-source: url(../assets/ui/btn_primary.png); color: #f8e7b0; font-size: 15px; }
button.primary:hover { border-image-source: url(../assets/ui/btn_primary_hover.png); }
button.primary:active { border-image-source: url(../assets/ui/btn_primary_pressed.png); }
button.primary:disabled { border-image-source: url(../assets/ui/btn_primary_disabled.png); color: #d9cdb8; }
button.side { border-width: 8px 6px; border-image-width: 8px 6px; padding: 2px 0; font-size: 12px; flex: 1; }
button.small { border-width: 6px 8px; border-image-width: 6px 8px; padding: 0; min-height: 36px; width: 52px; font-size: 20px; }
.lang { display: inline-flex; gap: 2px; }
.lang button { border-width: 6px 8px; border-image-width: 6px 8px; padding: 0; min-height: 0; font-size: 13px; width: 48px; height: 32px; }
.lang.small button { width: 38px; height: 26px; font-size: 12px; }

input[type=text], textarea, select {
  font: 15px var(--body); color: var(--ink); background: rgba(255, 251, 240, .88);
  border: 1px solid #8a6a44; border-radius: 6px; padding: 5px 8px; outline: none; min-width: 0;
}
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--crimson); }
textarea { resize: vertical; width: 100%; }
select { appearance: none; padding-right: 28px; cursor: pointer;
  background: rgba(255, 251, 240, .88) url(../assets/ui/arrow_down.png) no-repeat right 8px center / 12px 12px; }
select:disabled { opacity: .55; cursor: default; }
::selection { background: var(--crimson); color: #f8ecd0; }

label.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 20px; }
label.check.off { color: #8d7e6a; cursor: default; }
input[type=checkbox], input[type=radio] { appearance: none; margin: 0; width: 20px; height: 20px; flex: none;
  background: url(../assets/ui/check_off.png) center / contain no-repeat; cursor: pointer; }
input[type=checkbox]:checked { background-image: url(../assets/ui/check_on.png); }
input[type=checkbox]:checked:disabled { background-image: url(../assets/ui/check_locked.png); }
input[type=radio] { background-image: url(../assets/ui/radio_off.png); }
input[type=radio]:checked { background-image: url(../assets/ui/radio_on.png); }
input:disabled { cursor: default; }

.scroll { overflow-y: auto; overflow-x: hidden; min-height: 0; }
.scroll::-webkit-scrollbar { width: 12px; }
.scroll::-webkit-scrollbar-track { background: rgba(60, 40, 20, .10); border-radius: 5px; margin: 2px; }
.scroll::-webkit-scrollbar-thumb { background: #8a6a44; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
.scroll { scrollbar-color: #8a6a44 rgba(60, 40, 20, .10); }

/* --------------------------------------------------------------- panels */
.panel { border: 22px solid transparent; border-image: url(../assets/ui/frame.png) 48 fill / 29px stretch; min-width: 0; }
.panel.dark { border-width: 18px; border-image-source: url(../assets/ui/frame_dark.png); }
.divider { height: 16px; position: relative; flex: none; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 7.5px; height: 1.2px;
  background: linear-gradient(90deg, rgba(92, 58, 30, 0), rgba(92, 58, 30, .8), rgba(92, 58, 30, 0)); }
.divider::after { content: ""; position: absolute; left: calc(50% - 4px); top: 4px; width: 7px; height: 7px;
  background: var(--gold); border: 1px solid var(--brown); transform: rotate(45deg); }
.ribbon { align-self: center; display: flex; justify-content: center; height: 64px; max-width: 100%;
  border-style: solid; border-width: 0 64px; border-image: url(../assets/ui/ribbon.png) 0 110 fill / 0 64px stretch;
  padding: 13px 23px 0; font: 700 23px/38px var(--head); color: #f8e7b0; white-space: nowrap; overflow: hidden;
  text-shadow: 1px 2px 0 rgba(40, 6, 6, .78); }

/* rich text */
.rich h1 { font-size: 22px; color: #4a1010; margin: 0 0 2px; }
.rich h2 { font-size: 16px; color: var(--brown); margin: 10px 0 2px; }
.rich h3 { font-size: 13px; color: var(--brown); margin: 8px 0 0; }
.rich p { margin: 2px 0 6px; }
.rich .tag { color: var(--crimson); font-weight: 700; }
.rich .k, .k { font: 12px var(--head); color: var(--ink-soft); text-transform: uppercase; }
.rich table { border-collapse: collapse; }
.rich td { padding: 2px 8px 2px 0; vertical-align: top; }
.rich td.k { white-space: nowrap; }

/* --------------------------------------------------------- medallions */
.medal { position: relative; flex: none; background: url(../assets/ui/medallion.png) center / 100% 100% no-repeat; }
.medal.glow { background: radial-gradient(closest-side, rgba(246, 222, 140, .9) 66%, rgba(246, 222, 140, 0)); }
.medal.glow::before { content: ""; position: absolute; inset: 11%; background: url(../assets/ui/medallion.png) center / 100% 100% no-repeat; }
.medal > i, .medal > img { position: absolute; left: 27%; top: 27%; width: 46%; height: 46%; }
.medal.glow > i { left: 32.06%; top: 32.06%; width: 35.88%; height: 35.88%; }
.medal > img.photo { left: 15%; top: 15%; width: 70%; height: 70%; border-radius: 50%; object-fit: cover; }
.icon { display: inline-block; flex: none; background: currentColor;
  -webkit-mask-position: center; mask-position: center; -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }

/* ---------------------------------------------------------------- cards */
.cards { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, var(--cw)); }
.card { position: relative; width: var(--cw); height: var(--ch); padding: 0; min-height: 0; border: 0;
  border-image: none; background: none; cursor: pointer; display: block; text-align: center; color: var(--ink); }
.card:hover, .card:active { border-image: none; }
.card .face { position: absolute; inset: 5px; border: 18px solid transparent;
  border-image: url(../assets/ui/frame_card.png) 32 fill / 18px stretch; }
.card:hover .face, .card.on .face { box-shadow: 0 1px 0 4px rgba(201, 162, 74, .27); border-radius: 12px; }
.card.on .face { border-image-source: url(../assets/ui/frame_card_sel.png); box-shadow: 0 1px 0 4px rgba(201, 162, 74, .43); }
.card .medal { position: absolute; left: 50%; top: 17px; transform: translateX(-50%); }
.card .t { position: absolute; left: 11px; right: 11px; font: 700 var(--tpx, 14px) var(--head); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.card.on .t { color: var(--crimson); }
.card .s { position: absolute; left: 13px; right: 13px; bottom: 9px; font: italic 12px/1.2 var(--body);
  color: var(--ink-soft); overflow: hidden; }
.card .seal { position: absolute; right: 1px; top: 1px; width: 34px; height: 34px; background: url(../assets/ui/seal.png) center / contain; }

/* ---------------------------------------------------------- title page */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; overflow: hidden;
  background: url(../assets/ui/parchment.jpg) center / cover; padding: 20px 28px 24px 40px; }
#title .circle { position: absolute; left: 50%; top: 43%; width: 105vmin; height: 105vmin; margin: -52.5vmin 0 0 -52.5vmin;
  background: url(../assets/ui/arcane_circle.png) center / contain no-repeat; opacity: .13; animation: spin 96s linear infinite; }
#title .vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle 75vmax at center, rgba(0, 0, 0, 0) 55%, rgba(40, 20, 5, .55) 100%); }
@keyframes spin { to { transform: rotate(360deg); } }
#title > *:not(.circle):not(.vignette) { position: relative; }
#title .top { align-self: stretch; display: flex; justify-content: flex-end; }
#title .big { font: 700 clamp(34px, 6.5vw, 66px) var(--title); color: #5a1212; text-align: center; margin-top: 10px; }
#title .sub { font: 700 clamp(15px, 2vw, 19px) var(--head); color: var(--brown); text-align: center; }
#title > button { width: 300px; max-width: 86vw; margin-top: 8px; }
#title > button.primary { height: 58px; }
#title .credits { font-size: 12px; color: var(--ink-soft); font-style: italic; text-align: center; max-width: 1100px; }

/* ----------------------------------------------------------- workspace */
#work { position: fixed; inset: 0; display: flex; }
#side { width: 272px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 16px 22px 12px 10px;
  background: url(../assets/ui/leather.jpg) top / 100% auto, #2a1a10; overflow-y: auto; }
#side .brand { font: 700 21px var(--title); color: #e2c068; text-align: center; }
#side .cap { color: #bfa77a; font-size: 12px; font-style: italic; }
.step { display: flex; align-items: center; height: 38px; flex: none; padding: 0 10px 0 18px; margin: 0 4px 0 6px; gap: 10px;
  border: 0; border-radius: 6px; background: none; color: var(--cream); font: 400 14px var(--head); text-align: left; }
.step, .step:hover, .step:active, .step:disabled { border-image: none; }
.step:hover:not(:disabled) { background: rgba(201, 162, 74, .10); }
.step .icon { width: 24px; height: 24px; color: var(--gold); }
.step .lbl { flex: 1; }
.step.cur { background: linear-gradient(90deg, rgba(201, 162, 74, .59), rgba(201, 162, 74, .04)); color: #fff3d0;
  font-weight: 700; box-shadow: inset 3px 0 0 -0px var(--gold-hi); }
.step.cur .icon { color: var(--gold-hi); }
.step:disabled { color: #968064; }
.step:disabled .icon { color: #968064; }
.step .mark { width: 22px; height: 22px; flex: none; position: relative; }
.step.done .mark { background: url(../assets/ui/seal.png) center / contain; }
.step.issue .mark::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--crimson-hi); border: 1.5px solid var(--gold); }
.step.skip .mark::after { content: ""; position: absolute; left: 5px; right: 5px; top: 10px; height: 2px; background: #968064; }
#summary { margin-top: auto; color: var(--cream); }
#summary .name { font: 700 15px var(--head); color: #f3e6c8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#summary .line { color: #cdb88f; font-size: 12px; }
#summary .abil { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 12px; text-align: center; gap: 2px; }
#summary .abil b { color: var(--gold); }
#summary .abil span { color: #cdb88f; }
.badges { display: flex; justify-content: space-around; }
.badge { width: 52px; text-align: center; }
.badge .icon { width: 22px; height: 22px; color: var(--gold); }
.badge .v { font: 700 21px/28px var(--body); color: var(--cream); font-variant-numeric: lining-nums; }
.badge .c { font: 700 9px var(--head); color: var(--gold); text-transform: uppercase; white-space: nowrap; }

#content { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px 0; gap: 2px;
  background: url(../assets/ui/parchment.jpg) center / cover; }
#content > .sub { text-align: center; font-size: 16px; padding: 0 16px; }
#page { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 6px 18px; }
#foot { display: flex; align-items: center; gap: 8px; padding: 4px 22px 0; }
#foot .hint { flex: 1; }
#back { width: 130px; }
#next { min-width: 220px; }
#toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); background: #2b1a0e; color: #f3e6c8;
  border: 1px solid var(--gold); border-radius: 8px; padding: 8px 16px; font-size: 15px; z-index: 10; }

/* ------------------------------------------------------------- pages */
.sel-left { flex: none; width: calc(var(--cols) * (var(--cw) + 6px) + 22px); }
.detail { flex: 1; display: flex; }
.detail > .scroll { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 0 8px 0 4px; }
.placeholder { text-align: center; padding-top: 90px; }
.choice-grid { display: grid; gap: 2px 14px; }
.radio-grid { display: grid; gap: 2px 16px; }
.radio-grid .desc { margin: 0 0 4px 28px; font-size: 14px; }
.counter.ok { color: var(--ok); }
.counter.bad { color: var(--crimson); }

.abil-page { flex-direction: column; gap: 8px; padding: 4px 22px 6px; overflow-y: auto; }
.shields { display: grid; grid-template-columns: repeat(6, minmax(124px, 1fr)); gap: 4px 10px; justify-items: center; }
.shields > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.shield-svg { width: 124px; height: 158px; }
.abil-bottom { display: flex; gap: 14px; flex: 1; min-height: 230px; }
.dice-grid { display: grid; grid-template-columns: repeat(4, 28px) 40px; gap: 4px; align-items: center; }
.die { width: 28px; height: 28px; }
.die.dim { opacity: .35; }
.dice-grid .total { font: 700 21px var(--body); text-align: center; color: #4a2a12; }
.pool b { color: var(--crimson); font-size: 20px; }
.pool s { color: #9b8a70; }

.prof-left { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 0 10px 0 6px; }
.prof-right { width: 330px; flex: none; display: flex; }
.prof-right > .scroll { flex: 1; }
table.skills { width: 100%; border-collapse: collapse; }
table.skills td { padding: 1px 2px; }
table.skills td:last-child { text-align: right; font-weight: 700; }

.eq-wrap { flex-direction: column; gap: 8px; padding: 4px 18px 6px; }
.eq-body { flex: 1; min-height: 0; display: flex; gap: 16px; }
.eq-left { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 0 10px 0 4px; }
.eq-right { width: 360px; flex: none; display: flex; }
.eq-right > .col { flex: 1; min-height: 0; gap: 6px; }
.eq-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eq-line select { max-width: 260px; }
.inv { flex: 1; }
.inv table { width: 100%; border-collapse: collapse; }
.inv td { padding: 2px 0; vertical-align: top; }
.inv td:last-child { text-align: right; white-space: nowrap; padding-left: 8px; }
.shop-table { max-height: 380px; border: 1px solid #b89a6a; border-radius: 6px; background: rgba(255, 251, 240, .7); }
.shop-table table { width: 100%; border-collapse: collapse; }
.shop-table th { position: sticky; top: 0; background: #3b2416; color: #f3e1b8; font: 700 12px var(--head); padding: 5px;
  text-align: left; }
.shop-table td { padding: 4px 6px; border-bottom: 1px solid rgba(92, 58, 30, .18); cursor: pointer; }
.shop-table td.r { text-align: right; white-space: nowrap; }
.shop-table tr:hover td { background: rgba(201, 162, 74, .18); }
.shop-table tr.sel td { background: rgba(125, 29, 29, .18); }

.spell-left { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 0 10px 0 4px; }
.spell-right { width: 400px; flex: none; display: flex; }
.spell-right > .scroll { flex: 1; }
.spell-list { background: rgba(255, 251, 240, .65); border: 1px solid #b89a6a; border-radius: 6px; }
.spell-list label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; min-height: 30px; cursor: pointer;
  border-bottom: 1px solid rgba(92, 58, 30, .15); white-space: nowrap; overflow: hidden; }
.spell-list label:last-child { border-bottom: 0; }
.spell-list label span { overflow: hidden; text-overflow: ellipsis; }
.spell-list label:hover { background: rgba(201, 162, 74, .18); }
.spell-list label.focus { background: rgba(125, 29, 29, .14); }
.spell-list label.off { color: var(--ink-soft); }
.spell-list input:disabled { opacity: .55; }

.details-page > .panel { flex: 1; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.portrait-col { display: flex; flex-direction: column; gap: 4px; width: 170px; flex: none; align-items: center; }
.portrait-col button { width: 100%; font-size: 12px; }
.name-input { font: 700 22px var(--head) !important; padding: 6px 10px !important; }
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.phys-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; }
.phys-grid label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.phys-grid input { width: 100%; }
.pers textarea { height: 58px; }
.pers textarea.story { flex: 1; min-height: 120px; }

.sheet-page { flex-direction: column; gap: 6px; padding: 2px 18px 6px; }
.sheet-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-view { flex: 1; overflow: auto; text-align: center; padding: 10px 0; }
.sheet-view canvas { display: block; margin: 0 auto 30px; box-shadow: 6px 8px 0 rgba(0, 0, 0, .27); }
input[type=range] { accent-color: var(--crimson); width: 160px; }

/* -------------------------------------------------------------- narrow */
@media (max-width: 980px) {
  body { overflow: auto; }
  #work { position: static; flex-direction: column; min-height: 100%; }
  #side { width: auto; padding: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; }
  #side .brand-box { width: 100%; }
  #side .step { margin: 0; padding: 0 8px; flex: 1 1 30%; }
  #summary { display: none; }
  #side .side-buttons { width: 100%; }
  #content { min-height: 100vh; }
  #page { flex-direction: column; flex: none; }
  .sel-left, .prof-right, .eq-right, .spell-right { width: auto; }
  .detail > .scroll, .scroll { overflow: visible; }
  .shields { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
  .abil-bottom, .eq-body { flex-direction: column; }
  #foot { position: sticky; bottom: 0; background: rgba(241, 228, 198, .95); padding: 6px 10px; flex-wrap: wrap; }
  #next { min-width: 0; flex: 1; }
  .ribbon { font-size: 16px; border-width: 0 34px; border-image-width: 0 34px; padding: 13px 8px 0; }
}
