:root {
  color-scheme: dark;
  --gold: #d6ac67;
  --gold-light: #f3d694;
  --gold-shadow: #73502d;
  --wine: #4d2220;
  --ink: #332119;
  --muted-ink: #695444;
  --paper: #ecdbb9;
  --line: #b09771;
  --serif: 'Noto Serif KR', 'Noto Sans KR', Batang, Georgia, serif;
  --sans: 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  font-family: var(--sans);
  color: #ebd9b9;
  background:
    radial-gradient(ellipse at 45% -20%, #70463298 0%, transparent 58%),
    radial-gradient(ellipse at 68% 110%, #4d30258f 0%, transparent 60%),
    linear-gradient(#271a16d9, #211713fa), url('assets/parchment.webp'), #231611;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  border: 1px solid #bb8f5533;
  pointer-events: none;
}
h1, h2, h3, p, blockquote, figure { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #ecb95e; outline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }
button .icon { pointer-events: none; }
.icon { display: inline-block; width: 1.35em; height: 1.35em; flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

.game-shell { width: min(100% - 64px, 1460px); margin: 0 auto; }
#game, #game-dialog { -webkit-user-select: none; user-select: none; }
#game :is(input, textarea), #game-dialog :is(input, textarea) { -webkit-user-select: text; user-select: text; }
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 103px;
  padding: 14px 1px 15px;
}
.brand { display: flex; gap: 14px; align-items: center; flex-shrink: 0; }
.brand-mark {
  display: grid;
  position: relative;
  place-items: center;
  width: 59px;
  height: 59px;
  color: var(--gold-light);
  background: radial-gradient(ellipse at 45% 30%, #805036, #3f241c 74%);
  border: 1px solid #dbb673;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px #382319, inset 0 0 0 4px #a87e48, 0 0 12px #e2a45126;
}
.brand-mark .icon { width: 40px; height: 40px; }
.brand h1 {
  color: #f6e1ac;
  font: 800 clamp(1.75rem, 3vw, 2.55rem)/1.18 var(--serif);
  letter-spacing: -.035em;
  text-shadow: 0 2px 3px #160c08;
}
.brand p {
  margin-top: 4px;
  color: #c8a576;
  font-size: .83rem;
  letter-spacing: .1em;
}
.resources { display: flex; gap: 12px; align-items: stretch; justify-content: flex-end; }
.dashboard-masthead .resources { margin-left: auto; }
.resource {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 132px;
  min-height: 58px;
  padding: 7px 13px;
  color: var(--gold);
  background: linear-gradient(156deg, #583832, #2e201a 83%);
  border: 1px solid #ad8555;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px #19100e93, inset 0 0 0 3px #ad85555c, 0 3px 8px #150e0b53;
}
.resource > .icon { width: 26px; height: 26px; }
.resource > div { display: grid; gap: 2px; }
.resource span { color: #d1b58e; font-size: .72rem; font-weight: 600; }
.resource strong { font: 750 1.04rem/1.3 var(--serif); color: #ffedd2; white-space: nowrap; }
.resource-countdown { color: #ebc689; font-size: .75rem; font-variant-numeric: tabular-nums; }
.resource--time { min-width: 203px; }
.resource--gold { min-width: 159px; }
.resource-link {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin-left: auto;
  padding: 0;
  color: #f1ca8b;
  border: 1px solid #9d7149;
  border-radius: 3px;
  background: #7040357b;
}
.resource-link:hover { background: #916048; }
.resource-link .icon { width: 16px; height: 16px; }

.game-grid {
  --menu-width: 126px;
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(290px, .82fr) minmax(540px, 1.34fr) var(--menu-width);
  gap: 14px;
}
html[lang="en"] .game-grid { --menu-width: 150px; }
.frame {
  position: relative;
  border: 1px solid #c8a36c;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #22140d, inset 0 0 0 2px #674223, inset 0 0 0 4px #d0a872, 0 5px 14px #140d09ab;
}
.frame::before, .frame::after {
  content: '';
  position: absolute;
  z-index: 2;
  width: 20px;
  height: 20px;
  pointer-events: none;
  opacity: .88;
}
.frame::before {
  top: 3px;
  left: 3px;
  border-top: 3px double #f0ca8a;
  border-left: 3px double #f0ca8a;
  border-radius: 4px 0 0 0;
}
.frame::after {
  right: 3px;
  bottom: 3px;
  border-right: 3px double #e5bd7c;
  border-bottom: 3px double #e5bd7c;
  border-radius: 0 0 4px 0;
}
.portrait {
  min-height: clamp(586px, 46vw, 674px);
  overflow: hidden;
  isolation: isolate;
  background: #59402a;
}
.portrait img {
  position: absolute;
  z-index: -2;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  object-fit: cover;
  object-position: 55% center;
}
.portrait::before, .portrait::after { width: 32px; height: 32px; }
.portrait-line {
  position: absolute;
  inset: 7px;
  border: 1px solid #e1be837f;
  border-radius: 3px;
  background: linear-gradient(to top, #1c100dfc 0%, #20130ebe 10%, transparent 31%),linear-gradient(90deg, #26150f38, transparent 25%);
  pointer-events: none;
}
.portrait-caption {
  position: absolute;
  z-index: 1;
  inset: auto 20px 25px 21px;
  color: #f9e4b9;
  text-shadow: 0 2px 4px #1d110bea;
}
.portrait-place {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #edcd92;
  font-size: .76rem;
  font-weight: 650;
}
.portrait-place .icon { width: 16px; height: 16px; }
.portrait-caption h2 {
  margin: 4px 0 2px;
  font: 800 clamp(2rem, 4.1vw, 3.65rem)/1.14 var(--serif);
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
.portrait-rank { font: 650 .89rem/1.45 var(--serif); color: #e9d3af; }

.dashboard { display: grid; grid-template-rows: auto auto 1fr; gap: 13px; min-width: 0; }
.parchment {
  color-scheme: light;
  color: var(--ink);
  background: url('assets/parchment.webp'), radial-gradient(ellipse at 35% 30%, #fbefda 0%, #f0e0c0 67%, #e8d1a9 100%);
}
.paper-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin: 4px 4px 0;
  min-height: 43px;
  padding: 0 14px;
  color: #f9e8c6;
  border-bottom: 1px solid #754e2d;
  border-radius: 2px 2px 0 0;
  background: url('assets/parchment.webp'), linear-gradient(110deg, #502522, #66312b 59%, #42201e);
  box-shadow: 0 1px #b89259;
}
.paper-header h2 {
  display: flex;
  gap: 9px;
  align-items: center;
  font: 750 1.02rem/1.4 var(--serif);
  letter-spacing: .01em;
}
.paper-header h2 .icon { color: #e6bf79; width: 18px; height: 18px; }
.paper-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 8px;
  background: #381a16a0;
  color: #f1d6a6;
  border: 1px solid #aa7c4f;
  border-radius: 3px;
  font-size: .75rem;
  font-weight: 650;
  white-space: nowrap;
}
.paper-link:hover { background: #622e25; color: #fff2d0; }
.paper-link .icon { width: 14px; height: 14px; }
.stats-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 19px;
  padding: 13px 0 11px;
  border-bottom: 1px solid #a587625e;
}
.rank-name { display: flex; min-width: 0; align-items: center; gap: 10px; }
.rank-name > .icon { color: #94693a; width: 32px; height: 32px; }
.rank-name strong { font: 800 clamp(1.68rem, 3.3vw, 2.65rem)/1.13 var(--serif); letter-spacing: -.07em; overflow-wrap: anywhere; }
.experience { display: grid; align-content: center; gap: 6px; width: min(45%, 233px); flex-shrink: 0; }
.experience > div { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.level {
  padding: 2px 7px 3px;
  color: #f8e1a5;
  background: linear-gradient(#603c28, #472917);
  border: 1px solid #b4854f;
  border-radius: 3px;
  font: 750 .82rem/1.15 var(--serif);
  white-space: nowrap;
}
.xp-text { color: #634b34; font-size: .74rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.meter {
  display: block;
  overflow: hidden;
  height: 8px;
  min-width: 0;
  border: 1px solid #4d3528;
  border-radius: 4px;
  background: #513c30;
  box-shadow: inset 0 1px 2px #200d0888, 0 1px 0 #fffaf0ab;
  --meter-fill: #ae8548;
}
.meter > span {
  display: block;
  height: 100%;
  width: var(--value);
  border-radius: 2px;
  background: linear-gradient(#ffffff32, #ffffff00 54%, #17100c3d), var(--meter-fill);
  box-shadow: inset 0 1px #fff7d75e, 1px 0 #f6e0a676;
}
.meter--xp { height: 9px; --meter-fill: #cf963f; }
.meter--strength, .meter--injury { --meter-fill: #a3463e; }
.meter--agility, .meter--stamina { --meter-fill: #c79036; }
.meter--vitality, .meter--mood { --meter-fill: #6e843b; }
.meter--defense, .meter--fatigue { --meter-fill: #757e8c; }
.meter--technique { --meter-fill: #856281; }
.meter--honor { --meter-fill: #67809a; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; row-gap: 11px; padding: 13px 19px; }
.stat { display: grid; align-items: center; grid-template-columns: 35px minmax(0,1fr) auto; gap: 8px; }
.stat-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 1px solid #a47750;
  border-radius: 5px;
  color: #f2d39b;
  background: linear-gradient(145deg, #895448, #582c28);
  box-shadow: inset 0 0 0 1px #f3d99c42;
}
.stat-icon .icon { width: 20px; height: 20px; }
.stat-icon--agility { background: linear-gradient(145deg, #986733, #71491f); }
.stat-icon--vitality { background: linear-gradient(145deg, #7d793d, #585627); }
.stat-icon--defense { background: linear-gradient(145deg, #6b6e78, #494951); }
.stat-icon--technique { background: linear-gradient(145deg, #815365, #57374b); }
.stat-icon--honor { background: linear-gradient(145deg, #637285, #40546a); }
.stat-content { display: grid; align-items: center; gap: 5px; }
.stat-label { font-size: .83rem; font-weight: 740; line-height: 1; }
.stat-value { min-width: 23px; text-align: right; font: 800 1.13rem/1 var(--serif); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-delta { margin-left: 3px; color: #46613f; font: 750 .66rem/1 var(--sans); }
.record-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  margin: 0 19px 13px;
  border: 1px solid #a788645e;
  border-radius: 3px;
  background: #c7a47219;
}
.record-row > span { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 4px; color: #6d543c; font-size: .72rem; white-space: nowrap; }
.record-row > span + span { border-left: 1px solid #a7886450; }
.record-row .icon { color: #8a6038; width: 16px; height: 16px; }
.record-row strong { color: #3b271b; font: 800 .78rem/1.2 var(--sans); }

.condition-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); margin: 12px 13px 13px; }
.condition-item { display: grid; align-content: start; gap: 5px; padding: 0 9px; min-width: 0; }
.condition-item + .condition-item { border-left: 1px solid #b396704d; }
.condition-label { display: flex; align-items: center; gap: 4px; min-width: 0; color: #644836; font-size: .75rem; font-weight: 650; white-space: nowrap; }
.condition-label .icon { color: #8b5536; width: 15px; height: 15px; }
.condition-item strong { color: #3f291e; font: 780 clamp(.74rem,1.18vw,1rem)/1.36 var(--serif); white-space: nowrap; }
.condition-item .meter { height: 6px; }

.story-panel { min-height: 157px; }
.story-body {
  position: relative;
  padding: 12px 19px 15px;
  isolation: isolate;
}
.story-title { color: #4a2a20; font: 800 1.03rem/1.45 var(--serif); }
.story-body p { margin-top: 4px; font-size: .85rem; color: #5a4532; line-height: 1.65; }
.story-body blockquote {
  margin-top: 9px;
  padding: 7px 10px;
  color: #623e2b;
  border-left: 2px solid #ac8050;
  background: #bd98682b;
  border-radius: 0 3px 3px 0;
  font: 650 .86rem/1.5 var(--serif);
}
.event-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid #a66642;
  border-radius: 4px;
  background: #e9cda7;
  color: #5b321f;
}
.event-banner:hover { background: #f4d2a0; }
.event-banner > .icon { color: #9e5d38; width: 25px; height: 25px; }
.event-banner strong { display: block; font-weight: 800; }
.event-banner small { display: block; color: #694d37; margin-top: 3px; }

.navigation {
  background: url('assets/parchment.webp'), linear-gradient(#4f3328, #2d201a 77%);
  align-self: stretch;
  padding: 9px 7px;
}
.navigation nav { display: grid; height: 100%; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(39px,1fr); gap: 6px; }
.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
  padding: 4px 8px 4px 10px;
  border: 1px solid #a47b50;
  border-radius: 4px;
  background: linear-gradient(145deg, #5d332b, #3e221d);
  box-shadow: inset 0 0 0 2px #2d18159c, inset 0 0 0 3px #b388593c, 0 2px 3px #160e0ba1;
  color: #f5e5c9;
  text-align: left;
  font: 750 .91rem/1.1 var(--serif);
}
.nav-button > span { min-width: 0; overflow-wrap: anywhere; }
.nav-button .icon { color: #dfb574; width: 22px; height: 22px; }
.nav-button:hover { background: linear-gradient(145deg, #81463b, #553026); }
.nav-button.is-active {
  border-color: #e0b87b;
  color: #fff0d0;
  background: linear-gradient(135deg, #8b5637, #563120);
  box-shadow: inset 0 0 0 2px #3e271c, inset 0 0 0 3px #d7a76b82, 0 2px 4px #1a0e0bba;
}

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 16px 0 0; }
.quick {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 75px;
  padding: 9px 12px;
  color: #fff0d0;
  text-align: left;
  border: 1px solid #c79f63;
  border-radius: 5px;
  background: url('assets/parchment.webp'), linear-gradient(155deg, var(--quick-start), var(--quick-end));
  box-shadow: inset 0 0 0 2px #291813b5, inset 0 0 0 3px #e1b7799c, 0 4px 10px #170e0b98;
  transition: filter .15s ease, transform .15s ease;
}
.quick::before, .quick::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border: 1px solid #e0b579a8;
  background: #4e3227;
  transform: rotate(45deg);
  pointer-events: none;
}
.quick::before { left: 2px; top: 2px; }
.quick::after { right: 2px; bottom: 2px; }
.quick:enabled:hover { filter: brightness(1.19); transform: translateY(-1px); }
.quick:enabled:active { transform: translateY(1px); }
.quick:disabled { filter: saturate(.36); opacity: .69; }
.quick--red { --quick-start: #773930; --quick-end: #522420; }
.quick--blue { --quick-start: #414c5e; --quick-end: #283241; }
.quick--green { --quick-start: #516040; --quick-end: #303d2c; }
.quick--plum { --quick-start: #694252; --quick-end: #432934; }
.quick-icon { display: flex; color: #f1c985; text-shadow: 0 1px #000; }
.quick-icon .icon { width: 32px; height: 32px; }
.quick strong, .quick small { display: block; }
.quick strong { font: 800 clamp(.89rem,1.25vw,1.15rem)/1.4 var(--serif); text-shadow: 0 1px 2px #1c100b90; }
.quick small { color: #e1c9a5; font-size: .73rem; line-height: 1.4; margin-top: 2px; }

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 1px 17px;
  color: #bda887;
  font-size: .73rem;
}
.game-footer > span:first-child { display: flex; align-items: center; gap: 6px; }
.game-footer .icon { color: #caab77; width: 14px; height: 14px; }

.game-dialog {
  position: fixed;
  inset: 0;
  width: min(865px, calc(100vw - 38px));
  max-width: none;
  max-height: min(85dvh, 870px);
  margin: auto;
  padding: 0;
  color-scheme: light;
  color: var(--ink);
  background: url('assets/parchment.webp'), radial-gradient(ellipse at 42% 35%, #fbefd7, #ead7b2);
  border: 1px solid #e7c184;
  border-radius: 7px;
  box-shadow: 0 0 0 2px #452c19, 0 0 0 3px #bc8d57, 0 13px 65px #0e0806db;
}
.game-dialog[open] { animation: dialog-enter .15s ease-out; }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.game-dialog::backdrop { background: #190f0cc9; backdrop-filter: blur(3px); }
.dialog-shell { display: flex; flex-direction: column; max-height: min(85dvh, 870px); }
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-height: 57px;
  padding: 6px 12px 6px 19px;
  background: url('assets/parchment.webp'), linear-gradient(115deg, #582a26, #60312a 65%, #46231f);
  color: #f7e4bc;
  border-bottom: 2px solid #b18451;
}
.dialog-header h2 { display: flex; align-items: center; gap: 10px; font: 800 1.25rem/1.4 var(--serif); }
.dialog-header h2:focus { outline: none; }
.dialog-header .icon { color: #e4b978; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #f6daa7;
  border: 1px solid #a6764d;
  border-radius: 4px;
  background: #381c18;
}
.dialog-close:hover { background: #81463a; }
.dialog-body { min-height: 0; overflow: auto; padding: 19px 21px 24px; overscroll-behavior: contain; scrollbar-color: #ae8862 #f0dfbf; }
.panel-intro { color: #5b4333; line-height: 1.6; margin-bottom: 15px; font-size: .95rem; }
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.game-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  background: #fff7e563;
  border: 1px solid #b1946c;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px #f9ebccab;
}
.game-card__header { display: flex; gap: 9px; align-items: flex-start; }
.game-card__header h3 { font: 800 1.05rem/1.4 var(--serif); }
.game-card__header p, .game-card__body p { margin-top: 3px; color: #624c3c; font-size: .85rem; line-height: 1.5; }
.game-card__icon { display: grid; place-items: center; min-width: 35px; height: 35px; background: #704635; border: 1px solid #b1814c; border-radius: 4px; color: #f1ce91; }
.game-card__icon .icon { width: 21px; height: 21px; }
.game-card__footer { margin-top: auto; }
.tag-list, .compact-list { margin: 0; padding: 0; list-style: none; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 3px 6px; color: #674b35; font-size: .75rem; font-weight: 650; line-height: 1.35; background: #e5cda6; border: 1px solid #b48e603d; border-radius: 3px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.panel-button {
  padding: 7px 10px;
  color: #ffecd0;
  background: linear-gradient(#784437, #5a2c25);
  border: 1px solid #a57950;
  border-radius: 4px;
  font-size: .84rem;
  font-weight: 730;
  line-height: 1.35;
  box-shadow: inset 0 0 0 1px #e2b57755;
}
.panel-button:enabled:hover { background: #874c3c; }
.panel-button.secondary { color: #5c3928; background: #f5e6c9; }
.panel-button.secondary:enabled:hover { background: #eed5a8; }
.panel-button:disabled { color: #685d50; background: #ded1b9; opacity: .73; }
.blocked-reason { font-size: .76rem; margin-top: 6px; color: #7b422c; }
.mini-heading { margin: 19px 0 9px; color: #543624; font: 800 1.05rem/1.35 var(--serif); }
.dialog-body > .mini-heading:first-child { margin-top: 0; }
.panel-empty { padding: 12px; border: 1px solid #bc9b706a; border-radius: 4px; color: #654d37; background: #dfc39e4a; font-size: .86rem; }
.compact-list { margin-top: 7px; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 6px; border-top: 1px solid #b6987254; font-size: .84rem; }
.compact-row > span { flex: none; color: #77563d; font-size: .75rem; }
.compact-row > p { flex: 1; }
.compact-row strong { font-size: .85rem; }
.compact-row small { color: #674e38; }
.tactics-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.tactic-choice, .origin-option {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 10px;
  color: #4b3025;
  background: #f6e8cb;
  border: 1px solid #b3966c;
  border-radius: 4px;
  text-align: left;
}
.tactic-choice:hover, .origin-option:hover { background: #f0dbb2; }
.tactic-choice.is-selected, .origin-option:has(input:checked) { border-color: #92603e; background: #e8cca3; box-shadow: inset 0 0 0 1px #a27449; }
.tactic-choice .icon { color: #9a6038; width: 18px; height: 18px; }
.tactic-choice strong, .origin-option strong { font-size: .89rem; }
.tactic-choice small, .origin-option small { display: block; margin-top: 3px; color: #5e4633; font-size: .76rem; line-height: 1.4; }
.win-result, .loss-result { padding: 12px; border: 1px solid #9b8758; border-radius: 4px; background: #e4dfb4; color: #4b471f; }
.loss-result { border-color: #a47158; background: #ebcbb6; color: #703a2b; }
.market-scroll { overflow-x: auto; }
.market-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .84rem; }
.market-table th, .market-table td { padding: 7px 8px; border-bottom: 1px solid #bdab85; white-space: nowrap; }
.market-table thead { color: #f8e6c9; background: #684030; }
.market-table tbody tr:nth-child(even) { background: #bc975e16; }
.market-table td .panel-button { margin-left: 7px; }
.market-table small { display: block; margin-top: 3px; color: #6f563e; }
.field-switch { display: flex; justify-content: space-between; align-items: center; gap: 16px; cursor: pointer; width: 100%; }
.field-switch input, .origin-option input { accent-color: #6f3d2d; width: 18px; height: 18px; flex: none; }
.field-switch small { display: block; margin-top: 4px; color: #654c37; }
.name-field { display: grid; gap: 6px; font-weight: 730; }
.name-field input {
  width: min(100%, 333px);
  padding: 9px 10px;
  color: #3b291d;
  background: #fffae9;
  border: 1px solid #ad8967;
  border-radius: 4px;
}
.origin-field { margin: 16px 0; padding: 0; border: 0; }
.origin-field legend { margin-bottom: 7px; font-weight: 730; }
.origin-option { display: flex; align-items: flex-start; gap: 7px; cursor: pointer; }
.origin-option input { margin: 2px 0 0; }
.toast {
  position: fixed;
  z-index: 10;
  inset: auto auto 20px 50%;
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 10px 14px;
  color: #ffeacd;
  background: #48281f;
  border: 1px solid #c09763;
  border-radius: 4px;
  box-shadow: 0 4px 14px #1a0e09a8;
  font-size: .86rem;
  transform: translateX(-50%);
}
.dialog-feedback { flex: none; padding: 8px 20px; color: #633b25; border-top: 1px solid #be9e73; background: #edd7af; font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.no-script { padding: 18px; text-align: center; }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 1190px) {
  .game-shell { width: min(100% - 38px, 1460px); }
  .game-grid { --menu-width: 108px; grid-template-columns: minmax(285px,.75fr) minmax(435px,1.25fr) var(--menu-width); gap: 11px; }
  html[lang="en"] .game-grid { --menu-width: 138px; }
  .navigation { padding-inline: 6px; }
  .nav-button { padding-inline: 7px; gap: 7px; }
  .stats-grid { column-gap: 15px; }
  .condition-item { padding-inline: 6px; }
}
@media (max-width: 960px) {
  .game-grid { grid-template-columns: minmax(245px,.76fr) minmax(0,1.24fr); }
  .navigation { grid-column: 1 / -1; grid-row: 1; }
  .navigation nav { grid-auto-rows: auto; grid-template-columns: repeat(6,minmax(0,1fr)); }
  .nav-button { min-height: 42px; justify-content: center; padding-inline: 3px; gap: 3px; font-size: .78rem; }
  .nav-button .icon { width: 16px; height: 16px; }
  .masthead { min-height: 91px; }
  .resource { min-width: 0; }
  .resource > .icon { width: 20px; height: 20px; }
  .brand { gap: 8px; }
  .brand-mark { width: 47px; height: 47px; }
  .brand-mark .icon { width: 32px; height: 32px; }
  .resources { gap: 7px; }
  .resource { gap: 6px; padding: 5px 8px; }
  .resource strong { font-size: .88rem; }
}
@media (max-width: 700px) {
  .game-shell { width: calc(100% - 24px); }
  .masthead { align-items: stretch; gap: 9px; flex-direction: column; padding-block: 10px; }
  .brand h1 { font-size: 1.78rem; }
  .brand p { font-size: .74rem; }
  .resources { justify-content: stretch; }
  .resource { flex: 1; min-height: 45px; }
  .resource--time { flex: 1.6; }
  .resource strong { font-size: .82rem; }
  .resource-link { width: 21px; height: 21px; }
  .navigation nav { grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; }
  .nav-button { min-height: 35px; }
  .game-grid { grid-template-columns: 1fr; gap: 10px; }
  .portrait { min-height: 0; height: min(128vw, 570px); }
  .portrait img { object-position: 50% 42%; }
  .portrait-caption { inset: auto 16px 19px; }
  .stats-top { margin-inline: 14px; gap: 8px; }
  .stats-grid { padding-inline: 14px; }
  .record-row { margin-inline: 14px; }
  .condition-item strong { font-size: .8rem; }
  .quick-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
  .quick { min-height: 59px; justify-content: flex-start; gap: 8px; }
  .quick-icon .icon { width: 24px; height: 24px; }
  .game-footer { flex-wrap: wrap; gap: 3px; }
  .dialog-body { padding: 13px; }
  .dialog-header { min-height: 49px; padding-left: 12px; }
}
@media (max-width: 480px) {
  .resource { padding-inline: 6px; gap: 4px; }
  .resource > .icon { width: 15px; height: 15px; }
  .resource strong { font-size: .74rem; }
  .resource span { font-size: .66rem; }
  .stat { grid-template-columns: 29px minmax(0,1fr) auto; gap: 6px; }
  .stat-icon { width: 29px; height: 29px; }
  .stat-icon .icon { width: 17px; height: 17px; }
  .record-row > span { font-size: .69rem; gap: 4px; }
  .record-row .icon { width: 13px; height: 13px; }
  .condition-grid { margin-inline: 8px; }
  .condition-item { padding-inline: 4px; }
  .condition-label { font-size: .69rem; gap: 2px; }
  .condition-label .icon { width: 12px; height: 12px; }
  .game-dialog { width: calc(100vw - 20px); }
  .panel-grid, .tactics-grid { grid-template-columns: 1fr; }
}

.game-card__body .arena-forecast { margin: 8px 0 4px; padding: 6px 8px; background: #e9d4a9; color: #624325; border-radius: 3px; }
.arena-forecast strong { font-weight: 800; }
.event-choices { margin-top: 12px; }

.form-badge {
  padding: 4px 9px;
  color: #f1d6a6;
  border: 1px solid #aa7c4f;
  border-radius: 3px;
  background: #381a16a0;
  font-size: .77rem;
  font-weight: 720;
}
.form-badge--rare { color: #ffe6a4; background: #65471d; border-color: #d1ab65; }
.portrait:not(.gate-portrait) {
  background: linear-gradient(180deg,#3c221818 0%,#7f482500 52%,#3c221844 100%),
    #5b3b2a url('assets/colosseum.webp') center 64% / cover no-repeat;
}
.portrait:not(.gate-portrait) img {
  bottom: 101px;
  height: calc(100% - 106px);
  object-fit: contain;
  object-position: center;
}
.portrait-line {
  background: linear-gradient(to top, #25140f 0, #341f16 92px, #36231755 100px, transparent 138px);
}
.portrait-caption { bottom: 15px; }
.portrait-caption h2 { font-size: clamp(1.8rem,3.25vw,2.55rem); }
.gate-masthead { width: min(100%, 1000px); margin: 0 auto; }
.gate-grid {
  display: grid;
  width: min(100%, 1000px);
  min-height: min(570px, 75vh);
  margin: 0 auto 20px;
  grid-template-columns: minmax(245px,.72fr) minmax(0,1.28fr);
  gap: 14px;
}
.gate-portrait { min-height: 0; }
.gate-portrait img { object-fit: contain; object-position: center; }
.gate-content { align-self: center; }
.gate-body { padding: 24px 23px 28px; }
.gate-body > p { color: #5b4333; line-height: 1.65; margin-bottom: 14px; }
.gate-link { display: inline-block; text-decoration: none; }
.gate-link:hover { background: #874c3c; }
#new-game-form .tactics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#new-game-form .origin-option { align-items: center; padding-inline: 8px; }
.gender-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.recruit-hint { margin-top: 8px; color: #694e3a; font-size: .86rem; }
.legacy-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 17px;
  padding-top: 12px;
  border-top: 1px solid #bc9b706a;
}
.legacy-import {
  align-self: start;
  color: #69432e;
  font-size: .83rem;
  padding: 5px 2px;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 700px) {
  .navigation nav { grid-template-columns: repeat(6,minmax(0,1fr)); }
  html[lang="en"] .navigation nav { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .gate-grid { grid-template-columns: 1fr; align-content: start; }
  .gate-portrait { height: min(65vw,340px); }
  .gate-body { padding: 14px 16px 19px; }
  .gate-grid--creation .gate-content { grid-row: 1; }
}
@media (max-width: 445px) {
  .navigation nav { grid-template-columns: repeat(4,minmax(0,1fr)); }
  html[lang="en"] .navigation nav { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

.cooldown-label { color:#6e4d34; font-size:.81rem; font-variant-numeric:tabular-nums; }

.tutorial-callout, .tutorial-next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  color: #593725;
  background: #e8cd9e9e;
  border: 1px solid #b99060;
  border-radius: 5px;
}
.tutorial-callout { margin-bottom: 12px; }
.tutorial-callout__text { display: flex; gap: 8px; align-items: center; }
.tutorial-callout__text > .icon { width: 25px; height: 25px; color: #8d4e31; }
.tutorial-callout__text small,.tutorial-callout__text strong { display: block; }
.tutorial-callout__text small { color: #775439; font-size: .74rem; }
.tutorial-callout strong { font: 760 .98rem/1.3 var(--serif); }
.tutorial-callout button, .tutorial-next button { flex: none; }
.tutorial-panel__progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: #6c442b;
}
.tutorial-panel__progress strong { font: 800 1.15rem/1.3 var(--serif); }
.tutorial-panel__progress span { font-size: .86rem; font-weight: 680; }
.tutorial-next { margin-top: 13px; }
.tutorial-next small { color: #734b28; font-size: .77rem; font-weight: 700; }
.tutorial-next h3 { color: #4b2c20; margin-top: 2px; font: 800 1.05rem/1.4 var(--serif); }
.tutorial-next p, .tutorial-steps p { margin-top: 3px; line-height: 1.55; font-size: .84rem; color: #654b37; }
.tutorial-steps { display: grid; margin: 13px 0 0; padding: 0; list-style: none; }
.tutorial-steps li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-top: 1px solid #b6987254;
}
.tutorial-steps li > span { flex: none; color: #84572e; font-size: .78rem; font-weight: 720; }
.tutorial-steps li.is-complete > span { color: #486247; }
.tutorial-match-reward { display: flex; gap: 6px; align-items: center; margin-top: 10px; color: #6d4427; font-weight: 670; }
.recruit-field { margin: 0 0 16px; }
.hire-confirm {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 0 14px;
  color: #583929;
  font-size: .86rem;
}
.hire-confirm input { width: 17px; height: 17px; flex: none; margin: 2px 0 0; accent-color: #6f3d2d; }
.gate-grid--creation { width: min(100%, 1150px); }
.gate-grid--creation .gate-content { align-self: start; }
@media (max-width: 460px) {
  .tutorial-panel__progress { flex-wrap: wrap; }
  .tutorial-next { align-items: flex-start; flex-direction: column; }
}

.gate-portrait {
  background: linear-gradient(180deg, #3c221820, #3c221855),
    #5b3b2a url('assets/colosseum.webp') center 64% / cover no-repeat;
}
.portrait-edit {
  display: inline-flex;
  flex: none;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 4px 7px;
  border: 1px solid #ac8055;
  border-radius: 4px;
  color: #6e3f2a;
  background: #f6e6c5;
  font-size: .73rem;
  font-weight: 720;
  white-space: nowrap;
}
.portrait-edit:hover { background: #efd3a2; }
.portrait-edit .icon { width: 15px; height: 15px; }
.portrait-file-spec {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 12px;
  padding: 6px 0 12px;
  color: #6b422c;
}
.portrait-file-spec span { font-size: .83rem; }
@media (max-width: 480px) {
  .rank-name { gap: 6px; }
  .portrait-edit { padding: 4px 6px; }
  .portrait-edit span { display: none; }
}

.career-details {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin: 0 19px 1px;
  padding-top: 9px;
}
.career-age, .career-title, .career-challenge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #70492f;
  font-size: .81rem;
  line-height: 1.35;
}
.career-age { padding-right: 6px; }
.career-age strong { color: #543727; }
.career-title, .career-challenge {
  padding: 4px 7px;
  border: 1px solid #b18456;
  border-radius: 4px;
  background: #f4e1b8;
}
.career-title.is-ranked {
  color: #f9e0ac;
  border-color: #a67d46;
  background: #673b28;
}
.career-title:hover, .career-challenge:hover { filter: brightness(1.1); }
.career-challenge { color: #fcdfb2; background: #74382d; }
.career-death { display: grid; gap: 12px; }
.career-death p { color: #634532; line-height: 1.65; }
.career-death__title { display: flex; align-items: center; gap: 7px; font-size: 1.1rem; }
@media (max-width: 700px) {
  .career-details { margin-inline: 14px; }
}

.market-table tr[data-ranked-self] { background: #e7ce9b; }

.portrait-name { display: flex; gap: 8px; align-items: center; }
.portrait-name h2 { min-width: 0; }
.portrait-name .portrait-edit { text-shadow: none; }
.language-switch {
  display: flex;
  align-self: center;
  flex: none;
  border: 1px solid #bf9660;
  border-radius: 4px;
  padding: 2px;
  background: #2e1b17;
}
.language-switch button {
  padding: 5px 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #e8cd9e;
  font-size: .79rem;
  font-weight: 710;
}
.language-switch button[aria-pressed="true"] { background: #794a30; color: #fff0cc; }
.live-summary { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.live-summary [data-live-until] { color: #e0bd85; font-variant-numeric: tabular-nums; }
.abandon-confirm { display: grid; gap: 13px; color: #683b29; }
.community-form, .community-board { display: grid; gap: 12px; }
.community-form { margin-bottom: 22px; }
.community-form label { display: grid; gap: 5px; font-weight: 700; }
.community-form input, .community-form textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: #42271c;
  background: #fff2d5; border: 1px solid #b18b5c; border-radius: 4px;
}
.community-form textarea { resize: vertical; }
.community-form .panel-intro { margin: 0; }
.community-form > button { justify-self: start; }
.community-board > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.community-post { padding: 12px; border: 1px solid #b18b5c; border-radius: 4px; background: #fff2d59c; overflow-wrap: anywhere; }
.community-post + .community-post { margin-top: 9px; }
.community-byline { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 3px 0 8px; color: #6a4b34; font-size: .88rem; }
.community-content { white-space: pre-wrap; }
@media (min-width: 761px) and (max-width: 1080px) {
  .dashboard-masthead { gap: 12px; }
  .dashboard-masthead .resource { min-width: 0; }
}
@media (max-width: 760px) {
  .masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; }
  .masthead .language-switch { grid-column: 2; grid-row: 1; }
  .dashboard-masthead .resources {
    grid-column: 1 / -1; grid-row: 2; display: grid; margin: 0;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, .85fr) minmax(0, 1fr);
  }
  .resource > div { min-width: 0; }
  .resource strong { white-space: normal; font-size: .83rem; }
  .resource-link { flex: none; }
  .brand h1 { font-size: clamp(1.2rem, 5.05vw, 1.78rem); }
  .brand p { font-size: .7rem; line-height: 1.3; letter-spacing: .05em; }
}
@media (max-width: 400px) {
  .masthead .brand-mark { width: 36px; height: 36px; }
  .masthead .brand-mark .icon { width: 25px; height: 25px; }
  .language-switch button { padding-inline: 5px; }
}
