/* Character creation.
 *
 * Plain CSS, no build step and no third-party code — the page holds an access
 * token, so the fewer scripts it loads, the better.
 */

:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --panel-2: #23272f;
  --line: #333944;
  --text: #e6e8ec;
  --muted: #9aa3b0;
  --accent: #c8a25a;
  --accent-ink: #14161a;
  --danger: #e2756a;
  --warn: #d8b45c;
  --radius: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f2;
    --panel: #ffffff;
    --panel-2: #f0efec;
    --line: #d9d6d0;
    --text: #1d1f24;
    --muted: #6a7280;
    --accent: #8a6a20;
    --accent-ink: #ffffff;
    --danger: #a8362a;
    --warn: #8a6a20;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}

header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.whoami { display: flex; align-items: baseline; gap: 0.75rem; font-size: 0.9rem; }

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

h2 { margin: 0 0 0.35rem; font-size: 1.6rem; letter-spacing: -0.01em; }
h3 { margin: 0 0 0.5rem; font-size: 1rem; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.3rem 0 0; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0.75rem 0 0; }
.warning {
  color: var(--warn);
  font-size: 0.9rem;
  border-left: 2px solid var(--warn);
  padding-left: 0.75rem;
  margin: 1rem 0 0;
}

/* ---- form furniture ---------------------------------------------------- */

form { margin-top: 1.5rem; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.35rem;
  margin: 1.75rem 0 0;
}

legend {
  padding: 0 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.counter { color: var(--muted); font-weight: 400; margin-left: 0.4rem; }

.field { margin-top: 1.1rem; }
.field:first-child { margin-top: 0; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .field { flex: 1 1 12rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 0.3rem;
}

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.75rem;
}

.actions .hint { margin: 0; }

/* ---- attributes -------------------------------------------------------- */

.attributes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.attribute { position: relative; }
.attribute label { color: var(--muted); font-weight: 500; }

.attribute .mod {
  position: absolute;
  right: 0.7rem;
  bottom: 0.55rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  pointer-events: none;
}

.attribute select { padding-right: 2.75rem; }

/* ---- skills ------------------------------------------------------------ */

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.4rem 1rem;
  margin-top: 1rem;
}

.skill {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 0.3rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  margin: 0;
}

.skill:hover { background: var(--panel-2); }
.skill.disabled { opacity: 0.4; cursor: not-allowed; }
.skill .muted { margin-left: auto; font-size: 0.8rem; }
.skill input { accent-color: var(--accent); }

/* ---- preview ----------------------------------------------------------- */

.preview {
  margin-top: 2rem;
  padding: 1.1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.preview dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.25rem;
  margin: 0.85rem 0 0;
}

.preview dt { color: var(--muted); font-size: 0.9rem; }
.preview dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---- results ----------------------------------------------------------- */

.notice {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1.25rem 0;
}

.token {
  display: block;
  word-break: break-all;
  background: var(--panel-2);
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
  margin: 0.85rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.25rem 0;
}

.sheet .lead { margin-top: 0; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: 0.6rem;
  margin: 1.1rem 0;
}

.stat {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 0.6rem;
  text-align: center;
}

