:root {
  color-scheme: dark;
  --ink: #f1eadf;
  --muted: #b8ae9e;
  --soft: #837967;
  --paper: #e7dcc8;
  --bg: #101310;
  --bg-2: #171b16;
  --panel: rgba(31, 35, 28, 0.9);
  --panel-2: rgba(46, 50, 38, 0.86);
  --line: rgba(231, 220, 200, 0.15);
  --line-strong: rgba(231, 220, 200, 0.28);
  --ember: #e3683d;
  --gold: #d6b15f;
  --moss: #86a66a;
  --teal: #67a9a0;
  --berry: #b35d7a;
  --danger: #e05a56;
  --good: #9ccc75;
  --warn: #e4b557;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius: 8px;
  --mono: "SFMono-Regular", "Cascadia Mono", "Menlo", monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% 14%, rgba(227, 104, 61, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 18%, rgba(103, 169, 160, 0.14), transparent 30rem),
    linear-gradient(135deg, #0e110f 0%, #191c15 47%, #111315 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: rgba(231, 220, 200, 0.08);
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(231, 220, 200, 0.44);
  background: rgba(231, 220, 200, 0.14);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(10, 12, 10, 0.64);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(214, 177, 95, 0.7);
  box-shadow: 0 0 0 3px rgba(214, 177, 95, 0.12);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px, 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 92%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 18px;
}

.join-screen {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.brand-panel,
.join-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.brand-kicker {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.brand-title {
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: clamp(36px, 6vw, 68px);
  line-height: 0.95;
  font-weight: 700;
}

.brand-copy {
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.7;
  font-size: 16px;
}

.objective-panel {
  margin-top: 14px;
  border: 1px solid rgba(214, 177, 95, 0.28);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(214, 177, 95, 0.11), transparent 58%),
    rgba(0, 0, 0, 0.2);
}

.objective-intro {
  margin-top: 18px;
  border-color: rgba(214, 177, 95, 0.4);
  background:
    linear-gradient(135deg, rgba(214, 177, 95, 0.16), transparent 46%),
    linear-gradient(180deg, rgba(103, 169, 160, 0.08), rgba(0, 0, 0, 0.18));
}

.objective-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.objective-kicker {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
}

.objective-title {
  margin-top: 3px;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}

.objective-badge {
  flex: 0 0 auto;
  min-height: 24px;
  border: 1px solid rgba(156, 204, 117, 0.34);
  border-radius: 6px;
  padding: 3px 8px;
  color: #d8efc9;
  background: rgba(156, 204, 117, 0.08);
  font-family: var(--mono);
  font-size: 12px;
}

.objective-flow {
  display: grid;
  gap: 7px;
  margin-top: 11px;
}

.objective-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  line-height: 1.4;
  font-size: 13px;
}

.objective-step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(214, 177, 95, 0.36);
  border-radius: 6px;
  color: #1b160d;
  background: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.objective-fail {
  margin-top: 10px;
  border-top: 1px solid rgba(231, 220, 200, 0.12);
  padding-top: 8px;
  color: #efc3b2;
  font-size: 12px;
  line-height: 1.45;
}

.objective-status .objective-title,
.objective-lobby .objective-title {
  font-size: 17px;
}

.objective-status .objective-step,
.objective-lobby .objective-step {
  font-size: 12px;
}

.table-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 36px;
  transform: rotate(-2deg);
}

.preview-card {
  aspect-ratio: 2.5 / 3.5;
  border: 1px solid rgba(231, 220, 200, 0.24);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.35);
}

.preview-card:nth-child(2),
.preview-card:nth-child(4) {
  transform: translateY(22px) rotate(4deg);
}

.join-panel {
  align-self: center;
  justify-self: center;
  width: min(100%, 520px);
  padding: 22px;
}

.join-panel h2,
.panel-title,
.section-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
}

