:root {
  --felt-1: #21412f;
  --felt-2: #14231d;
  --felt-3: #0b1511;
  --gold: #d9b25f;
  --gold-soft: rgba(217, 178, 95, 0.35);
  --text: #efe6d2;
  --text-muted: #a9b5a8;
  --paper: #f4e9cf;
  --paper-2: #e9d9b4;
  --ink: #2b2118;
  --ink-muted: #6b5a45;
  --ink-dark: #2a1f0e;
  --ink-print: #1d1710;
  --rule-print: #b9a888;
  --tone-good: #2f7a3e;
  --tone-bad: #a12f2b;
  --deck-wine: #7a2a33;
  --deck-teal: #1f5f63;
  --deck-indigo: #3c3f7a;
  --deck-rust: #8a4b1c;
  --deck-violet: #5a2d73;
  --ap-careful: #c97a16;
  --ap-clever: #2f63b8;
  --ap-flashy: #2f8a4a;
  --ap-forceful: #b8322f;
  --ap-quick: #6f9a1c;
  --ap-sneaky: #7d3fa3;

  --gold-ink: #8a6417;
  --radius: 14px;
  --card-w: 240px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  background: var(--felt-3);
}

body {
  font-family: "Alegreya Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background-color: var(--felt-2);
  background-image:
    radial-gradient(ellipse at 50% 0%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 4px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  padding: 8px 14px;
  background: var(--gold);
  color: var(--ink);
  border-radius: 8px;
  z-index: 100;
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  text-align: center;
  padding: 40px 16px 8px;
}

.logo {
  font-family: "MedievalSharp", "Alegreya SC", serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  color: var(--gold);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 30px rgba(217, 178, 95, 0.18);
}

.tagline {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.table {
  max-width: 1240px;
  margin: 0 auto;
  transition: max-width 0.2s ease-out;
  padding: 16px 16px 40px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
  margin: 20px 0 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #e6c477, var(--gold));
  color: var(--ink-dark);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(217, 178, 95, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(239, 230, 210, 0.22);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--gold-soft);
}

.btn-small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(239, 230, 210, 0.22);
  transition: background-color 0.2s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s var(--ease-out);
}

.switch input:checked + .switch-track {
  background: var(--gold);
  border-color: var(--gold);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
  background: var(--ink-dark);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.switch-label {
  color: var(--text);
  font-weight: 500;
}

.notice {
  max-width: 720px;
  margin: -8px auto 24px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(217, 178, 95, 0.12);
  border: 1px solid var(--gold-soft);
  color: var(--text);
  text-align: center;
  font-size: 0.95rem;
}

.deck-tabs {
  display: none;
}

.decks {
  --cols: 4;
  --gap: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.decks[data-count="5"] {
  --cols: 5;
  --gap: 18px;
}

.decks > .deck {
  flex: 0 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  min-width: 0;
}

.deck {
  --deck-color: var(--deck-wine);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 12px 18px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.05);
}


.deck-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  max-width: var(--card-w);
  gap: 8px;
}

.deck-title {
  font-family: "Alegreya SC", serif;
  font-size: 1.2rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--deck-color);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.deck-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.deck-stage {
  position: relative;
  width: 100%;
  max-width: var(--card-w);
  aspect-ratio: 5 / 7;
  perspective: 1200px;
}

.deck-stage::before,
.deck-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--deck-color);
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: opacity 0.3s;
}

.deck-stage::before {
  transform: translate(6px, 7px) rotate(2.2deg);
  filter: brightness(0.55);
}

.deck-stage::after {
  transform: translate(3px, 3px) rotate(1deg);
  filter: brightness(0.75);
}

.deck-stage.is-empty::before,
.deck-stage.is-empty::after {
  opacity: 0;
}

.card {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease-out);
  border-radius: var(--radius);
}

.card:hover .card-inner {
  transform: translateY(-4px);
}

.card.is-revealed .card-inner {
  transform: rotateY(180deg);
}

.card.is-revealed:hover .card-inner {
  transform: rotateY(180deg) translateY(-4px);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.card-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.14), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 6px, transparent 6px 12px),
    var(--deck-color);
  border: 2px solid rgba(0, 0, 0, 0.4);
  color: rgba(255, 244, 220, 0.92);
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px solid rgba(217, 178, 95, 0.55);
  border-radius: 9px;
}

.card-back::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(217, 178, 95, 0.25);
  border-radius: 6px;
}

