:root {
  --bg: #0a0b10;
  --bg-2: #11131c;
  --panel: #161925;
  --panel-2: #1c2030;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #eef0f6;
  --muted: #8b93a7;
  --accent: #c9a227;
  --accent-2: #e8c547;
  --accent-dim: rgba(201, 162, 39, 0.14);
  --health: #3ecf8e;
  --danger: #e85d5d;
  --danger-dim: rgba(232, 93, 93, 0.14);
  --red: #c41e3a;
  --black: #1a1d26;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --display: "Cinzel", "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  /* Multiplier for rank/suit/type text on cards (Settings → Card text size) */
  --card-font-scale: 1.25;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(201, 162, 39, 0.12), transparent 55%),
    radial-gradient(700px 400px at 100% 80%, rgba(232, 93, 93, 0.06), transparent 50%),
    radial-gradient(600px 360px at 0% 60%, rgba(110, 168, 255, 0.05), transparent 50%),
    var(--bg);
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.back-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(22, 25, 37, 0.9);
  border: 1px solid var(--line);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0 14px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s;
}
.back-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 56px 16px 40px;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen[hidden],
.overlay[hidden],
[hidden] {
  display: none !important;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  border: 1px solid transparent;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #1a1405;
  box-shadow: 0 8px 24px rgba(201, 162, 39, 0.28);
}
.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(201, 162, 39, 0.4);
}
.btn-ghost {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}
.btn-sm {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  font-size: 0.86rem;
  border-radius: 8px;
}
.btn-skip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
  white-space: nowrap;
}
.btn-skip.is-available {
  border-color: rgba(201, 162, 39, 0.45);
  color: var(--accent-2);
  background: var(--accent-dim);
}
.btn-skip.is-available:hover {
  border-color: var(--accent);
  color: #fff2b0;
}
.btn-skip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— Title —— */
.screen-title {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 96px);
  min-height: calc(100dvh - 96px);
  position: relative;
}
.title-glow {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.2), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}
.title-card {
  position: relative;
  text-align: center;
  max-width: 440px;
  padding: 36px 28px;
  background: linear-gradient(165deg, rgba(28, 32, 48, 0.95), rgba(18, 20, 30, 0.98));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.title-card h1,
.brand-mini h1 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.title-card h1 {
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  line-height: 1.05;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #f5e6b0, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  color: var(--muted);
  font-size: 0.98rem;
  margin-bottom: 28px;
}
.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.credit {
  margin-top: 22px;
  font-size: 0.78rem;
  color: #5c6478;
}
.stats-line {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* —— Game layout —— */
.screen-game {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: linear-gradient(145deg, #2a2438, #1a1525);
  border: 1px solid var(--line-strong);
  color: var(--accent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
.brand-mini h1 {
  font-size: 1.15rem;
  line-height: 1.1;
}
.brand-mini p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-bar {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 0.7fr;
  gap: 10px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
}
.mono {
  font-family: var(--mono);
}
.health-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.health-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.health-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2a9d68, var(--health));
  transition: width 0.35s ease, background 0.3s;
}
.health-fill.low {
  background: linear-gradient(90deg, #a33, var(--danger));
}
.health-fill.mid {
  background: linear-gradient(90deg, #b8860b, var(--accent));
}
.health-num {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
}

.section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.muted {
  color: #5c6478;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.weapon-panel,
.room-panel,
.log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.weapon-empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 8px 0;
}
.weapon-active {
  display: flex;
  align-items: center;
  gap: 14px;
}
.weapon-name {
  font-weight: 700;
  font-size: 1rem;
}
.weapon-hint {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}
.weapon-kills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.kill-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
}

.room-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.room-header .section-label {
  margin-bottom: 0;
}
.skip-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.skip-note {
  font-size: 0.68rem;
  max-width: 200px;
  text-align: right;
  line-height: 1.25;
  color: #5c6478;
}
.skip-note.ok {
  color: var(--accent-2);
}
.skip-note.blocked {
  color: #7a8296;
}

.room-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 10px;
  margin-top: 12px;
  align-items: start;
}
.card-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  animation: dealIn 0.28s ease backwards;
}
.card-slot:nth-child(1) { animation-delay: 0.02s; }
.card-slot:nth-child(2) { animation-delay: 0.06s; }
.card-slot:nth-child(3) { animation-delay: 0.1s; }
.card-slot:nth-child(4) { animation-delay: 0.14s; }
.card-slot.is-played {
  opacity: 0.35;
  filter: grayscale(0.45);
  pointer-events: none;
}
.card-slot.is-empty {
  min-height: 0;
}
.empty-slot {
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  border: 1.5px dashed rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

/* Escape — sits in the empty 4th slot of a partial final room */
.escape-slot .escape-card {
  aspect-ratio: 5 / 7;
  width: 100%;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  color: #e8f5e9;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(62, 207, 142, 0.2), transparent 70%),
    linear-gradient(165deg, #1a2e24 0%, #0e1814 100%);
  border: 1.5px solid rgba(62, 207, 142, 0.45);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(62, 207, 142, 0.12),
    inset 0 0 24px rgba(62, 207, 142, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s, border-color 0.15s;
}
.escape-slot .escape-card:hover {
  transform: translateY(-3px);
  border-color: rgba(62, 207, 142, 0.75);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(62, 207, 142, 0.18);
}
.escape-slot .escape-card:focus-visible {
  outline: 2px solid var(--health);
  outline-offset: 2px;
}
.escape-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: grayscale(0.15);
}
.escape-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--health);
}
.escape-sub {
  font-size: 0.68rem;
  color: #8bb89a;
  line-height: 1.25;
  max-width: 7.5em;
}
.act-escape {
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(62, 207, 142, 0.08);
}
.act-escape:hover:not(:disabled) {
  border-color: rgba(62, 207, 142, 0.6);
  background: rgba(62, 207, 142, 0.16);
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.slot-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 4.5rem;
}
.slot-actions.disabled {
  min-height: 0;
}

.act {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  line-height: 1.2;
}
.act:hover:not(:disabled) {
  transform: translateY(-1px);
}
.act:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.act-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.act-sub {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}
.act-sub.dmg { color: #f0a0a0; }
.act-sub.safe,
.act-sub.heal { color: var(--health); }
.act-sub.muted { color: #5c6478; }

.act-bare:hover:not(:disabled) {
  border-color: rgba(232, 93, 93, 0.45);
  background: var(--danger-dim);
}
.act-weapon:hover:not(:disabled),
.act-equip:hover:not(:disabled) {
  border-color: rgba(201, 162, 39, 0.5);
  background: var(--accent-dim);
}
.act-potion:hover:not(:disabled) {
  border-color: rgba(236, 72, 120, 0.45);
  background: rgba(236, 72, 120, 0.12);
}
.act-equip {
  border-color: rgba(201, 162, 39, 0.28);
}
.act-potion {
  border-color: rgba(236, 72, 120, 0.28);
}
.act-bare {
  border-color: rgba(232, 93, 93, 0.22);
}

.room-hint {
  margin-top: 12px;
  font-size: 0.86rem;
  color: var(--muted);
  min-height: 1.3em;
}

@media (max-width: 560px) {
  .room-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .status-bar {
    grid-template-columns: 1fr 1fr;
  }
  .health-stat {
    grid-column: 1 / -1;
  }
  .skip-note {
    max-width: 140px;
  }
}

/* —— Cards base —— */
.card {
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  position: relative;
  user-select: none;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s;
}
.card-slot:not(.is-played) .card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.card-face {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-corner {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-family: var(--mono);
  font-weight: 700;
  font-size: calc(0.92rem * var(--card-font-scale));
  padding: 7px 8px;
}
.card-corner .suit {
  font-size: calc(0.82rem * var(--card-font-scale));
  margin-top: 1px;
}
.card-corner.br {
  right: 0;
  bottom: 0;
  transform: rotate(180deg);
}
.card-corner.tl {
  top: 0;
  left: 0;
}

.card-art {
  position: absolute;
  inset: 18% 12% 22%;
  display: grid;
  place-items: center;
  z-index: 1;
}
.card-art-svg {
  width: min(72%, 64px);
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.card-pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(clamp(1.8rem, 7vw, 2.6rem) * var(--card-font-scale));
  z-index: 1;
  pointer-events: none;
  opacity: 0.92;
}

.card-footer {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 2;
}
.card-type-tag {
  font-size: calc(0.58rem * var(--card-font-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}
.card-value-badge {
  font-family: var(--mono);
  font-size: calc(0.7rem * var(--card-font-scale));
  font-weight: 600;
  opacity: 0.85;
}

/* ========== CLASSIC (default): real playing-card look ========== */
body[data-deck="classic"] .card-face {
  background: linear-gradient(165deg, #ffffff, #f4f1ea);
  border: 1px solid #d0ccc4;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}
body[data-deck="classic"] .card-face.black,
body[data-deck="classic"] .card-face.monster {
  color: #141414;
}
body[data-deck="classic"] .card-face.red,
body[data-deck="classic"] .card-face.weapon,
body[data-deck="classic"] .card-face.potion {
  color: var(--red);
}
body[data-deck="classic"] .card-face.monster .card-type-tag {
  background: rgba(20, 20, 20, 0.08);
  color: #333;
}
body[data-deck="classic"] .card-face.weapon .card-type-tag,
body[data-deck="classic"] .card-face.potion .card-type-tag {
  background: rgba(196, 30, 58, 0.1);
  color: #9a1830;
}
body[data-deck="classic"] .card-face .card-value-badge {
  color: inherit;
  opacity: 0.7;
}
body[data-deck="classic"] .card-pattern {
  opacity: 0;
}
/* Subtle type tint so kinds still read at a glance */
body[data-deck="classic"] .card-face.monster {
  background: linear-gradient(165deg, #fafafa, #ebe8e2);
}
body[data-deck="classic"] .card-face.weapon {
  background: linear-gradient(165deg, #fffef8, #f7f0dc);
}
body[data-deck="classic"] .card-face.potion {
  background: linear-gradient(165deg, #fffafa, #f8ecee);
}

/* ========== INK: dark themed, no green ========== */
body[data-deck="ink"] .card-face.monster.suit-spades {
  color: #e6e0f0;
  background:
    radial-gradient(ellipse 80% 55% at 50% 40%, rgba(120, 100, 160, 0.22), transparent 70%),
    linear-gradient(165deg, #2a2535 0%, #16131c 100%);
  border: 1.5px solid rgba(160, 140, 190, 0.3);
}
body[data-deck="ink"] .card-face.monster.suit-spades .card-art {
  color: #b8a8d0;
}
body[data-deck="ink"] .card-face.monster.suit-spades .card-type-tag {
  background: rgba(160, 140, 190, 0.2);
  color: #d0c4e4;
}

body[data-deck="ink"] .card-face.monster.suit-clubs {
  color: #e4e6ec;
  background:
    radial-gradient(ellipse 80% 55% at 50% 40%, rgba(100, 110, 130, 0.2), transparent 70%),
    linear-gradient(165deg, #23262e 0%, #12141a 100%);
  border: 1.5px solid rgba(140, 150, 170, 0.32);
}
body[data-deck="ink"] .card-face.monster.suit-clubs .card-art {
  color: #a8b0c0;
}
body[data-deck="ink"] .card-face.monster.suit-clubs .card-type-tag {
  background: rgba(140, 150, 170, 0.2);
  color: #c4cad6;
}

body[data-deck="ink"] .card-face.weapon {
  color: #8a5a18;
  background: linear-gradient(145deg, #fff6e0 0%, #e8d4a0 100%);
  border: 1.5px solid rgba(180, 140, 40, 0.5);
}
body[data-deck="ink"] .card-face.weapon .card-art {
  color: #9a7020;
}
body[data-deck="ink"] .card-face.weapon .card-type-tag {
  background: rgba(160, 120, 20, 0.16);
  color: #7a5510;
}

body[data-deck="ink"] .card-face.potion {
  color: #a01840;
  background:
    radial-gradient(ellipse 70% 50% at 50% 70%, rgba(255, 120, 150, 0.28), transparent 65%),
    linear-gradient(165deg, #fff5f8 0%, #f0c8d4 100%);
  border: 1.5px solid rgba(200, 70, 110, 0.4);
}
body[data-deck="ink"] .card-face.potion .card-art {
  color: #c04068;
}
body[data-deck="ink"] .card-face.potion .card-type-tag {
  background: rgba(200, 50, 100, 0.12);
  color: #901838;
}

body[data-deck="ink"] .card-face .card-pattern {
  opacity: 0.25;
  background: repeating-linear-gradient(
    -18deg,
    transparent,
    transparent 7px,
    rgba(255, 255, 255, 0.03) 7px,
    rgba(255, 255, 255, 0.03) 8px
  );
}

/* ========== PARCHMENT ========== */
body[data-deck="parchment"] .card-face {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.35), transparent 50%),
    linear-gradient(165deg, #f3e6c8 0%, #e2d0a8 55%, #d4c090 100%);
  border: 1.5px solid rgba(120, 90, 40, 0.35);
  box-shadow: inset 0 0 20px rgba(90, 60, 20, 0.08);
}
body[data-deck="parchment"] .card-face.black,
body[data-deck="parchment"] .card-face.monster {
  color: #2a2218;
}
body[data-deck="parchment"] .card-face.red,
body[data-deck="parchment"] .card-face.weapon,
body[data-deck="parchment"] .card-face.potion {
  color: #9a2030;
}
body[data-deck="parchment"] .card-face.monster .card-type-tag {
  background: rgba(40, 30, 20, 0.1);
  color: #4a3828;
}
body[data-deck="parchment"] .card-face.weapon .card-type-tag,
body[data-deck="parchment"] .card-face.potion .card-type-tag {
  background: rgba(154, 32, 48, 0.12);
  color: #7a1828;
}
body[data-deck="parchment"] .card-pattern {
  opacity: 0.4;
  background:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
}

/* Mini weapon card */
.mini-card {
  width: 52px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.mini-card .card-face {
  border-radius: 7px;
}
.mini-card .card-corner {
  font-size: 0.7rem;
  padding: 4px 5px;
}
.mini-card .card-corner .suit {
  font-size: 0.62rem;
}
.mini-card .card-art {
  inset: 22% 15% 18%;
}
.mini-card .card-art-svg {
  width: 70%;
}
.mini-card .card-pip {
  font-size: 1.35rem;
}
.mini-card .card-footer {
  display: none;
}

/* Log */
.log {
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
  color: var(--muted);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.log li {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  animation: logIn 0.25s ease;
}
.log li:last-child {
  border-bottom: none;
  color: var(--ink);
}
.log li.good { color: var(--health); }
.log li.bad { color: #f0a0a0; }
.log li.warn { color: var(--accent-2); }
@keyframes logIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 7, 12, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  width: min(440px, 100%);
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  animation: popIn 0.25s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.rules-modal,
.settings-modal {
  width: min(520px, 100%);
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: var(--display);
  font-size: 1.25rem;
}
.rules-body,
.settings-body {
  padding: 16px 20px 22px;
  overflow-y: auto;
  font-size: 0.92rem;
  color: #c5cad8;
}
.rules-body h3 {
  font-size: 0.95rem;
  color: var(--accent-2);
  margin: 16px 0 6px;
  font-family: var(--display);
}
.rules-body p,
.rules-body ul {
  margin-bottom: 8px;
}
.rules-body ul {
  padding-left: 1.1rem;
}
.rules-body li {
  margin-bottom: 6px;
}
.rules-body strong {
  color: var(--ink);
}
.suit-black { color: #c8cce0; }
.suit-red { color: #f0a0a0; }
.rules-credit {
  margin-top: 16px;
  font-size: 0.8rem;
  color: #5c6478;
}

/* Settings */
.settings-field {
  border: none;
  margin: 0;
  padding: 0;
  margin-bottom: 18px;
}
.settings-field legend {
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.settings-help {
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.settings-range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 6px;
}
.settings-range-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  min-width: 3.2em;
  text-align: right;
  color: var(--accent-2);
}
.deck-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deck-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.deck-option:hover {
  border-color: var(--line-strong);
}
.deck-option.is-selected {
  border-color: rgba(201, 162, 39, 0.55);
  background: var(--accent-dim);
}
.deck-option input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.deck-option-name {
  display: block;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.deck-option-blurb {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}
.deck-preview-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.preview-card .card {
  animation: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.preview-card .card:hover {
  transform: none;
}

.end-modal {
  text-align: center;
}
.end-modal h2 {
  font-family: var(--display);
  font-size: 1.6rem;
  margin: 6px 0 12px;
}
.end-modal.win h2 {
  background: linear-gradient(180deg, #f5e6b0, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.end-modal.lose h2 {
  color: #f0a0a0;
}
.end-body {
  color: var(--muted);
  margin-bottom: 16px;
}
.end-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}
.end-stat {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
}

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