.join-panel h2 {
  font-size: 28px;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary {
  border-color: rgba(227, 104, 61, 0.72);
  background: linear-gradient(180deg, rgba(227, 104, 61, 0.92), rgba(169, 64, 42, 0.92));
  color: #fff7ed;
}

.secondary {
  border-color: rgba(103, 169, 160, 0.52);
}

.danger {
  border-color: rgba(224, 90, 86, 0.58);
  color: #ffd1cd;
}

.good {
  border-color: rgba(156, 204, 117, 0.58);
  color: #dbffc7;
}

.tiny-note {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
}

.warn-text {
  color: #efdda8;
}

.game {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(620px, 1fr) minmax(340px, 400px);
  gap: 14px;
  min-height: calc(100vh - 36px);
}

.rail,
.center,
.log-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel {
  padding: 14px;
}

.guide-panel {
  border-color: rgba(214, 177, 95, 0.32);
  background:
    linear-gradient(135deg, rgba(214, 177, 95, 0.12), transparent 44%),
    var(--panel);
}

.guide-lead {
  margin: 0 0 12px;
  color: var(--paper);
  line-height: 1.55;
  font-size: 13px;
}

.guide-steps {
  display: grid;
  gap: 8px;
}

.guide-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.guide-step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #18160f;
  background: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.guide-tip {
  margin-top: 12px;
  border: 1px solid rgba(103, 169, 160, 0.26);
  border-radius: 6px;
  padding: 8px;
  color: #cde9e4;
  background: rgba(103, 169, 160, 0.09);
  font-size: 12px;
  line-height: 1.45;
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.inline-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.inline-buttons button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.room-code {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 18px;
}

.phase-pill {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.stat-label {
  color: var(--soft);
  font-size: 12px;
}

.stat-value {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 18px;
}

.players {
  display: grid;
  gap: 8px;
}

.player-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-name {
  min-width: 0;
  font-weight: 700;
}

.player-name span {
  color: var(--muted);
  font-weight: 500;
}

.meter-row {
  display: grid;
  grid-template-columns: 42px 1fr 32px;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.meter {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: rgba(231, 220, 200, 0.1);
}

.meter > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--moss);
}

.meter.sanity > i {
  background: var(--teal);
}

.meter.health > i {
  background: var(--berry);
}

.tag-row,
.actions-grid,
.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
}

.table-panel {
  flex: 1;
  min-height: 0;
}

.table-board {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(380px, 1.22fr);
  gap: 12px;
}

.camp-map {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(231, 220, 200, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(231, 220, 200, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 46%, rgba(227, 104, 61, 0.16), transparent 8rem),
    rgba(0, 0, 0, 0.18);
  background-size: 28px 28px, 28px 28px, auto, auto;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.campfire-mark {
  align-self: center;
  justify-self: center;
  width: 132px;
  aspect-ratio: 1;
  border: 1px solid rgba(227, 104, 61, 0.46);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffccb5;
  background:
    radial-gradient(circle, rgba(227, 104, 61, 0.42), transparent 48%),
    rgba(0, 0, 0, 0.28);
  box-shadow: 0 0 42px rgba(227, 104, 61, 0.24);
  font-family: var(--serif);
  font-size: 18px;
  text-align: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 10px;
}

.game-card {
  position: relative;
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 22, 18, 0.88);
  overflow: hidden;
  isolation: isolate;
}

.game-card.clickable {
  cursor: pointer;
}

.game-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(214, 177, 95, 0.24);
}

.game-card img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
  background: rgba(0, 0, 0, 0.2);
}

img[data-action="open-card"] {
  cursor: zoom-in;
}

img[data-action="open-card"]:focus-visible {
  outline: 3px solid rgba(214, 177, 95, 0.72);
  outline-offset: 2px;
}

.game-card .card-body {
  padding: 8px;
}

.card-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.card-type {
  margin-top: 4px;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.35;
}

.card-use {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-top: 6px;
  padding: 0 6px;
  border: 1px solid rgba(228, 181, 87, 0.24);
  border-radius: 5px;
  color: #e9d39b;
  background: rgba(228, 181, 87, 0.08);
  font-size: 11px;
  line-height: 1;
}