.back-emblem {
  font-size: 2.6rem;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.back-title {
  font-family: "MedievalSharp", serif;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: var(--gold);
}

.back-name {
  font-family: "Alegreya SC", serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.back-hint {
  position: absolute;
  bottom: 26px;
  left: 24px;
  right: 24px;
  text-align: center;
  line-height: 1.25;
  font-size: 0.8rem;
  opacity: 0.7;
}

.card-front {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.6), transparent 55%),
    linear-gradient(160deg, var(--paper), var(--paper-2));
  color: var(--ink);
  border: 2px solid rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  font-family: "Alegreya", Georgia, serif;
}

.card-front::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--deck-color);
}

.front-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 14px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 33, 24, 0.3) transparent;
}

.front-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--deck-color);
}

.badge {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(125, 63, 163, 0.14);
  color: #6a2f8f;
  border: 1px solid rgba(125, 63, 163, 0.35);
}

.front-name {
  font-family: "Alegreya SC", serif;
  font-size: 1.3rem;
  line-height: 1.1;
  color: var(--ink);
}

.front-text {
  font-size: 1rem;
  line-height: 1.38;
  white-space: pre-line;
}

.front-text.is-centered {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.1rem;
  padding: 0 4px;
}

.front-aspect {
  font-size: 0.86rem;
  line-height: 1.32;
  white-space: pre-line;
}

.front-aspect strong {
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 2px;
}

.front-quote {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(43, 33, 24, 0.18);
  font-style: italic;
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--ink-muted);
  white-space: pre-line;
}

.approaches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  list-style: none;
}

.approach {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.84rem;
  color: rgba(43, 33, 24, 0.45);
}

.approach-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid currentColor;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.approach.is-good {
  color: var(--ink);
  font-weight: 700;
}

.approach.is-good .approach-mark {
  background: var(--ap);
  border-color: var(--ap);
  color: #fff;
}

.approach[data-ap="careful"] { --ap: var(--ap-careful); }
.approach[data-ap="clever"] { --ap: var(--ap-clever); }
.approach[data-ap="flashy"] { --ap: var(--ap-flashy); }
.approach[data-ap="forceful"] { --ap: var(--ap-forceful); }
.approach[data-ap="quick"] { --ap: var(--ap-quick); }
.approach[data-ap="sneaky"] { --ap: var(--ap-sneaky); }

.card.is-entering {
  animation: cardEnter 0.45s var(--ease-out) both;
}

.card.is-leaving {
  pointer-events: none;
  animation: cardLeave 0.42s ease-in forwards;
  z-index: 2;
}

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

@keyframes cardLeave {
  to {
    opacity: 0;
    transform: translate(70%, 10%) rotate(14deg);
  }
}

.decks > .deck {
  transition: opacity 0.2s ease-in, transform 0.2s ease-in;
}

.decks.is-switching > .deck {
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
}

.decks.is-entering > .deck {
  animation: deckEnter 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes deckEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.deck-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  border-radius: var(--radius);
  border: 2px dashed rgba(239, 230, 210, 0.2);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.skeleton {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.04) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.deck-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: var(--card-w);
}

.deck-actions .btn {
  flex: 1;
  padding: 0 10px;
}

.hint {
  margin-top: 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

kbd {
  font-family: inherit;
  font-size: 0.85em;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid rgba(239, 230, 210, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 36px;
}

.story {
  padding: 22px 24px 24px;
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(244, 233, 207, 0.97), rgba(233, 217, 180, 0.97));
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  scroll-margin-top: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-family: "MedievalSharp", "Alegreya SC", serif;
  font-weight: 400;
  font-size: 1.6rem;
}

.story .btn-ghost {
  color: var(--ink);
  border-color: rgba(43, 33, 24, 0.25);
  background: rgba(255, 255, 255, 0.35);
}

.story .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(43, 33, 24, 0.45);
}

.story-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  font-family: "Alegreya", Georgia, serif;
}

.story-list dt {
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-top: 4px;
  color: var(--c, var(--ink-muted));
}

.story-list dd {
  font-size: 1.05rem;
  line-height: 1.45;
}

.story-list dd.is-empty {
  color: rgba(43, 33, 24, 0.45);
  font-style: italic;
}

.story-list dt.is-question {
  color: var(--gold-ink);
  padding-top: 10px;
  border-top: 1px solid rgba(43, 33, 24, 0.15);
  margin-top: 4px;
}

.story-list dt.is-question + dd {
  padding-top: 8px;
  border-top: 1px solid rgba(43, 33, 24, 0.15);
  margin-top: 4px;
}

