:root {
  color-scheme: dark;
  --ground: #11141a;
  --panel: #1b2028;
  --sunken: #151a21;
  --ink: #eeeae0;
  --muted: #b2b8c5;
  --metal: #454b58;
  --brass: #ddbc82;
  --brass-ink: #211b12;
  --amber: #f0cc8c;
  --teal: #89c3b0;
  --rust: #edaa93;
  font: 1rem/1.38 system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse 36rem 35rem at 50% 4rem, #202732, transparent 98%), var(--ground);
}
body.in-duel { height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
.frame {
  width: min(100%, 690px);
  margin-inline: auto;
  padding-inline: max(1rem, env(safe-area-inset-left), env(safe-area-inset-right));
}
.mast {
  background: #10141b;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--metal);
}
.mast-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  min-height: 51px;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--brass);
  text-decoration: none;
  font: 700 .83rem/1.1 Georgia, serif;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding-block: .8rem;
}
.wordmark::before {
  content: "";
  flex: 0 0 .85rem;
  height: .85rem;
  display: block;
  background: linear-gradient(90deg, transparent 43%, var(--brass) 43% 57%, transparent 57%);
  border: 1px solid currentColor;
  transform: rotate(45deg);
}
#identity {
  color: var(--muted);
  font-size: .82rem;
  min-width: 0;
  max-width: 46%;
  overflow-wrap: anywhere;
  text-align: end;
}
#identity button {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  min-height: 44px;
}
main { padding-block: 1.15rem max(1.1rem, env(safe-area-inset-bottom)); }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-family: Georgia, serif; line-height: 1.12; overflow-wrap: anywhere; }
h1 { color: var(--ink); font-size: clamp(1.75rem, 8vw, 2.6rem); letter-spacing: -.035em; }
h1[tabindex="-1"]:focus { outline: none; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.06rem; }
.panel { border: 1px solid var(--metal); border-radius: .35rem; background: var(--panel); padding: .85rem; }
.flow { display: grid; gap: .8rem; }
.stack { display: grid; gap: .5rem; }
button, input { font: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: .45rem;
  min-height: 46px;
  padding: .48rem .65rem;
  border: 1px solid #576171;
  border-radius: .24rem;
  background: #262d38;
  color: var(--ink);
  font-size: .9375rem;
  text-decoration: none;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}
