@font-face {
  font-family: "Departure Mono";
  src: url("/fonts/DepartureMono-Regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

:root {
  --ink: #281a38;
  --ink-soft: #675c72;
  --paper: #fffaf0;
  --paper-deep: #f5eddc;
  --purple: #5b2b82;
  --purple-dark: #2b1746;
  --yellow: #ffcf4a;
  --pink: #ef6c8f;
  --green: #1a8165;
  --red: #b53d4d;
  --line: rgba(43, 23, 70, .15);
  --shadow: 0 18px 60px rgba(43, 23, 70, .12);
  font-family: "Departure Mono", ui-monospace, monospace;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 85% 0%, rgba(255,207,74,.23), transparent 28rem), var(--paper); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.hidden { display: none !important; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -4rem; padding: .7rem 1rem; background: var(--purple-dark); color: white; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }

.site-header { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1240px; margin: auto; padding: 1.25rem clamp(1rem, 4vw, 3rem); }
.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; letter-spacing: .04em; }
.brand strong { display: block; font-family: inherit; font-size: 1.15rem; }
.brand small { display: block; color: var(--ink-soft); font-size: .66rem; letter-spacing: .08em; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; place-items: center; width: 2.6rem; height: 2.1rem; padding: .2rem; border-radius: 1rem 1rem .55rem .55rem; color: white; background: var(--purple-dark); font-weight: 900; transform: rotate(-3deg); }
.brand-mark span:last-child { color: var(--yellow); }
.header-actions { display: flex; gap: .5rem; }

.button { min-height: 2.75rem; border: 0; border-radius: 999px; padding: .65rem 1.1rem; font-weight: 700; color: var(--ink); background: white; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:hover { transform: translateY(-2px); }
.button-ghost { border: 1px solid var(--line); background: rgba(255,255,255,.55); }
.button-primary { background: var(--purple-dark); color: white; box-shadow: 0 10px 24px rgba(43,23,70,.25); }
.button-primary span { margin-left: 1rem; }
.button-danger { color: white; background: var(--red); }
.button-large { min-height: 3.7rem; padding: .9rem 1.5rem; font-size: 1rem; }
.button-small { min-height: 2.25rem; padding: .4rem .8rem; font-size: .8rem; }
.button:disabled { cursor: not-allowed; opacity: .42; transform: none; }

main { min-height: calc(100vh - 10rem); }
.setup-view { max-width: 1120px; margin: 0 auto; padding: clamp(2.2rem, 7vw, 6.5rem) clamp(1rem, 4vw, 3rem) 6rem; }
.hero { max-width: 800px; margin-bottom: 5rem; }
.eyebrow { margin: 0 0 .7rem; color: var(--purple); font-size: .78rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3 { font-family: inherit; }
h1 { margin: 0; max-width: 900px; font-size: clamp(2.8rem, 8vw, 6.3rem); line-height: .93; letter-spacing: -.055em; }
h1 em { color: var(--purple); font-style: normal; }
.hero-copy { max-width: 690px; margin: 2rem 0 1.4rem; color: var(--ink-soft); font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.65; }
.hero-badges { display: flex; flex-wrap: wrap; gap: .55rem; }
.hero-badges span { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.7); font-size: .83rem; font-weight: 600; }

.setup-form { display: grid; gap: 1.2rem; }
.setup-section { padding: clamp(1.1rem, 3vw, 2.2rem); border: 1px solid var(--line); border-radius: 1.7rem; background: rgba(255,255,255,.72); box-shadow: 0 12px 42px rgba(43,23,70,.06); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.section-heading > div:first-child { display: flex; align-items: center; gap: .8rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.section-heading p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.step { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: 0 0 auto; border-radius: 50%; color: white; background: var(--purple-dark); font-size: .72rem; font-weight: 800; }

.deck-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.deck-choice { position: relative; min-height: 8.5rem; cursor: pointer; }
.deck-choice input { position: absolute; opacity: 0; }
.deck-choice-card { display: flex; height: 100%; flex-direction: column; justify-content: space-between; padding: 1rem; border: 2px solid transparent; border-radius: 1.15rem; background: var(--deck-pale); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.deck-choice:hover .deck-choice-card { transform: translateY(-3px) rotate(-.4deg); }
.deck-choice input:focus-visible + .deck-choice-card { outline: 3px solid var(--yellow); outline-offset: 3px; }
.deck-choice input:checked + .deck-choice-card { border-color: var(--deck); box-shadow: inset 0 0 0 1px var(--deck), 0 8px 24px rgba(43,23,70,.12); }
.deck-choice input:checked + .deck-choice-card::after { content: "✓"; position: absolute; right: .65rem; top: .65rem; display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; color: white; background: var(--deck); font-size: .78rem; font-weight: 900; }
.deck-emoji { font-size: 1.8rem; }
.deck-choice strong { display: block; margin-top: .4rem; font-family: inherit; font-size: 1.05rem; }
.deck-choice small { color: var(--ink-soft); font-size: .72rem; }

.counter-control { display: flex; align-items: center; gap: .4rem; padding: .25rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.counter-control button { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border: 0; border-radius: 50%; background: white; font-size: 1.15rem; }
.counter-control output { min-width: 1.8rem; text-align: center; font-weight: 800; }
.player-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.player-field { display: grid; grid-template-columns: minmax(8rem, .75fr) minmax(11rem, 1.25fr); gap: .65rem; padding: .8rem; border-radius: 1rem; background: var(--paper-deep); }
.player-field label { display: grid; gap: .35rem; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
input, select { width: 100%; min-height: 2.7rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--ink); background: white; }
.setup-options { display: grid; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.2rem; }
.option-grid label { display: grid; gap: .5rem; color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
.setup-options .button-primary { justify-self: start; }
.form-error { min-height: 1.15rem; margin: .75rem 0 0; color: var(--red); font-size: .82rem; font-weight: 700; }

.game-view { max-width: 1440px; margin: 0 auto; padding: 1rem clamp(.75rem, 2.5vw, 2rem) 4rem; }
.game-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.round-meter { justify-self: center; color: var(--ink-soft); font-size: .78rem; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .08em; }
.round-meter progress { display: block; width: min(18rem, 40vw); height: .45rem; margin-top: .4rem; accent-color: var(--purple); }
.deck-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.deck-pill { padding: .35rem .55rem; border-radius: 999px; background: var(--deck-pale); color: var(--deck); font-size: .72rem; font-weight: 800; }
.save-status { justify-self: end; color: var(--ink-soft); font-size: .72rem; }

.table-layout { display: grid; grid-template-columns: minmax(14rem, .7fr) minmax(22rem, 1.55fr) minmax(15rem, .8fr); gap: 1rem; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 1.4rem; background: rgba(255,255,255,.72); box-shadow: 0 10px 35px rgba(43,23,70,.06); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 1rem .75rem; }
.panel-heading h2 { margin: 0; font-size: 1.2rem; }

.role-stack { display: grid; gap: .65rem; padding: 0 .8rem .8rem; }
.role-card { padding: 1rem; border-radius: 1rem; background: var(--paper-deep); }
.role-card.director { color: white; background: var(--purple-dark); }
.role-card.bida { color: var(--ink); background: var(--yellow); }
.role-label { display: block; margin-bottom: .3rem; font-size: .67rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.role-card strong { display: block; font-family: inherit; font-size: 1.35rem; }
.role-card small { display: block; margin-top: .15rem; opacity: .78; }

.players-list { display: grid; gap: .5rem; padding: 0 .8rem .8rem; }
.player-summary { padding: .8rem; border: 1px solid var(--line); border-radius: .9rem; background: white; }
.player-summary.is-bida { border-color: var(--yellow); box-shadow: inset 4px 0 var(--yellow); }
.player-summary-top { display: flex; justify-content: space-between; gap: .5rem; }
.player-summary h3 { margin: 0; font-family: inherit; font-size: .9rem; }
.player-summary .character { color: var(--ink-soft); font-size: .72rem; }
.stats { display: flex; gap: .45rem; margin-top: .55rem; }
.stat { padding: .3rem .48rem; border-radius: .45rem; background: var(--paper-deep); font-size: .72rem; font-weight: 800; }
.inventory-counts { margin-left: auto; color: var(--ink-soft); font-size: .68rem; }
.player-details { margin-top: .65rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.player-details summary { cursor: pointer; color: var(--purple); font-size: .72rem; font-weight: 800; }
.ability { margin: .6rem 0; font-size: .76rem; line-height: 1.45; }
.owned-cards { display: grid; gap: .35rem; }
.owned-card { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: .45rem; padding: .5rem; border-radius: .6rem; background: var(--paper-deep); font-size: .68rem; }
.owned-card.used { opacity: .5; text-decoration: line-through; }
.owned-card button { border: 0; border-radius: 999px; background: white; font-size: .62rem; }

.story-panel { min-height: 38rem; background: var(--purple-dark); color: white; }
.story-stage { display: grid; min-height: 38rem; grid-template-rows: auto 1fr auto; }
.simula-strip { padding: .85rem 1.1rem; color: var(--ink); background: var(--yellow); font-size: .78rem; }
.simula-strip strong { font-family: inherit; }
.simula-strip button { float: right; border: 0; background: transparent; font-weight: 800; }
.scene-area { display: grid; place-items: center; padding: clamp(1.3rem, 4vw, 3rem); text-align: center; }
.empty-scene { max-width: 29rem; }
.empty-scene .giant-icon { display: block; margin-bottom: 1rem; font-size: 4rem; }
.empty-scene h2 { margin: 0 0 .8rem; font-size: clamp(2rem, 5vw, 3.5rem); }
.empty-scene p { color: rgba(255,255,255,.72); line-height: 1.6; }
.scene-card { --scene-color: var(--yellow); position: relative; width: min(100%, 38rem); padding: clamp(1.3rem, 4vw, 2.6rem); border: 3px solid var(--scene-color); border-radius: 1.6rem; color: var(--ink); background: var(--paper); box-shadow: 0 20px 80px rgba(0,0,0,.28); transform: rotate(-.4deg); }
.scene-card::before, .scene-card::after { content: ""; position: absolute; width: .6rem; height: .6rem; border: 2px solid var(--scene-color); border-radius: 50%; }
.scene-card::before { left: .8rem; top: .8rem; }
.scene-card::after { right: .8rem; bottom: .8rem; }
.card-source { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .55rem; border-radius: 999px; color: var(--scene-color); background: color-mix(in srgb, var(--scene-color) 12%, white); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.scene-card h2 { margin: 1rem 0 .7rem; font-size: clamp(2rem, 5vw, 3rem); line-height: .95; }
.scene-card .situation { margin: 0 auto 1rem; max-width: 30rem; font-size: 1.03rem; line-height: 1.55; }
.scene-card .prompt { margin: 1rem auto; color: var(--purple); font-family: inherit; font-size: 1.1rem; font-style: normal; line-height: 1.4; }
.check-badge { display: inline-flex; gap: .5rem; padding: .55rem .8rem; border-radius: .65rem; background: var(--paper-deep); font-size: .78rem; font-weight: 800; }
.signature-card { background: var(--yellow); }

.scene-controls { padding: 1rem; border-top: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.12); }
.control-row { display: flex; justify-content: center; flex-wrap: wrap; gap: .6rem; }
.resolution-panel { display: grid; gap: .8rem; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.mode-tabs button { border: 1px solid rgba(255,255,255,.23); border-radius: .7rem; padding: .65rem; color: white; background: transparent; font-weight: 800; }
.mode-tabs button.active { color: var(--ink); background: var(--yellow); }
.roll-config { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.roll-config label { color: rgba(255,255,255,.7); font-size: .68rem; font-weight: 700; text-align: left; }
.roll-config select, .roll-config input { min-height: 2.4rem; margin-top: .3rem; }
.dice-result { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .55rem; }
.die { display: grid; place-items: center; width: 3.1rem; height: 3.1rem; border-radius: .7rem; color: var(--ink); background: white; font-family: inherit; font-size: 1.5rem; font-weight: 900; box-shadow: inset 0 0 0 2px rgba(43,23,70,.16); }
.roll-total { min-width: 7rem; font-size: .8rem; }
.roll-total strong { display: block; font-family: inherit; font-size: 1.7rem; }
.result-banner { padding: .75rem; border-radius: .75rem; font-weight: 900; text-align: center; }
.result-banner.success { color: white; background: var(--green); }
.result-banner.failure { color: white; background: var(--red); }
.result-banner.pending { color: var(--ink); background: var(--yellow); }

.guide-list { display: grid; gap: .65rem; padding: 0 .85rem .85rem; }
.guide-step { display: grid; grid-template-columns: 1.7rem 1fr; gap: .55rem; color: var(--ink-soft); font-size: .76rem; line-height: 1.45; }
.guide-step span { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; color: white; background: var(--purple); font-weight: 900; }
.guide-step strong { color: var(--ink); }
.log { max-height: 18rem; overflow: auto; padding: 0 .85rem .85rem; }
.log-entry { padding: .55rem 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: .69rem; line-height: 1.4; }
.log-entry strong { color: var(--ink); }

.finale-layout { padding: 1rem; }
.finale-card { max-width: 48rem; margin: 1rem auto; text-align: center; }
.finale-rolls { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin: 1rem 0; }
.finale-player { padding: .8rem; border: 1px solid rgba(255,255,255,.18); border-radius: .8rem; }
.finale-player h3 { margin: 0 0 .55rem; font-family: "DM Sans", sans-serif; font-size: .9rem; }
.finale-player .dice-result { margin-top: .55rem; }
.ending { padding: 1rem; border-radius: 1rem; color: var(--ink); background: var(--yellow); }
.epilogue-list { display: grid; gap: .5rem; margin-top: .8rem; text-align: left; }
.epilogue-list label { display: grid; gap: .25rem; font-size: .7rem; font-weight: 700; }

dialog { width: min(92vw, 38rem); padding: 1.5rem; border: 1px solid var(--line); border-radius: 1.4rem; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20,11,32,.66); backdrop-filter: blur(4px); }
.dialog-close { float: right; width: 2.4rem; height: 2.4rem; border: 0; border-radius: 50%; background: var(--paper-deep); font-size: 1.4rem; }
.rules-dialog h2 { margin: 0 0 1rem; font-size: 2.2rem; }
.rules-dialog ol { padding-left: 1.3rem; line-height: 1.55; }
.rules-dialog li { margin-bottom: .65rem; }
.difficulty-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.difficulty-row span { padding: .5rem; border-radius: .55rem; background: var(--paper-deep); font-size: .7rem; font-weight: 800; text-align: center; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 1.2rem; max-width: calc(100vw - 2rem); padding: .75rem 1rem; border-radius: 999px; color: white; background: var(--purple-dark); box-shadow: var(--shadow); font-size: .78rem; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 1rem); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
footer { display: flex; justify-content: space-between; max-width: 1240px; margin: auto; padding: 1.5rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

@media (max-width: 1000px) {
  .deck-grid { grid-template-columns: repeat(3, 1fr); }
  .table-layout { grid-template-columns: minmax(13rem, .8fr) minmax(20rem, 1.4fr); }
  .guide-panel { grid-column: 1 / -1; }
  .guide-panel .guide-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .site-header { align-items: flex-start; }
  .brand small { display: none; }
  .header-actions .button { padding-inline: .8rem; font-size: .75rem; }
  .setup-view { padding-top: 2.5rem; }
  .hero { margin-bottom: 3rem; }
  h1 br { display: none; }
  .deck-grid { grid-template-columns: repeat(2, 1fr); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { padding-left: 3rem; }
  .player-fields, .option-grid { grid-template-columns: 1fr; }
  .player-field { grid-template-columns: 1fr; }
  .game-topbar { grid-template-columns: 1fr auto; }
  .round-meter { grid-column: 1 / -1; grid-row: 2; }
  .round-meter progress { width: min(80vw, 25rem); }
  .table-layout { grid-template-columns: 1fr; }
  .roles-panel { order: 2; }
  .story-panel { order: 1; min-height: 32rem; }
  .story-stage { min-height: 32rem; }
  .guide-panel { order: 3; grid-column: auto; }
  .guide-panel .guide-list { grid-template-columns: 1fr; }
  .roll-config { grid-template-columns: 1fr 1fr; }
  .finale-rolls { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .deck-choice { min-height: 7.5rem; }
  .deck-choice-card { padding: .8rem; }
  .deck-choice small { font-size: .65rem; }
  .setup-section { border-radius: 1.15rem; }
  .scene-area { padding: 1rem; }
  .scene-card { padding: 1.4rem 1rem; border-radius: 1.1rem; }
  .roll-config { grid-template-columns: 1fr; }
  .difficulty-row { grid-template-columns: repeat(2, 1fr); }
}

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

@media print {
  .site-header, footer, .scene-controls, .guide-panel { display: none; }
  body { background: white; }
  .game-view { padding: 0; }
  .table-layout { display: block; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* Departure Mono / text-terminal art direction */
:root {
  --ink: #333333;
  --ink-soft: #6c6c58;
  --paper: #eeeeee;
  --paper-deep: #cccccc;
  --purple: #444444;
  --purple-dark: #222222;
  --yellow: #ffa133;
  --pink: #e47b1a;
  --green: #46735c;
  --red: #9a3e32;
  --line: rgba(34,34,34,.42);
  --shadow: none;
  font-size: 11px;
  background: #141414;
}

body {
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(rgba(34,34,34,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(34,34,34,.025) 1px, transparent 1px);
  background-size: 22px 22px;
}

::selection { color: var(--paper); background: var(--purple-dark); }
.site-header { max-width: 1440px; padding: 22px 44px; border-bottom: 1px solid var(--line); }
.brand { gap: 11px; letter-spacing: 0; }
.brand strong { font-size: 16.5px; font-weight: 400; }
.brand small { font-size: 11px; letter-spacing: 0; }
.brand-mark { width: auto; height: auto; padding: 5px 7px; border-radius: 0; background: var(--purple-dark); transform: none; }
.brand-mark span:last-child { color: var(--yellow); }
.button { min-height: 33px; padding: 7px 11px; border: 1px solid currentColor; border-radius: 0; font-weight: 400; text-transform: uppercase; letter-spacing: .04em; background: transparent; }
.button::before { content: "> "; }
.button:hover { transform: none; color: var(--paper); background: var(--purple-dark); box-shadow: none; }
.button-primary { color: var(--purple-dark); background: var(--yellow); box-shadow: none; }
.button-ghost { border-color: var(--line); background: transparent; }
.button-large { min-height: 44px; font-size: 16.5px; }
.setup-view { max-width: 1440px; padding: 88px 44px 132px; }
.hero { max-width: 1100px; margin-bottom: 110px; }
.eyebrow { color: var(--ink-soft); font-size: 11px; font-weight: 400; letter-spacing: 0; }
.eyebrow::before { content: "░ "; color: var(--yellow); }
h1 { max-width: 1100px; color: var(--purple-dark); font-size: clamp(44px, 7vw, 88px); font-weight: 400; line-height: 1; letter-spacing: -0.04em; text-transform: uppercase; }
h1 em { display: inline; padding: 0 .08em; color: var(--purple-dark); background: var(--paper-deep); font-style: normal; }
.hero-copy { max-width: 72ch; margin: 33px 0 22px; color: var(--ink-soft); font-size: 16.5px; line-height: 1.5; }
.hero-badges { gap: 0; border-block: 1px solid var(--line); }
.hero-badges span { flex: 1; padding: 11px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; font-size: 11px; font-weight: 400; text-transform: uppercase; }
.hero-badges span:last-child { border-right: 0; }
.setup-form { gap: 44px; }
.setup-section { padding: 22px; border: 1px solid var(--ink); border-radius: 0; background: rgba(238,238,238,.86); box-shadow: none; clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%); }
.section-heading { margin-bottom: 22px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.section-heading h2 { font-size: 22px; font-weight: 400; text-transform: uppercase; }
.section-heading p { font-size: 11px; }
.step { display: block; width: auto; height: auto; border-radius: 0; color: var(--yellow); background: transparent; font-size: 11px; font-weight: 400; }
.step::before { content: "["; }.step::after { content: "]"; }
.deck-grid { gap: 1px; background: var(--ink); border: 1px solid var(--ink); }
.deck-choice { min-height: 110px; }
.deck-choice-card { padding: 11px; border: 0; border-radius: 0; background: var(--paper); transition: background .1s steps(1); }
.deck-choice:hover .deck-choice-card { transform: none; background: var(--paper-deep); }
.deck-choice input:checked + .deck-choice-card { border: 0; color: var(--paper); background: var(--purple-dark); box-shadow: none; }
.deck-choice input:checked + .deck-choice-card::after { right: 8px; top: 8px; width: auto; height: auto; border-radius: 0; color: var(--yellow); background: transparent; font-size: 11px; content: "[ON]"; }
.deck-emoji { font-size: 22px; filter: grayscale(1); }
.deck-choice strong { font-size: 16.5px; font-weight: 400; text-transform: uppercase; }
.deck-choice small { color: inherit; font-size: 11px; opacity: .72; }
.counter-control { padding: 0; border-radius: 0; background: transparent; }
.counter-control button { width: 33px; height: 33px; border-radius: 0; background: transparent; }
.counter-control output { min-width: 44px; }
.player-fields { gap: 1px; border: 1px solid var(--ink); background: var(--ink); }
.player-field { gap: 11px; padding: 11px; border-radius: 0; background: var(--paper); }
.player-field label, .option-grid label { color: var(--ink-soft); font-size: 11px; font-weight: 400; text-transform: uppercase; }
input, select { min-height: 33px; padding: 6px 8px; border: 1px solid var(--ink); border-radius: 0; color: var(--ink); background: transparent; }
.form-error { color: var(--red); font-size: 11px; font-weight: 400; }
.form-error:not(:empty)::before { content: "ERR: "; }

.game-view { max-width: 1600px; padding: 11px 22px 88px; }
.game-topbar { padding: 11px 0; border-bottom: 1px solid var(--line); }
.round-meter, .save-status { color: var(--ink-soft); font-size: 11px; font-weight: 400; }
.round-meter progress { height: 5px; border-radius: 0; accent-color: var(--yellow); }
.deck-pills { gap: 4px; }
.deck-pill { padding: 3px 6px; border: 1px solid currentColor; border-radius: 0; color: var(--ink); background: transparent; font-size: 11px; font-weight: 400; }
.table-layout { gap: 11px; }
.panel { border-color: var(--ink); border-radius: 0; background: rgba(238,238,238,.9); box-shadow: none; }
.panel-heading { padding: 11px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 16.5px; font-weight: 400; text-transform: uppercase; }
.panel-heading h2::before { content: "┌─ "; color: var(--ink-soft); }
.panel-heading h2::after { content: " ─┐"; color: var(--ink-soft); }
.role-stack, .players-list { gap: 1px; padding: 0; background: var(--ink); }
.role-card { padding: 11px; border-radius: 0; background: var(--paper); }
.role-card.director { background: var(--purple-dark); }
.role-card.bida { background: var(--yellow); }
.role-label { font-size: 11px; font-weight: 400; }
.role-label::before { content: "["; }.role-label::after { content: "]"; }
.role-card strong { font-size: 16.5px; font-weight: 400; text-transform: uppercase; }
.player-summary { padding: 11px; border: 0; border-radius: 0; background: var(--paper); }
.player-summary.is-bida { box-shadow: inset 5px 0 var(--yellow); }
.player-summary h3 { font-size: 11px; font-weight: 400; text-transform: uppercase; }
.player-summary .character, .inventory-counts { font-size: 11px; }
.stat { padding: 3px 5px; border: 1px solid var(--line); border-radius: 0; background: transparent; font-size: 11px; font-weight: 400; }
.player-details summary { color: var(--ink); font-size: 11px; font-weight: 400; }
.ability { font-size: 11px; }
.owned-card { border-radius: 0; font-size: 11px; }
.story-panel, .story-stage { min-height: 616px; }
.story-panel { color: var(--paper); background: var(--purple-dark); }
.simula-strip { padding: 11px; color: var(--purple-dark); background: var(--paper-deep); font-size: 11px; }
.scene-area { padding: 44px; }
.empty-scene .giant-icon { font-size: 44px; filter: grayscale(1); }
.empty-scene h2 { font-size: 33px; font-weight: 400; text-transform: uppercase; }
.empty-scene p { font-size: 11px; }
.scene-card { width: min(100%, 616px); padding: 33px; border: 1px solid var(--paper); border-radius: 0; color: var(--paper); background: var(--purple-dark); box-shadow: none; transform: none; clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px)); }
.scene-card::before { left: 11px; top: 11px; width: 6px; height: 22px; border: 0; border-radius: 2px; background: var(--scene-color); }
.scene-card::after { right: 11px; bottom: 11px; width: 6px; height: 22px; border: 0; border-radius: 2px; background: var(--scene-color); }
.card-source { padding: 4px 6px; border-radius: 0; color: var(--scene-color); background: transparent; font-size: 11px; font-weight: 400; }
.card-source::before { content: "░ "; }
.scene-card h2 { margin: 22px 0 11px; font-size: 44px; font-weight: 400; line-height: 1; text-transform: uppercase; }
.scene-card .situation { font-size: 16.5px; line-height: 1.5; }
.scene-card .prompt { color: var(--yellow); font-size: 16.5px; }
.scene-card .prompt::before { content: "> "; }
.check-badge { padding: 6px 8px; border: 1px solid var(--paper); border-radius: 0; color: var(--paper); background: transparent; font-size: 11px; font-weight: 400; }
.signature-card { color: var(--purple-dark); background: var(--yellow); }
.signature-card .prompt, .signature-card .card-source { color: var(--purple-dark); }
.scene-controls { padding: 11px; border-top: 1px solid var(--paper-deep); background: var(--purple-dark); }
.scene-controls select, .scene-controls input { color: var(--paper); border-color: var(--paper-deep); background: var(--purple-dark); }
.scene-controls .button { color: var(--paper); border-color: var(--paper-deep); }
.scene-controls .button-primary { color: var(--purple-dark); border-color: var(--yellow); background: var(--yellow); }
.mode-tabs button { border-radius: 0; padding: 8px; font-weight: 400; text-transform: uppercase; }
.mode-tabs button.active { background: var(--paper-deep); }
.roll-config label { font-size: 11px; font-weight: 400; }
.die { width: 44px; height: 44px; border-radius: 0; color: var(--purple-dark); background: var(--paper); font-size: 22px; font-weight: 400; box-shadow: none; }
.roll-total { font-size: 11px; }.roll-total strong { font-size: 22px; font-weight: 400; }
.result-banner { border-radius: 0; font-weight: 400; text-transform: uppercase; }
.guide-step { grid-template-columns: 22px 1fr; font-size: 11px; }
.guide-step span { width: 22px; height: 22px; border-radius: 0; background: var(--purple-dark); font-weight: 400; }
.guide-step strong { font-weight: 400; text-transform: uppercase; }
.log-entry { font-size: 11px; }.log-entry strong { font-weight: 400; text-transform: uppercase; }
.finale-card { text-align: left; }
.finale-player, .ending { border-radius: 0; }
.finale-player h3 { font-size: 11px; font-weight: 400; }
dialog { border-radius: 0; background: var(--paper); box-shadow: none; clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%); }
.dialog-close { border-radius: 0; }
.rules-dialog h2 { font-size: 33px; font-weight: 400; text-transform: uppercase; }
.difficulty-row span { border-radius: 0; font-size: 11px; font-weight: 400; }
.toast { border-radius: 0; font-size: 11px; font-weight: 400; }
footer { max-width: 1440px; padding: 22px 44px; border-color: var(--line); font-size: 11px; font-weight: 400; }

@media (max-width: 767px) {
  .site-header, .setup-view { padding-inline: 16px; }
  .setup-view { padding-top: 66px; }
  .hero { margin-bottom: 66px; }
  h1 { font-size: 44px; letter-spacing: -.03em; }
  .hero-copy { font-size: 13px; }
  .hero-badges span { min-width: 50%; }
  .scene-area { padding: 22px 11px; }
  .scene-card { padding: 22px; }
  .scene-card h2 { font-size: 33px; }
  .story-panel, .story-stage { min-height: 528px; }
}

/* Balatro-inspired casino-night iteration: original CSS shapes and palette */
:root {
  --ink: #fff7d6;
  --ink-soft: #c9bfda;
  --paper: #2a203f;
  --paper-deep: #3a2b58;
  --purple: #9a4fd1;
  --purple-dark: #171021;
  --yellow: #f5ad3d;
  --pink: #ef5a55;
  --green: #42c39a;
  --red: #ee5351;
  --blue: #4aa8e8;
  --cream: #fff7d6;
  --card-ink: #2a203f;
  --line: rgba(255, 247, 214, .28);
  --hard-shadow: 0 5px 0 #0b0811;
  color-scheme: dark;
}

body {
  position: relative;
  color: var(--ink);
  background-color: #171021;
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(91, 39, 128, .92), transparent 42%),
    radial-gradient(ellipse at 88% 22%, rgba(127, 38, 76, .72), transparent 40%),
    radial-gradient(ellipse at 50% 105%, rgba(18, 81, 85, .72), transparent 48%),
    linear-gradient(135deg, #241533, #171021 52%, #21142d);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: -18vmax;
  opacity: .34;
  background:
    repeating-radial-gradient(ellipse at 42% 46%, transparent 0 26px, rgba(255,255,255,.06) 28px 30px, transparent 32px 46px),
    conic-gradient(from 30deg at 48% 52%, rgba(239,90,85,.14), rgba(74,168,232,.12), rgba(154,79,209,.2), rgba(239,90,85,.14));
  filter: blur(12px) saturate(1.25);
  transform: rotate(-4deg) scale(1.06);
  animation: table-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  z-index: 30;
  inset: 0;
  opacity: .12;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.45) 4px);
  mix-blend-mode: multiply;
  pointer-events: none;
}

@keyframes table-drift {
  to { transform: rotate(3deg) scale(1.12) translate3d(2.5%, -1.5%, 0); }
}

::selection { color: var(--purple-dark); background: var(--yellow); }
.site-header { color: var(--cream); border-bottom: 2px solid rgba(255,255,255,.18); background: rgba(18, 11, 27, .78); box-shadow: 0 5px 0 rgba(8,5,12,.55); backdrop-filter: blur(12px); }
.brand small { color: var(--ink-soft); }
.brand-mark { color: var(--cream); border: 2px solid var(--cream); background: var(--pink); box-shadow: 3px 3px 0 #08050c; }

.button {
  color: var(--cream);
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 6px;
  background: #37294f;
  box-shadow: var(--hard-shadow);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.button:hover { color: var(--cream); background: #4a3568; transform: translateY(-2px); box-shadow: 0 7px 0 #0b0811; filter: brightness(1.08); }
.button:active { transform: translateY(3px); box-shadow: 0 2px 0 #0b0811; }
.button-primary { color: #24162c; border-color: #ffd26b; background: var(--yellow); }
.button-primary:hover { color: #24162c; background: #ffc95c; }
.button-danger { color: var(--cream); border-color: #ff9790; background: var(--red); }

.setup-view { padding-top: clamp(56px, 7vw, 100px); }
.hero { max-width: 1200px; margin-bottom: clamp(66px, 9vw, 120px); }
.eyebrow { color: var(--green); text-shadow: 2px 2px 0 #0b0811; }
.eyebrow::before { color: var(--yellow); }
h1 {
  width: min(100%, 12ch);
  max-width: none;
  color: var(--cream);
  font-size: clamp(42px, 8vw, 108px);
  line-height: .9;
  letter-spacing: -.065em;
  text-wrap: balance;
  overflow-wrap: normal;
  text-shadow:
    2px 0 0 #24162c, -2px 0 0 #24162c, 0 2px 0 #24162c, 0 -2px 0 #24162c,
    3px 3px 0 #8b3eae,
    6px 6px 0 #214d69,
    9px 9px 0 rgba(5,3,9,.82);
}
h1 em {
  display: inline;
  padding: 0 .08em .04em;
  color: #fff5cf;
  background: var(--pink);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  text-shadow:
    2px 0 0 #481c2d, -2px 0 0 #481c2d, 0 2px 0 #481c2d, 0 -2px 0 #481c2d,
    3px 3px 0 #71305b,
    6px 6px 0 #173f51;
}
.hero-copy { color: #e0d7e7; text-shadow: 2px 2px 0 rgba(0,0,0,.52); }
.hero-badges { border: 2px solid rgba(255,255,255,.42); background: rgba(20,13,31,.74); box-shadow: var(--hard-shadow); }
.hero-badges span { border-color: rgba(255,255,255,.28); }

.setup-section {
  border: 3px solid #5b467a;
  border-radius: 9px;
  color: var(--cream);
  background: linear-gradient(145deg, rgba(61,44,88,.96), rgba(35,25,54,.97));
  box-shadow: 0 7px 0 #0b0811, inset 0 0 0 2px rgba(255,255,255,.06);
  clip-path: none;
}
.section-heading { border-color: rgba(255,255,255,.22); }
.section-heading p, .player-field label, .option-grid label { color: var(--ink-soft); }
.step { color: var(--yellow); text-shadow: 2px 2px 0 #0b0811; }
.deck-grid { gap: 10px; border: 0; background: transparent; }
.deck-choice { min-height: 126px; perspective: 600px; }
.deck-choice-card {
  position: relative;
  overflow: hidden;
  padding: 12px;
  border: 3px solid #fff8dc;
  border-radius: 8px;
  color: var(--card-ink);
  background:
    linear-gradient(135deg, rgba(255,255,255,.58), transparent 42%),
    var(--deck-pale);
  box-shadow: 0 6px 0 #0b0811, 0 10px 18px rgba(0,0,0,.22);
  transform: rotate(var(--card-tilt, 0deg));
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.deck-choice:nth-child(4n+1) { --card-tilt: -.7deg; }
.deck-choice:nth-child(4n+2) { --card-tilt: .55deg; }
.deck-choice:nth-child(4n+3) { --card-tilt: -.35deg; }
.deck-choice:nth-child(4n) { --card-tilt: .75deg; }
.deck-choice-card::before { content: ""; position: absolute; inset: 5px; border: 1px solid color-mix(in srgb, var(--deck) 62%, transparent); border-radius: 4px; pointer-events: none; }
.deck-choice:hover .deck-choice-card { transform: translateY(-8px) rotate(calc(var(--card-tilt, 0deg) * -.7)); background: var(--deck-pale); box-shadow: 0 12px 0 #0b0811, 0 16px 25px rgba(0,0,0,.3); }
.deck-choice input:checked + .deck-choice-card { color: #fff; border: 3px solid #fff5cf; background: linear-gradient(145deg, var(--deck), color-mix(in srgb, var(--deck) 48%, #171021)); box-shadow: 0 7px 0 #0b0811, 0 0 0 3px var(--yellow); }
.deck-choice input:checked + .deck-choice-card::after { color: #25172c; background: var(--yellow); padding: 3px 5px; border: 2px solid #fff5cf; border-radius: 4px; }
.deck-choice small { opacity: .8; }
.deck-emoji { filter: none; text-shadow: 2px 2px 0 rgba(0,0,0,.22); }

.player-fields { gap: 8px; border: 0; background: transparent; }
.player-field { border: 2px solid rgba(255,255,255,.2); border-radius: 7px; color: var(--cream); background: rgba(20,13,31,.56); }
input, select { color: var(--cream); border: 2px solid #725c91; border-radius: 5px; background: #21172f; box-shadow: inset 0 2px 0 rgba(0,0,0,.3); }
input::placeholder { color: #a99dbb; }
.counter-control { color: var(--cream); border: 2px solid #725c91; border-radius: 6px; background: #21172f; box-shadow: var(--hard-shadow); }
.counter-control button { color: var(--cream); border-radius: 4px; background: #493563; }

.game-topbar { color: var(--cream); border-color: rgba(255,255,255,.2); }
.deck-pill { color: #fff; border: 2px solid color-mix(in srgb, var(--deck) 72%, white); border-radius: 5px; background: color-mix(in srgb, var(--deck) 58%, #21172f); box-shadow: 0 3px 0 #0b0811; }
.round-meter, .save-status { color: var(--ink-soft); }
.panel { border: 3px solid #594475; border-radius: 8px; color: var(--cream); background: linear-gradient(160deg, #34254d, #21172f); box-shadow: 0 7px 0 #0b0811; }
.panel-heading { border-color: rgba(255,255,255,.2); background: rgba(16,10,25,.34); }
.panel-heading h2::before, .panel-heading h2::after { color: var(--green); }
.role-stack, .players-list { gap: 3px; background: #140d1f; }
.role-card { color: var(--cream); background: #33254a; }
.role-card.director { color: #fff; background: #7b3fa1; }
.role-card.bida { color: #27182f; background: var(--yellow); }
.player-summary { color: var(--cream); background: #2a1e3e; }
.player-summary.is-bida { box-shadow: inset 6px 0 var(--yellow); }
.player-summary .character, .inventory-counts { color: var(--ink-soft); }
.stat { color: var(--cream); border-color: rgba(255,255,255,.22); background: #1c1429; }
.player-details summary { color: var(--green); }
.owned-card { color: var(--cream); background: #1c1429; }

.story-panel { border-color: #604681; background: #171021; }
.simula-strip { color: #2b1c35; background: var(--yellow); }
.scene-card {
  color: var(--card-ink);
  border: 4px solid #fff9dc;
  border-radius: 10px;
  background:
    radial-gradient(circle at 90% 8%, color-mix(in srgb, var(--scene-color) 16%, transparent), transparent 30%),
    #fff9dc;
  box-shadow: 0 10px 0 #09060d, 0 18px 35px rgba(0,0,0,.42);
  clip-path: none;
  transform: rotate(-.35deg);
}
.scene-card::before, .scene-card::after { background: var(--scene-color); }
.card-source { color: color-mix(in srgb, var(--scene-color) 78%, #25172c); }
.scene-card h2 { color: #25172c; text-shadow: 2px 2px 0 color-mix(in srgb, var(--scene-color) 35%, white); }
.scene-card .prompt { color: #7d2f71; }
.check-badge { color: #25172c; border: 2px solid #493a58; border-radius: 5px; background: #f2e6c8; box-shadow: 0 3px 0 rgba(25,16,32,.45); }
.signature-card { background: linear-gradient(145deg, #ffd35a, #f18e3f); }
.signature-card .prompt, .signature-card .card-source { color: #3f1834; }
.scene-controls { border-color: rgba(255,255,255,.2); background: #20152f; }
.scene-controls select, .scene-controls input { color: var(--cream); border-color: #725c91; background: #171021; }
.mode-tabs button { border: 2px solid #725c91; border-radius: 5px; background: #2c2041; }
.mode-tabs button.active { color: #25172c; border-color: #fff3c2; background: var(--yellow); box-shadow: 0 4px 0 #0b0811; }
.die { color: #25172c; border: 3px solid #fff; border-radius: 7px; background: #fff4cf; box-shadow: 0 5px 0 #0b0811; }
.result-banner { border: 2px solid rgba(255,255,255,.65); border-radius: 5px; box-shadow: 0 4px 0 #0b0811; }
.guide-step span { border: 2px solid #7d66a0; border-radius: 4px; background: #1b1328; }
.guide-step strong, .log-entry strong { color: var(--green); }
.guide-step, .log-entry { color: var(--ink-soft); }
.ending { color: #25172c; border: 3px solid #fff0b3; border-radius: 8px; background: var(--yellow); box-shadow: var(--hard-shadow); }
dialog { color: var(--cream); border: 3px solid #725c91; border-radius: 8px; background: #2b1f41; box-shadow: 0 10px 0 #0b0811; clip-path: none; }
dialog::backdrop { background: rgba(9,6,13,.78); }
.dialog-close, .difficulty-row span { color: var(--cream); background: #1c1429; }
.toast { border: 2px solid #fff1bc; border-radius: 5px; color: #25172c; background: var(--yellow); box-shadow: var(--hard-shadow); }
footer { color: var(--ink-soft); border-color: rgba(255,255,255,.18); background: rgba(16,10,25,.55); }

@media (max-width: 767px) {
  .site-header { padding-inline: 14px; }
  .setup-view { padding: 52px 14px 88px; }
  .hero { margin-bottom: 62px; }
  h1 {
    width: 100%;
    font-size: clamp(36px, 11.2vw, 52px);
    line-height: .91;
    letter-spacing: -.07em;
    text-shadow:
      1px 0 0 #24162c, -1px 0 0 #24162c, 0 1px 0 #24162c, 0 -1px 0 #24162c,
      2px 2px 0 #8b3eae,
      4px 4px 0 #214d69,
      6px 6px 0 rgba(5,3,9,.82);
  }
  .hero h1 br { display: block; }
  h1 em { padding-inline: .04em; }
  .hero-copy { max-width: 42ch; font-size: 13px; }
  .deck-grid { gap: 8px; }
  .deck-choice { min-height: 116px; }
  .deck-choice-card { transform: none; }
  .scene-card { transform: none; }
}

@media (max-width: 390px) {
  h1 { font-size: clamp(34px, 10.9vw, 42px); letter-spacing: -.075em; }
  .hero-badges span { min-width: 100%; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.2); }
  .hero-badges span:last-child { border-bottom: 0; }
  .deck-grid { grid-template-columns: 1fr 1fr; }
  .deck-choice { min-height: 108px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}
