:root {
  color-scheme: dark;
  --bg: #111412;
  --felt: #1b2b25;
  --ink: #f5ead8;
  --muted: #b9ad9b;
  --line: rgba(245, 234, 216, 0.16);
  --gold: #d5aa5c;
  --red: #c95c5c;
  --blue: #6b9bd6;
  --green: #6ba66f;
  --violet: #a17bd1;
  --shadow: rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(213, 170, 92, 0.16), transparent 34rem),
    linear-gradient(135deg, #0d0f0e 0%, #17211d 48%, #101211 100%);
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  width: min(1600px, 100%);
  height: 100svh;
  min-height: 0;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  overflow: hidden;
}

.topbar,
.timeline,
.boss-panel,
.play-area,
.action-panel,
.modal-panel {
  background: rgba(21, 24, 22, 0.82);
  border: 1px solid var(--line);
  box-shadow: 0 18px 54px var(--shadow);
}

.topbar {
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.run-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.run-stats span,
.status-row span {
  min-height: 32px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(245, 234, 216, 0.06);
  font-size: 0.82rem;
}

.timeline {
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.timeline-item {
  min-height: 86px;
  padding: 10px;
  border-radius: 7px;
  color: var(--ink);
  background: rgba(245, 234, 216, 0.05);
  border: 1px solid transparent;
  text-align: left;
}

.timeline-item span,
.timeline-item small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.timeline-item strong {
  display: block;
  margin: 5px 0;
  line-height: 1.1;
}

.timeline-item.current {
  border-color: var(--gold);
  background: rgba(213, 170, 92, 0.14);
}

.timeline-item.overtime {
  border-style: dashed;
}

.timeline-item.past {
  opacity: 0.56;
}

.combat-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(460px, 2fr) minmax(280px, 0.95fr);
  gap: 14px;
  overflow: hidden;
}

.boss-panel,
.play-area,
.action-panel {
  min-height: 0;
  border-radius: 8px;
}

.boss-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.boss-portrait {
  min-height: 190px;
  border-radius: 7px;
  border: 1px solid var(--line);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.1), transparent 35%),
    linear-gradient(45deg, #232323, #3a3329);
  box-shadow: inset 0 0 34px rgba(245, 234, 216, 0.08), 0 0 0 rgba(213, 170, 92, 0);
  animation: boss-breathe 5.8s ease-in-out infinite;
  transition: box-shadow 180ms ease, border-color 180ms ease, filter 180ms ease;
}

.boss-portrait::before,
.boss-portrait::after {
  content: "";
  position: absolute;
  inset: 20%;
  border: 2px solid rgba(245, 234, 216, 0.35);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: 1;
}

.boss-portrait::before {
  animation: boss-rune-spin 8s ease-in-out infinite;
}

.boss-portrait::after {
  inset: 34%;
  border-color: rgba(213, 170, 92, 0.55);
  transform: rotate(0deg);
  animation: boss-core-morph 4.6s ease-in-out infinite;
}

.boss-portrait.intent-attack,
.boss-portrait.intent-overtime {
  border-color: rgba(213, 94, 81, 0.72);
  box-shadow: inset 0 0 42px rgba(213, 94, 81, 0.18), 0 0 28px rgba(213, 94, 81, 0.18);
  animation-duration: 3.2s;
}

.boss-portrait.intent-attack::after,
.boss-portrait.intent-overtime::after {
  border-color: rgba(213, 94, 81, 0.72);
  animation-duration: 2.8s;
}

.boss-portrait.intent-defend,
.boss-portrait.intent-lock {
  border-color: rgba(89, 160, 107, 0.66);
  box-shadow: inset 0 0 38px rgba(89, 160, 107, 0.14), 0 0 22px rgba(89, 160, 107, 0.13);
}

.boss-portrait.intent-defend::after,
.boss-portrait.intent-lock::after {
  border-color: rgba(89, 160, 107, 0.68);
}

.boss-portrait.intent-buff,
.boss-portrait.intent-status {
  border-color: rgba(139, 111, 184, 0.7);
  box-shadow: inset 0 0 38px rgba(139, 111, 184, 0.16), 0 0 24px rgba(139, 111, 184, 0.13);
}

.boss-portrait.intent-buff::after,
.boss-portrait.intent-status::after {
  border-color: rgba(139, 111, 184, 0.7);
}