button[disabled] { cursor: default; }
button[disabled]:not(.choice) { opacity: .67; }
.primary {
  justify-content: center;
  background: linear-gradient(0deg, #cfa96e, #e1c48d);
  border-color: #e6ca92;
  color: var(--brass-ink);
}
.primary:hover:not(:disabled) { background: #edcd95; }
:where(button, input, a, summary):focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
:where(a, button, input, summary) { touch-action: manipulation; }
.bare {
  border-color: transparent;
  background: transparent;
  color: var(--brass);
  padding-inline: 0;
  text-decoration: underline;
}
input[type="text"], .build-stats input, #build-form select {
  width: 100%;
  min-height: 44px;
  padding: .5rem;
  border: 1px solid #626c7a;
  border-radius: .24rem;
  color: var(--ink);
  background: #10141b;
}
.portrait {
  display: block;
  flex: none;
  width: 3rem;
  height: 6rem;
  border: 1px solid var(--metal);
  border-radius: .2rem;
  background: #12161d;
  object-fit: contain;
}
.person { display: flex; align-items: center; gap: .7rem; min-width: 0; overflow-wrap: anywhere; }
.person strong { display: block; }
.meta { color: var(--muted); font-size: .83rem; }
.tag {
  color: var(--brass);
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.hall h1 { margin-block: .15rem .2rem; }
.home-profile {
  display: grid;
  grid-template-columns: minmax(0, 8.3rem) minmax(0, 1fr);
  gap: .9rem;
  padding: .55rem .72rem .55rem .55rem;
  align-items: center;
  background: linear-gradient(135deg, #242c39, #171c25 83%);
  border-top-color: #776853;
}
.home-profile > .portrait {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 2;
}
.home-profile h2 { font-size: clamp(1.4rem, 7vw, 2rem); margin-block: .25rem .3rem; }
.attributes { display: grid; gap: .24rem; color: var(--muted); margin-block: .64rem; font-size: .84rem; }
.attributes > div, .gear-preview dl > div {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .32rem;
  padding-bottom: .18rem;
  border-bottom: 1px solid #424a58;
}
.attributes dt { min-width: 0; overflow-wrap: anywhere; }
.attributes dd { color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; }
.home-profile button { width: 100%; }
.invitation {
  gap: .48rem;
  border-top-color: #776853;
  background: linear-gradient(104deg, #252b35, #1d222b 76%);
}
.invitation .primary { margin-top: .25rem; }
.offer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding-block: .4rem; border-bottom: 1px solid var(--metal); }
.offer-row .portrait { width: 2rem; height: 4rem; }
.offer-row .person { flex: 1 1 9rem; }
.offer-row button { margin-inline-start: auto; }
.notice {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(.6rem, env(safe-area-inset-bottom));
  translate: -50% 0;
  max-width: min(90%, 32rem);
  width: max-content;
  padding: .55rem .8rem;
  color: var(--brass-ink);
  background: var(--brass);
  border-radius: .25rem;
  pointer-events: none;
}
.notice:empty { display: none; }
dialog {
  width: min(94vw, 430px);
  max-height: 90dvh;
  overflow: auto;
  padding: 1rem;
  border: 1px solid #776853;
  border-radius: .38rem;
  background: var(--panel);
  color: var(--ink);
}
dialog::backdrop { background: #080c13bc; }
dialog form { display: grid; gap: .8rem; }
dialog input { margin-top: .3rem; }
dialog p[role="alert"] { color: var(--rust); }
dialog p[role="alert"]:empty { display: none; }
.build-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.character-sheet h2 { font-size: 1.85rem; margin-top: .3rem; }
.sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 8.3rem) minmax(0, 1fr);
  gap: .85rem;
  align-items: center;
  padding: .5rem;
  border: 1px solid var(--metal);
  border-radius: .28rem;
  background: var(--sunken);
}
.sheet-body .portrait { width: 100%; height: auto; aspect-ratio: 1 / 2; }
.gear-preview { display: grid; gap: .45rem; }
.gear-preview dl { display: grid; gap: .3rem; color: var(--muted); font-size: .85rem; }
.gear-preview dd { color: var(--ink); font-weight: 650; text-align: end; }
.gear-preview dt { overflow-wrap: anywhere; min-width: 0; }
.portraits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
}
.portrait-option {
  display: grid;
  gap: .25rem;
  justify-items: center;
  min-width: 0;
  min-height: 44px;
  padding: .3rem;
  border: 1px solid var(--metal);
  border-radius: .25rem;
  cursor: pointer;
}
.portrait-option .portrait { width: 100%; height: auto; aspect-ratio: 1 / 2; }
.portrait-option input { margin: 0; accent-color: var(--brass); }
.portrait-option:has(:checked) { border-color: var(--brass); background: #30291f; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.duel {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding-block: .65rem max(.6rem, env(safe-area-inset-bottom));
  gap: .5rem;
}
.duel-top { display: grid; gap: .6rem; }
.round { display: flex; gap: .65rem; align-items: center; justify-content: space-between; }
.round h1 { font-size: clamp(1.19rem, 5.9vw, 1.8rem); letter-spacing: -.018em; }
.timer {
  display: inline-block;
  min-width: 3.6rem;
  padding: .19rem .5rem;
  border: 1px solid #776853;
  border-radius: .2rem;
  color: var(--amber);
  background: #29251e;
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  text-align: center;
  white-space: nowrap;
}
.fighters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.fighter {
  display: grid;
  grid-template-columns: 3.7rem minmax(0, 1fr);
  align-items: center;
  gap: .48rem;
  min-width: 0;
  padding: .3rem;
  border: 1px solid #4d5e60;
  border-radius: .28rem;
  background: linear-gradient(130deg, #202d32, #1a2129);
  --health: var(--teal);
}
.fighter:nth-child(2) {
  border-color: #68584e;
  background: linear-gradient(130deg, #322a2b, #221e26);
  --health: var(--rust);
}
.fighter .portrait { width: 100%; height: auto; aspect-ratio: 1 / 2; }
.fighter-info { display: grid; grid-template-columns: minmax(0, 1fr); gap: .12rem; min-width: 0; overflow-wrap: anywhere; }
.fighter-info strong { font-size: .9rem; overflow-wrap: anywhere; }
.fighter-info .hp { color: var(--ink); font-size: .79rem; font-variant-numeric: tabular-nums; }
.fighter-info .tag { font-size: .6rem; }
progress {
  display: block;
  width: 100%;
  height: .35rem;
  margin-top: .22rem;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #474d58;
  accent-color: var(--health);
}
progress::-webkit-progress-bar { background: #474d58; }
progress::-webkit-progress-value { background: var(--health); }
progress::-moz-progress-bar { background: var(--health); }
.duel-scroll {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: .2rem;
  margin-inline: -.2rem;
}
.log {
  padding: .65rem;
  display: grid;
  gap: .25rem;
  overflow-wrap: anywhere;
  background: var(--sunken);
  border-left: 2px solid #9e875e;
}
.log .tag { margin-bottom: .12rem; }
.log p:not(.tag) { color: var(--muted); font-size: .84rem; }
.log strong { color: var(--ink); }
.controls { display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); gap: .6rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .35rem; padding: 0; color: var(--muted); font-size: .82rem; font-weight: 750; }
.choices { display: grid; gap: .32rem; }
.choice { overflow-wrap: anywhere; }
.choice[aria-pressed="true"] {
  background: #403522;
  border-color: #d1b276;
  color: #ffdf9c;
}
.choice[aria-pressed="true"]::before { content: "✓"; flex: none; }
.choice:disabled:not([aria-pressed="true"]) { opacity: .67; }
.duel-bottom { display: grid; gap: .25rem; }
.duel-bottom .primary { width: 100%; }
.status { font-size: .82rem; color: var(--muted); }
.status:empty { display: none; }
.aux { margin: .25rem 0; border-top: 1px solid var(--metal); }
.aux p { padding-bottom: .5rem; color: var(--muted); }
summary { cursor: pointer; min-height: 44px; padding-block: .65rem; color: var(--brass); font-weight: 700; }
.full-log { display: grid; gap: .5rem; }
.result h1 { margin-block: .25rem; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
@media (min-height: 730px) {
  .duel-scroll { gap: .9rem; }
  .controls { margin-top: auto; }
  .fighter { grid-template-columns: clamp(4.25rem, 21vw, 5.1rem) minmax(0, 1fr); }
}
@media (max-height: 700px) {
  .habit { display: none; }
  .duel, .duel-top, .duel-scroll { gap: .4rem; }
  .fighter { grid-template-columns: 2.65rem minmax(0, 1fr); }
  .log { padding: .45rem; }
  .home-profile { grid-template-columns: minmax(0, 6.3rem) minmax(0, 1fr); }
}
@media (max-width: 349px) {
  .mast-content { flex-wrap: wrap; gap: 0 .4rem; }
  #identity { margin-inline-start: auto; max-width: 100%; }
  .frame { padding-inline: max(.65rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .fighter { grid-template-columns: min(33%, 2.65rem) minmax(0, 1fr); gap: .33rem; }
  .choice { padding-inline: .5rem; }
  .sheet-body { grid-template-columns: minmax(0, 6rem) minmax(0, 1fr); }
}
@media (max-height: 420px) {
  body.in-duel { height: auto; min-height: 100dvh; }
  .duel-scroll { overflow: visible; }
}