.stat-name { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-score { display: block; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-mod { display: block; font-size: 0.85rem; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---- navigation --------------------------------------------------------- */

nav { display: flex; gap: 1.1rem; font-size: 0.9rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--text); text-decoration: underline; }

.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.screen-head h2 { margin-top: 0.2rem; }

a.link { color: var(--muted); font-size: 0.85rem; }

.button-link {
  display: inline-block;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
}

.button-link.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

/* ---- cards -------------------------------------------------------------- */

.cards { display: grid; gap: 0.85rem; margin: 1rem 0 2rem; }

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  color: inherit;
  text-decoration: none;
}

a.card:hover { border-color: var(--accent); }
.card h3, .card h4 { margin: 0 0 0.3rem; }
.card p { margin: 0.3rem 0; }
.card input[type="text"] { margin: 0.6rem 0; }

.card-actions { margin-top: 0.85rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

.mission-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.meta { color: var(--muted); font-size: 0.85rem; }

.badge, .badge-inline, .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge-in_progress { border-color: var(--accent); color: var(--accent); }
.badge-complete { opacity: 0.6; }
.badge-inline { margin: 0.2rem 0; }

.attention {
  color: var(--warn);
  font-size: 0.88rem;
  border-left: 2px solid var(--warn);
  padding-left: 0.7rem;
  margin: 0.6rem 0;
}

.quote {
  border-left: 2px solid var(--line);
  padding-left: 0.8rem;
  font-style: italic;
}

/* ---- session ------------------------------------------------------------ */

.session-layout {
  display: grid;
  grid-template-columns: 1fr 15rem;
  gap: 1.5rem;
  margin-top: 1.25rem;
  align-items: start;
}

@media (max-width: 46rem) {
  .session-layout { grid-template-columns: 1fr; }
}

.log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  max-height: 60vh;
  overflow-y: auto;
}

.entry { margin: 0 0 1.15rem; }
.entry:last-child { margin-bottom: 0; }

.entry-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.entry-who {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.entry-dm .entry-who { color: var(--accent); }
.entry-body { margin: 0; }
.entry-character .entry-body { font-style: italic; }

.tag-review { border-color: var(--warn); color: var(--warn); }

.entry-roll {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  padding: 0.35rem 0;
}

.roll-outcome { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.roll-success, .roll-critical { color: var(--accent); }
.roll-failure, .roll-fumble { color: var(--danger); }

.play {
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

.play:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

#turn-box { margin-top: 1.1rem; }
#turn-form { margin: 0; display: grid; gap: 0.6rem; }
#turn-form select { max-width: 16rem; }

.admin-reply {
  margin-top: 1.1rem;
  background: var(--panel-2);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}

.admin-reply h4 { margin: 0 0 0.4rem; color: var(--accent); }
.admin-reply .ruling { font-weight: 600; }

.session-side h3 { margin-bottom: 0.6rem; }

.participant {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.participant:last-child { border-bottom: none; }
.participant-name { font-weight: 600; }

.mode {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.mode-autopilot { color: var(--warn); }

/* ---- set-up forms ------------------------------------------------------- */

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 0.6rem 0;
  background: var(--panel);
}

details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}

details[open] summary { margin-bottom: 0.5rem; }
details form { margin-top: 0.8rem; }
details .notice { margin-top: 1rem; }

#owner-tools { margin-top: 2rem; }


/* ---- the character sheet (record screen) -------------------------------- */
/* The look borrows from the Infinity Engine: dark panels, engraved slots,
 * gold rules, serif names, rarity colours. All CSS — no images, and no fonts
 * fetched from anywhere. */

:root {
  --r-common: #97a0ae;
  --r-uncommon: #57b87f;
  --r-rare: #5b9bd9;
  --r-very_rare: #a978e8;
  --r-legendary: #d99a3d;
  --gold-coin: #d4af37;
  --sheet-inset: rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --r-common: #6a7280;
    --r-uncommon: #257a4e;
    --r-rare: #2d6fb0;
    --r-very_rare: #7a44c0;
    --r-legendary: #a8690f;
    --gold-coin: #a8811a;
    --sheet-inset: rgba(0, 0, 0, 0.12);
  }
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.serif { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.01em; }

.char-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 17rem;
  gap: 1.25rem;
  margin-top: 1.5rem;
  align-items: start;
}

@media (max-width: 64rem) {
  .char-layout { grid-template-columns: 1fr; }
}

.char-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  /* The double rule that makes a panel read as a record screen. */
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px var(--line);
}

.char-heading {
  margin: 0.35rem 0 1.1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  text-align: center;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 600;
}

/* -- left column: the record -- */

.portrait {
  height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, var(--panel-2), var(--bg));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: inset 0 2px 10px var(--sheet-inset);
  margin: 0.35rem 0 1rem;
}

.portrait-glyph { width: 4rem; height: 4rem; color: var(--accent); opacity: 0.9; }

.bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.3rem; }
.bar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.bar-value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.9rem; }

.hp-track {
  height: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  overflow: hidden;
  box-shadow: inset 0 1px 4px var(--sheet-inset);
}

.hp-fill {
  height: 100%;
  background: linear-gradient(180deg, #d05043, #8c2b21);
  border-radius: 999px;
}

.ac-row { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0; }

.ac-badge { position: relative; width: 2.9rem; height: 2.9rem; flex: none; display: block; }
.ac-badge svg { width: 100%; height: 100%; color: var(--accent); }
.ac-badge .ac-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.3rem;
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.char-col .stats { margin: 0 0 1rem; }

.skill-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }

.chip {
  font-size: 0.75rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-2);
}

/* -- middle column: the paper doll -- */

.doll-wrap { position: relative; padding: 0.25rem 0 0.5rem; }

.doll-figure {
  position: absolute;
  inset: 0;
  margin: auto;
  height: 97%;
  max-height: 26rem;
  color: var(--muted);
  opacity: 0.09;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.doll {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 23rem;
  margin: 0 auto;
}

.doll-col { display: flex; flex-direction: column; gap: 0.85rem; }

.slot { display: flex; flex-direction: column; align-items: center; gap: 0.28rem; }

.slot-box {
  width: 4.4rem;
  height: 4.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: inset 0 2px 8px var(--sheet-inset), inset 0 0 0 1px var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.ghost { width: 2rem; height: 2rem; color: var(--muted); opacity: 0.3; }

/* -- item tiles, doll and pack alike -- */

.r-common    { --r: var(--r-common); }
.r-uncommon  { --r: var(--r-uncommon); }
.r-rare      { --r: var(--r-rare); }
.r-very_rare { --r: var(--r-very_rare); }
.r-legendary { --r: var(--r-legendary); }

button.tile {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid var(--r, var(--line));
  border-radius: 7px;
  color: var(--r, var(--text));
  box-shadow: inset 0 0 12px -5px var(--r, transparent);
  cursor: pointer;
}

button.tile:hover:not(:disabled) { filter: brightness(1.2); }
.tile-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.tile-glyph { width: 2.1rem; height: 2.1rem; }

.tile-qty {
  position: absolute;
  right: 0.18rem;
  bottom: 0.02rem;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 1px 2px var(--bg);
}

/* -- right column: the pack and the purse -- */

.gold-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; min-height: 2.1rem; }
.coin { width: 1.35rem; height: 1.35rem; color: var(--gold-coin); flex: none; }
.gold-amount { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.gold-label { color: var(--muted); font-size: 0.8rem; }
.gold-row .link { margin-left: auto; }
.gold-input { width: 7rem; }

.pack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.3rem, 1fr));
  gap: 0.55rem;
}

.pack .hint { grid-column: 1 / -1; margin: 0; }
.pack-cell { aspect-ratio: 1; }
.pack button.tile { background: var(--panel-2); box-shadow: inset 0 2px 6px var(--sheet-inset); }

.add-item { margin-top: 1.1rem; }

/* -- the selected item, described -- */

.item-detail {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--r, var(--line));
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.detail-face {
  width: 4.4rem;
  height: 4.4rem;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--r, var(--line));
  border-radius: 8px;
  color: var(--r, var(--text));
  background: var(--panel-2);
  box-shadow: inset 0 2px 8px var(--sheet-inset);
}

.detail-glyph { width: 2.4rem; height: 2.4rem; }
.detail-body { flex: 1 1 16rem; }

.item-name {
  margin: 0 0 0.2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  color: var(--r, var(--text));
}

.item-meta { margin: 0; color: var(--muted); font-size: 0.85rem; }
.item-desc { margin: 0.5rem 0 0; font-style: italic; }

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  flex-basis: 100%;
}

button.danger { border-color: var(--danger); color: var(--danger); }

/* -- links into the sheet from the board and the session -- */

a.char-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

a.char-link:hover { color: var(--accent); }

a.participant-name {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}

a.participant-name:hover { color: var(--accent); }

/* ---- equipment mechanics (Phase 10) ------------------------------------- */

.ac-detail { margin: 0.15rem 0 0; font-size: 0.72rem; color: var(--muted); }

.item-stats { margin: 0.3rem 0 0; font-size: 0.9rem; color: var(--accent); font-weight: 600; }

.stat-editor { flex-basis: 100%; margin: 0.25rem 0 0; padding: 0.55rem 0.9rem; }
.stat-editor summary { font-size: 0.85rem; }
.stat-editor-fields { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: flex-end; margin-top: 0.6rem; }
.stat-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; font-weight: 600; }
.stat-field input, .stat-field select { width: 7.5rem; }

.roll-damage { color: var(--danger); font-weight: 600; }