.story-list dd.story-question {
  font-weight: 700;
  font-style: italic;
  font-size: 1.12rem;
}

.story-list dd.is-fresh {
  animation: fresh 0.9s ease;
}

@keyframes fresh {
  from { background: rgba(217, 178, 95, 0.45); }
  to { background: transparent; }
}

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 16px 32px;
  opacity: 0.75;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #0e1a15;
  border: 1px solid var(--gold-soft);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease-out);
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 22px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(239, 230, 210, 0.14);
}

.mode-tab {
  min-height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab[aria-selected="true"] {
  background: var(--gold);
  color: var(--ink-dark);
}

body[data-mode="core"] .table {
  max-width: 1440px;
}

.filters {
  display: flex;
  align-items: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chip {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(239, 230, 210, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--gold-soft);
}

.chip[aria-pressed="true"] {
  background: rgba(217, 178, 95, 0.18);
  border-color: var(--gold);
  color: var(--gold);
}

.badge-genre {
  background: rgba(43, 33, 24, 0.07);
  color: var(--ink-muted);
  border-color: rgba(43, 33, 24, 0.2);
}

.front-skill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.original {
  font-family: "Alegreya", Georgia, serif;
  font-style: italic;
  font-size: 0.78rem;
  line-height: 1.2;
  opacity: 0.7;
}

.original:empty {
  display: none;
}

.front-skill .original {
  padding-left: 10px;
  color: var(--ink-muted);
}

.dice-result .original {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: rgba(43, 33, 24, 0.07);
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.skill-rating {
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--deck-color);
  color: #fff;
  text-align: center;
}

.dice {
  padding: 22px 24px 24px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(217, 178, 95, 0.22);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.dice .panel-head h2 {
  color: var(--gold);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(239, 230, 210, 0.14);
}

.segmented button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.segmented button[aria-checked="true"] {
  background: rgba(217, 178, 95, 0.2);
  color: var(--gold);
}

.dice-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 8px 0 14px;
}

.die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--paper), var(--paper-2));
  color: var(--ink);
  font-family: "Alegreya Sans", sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 6px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s var(--ease-out), opacity 0.2s;
}

.die[data-value="1"] { color: var(--tone-good); }
.die[data-value="-1"] { color: var(--tone-bad); }
.die.is-idle { opacity: 0.35; }

.die.is-rolling {
  animation: tumble 0.26s linear infinite;
}

.die:nth-child(2).is-rolling { animation-delay: -0.07s; }
.die:nth-child(3).is-rolling { animation-delay: -0.13s; }
.die:nth-child(4).is-rolling { animation-delay: -0.19s; }

@keyframes tumble {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-8px) rotate(-12deg); }
  50% { transform: translateY(0) rotate(0); }
  75% { transform: translateY(-5px) rotate(10deg); }
  100% { transform: translateY(0) rotate(0); }
}

.dice-result {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 92px;
  margin-bottom: 14px;
  text-align: center;
}