.card-use.usable {
  border-color: rgba(156, 204, 117, 0.28);
  color: #d5efc3;
  background: rgba(156, 204, 117, 0.08);
}

.card-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.ability-stack {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.ability-line {
  border: 1px solid rgba(214, 177, 95, 0.2);
  border-radius: 6px;
  padding: 6px;
  background: rgba(214, 177, 95, 0.055);
}

.ability-line span {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-bottom: 3px;
  padding: 0 6px;
  border: 1px solid rgba(231, 220, 200, 0.14);
  border-radius: 5px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.18);
  font-size: 10px;
  font-weight: 700;
}

.ability-line p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.hand-panel {
  min-height: 220px;
}

.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.log-rail .controls {
  grid-template-columns: 1fr;
}

.control-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.16);
  min-width: 0;
}

.control-block h3 {
  margin: 0 0 8px;
  color: var(--paper);
  font-size: 13px;
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.control-head h3 {
  margin: 0;
}

.control-head button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.control-block .actions-grid button {
  flex: 1 1 auto;
}

.log-rail .control-block .actions-grid button {
  flex: 1 1 92px;
}

.action-help-grid {
  display: grid;
  gap: 8px;
}

.active-skill-summary {
  margin-bottom: 8px;
  border: 1px solid rgba(103, 169, 160, 0.28);
  border-radius: 8px;
  padding: 8px;
  background:
    linear-gradient(135deg, rgba(103, 169, 160, 0.1), transparent 58%),
    rgba(0, 0, 0, 0.15);
}

.active-skill-summary.used {
  border-color: rgba(231, 220, 200, 0.16);
  opacity: 0.78;
}

.active-skill-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.active-skill-head span,
.active-skill-head i {
  color: var(--soft);
  font-size: 11px;
  font-style: normal;
}

.active-skill-head b {
  min-width: 0;
  color: var(--paper);
  font-size: 13px;
}

.active-skill-copy {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.action-help-button {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
  align-content: center;
  min-height: 58px;
  padding: 8px 10px;
  text-align: left;
}

.action-help-button span {
  font-weight: 700;
  line-height: 1.15;
}

.action-help-button small {
  margin-top: 4px;
  color: var(--soft);
  line-height: 1.25;
  font-size: 11px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.craft-summary {
  margin-top: 8px;
  border: 1px solid rgba(103, 169, 160, 0.22);
  border-radius: 6px;
  padding: 8px;
  color: var(--muted);
  background: rgba(103, 169, 160, 0.07);
  font-size: 12px;
  line-height: 1.45;
}

.craft-summary.blocked {
  border-color: rgba(224, 90, 86, 0.32);
  background: rgba(224, 90, 86, 0.07);
}

.craft-summary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--paper);
  font-weight: 700;
  margin-bottom: 4px;
}

.craft-summary-title b {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.craft-blocked {
  margin-top: 8px;
  border-top: 1px solid rgba(224, 90, 86, 0.22);
  padding-top: 7px;
  color: #ffd1cd;
}

.repair-summary {
  min-height: 38px;
  border: 1px solid rgba(214, 177, 95, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(214, 177, 95, 0.06);
  font-size: 12px;
  line-height: 1.35;
}

.site-row,
.facility-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: rgba(0, 0, 0, 0.18);
  margin-top: 8px;
}

.site-row img,
.facility-row img,
.small-img {
  width: 54px;
  height: 74px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
}

.row-title {
  font-weight: 700;
  font-size: 13px;
}

.row-sub {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

.pending {
  border-color: rgba(228, 181, 87, 0.62);
  background:
    linear-gradient(135deg, rgba(228, 181, 87, 0.14), transparent 46%),
    var(--panel);
}

.hand-limit-pending {
  border-color: rgba(224, 90, 86, 0.62);
  background:
    linear-gradient(135deg, rgba(224, 90, 86, 0.13), transparent 45%),
    var(--panel);
}

.hand-limit-copy {
  border: 1px solid rgba(224, 90, 86, 0.26);
  border-radius: 6px;
  padding: 10px;
  color: #ffd8d4;
  background: rgba(224, 90, 86, 0.08);
  line-height: 1.5;
  font-size: 13px;
}

.pending-title {
  color: var(--warn);
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 8px;
}

.progress-line {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(231, 220, 200, 0.12);
}

.progress-line > i {
  display: block;
  height: 100%;
  max-width: 100%;
  background: linear-gradient(90deg, var(--ember), var(--gold));
}

.log-list {
  overflow: auto;
  max-height: calc(100vh - 150px);
  padding-right: 4px;
}

.log-rail .log-list {
  max-height: 340px;
}

.log-item {
  border-left: 2px solid var(--line-strong);
  padding: 8px 0 8px 10px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.log-item.good {
  border-color: var(--good);
  color: #d5efc3;
}

.log-item.warn {
  border-color: var(--warn);
  color: #efdda8;
}

.log-item.danger {
  border-color: var(--danger);
  color: #ffd2cf;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(520px, 1.25fr);
  gap: 14px;
}

.scenario-panel {
  margin-bottom: 14px;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 10px;
}

.scenario-card {
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background:
    linear-gradient(145deg, rgba(103, 169, 160, 0.08), transparent 48%),
    rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.scenario-card:hover {
  transform: translateY(-2px);
  border-color: rgba(214, 177, 95, 0.58);
  background:
    linear-gradient(145deg, rgba(103, 169, 160, 0.12), transparent 48%),
    rgba(0, 0, 0, 0.22);
}

.scenario-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(214, 177, 95, 0.18);
}

.scenario-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.scenario-code {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.scenario-name {
  margin-top: 10px;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
}

.scenario-goal {
  min-height: 42px;
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.character-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease;
}

.character-card:hover {
  transform: translateY(-2px);
  border-color: rgba(214, 177, 95, 0.58);
}

.character-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(214, 177, 95, 0.18);
}

.character-card.taken {
  opacity: 0.45;
  cursor: not-allowed;
}

.character-card img {
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.player-ability {
  margin-top: 8px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--soft);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: min(440px, calc(100vw - 36px));
  border: 1px solid rgba(224, 90, 86, 0.42);
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffd8d6;
  background: rgba(44, 19, 18, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 8, 7, 0.72);
  backdrop-filter: blur(8px);
}

.catalog-modal {
  width: min(1120px, calc(100vw - 36px));
  max-height: min(820px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: rgba(24, 28, 22, 0.98);
  box-shadow: var(--shadow);
}

.confirm-backdrop {
  z-index: 6;
}

.confirm-modal {
  width: min(460px, calc(100vw - 36px));
  border: 1px solid rgba(214, 177, 95, 0.36);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(214, 177, 95, 0.1), transparent 38%),
    rgba(24, 28, 22, 0.98);
  box-shadow: var(--shadow);
}

.result-backdrop {
  z-index: 8;
  background:
    radial-gradient(circle at 50% 34%, rgba(224, 90, 86, 0.22), transparent 24rem),
    rgba(5, 6, 5, 0.84);
}

.result-modal {
  width: min(720px, calc(100vw - 36px));
  border: 1px solid rgba(224, 90, 86, 0.64);
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(224, 90, 86, 0.16), transparent 42%),
    rgba(20, 24, 19, 0.98);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.56),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.card-zoom-backdrop {
  z-index: 10;
  background:
    linear-gradient(135deg, rgba(12, 14, 12, 0.92), rgba(6, 8, 7, 0.82)),
    rgba(6, 8, 7, 0.86);
}

.card-zoom-modal {
  width: min(720px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid rgba(214, 177, 95, 0.38);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(214, 177, 95, 0.08), transparent 34%),
    rgba(21, 25, 20, 0.98);
  box-shadow: var(--shadow);
}

.card-zoom-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.card-zoom-frame {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
}

.card-zoom-image {
  width: auto;
  max-width: min(100%, 520px);
  max-height: calc(100vh - 168px);
  border: 1px solid rgba(231, 220, 200, 0.22);
  border-radius: 8px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.26);
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.42);
}

.card-zoom-caption {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.result-modal.victory {
  border-color: rgba(156, 204, 117, 0.66);
  background:
    linear-gradient(135deg, rgba(156, 204, 117, 0.14), transparent 42%),
    linear-gradient(180deg, rgba(214, 177, 95, 0.08), transparent),
    rgba(20, 24, 19, 0.98);
}

.result-kicker {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 13px;
}

.result-modal h2 {
  margin: 8px 0 14px;
  color: #fff7ed;
  font-family: var(--serif);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 0.95;
}

.result-modal.defeat h2 {
  color: #ffd0cc;
}

.result-reason {
  border: 1px solid rgba(231, 220, 200, 0.16);
  border-left-color: currentColor;
  border-radius: 8px;
  padding: 12px;
  color: #ffd1cd;
  background: rgba(0, 0, 0, 0.22);
}

.result-modal.victory .result-reason {
  color: #ddf5c9;
}

.result-reason span {
  display: block;
  margin-bottom: 4px;
  color: var(--soft);
  font-size: 12px;
}

.result-reason p {
  margin: 0;
  color: inherit;
  font-size: 17px;
  line-height: 1.5;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.result-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.result-stats span {
  display: block;
  color: var(--soft);
  font-size: 12px;
}

.result-stats b {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 22px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.confirm-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(214, 177, 95, 0.42);
  border-radius: 50%;
  color: #1d160d;
  background: var(--gold);
  font-family: var(--mono);
  font-weight: 800;
}

.issue-mark {
  border-color: rgba(224, 90, 86, 0.48);
  color: #fff6f4;
  background: var(--danger);
}

.confirm-kicker {
  margin-top: 12px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.confirm-title {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.05;
}

.confirm-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.confirm-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.confirm-stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.18);
}

.confirm-stats span {
  display: block;
  color: var(--soft);
  font-size: 11px;
}

.confirm-stats b {
  display: block;
  margin-top: 3px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 16px;
}

.confirm-warning {
  margin-top: 14px;
  border: 1px solid rgba(228, 181, 87, 0.32);
  border-radius: 6px;
  padding: 10px;
  color: #efdca8;
  background: rgba(228, 181, 87, 0.08);
  font-size: 12px;
  line-height: 1.45;
}

.confirm-warning strong {
  display: block;
  margin-bottom: 6px;
  color: #ffe7aa;
}

.confirm-warning p {
  margin: 6px 0 0;
}

.issue-hint {
  margin-top: 12px;
  border: 1px solid rgba(103, 169, 160, 0.28);
  border-radius: 6px;
  padding: 10px;
  color: #cde9e4;
  background: rgba(103, 169, 160, 0.08);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.catalog-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 0;
}

.catalog-section-title {
  margin-bottom: 8px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
}

.catalog-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding-right: 4px;
}

.catalog-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.catalog-card.locked {
  opacity: 0.68;
}

.catalog-card img {
  width: 56px;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 5px;
  object-fit: cover;
}

.catalog-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.catalog-card-head strong {
  min-width: 0;
  color: var(--paper);
  font-size: 13px;
}

.catalog-effect {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.action-modal {
  width: min(960px, calc(100vw - 36px));
}

.action-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding-right: 4px;
}

.action-detail-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.action-detail-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(214, 177, 95, 0.28);
  border-radius: 8px;
  background: rgba(214, 177, 95, 0.08);
  font-size: 20px;
}

@media (max-width: 1180px) {
  .game,
  .join-screen,
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .controls,
  .table-board {
    grid-template-columns: 1fr;
  }

  .log-list {
    max-height: 420px;
  }

  .catalog-columns {
    grid-template-columns: 1fr;
  }

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .split,
  .stat-grid,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .hand-grid,
  .card-grid,
  .scenario-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }

  .card-zoom-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 10px;
  }

  .card-zoom-image {
    max-height: calc(100vh - 150px);
  }

  .scenario-card {
    min-height: 170px;
  }
}