.boss-portrait.warden {
  background: linear-gradient(135deg, #26342f, #655a42);
}

.boss-portrait.prism {
  background: conic-gradient(from 20deg, #26342f, #355d72, #6e4f81, #8c6c3c, #26342f);
}

.boss-portrait.bell {
  background: radial-gradient(circle, #8d6b3f, #2a2421 68%);
}

.boss-portrait.vessel {
  background: radial-gradient(circle at 50% 38%, #f4ead6, #765c85 28%, #111412 70%);
}

.boss-portrait.maw {
  background: radial-gradient(circle at 50% 60%, #8b1a1a, #3a0e0e 55%, #1a0505 100%);
}

.boss-portrait.spire {
  background: linear-gradient(180deg, #3a3a4a, #5c5c7a 30%, #2a2a3a 60%, #4a4a5a);
}

.boss-portrait.shade {
  background: radial-gradient(ellipse at 50% 40%, rgba(200, 190, 220, 0.25), #1e1a2e 40%, #0a0814 80%);
}

.boss-portrait.pyre {
  background: conic-gradient(from 45deg, #4a1a0a, #8b3a1a, #c45a20, #8b3a1a, #4a1a0a);
}

.boss-portrait.grave_monarch {
  background: linear-gradient(135deg, #1a0a2e, #3a1a4e 40%, #5a2a3a 70%, #2a0a1a);
}

.boss-portrait.veilpiercer {
  background: radial-gradient(ellipse at 30% 50%, rgba(120, 80, 160, 0.5), #1a1028 40%, #0a0614 85%);
}

.boss-portrait.null_crown {
  background: conic-gradient(from 0deg, #2a2a3a, #4a4a6a, #8a8aaa, #4a4a6a, #2a2a3a);
}

.boss-portrait.mirror_tyrant {
  background: linear-gradient(160deg, #3a3a4a, #6a6a8a 30%, #aaaacc 50%, #6a6a8a 70%, #3a3a4a);
}

.boss-portrait.furnace_apostle {
  background: radial-gradient(circle at 50% 60%, #c45a10, #8a3a0a 40%, #3a1a05 80%);
}

.boss-portrait.thorn_matriarch {
  background: radial-gradient(circle at 50% 45%, #2a5a2a, #1a3a1a 50%, #0a1a0a 90%);
}

.boss-portrait.tax_collector {
  background: linear-gradient(135deg, #3a3a2a, #6a6a3a 40%, #4a4a2a 70%, #2a2a1a);
}

.boss-portrait.bellringer {
  background: radial-gradient(circle, #c8a84a, #5a4a2a 50%, #2a2418 80%);
}

.boss-portrait.gilded_hydra {
  background: conic-gradient(from 30deg, #6a5a1a, #aa9a2a, #c8b83a, #aa9a2a, #6a5a1a);
}

.boss-portrait.ossuary {
  background: linear-gradient(180deg, #4a4a4a, #8a8a7a 30%, #5a5a4a 60%, #3a3a2a);
}

.boss-portrait.velvet_duelist {
  background: radial-gradient(ellipse at 40% 40%, rgba(140, 80, 120, 0.4), #2a1a3a 45%, #140a1e 85%);
}

.boss-portrait.ashen_saint {
  background: conic-gradient(from 60deg, #4a2a1a, #7a4a2a, #aa6a3a, #7a4a2a, #4a2a1a);
}

.boss-portrait.cipher_engine {
  background: linear-gradient(135deg, #1a2a3a, #2a4a6a 40%, #4a6a8a 60%, #2a3a4a);
}

.boss-portrait.bloodmoon_stag {
  background: radial-gradient(circle at 50% 30%, #8a2a3a, #4a1a2a 40%, #1a0a1a 80%);
}

.boss-portrait.archivist {
  background: conic-gradient(from 90deg, #3a3a5a, #5a5a8a, #8a8aba, #5a5a8a, #3a3a5a);
}

.boss-portrait.pale_executor {
  background: linear-gradient(180deg, #e0dcd0, #8a8a8a 30%, #3a3a3a 70%, #1a1a1a);
}

.meter-row,
.player-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.player-strip > div {
  min-width: 0;
}

.meter-row span,
.player-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.77rem;
}

.deck-hud {
  flex: 1.7;
}

.relic-hud {
  flex: 1;
}

.bonus-hud strong {
  color: var(--gold);
}

.deck-hud small,
.relic-hud small {
  display: block;
  max-width: 18rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-hud small {
  max-width: none;
  white-space: normal;
}

.meter {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(245, 234, 216, 0.1);
}

.meter div {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 180ms ease;
}

.status-row {
  min-height: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.intent-box,
.trait-panel,
.preview,
.relic-chip {
  padding: 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(245, 234, 216, 0.055);
}

.intent-box span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.trait-panel {
  display: grid;
  gap: 9px;
}

.trait-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trait-tags span {
  padding: 4px 7px;
  border-radius: 999px;
  color: #17130d;
  background: var(--gold);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.trait-panel dl {
  margin: 0;
  display: grid;
  gap: 7px;
}

.trait-panel div {
  min-width: 0;
}

.trait-panel dt {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.trait-panel dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.trait-help {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 0.74rem;
}

.intent-box strong {
  display: block;
  margin: 4px 0;
}

.intent-box p,
.passive-text,
.preview p,
.relic-list p {
  color: var(--muted);
  line-height: 1.45;
}

.play-area {
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: 1fr minmax(120px, 0.42fr);
  gap: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(213, 170, 92, 0.13), transparent 20rem),
    rgba(21, 24, 22, 0.82);
}

.table-center {
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(245, 234, 216, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(245, 234, 216, 0.04) 1px, transparent 1px),
    var(--felt);
  background-size: 34px 34px;
  border: 1px solid rgba(245, 234, 216, 0.12);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.player-strip {
  padding: 10px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
}

.hand-zone {
  min-height: 0;
  align-self: end;
  display: grid;
  grid-template-columns: repeat(8, minmax(72px, 1fr));
  gap: 10px;
}

.card-slot {
  aspect-ratio: 0.72;
  min-height: 118px;
  position: relative;
  overflow: visible;
}

.card-slot.empty {
  border-radius: 8px;
  border: 1px dashed rgba(245, 234, 216, 0.12);
  background: rgba(0, 0, 0, 0.08);
}

.card {
  --card-glow: rgba(213, 170, 92, 0.32);
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 10px;
  border-radius: 8px;
  color: #211b16;
  background: #f2e6d4;
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: -35% -70%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.36) 48%, transparent 58%);
  opacity: 0.2;
  pointer-events: none;
  transform: translateX(-58%) skewX(-14deg);
  animation: card-sheen 6.8s ease-in-out infinite;
}

.card-slot:nth-child(2n) .card::before {
  animation-delay: 1.1s;
}

.card-slot:nth-child(3n) .card::before {
  animation-delay: 2.2s;
}

.card:hover {
  transform: translateY(-5px);
  border-color: rgba(213, 170, 92, 0.62);
  box-shadow: 0 13px 24px rgba(0, 0, 0, 0.3), 0 0 22px var(--card-glow);
}

.card.selected {
  transform: translateY(-12px);
  border-color: var(--gold);
  box-shadow: 0 18px 30px rgba(213, 170, 92, 0.23), 0 0 24px var(--card-glow);
  animation: selected-card-glow 1.8s ease-in-out infinite;
}

.card.locked::after {
  content: "LOCK";
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 6px;
  border-radius: 4px;
  color: #f7ead7;
  background: #8d3d3d;
  font-size: 0.65rem;
  font-weight: 900;
}

.card .rank {
  display: block;
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.card .suit {
  margin: 12px auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  animation: suit-heartbeat 3.8s ease-in-out infinite;
  transition: border-radius 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.card:hover .suit,
.card.selected .suit {
  border-radius: 34% 66% 38% 62%;
  transform: rotate(-6deg) scale(1.08);
  box-shadow: 0 0 18px var(--card-glow);
  animation: selected-suit-morph 1.5s ease-in-out infinite;
}

.card small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  color: rgba(33, 27, 22, 0.65);
  font-weight: 800;
  text-align: center;
}

.card.hearts .suit {
  color: var(--red);
}

.card.hearts {
  --card-glow: rgba(213, 94, 81, 0.34);
}

.card.spades .suit {
  color: #1a1a2e;
}

.card.spades {
  --card-glow: rgba(26, 26, 46, 0.36);
}

.card.clubs .suit {
  color: #1a1a2e;
}

.card.clubs {
  --card-glow: rgba(26, 26, 46, 0.36);
}

.card.diamonds .suit {
  color: var(--red);
}

.card.diamonds {
  --card-glow: rgba(213, 94, 81, 0.34);
}

.combat-log {
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
}

.combat-log p {
  margin: 0;
  padding: 5px 0;
  color: var(--muted);
  border-bottom: 1px solid rgba(245, 234, 216, 0.07);
  font-size: 0.88rem;
}

.action-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.preview-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.preview-numbers div {
  padding: 10px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.2);
}

.preview-numbers span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.preview-numbers strong {
  font-size: 1.35rem;
}

.preview-numbers small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row button,
.ghost,
.reward-card {
  min-height: 44px;
  border-radius: 7px;
  color: var(--ink);
  background: rgba(245, 234, 216, 0.08);
  border: 1px solid var(--line);
  cursor: pointer;
}

.button-row button.primary {
  color: #17130d;
  background: var(--gold);
  border-color: transparent;
  font-weight: 900;
}

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

.ghost {
  width: 100%;
}

.relic-list {
  overflow: auto;
  display: grid;
  gap: 8px;
}

.relic-chip strong,
.relic-chip span {
  display: block;
}

.relic-chip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.modal-backdrop.hidden,
.hidden {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100svh - 44px);
  overflow: auto;
  border-radius: 8px;
  padding: 22px;
}

.modal-panel > p {
  color: var(--muted);
}

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

.reward-card {
  min-height: 170px;
  padding: 14px;
  text-align: left;
}

.reward-card span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reward-card strong {
  display: block;
  margin: 8px 0;
  font-size: 1.05rem;
}

.reward-tags {
  min-height: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reward-tags small {
  padding: 3px 6px;
  border-radius: 999px;
  color: #17130d;
  background: rgba(213, 170, 92, 0.88);
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reward-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.35;
}

@keyframes boss-breathe {
  0%,
  100% {
    filter: saturate(1) brightness(1);
    transform: scale(1);
  }

  50% {
    filter: saturate(1.12) brightness(1.06);
    transform: scale(1.012);
  }
}

@keyframes boss-rune-spin {
  0%,
  100% {
    border-radius: 6%;
    transform: rotate(45deg) scale(1);
  }

  50% {
    border-radius: 28%;
    transform: rotate(60deg) scale(0.92);
  }
}

@keyframes boss-core-morph {
  0%,
  100% {
    border-radius: 8%;
    opacity: 0.72;
    transform: rotate(0deg) scale(1);
  }

  50% {
    border-radius: 42% 18% 42% 18%;
    opacity: 1;
    transform: rotate(18deg) scale(1.08);
  }
}

@keyframes card-sheen {
  0%,
  62%,
  100% {
    opacity: 0;
    transform: translateX(-58%) skewX(-14deg);
  }

  72% {
    opacity: 0.24;
  }

  86% {
    opacity: 0;
    transform: translateX(58%) skewX(-14deg);
  }
}

@keyframes selected-card-glow {
  0%,
  100% {
    box-shadow: 0 18px 30px rgba(213, 170, 92, 0.22), 0 0 20px var(--card-glow);
  }

  50% {
    box-shadow: 0 20px 34px rgba(213, 170, 92, 0.32), 0 0 34px var(--card-glow);
  }
}

@keyframes suit-heartbeat {
  0%,
  100% {
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }

  50% {
    border-radius: 42% 58% 48% 52%;
    box-shadow: 0 0 10px var(--card-glow);
  }
}

@keyframes selected-suit-morph {
  0%,
  100% {
    border-radius: 34% 66% 38% 62%;
    box-shadow: 0 0 14px var(--card-glow);
  }

  50% {
    border-radius: 62% 38% 64% 36%;
    box-shadow: 0 0 24px var(--card-glow);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .combat-grid {
    grid-template-columns: 1fr;
  }

  .boss-panel {
    display: grid;
    grid-template-columns: 180px 1fr;
  }

  .boss-portrait {
    min-height: 160px;
    grid-row: span 5;
  }

  .action-panel {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
  }

  .relic-list {
    grid-column: span 2;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .run-stats {
    justify-content: flex-start;
  }

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

  .boss-panel,
  .action-panel {
    display: flex;
  }

  .hand-zone {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }

  .card-slot {
    min-height: 104px;
  }

  .player-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .relic-hud {
    grid-column: span 2;
  }

  .deck-hud {
    grid-column: span 2;
  }

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