.result-total {
  font-family: "Alegreya SC", serif;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-ladder {
  font-family: "MedievalSharp", serif;
  font-size: 1.25rem;
  color: var(--gold);
}

.result-break {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.dice-result[data-tone="great"] .result-total { color: #9fd88a; }
.dice-result[data-tone="bad"] .result-total { color: #ef8f86; }

.dice-result.is-fresh .result-total {
  animation: pop 0.35s var(--ease-out);
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.dice-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 12px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(239, 230, 210, 0.22);
  background: rgba(255, 255, 255, 0.04);
}

.stepper-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}

.stepper-btn:hover {
  background: rgba(217, 178, 95, 0.25);
}

.stepper-value {
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dice-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  margin-top: 12px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) {
  background: rgba(217, 178, 95, 0.12);
}

.link-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.link-btn[hidden] {
  display: none;
}

.dice-meta {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dice-history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  list-style: none;
}

.dice-history:empty {
  display: none;
}

.history-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(239, 230, 210, 0.12);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-item:first-child {
  border-color: var(--gold-soft);
  color: var(--text);
}

.history-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-faces {
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.history-tag {
  font-size: 0.7rem;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(217, 178, 95, 0.2);
  color: var(--gold);
}

.history-item.is-rerolled {
  opacity: 0.5;
  text-decoration: line-through;
}

@media (max-width: 1279px) {
  .decks[data-count="5"] {
    --cols: 3;
  }
}

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

@media (max-width: 1100px) {
  .decks,
  .decks[data-count="5"] {
    --cols: 2;
  }

  :root {
    --card-w: 260px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding-top: 28px;
  }

  .toolbar {
    margin: 16px 0 18px;
  }

  .toolbar .btn-primary {
    width: 100%;
  }

  .deck-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 -16px 12px;
    padding: 2px 16px;
    scrollbar-width: none;
  }

  .deck-tabs::-webkit-scrollbar {
    display: none;
  }

  .deck-tab {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(239, 230, 210, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
  }

  .deck-tab[aria-current="true"] {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink-dark);
  }

  .decks {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -16px;
    padding: 0 16px 8px;
    scroll-padding: 0 16px;
    scrollbar-width: none;
  }

  .decks::-webkit-scrollbar {
    display: none;
  }

  .decks {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .decks > .deck {
    flex: 0 0 86%;
    scroll-snap-align: center;
  }

  .mode-tab {
    padding: 0 14px;
    font-size: 0.92rem;
  }

  .dice {
    padding: 18px 16px 20px;
  }

  .die {
    width: 52px;
    height: 52px;
  }

  :root {
    --card-w: 280px;
  }

  .story {
    padding: 18px 16px 20px;
  }

  .story-list {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .story-list dd {
    margin-bottom: 10px;
  }

  .hint {
    font-size: 0.85rem;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}

@media (hover: none) {
  .hint-kbd {
    display: none;
  }
}

.deck-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lock-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(239, 230, 210, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lock-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--gold-soft);
}

.lock-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lock-btn .lock-shackle {
  transform: translateY(-2px);
  transition: transform 0.2s var(--ease-out);
}

.lock-btn[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink-dark);
}

.lock-btn[aria-pressed="true"] .lock-shackle {
  transform: none;
}

.deck.is-pinned {
  border-color: var(--gold-soft);
  box-shadow: inset 0 0 0 1px rgba(217, 178, 95, 0.25);
}

.deck.is-pinned .card {
  cursor: default;
}

.deck.is-pinned .card-front {
  box-shadow: 0 0 0 2px var(--gold), 0 10px 26px rgba(0, 0, 0, 0.45);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-tools {
  margin-top: 6px;
}

.footer-tools .link-btn {
  font-size: 0.8rem;
}

.print-sheet {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 14mm 12mm;
  }

  html,
  body {
    background: #fff !important;
    color: #000;
  }

  body > *:not(.print-sheet) {
    display: none !important;
  }

  .print-sheet {
    display: block;
    color: var(--ink-print);
    font-family: "Alegreya", Georgia, serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ps-head {
    border-bottom: 2px solid var(--ink-print);
    padding-bottom: 6px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .ps-kicker {
    grid-column: 1 / -1;
    font-family: "Alegreya Sans", sans-serif;
    font-size: 9pt;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }

  .ps-title {
    font-family: "MedievalSharp", "Alegreya SC", serif;
    font-weight: 400;
    font-size: 22pt;
    line-height: 1.1;
  }

  .ps-date {
    font-size: 10pt;
    color: var(--ink-muted);
  }

  .ps-story {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 14px;
    font-size: 11pt;
    line-height: 1.35;
  }

  .ps-story dt {
    font-family: "Alegreya Sans", sans-serif;
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding-top: 2px;
    color: var(--c, var(--ink-muted));
  }

  .ps-question {
    margin: 10px 0 0;
    padding: 8px 12px;
    border: 1.5px solid var(--gold-ink);
    border-radius: 8px;
    font-size: 12pt;
    font-style: italic;
    font-weight: 700;
  }

  .ps-question strong {
    display: block;
    font-family: "Alegreya Sans", sans-serif;
    font-style: normal;
    font-size: 8pt;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-ink);
  }

  .ps-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
    gap: 8px;
    margin-top: 14px;
  }

  .ps-card {
    break-inside: avoid;
  }

  .ps-card .card-face {
    position: relative;
    inset: auto;
    transform: none;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    box-shadow: none;
    border: 1px solid var(--rule-print);
    border-radius: 8px;
    background: #fbf6ea;
    min-height: 0;
  }

  .ps-card .front-body {
    overflow: visible;
    padding: 10px 10px 8px;
    gap: 5px;
  }

  .ps-card .front-name {
    font-size: 12pt;
  }

  .ps-card .front-text,
  .ps-card .front-text.is-centered {
    font-size: 10pt;
    display: block;
    text-align: left;
  }

  .ps-card .front-aspect,
  .ps-card .front-quote,
  .ps-card .approach {
    font-size: 8.5pt;
  }

  .ps-notes {
    margin-top: 14px;
    break-inside: avoid;
  }

  .ps-notes h2 {
    font-family: "Alegreya SC", serif;
    font-size: 11pt;
    margin-bottom: 4px;
  }

  .ps-lines {
    height: 50mm;
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0 9mm,
      #c9bba0 9mm calc(9mm + 0.6pt)
    );
  }
}

.npcs {
  margin-top: 24px;
  padding: 22px 24px 24px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(217, 178, 95, 0.22);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.npcs .panel-head h2 {
  color: var(--gold);
}

.npc-sub {
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.npc-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.npc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 6px;
}

.npc-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed rgba(239, 230, 210, 0.2);
  border-radius: 14px;
  text-align: center;
  color: var(--text-muted);
}

.npc-card {
  --deck-color: var(--deck-wine);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 10%, rgba(255, 255, 255, 0.55), transparent 55%),
    linear-gradient(160deg, var(--paper), var(--paper-2));
  color: var(--ink);
  border-top: 5px solid var(--deck-color);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  font-family: "Alegreya", Georgia, serif;
  transition: opacity 0.2s, filter 0.2s;
}

.npc-card.is-fresh {
  animation: cardEnter 0.45s var(--ease-out);
}

.npc-card.is-down {
  opacity: 0.6;
  filter: grayscale(0.6);
}

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

.npc-role {
  font-family: "Alegreya SC", serif;
  font-size: 1.15rem;
  line-height: 1.15;
}

.npc-quirk {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.npc-tools {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.npc-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(43, 33, 24, 0.2);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.npc-icon:hover {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(43, 33, 24, 0.45);
}

.npc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Alegreya Sans", sans-serif;
}

.badge-level {
  background: rgba(138, 100, 23, 0.14);
  color: var(--gold-ink);
  border-color: rgba(138, 100, 23, 0.4);
  font-size: 0.7rem;
}

.npc-system {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.npc-aspects {
  list-style: none;
  display: grid;
  gap: 2px;
  font-size: 0.92rem;
  line-height: 1.3;
}

.npc-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.npc-line {
  font-size: 0.92rem;
  line-height: 1.3;
}

.npc-line strong {
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.npc-good strong { color: var(--tone-good); }
.npc-bad strong { color: var(--tone-bad); }

.npc-members {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(43, 33, 24, 0.15);
  font-family: "Alegreya Sans", sans-serif;
}

.npc-member {
  display: flex;
  align-items: center;
  gap: 8px;
}

.npc-num {
  min-width: 26px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.stress-boxes {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.stress-box {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 2px solid rgba(43, 33, 24, 0.45);
  background: #fffaf0;
  color: rgba(43, 33, 24, 0.55);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.stress-box[aria-pressed="true"] {
  background: var(--deck-wine);
  border-color: var(--deck-wine);
  color: #fff;
}

.stress-none {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-style: italic;
}

.out-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(43, 33, 24, 0.25);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.out-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.npc-member.is-out .stress-boxes {
  opacity: 0.4;
}

.npc-team {
  font-family: "Alegreya Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold-ink);
}

@media (max-width: 640px) {
  .npcs {
    padding: 18px 16px 20px;
  }

  .npc-controls {
    width: 100%;
  }

  .npc-controls .btn-primary {
    flex: 1 1 100%;
  }

  .stress-box {
    width: 36px;
    height: 36px;
  }
}

@media print {
  .ps-npcs {
    margin-top: 14px;
    break-inside: avoid;
  }

  .ps-npcs h2 {
    font-family: "Alegreya SC", serif;
    font-size: 11pt;
    margin-bottom: 4px;
  }

  .ps-npc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 12px;
  }

  .ps-npc {
    padding: 6px 8px;
    border: 1px solid var(--rule-print);
    border-radius: 6px;
    font-size: 9pt;
    line-height: 1.3;
    break-inside: avoid;
  }

  .ps-npc strong {
    display: block;
    font-size: 10pt;
  }
}

.npc-genre {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 3px 6px 3px 12px;
  border-radius: 999px;
  border: 1px solid rgba(239, 230, 210, 0.22);
  background: rgba(255, 255, 255, 0.04);
}

.npc-genre select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.08)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23efe6d2'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  appearance: none;
  cursor: pointer;
}

.npc-genre select option {
  background: var(--felt-2);
  color: var(--text);
}
