/* Wordfall for Windows — Windows 95-era application skin.
 * C 1995 vibes: 16-colour palette, 2px bevels, Tahoma, no rounded corners,
 * no gradients, no blur. Everything is drawn with borders and hard shadows.
 */

:root {
  --face: #c0c0c0;
  --light: #dfdfdf;
  --white: #ffffff;
  --shadow: #808080;
  --dark: #000000;
  --navy: #000080;
  --teal: #008080;
  --ink: #000000;
  --disabled: #808080;
  --desktop: #008080;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--desktop);
}

body {
  font-family: "Microsoft Sans Serif", Tahoma, Arial, sans-serif;
  font-size: 11px;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

svg { display: block; }
u { text-underline-offset: 1px; }

/* ── Desktop ─────────────────────────────────────────────────────────────── */
.desktop {
  position: fixed;
  inset: 0;
  background: var(--desktop);
  overflow: hidden;
}

.desktop-icons {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 1;
}

.desktop-icon {
  width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px;
}

.desktop-icon .icon32 {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.desktop-label {
  color: #fff;
  font-size: 11px;
  line-height: 13px;
  text-align: center;
  padding: 0 2px;
  text-shadow: 1px 1px 0 #000;
}

.desktop-icon.selected .desktop-label {
  background: var(--navy);
  outline: 1px dotted #fff;
  outline-offset: -1px;
}

/* ── Application window ──────────────────────────────────────────────────── */
.window {
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: inset 1px 1px var(--light), inset -1px -1px var(--shadow);
  padding: 3px;
}

.app {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1100px, calc(100vw - 200px));
  height: min(772px, calc(100vh - 92px));
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.app.dragging { cursor: default; }

.app.minimized,
.app.gone { display: none; }

.app.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 30px) !important;
  transform: none !important;
}

/* ── Title bar ───────────────────────────────────────────────────────────── */
.title-bar {
  height: 18px;
  flex: 0 0 18px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
}

.title-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  image-rendering: pixelated;
}

.title-text {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-buttons { display: flex; gap: 2px; }

.title-btn {
  width: 16px;
  height: 14px;
  background: var(--face);
  box-shadow:
    inset -1px -1px var(--dark),
    inset 1px 1px var(--white),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-btn:active {
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
}

.title-btn.min i { width: 6px; height: 2px; background: var(--dark); margin-top: 7px; }
.title-btn.max i { width: 9px; height: 8px; border: 1px solid var(--dark); border-top-width: 2px; }
.title-btn.close i { width: 10px; height: 10px; position: relative; }
.title-btn.close i::before,
.title-btn.close i::after {
  content: "";
  position: absolute;
  left: 4px;
  top: -1px;
  width: 2px;
  height: 12px;
  background: var(--dark);
  transform: rotate(45deg);
}
.title-btn.close i::after { transform: rotate(-45deg); }

/* ── Menu bar ────────────────────────────────────────────────────────────── */
.menu-bar {
  display: flex;
  align-items: stretch;
  height: 20px;
  flex: 0 0 20px;
  position: relative;
  z-index: 30;
  padding: 1px 0;
}

.menu-item { position: relative; }

.menu-label {
  display: block;
  padding: 3px 8px 2px;
  font-size: 11px;
  line-height: 14px;
}

.menu-item.open > .menu-label,
.menu-item:hover > .menu-label {
  background: var(--navy);
  color: #fff;
}

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 176px;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow:
    inset 1px 1px var(--light),
    inset -1px -1px var(--shadow),
    3px 3px 0 rgba(0, 0, 0, 0.24);
  padding: 2px;
  z-index: 40;
}

.menu-item.open .dropdown { display: block; }

.drop-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  padding: 3px 18px;
  font-size: 11px;
  white-space: nowrap;
}

.drop-item:hover { background: var(--navy); color: #fff; }

.drop-item.disabled {
  color: var(--disabled);
  text-shadow: 1px 1px 0 #fff;
}
.drop-item.disabled:hover { background: transparent; color: var(--disabled); }

.shortcut { opacity: 0.75; }

.drop-sep {
  height: 2px;
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--white);
  margin: 3px 2px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-top: 1px solid var(--white);
  border-bottom: 1px solid var(--shadow);
}

.tool-btn {
  width: 23px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: var(--face);
  box-shadow:
    inset -1px -1px var(--dark),
    inset 1px 1px var(--white),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
}

.tool-btn:active,
.tool-btn.open {
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
}

.tool-btn svg { width: 16px; height: 16px; }
.tool-btn.off svg { opacity: 0.35; }

.tool-sep {
  width: 2px;
  height: 19px;
  margin: 0 3px;
  border-left: 1px solid var(--shadow);
  border-right: 1px solid var(--white);
}

.tool-field {
  flex: 1;
  min-width: 0;
  height: 19px;
  margin-left: 3px;
  padding: 2px 5px;
  background: var(--face);
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

/* ── Playfield ───────────────────────────────────────────────────────────── */
.client {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 2px 1px 1px;
  background: #000020;
  overflow: hidden;
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #000020;
}

/* ── Status bar ──────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  gap: 2px;
  height: 21px;
  flex: 0 0 21px;
  padding: 1px 1px 0;
}

.status-panel {
  background: var(--face);
  padding: 3px 5px 2px;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
}

.status-panel.grow {
  flex: 1;
  min-width: 0;
}

/* ── Modal dialogs ───────────────────────────────────────────────────────── */
.modal-layer {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 5;
}
.modal-layer.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
}

.dialog {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow:
    inset 1px 1px var(--light),
    inset -1px -1px var(--shadow),
    5px 5px 0 rgba(0, 0, 0, 0.25);
  padding: 3px;
  z-index: 6;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow: auto;
}

.dialog.show {
  display: block;
  animation: dialog-in 0.12s steps(2, end) both;
}

.dialog-title {
  height: 18px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 3px;
  font-weight: 700;
  font-size: 11px;
}

.dialog-body {
  padding: 10px 12px 6px;
  font-size: 11px;
  line-height: 1.5;
}

.dialog-body p { margin: 0 0 6px; }
.dialog-body p:last-child { margin-bottom: 0; }

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 12px 10px;
}

.btn {
  min-width: 75px;
  height: 23px;
  padding: 1px 8px 0;
  background: var(--face);
  border: none;
  font-family: inherit;
  font-size: 11px;
  color: var(--ink);
  box-shadow:
    inset -1px -1px var(--dark),
    inset 1px 1px var(--white),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
  position: relative;
}

.btn:active {
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
  padding: 2px 7px 0 9px;
}

.btn.default { outline: 1px solid var(--dark); outline-offset: 1px; }

.btn:focus-visible { outline: 1px dotted var(--dark); outline-offset: -4px; }

.btn[disabled] {
  color: var(--disabled);
  text-shadow: 1px 1px 0 #fff;
}

/* Welcome */
.dlg-welcome { width: 430px; }

.welcome-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 14px 6px;
}

.welcome-icon { width: 32px; height: 32px; flex: 0 0 32px; }

.welcome-head { font-weight: 700; font-size: 12px; margin-bottom: 5px; }

.welcome-best { margin-top: 8px; color: var(--navy); font-weight: 700; }

/* Draft */
.dlg-draft { width: 660px; }

.draft-meta { margin: 0 0 8px; }

.draft-log {
  margin: 0 0 8px;
  padding: 5px 0 0;
  border-top: 1px solid var(--shadow);
  color: #404040;
  font-family: "Lucida Console", "Courier New", monospace;
  font-size: 10px;
  line-height: 1.4;
  min-height: 19px;
}

.draft-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.draft-card {
  position: relative;
  min-height: 150px;
  padding: 8px;
  background: var(--face);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: inset 1px 1px var(--white), inset -1px -1px var(--shadow);
}

.draft-card:hover {
  outline: 1px dotted var(--dark);
  outline-offset: -3px;
}

.draft-card .badge {
  align-self: flex-start;
  padding: 1px 4px;
  background: var(--navy);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.draft-card.boon .badge { background: #008000; }
.draft-card.gambit .badge { background: #808000; }
.draft-card.hex .badge { background: #800080; }

.draft-card .rare {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #800000;
  font-size: 9px;
  font-weight: 700;
}

.draft-card .draft-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  padding-right: 24px;
}

.draft-card .draft-desc {
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink);
}

.draft-card .draft-key {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 10px;
  color: #404040;
}

.draft-card:nth-child(1) { animation: card-rise 0.24s steps(4, end) 0s both; }
.draft-card:nth-child(2) { animation: card-rise 0.24s steps(4, end) 0.06s both; }
.draft-card:nth-child(3) { animation: card-rise 0.24s steps(4, end) 0.12s both; }

.draft-held {
  margin-top: 8px;
  font-size: 11px;
  color: #404040;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draft-note {
  margin-top: 4px;
  font-size: 10px;
  color: #404040;
}

/* Pause */
.dlg-pause { width: 400px; }

.pause-body {
  padding: 12px 14px 4px;
  font-size: 11px;
  line-height: 1.5;
}

.pause-seed {
  padding: 3px 6px;
  margin: 0 0 9px;
  background: var(--face);
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pause-note {
  margin: 0;
  color: var(--ink);
}

/* Records */
.dlg-records { width: 340px; }

.records-table {
  width: 100%;
  margin: 0 0 6px;
  border-collapse: collapse;
  background: var(--white);
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
}

.records-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--face);
  vertical-align: baseline;
}

.records-table tr:last-child td { border-bottom: none; }

.records-table .rec-val {
  padding-left: 24px;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

/* Message dialogs */
.dlg-message { width: 400px; }

.big-score {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
}

.dawn-score { color: #806000; }

.stats {
  font-size: 11px;
  color: #000;
  margin-bottom: 4px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.held-line {
  margin-top: 4px;
  font-size: 10px;
  color: #404040;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Controls */
.dlg-help { width: 470px; }

.key-table { border-collapse: collapse; margin: 0 0 6px; }
.key-table td { padding: 2px 10px 2px 0; vertical-align: top; }
.key-table .key { font-weight: 700; color: var(--navy); white-space: nowrap; }

.fine-print { font-size: 10px; color: #404040; }

/* About */
.dlg-help .about-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
}

.about-icon { width: 32px; height: 32px; flex: 0 0 32px; }
.about-head { font-weight: 700; font-size: 13px; }
.about-ver { color: #404040; margin-bottom: 6px; }

/* Quit */
.dlg-quit { width: 330px; }
.quit-body { display: flex; gap: 14px; align-items: flex-start; padding: 14px 14px 6px; }
.quit-icon { width: 32px; height: 32px; flex: 0 0 32px; }
.quit-line { margin: 0 0 4px; }

/* ── Taskbar ─────────────────────────────────────────────────────────────── */
.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px;
  background: var(--face);
  border-top: 1px solid var(--light);
  box-shadow: 0 -1px 0 var(--shadow);
  z-index: 50;
}

.start-btn {
  height: 23px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px 0 3px;
  font-weight: 700;
  background: var(--face);
  box-shadow:
    inset -1px -1px var(--dark),
    inset 1px 1px var(--white),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
}

.start-btn:active,
.start-btn.open {
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
  padding: 2px 6px 0 4px;
}

.start-btn .flag { width: 16px; height: 16px; }

.task-divider {
  width: 2px;
  height: 21px;
  border-left: 1px solid var(--shadow);
  border-right: 1px solid var(--white);
}

.task-btn {
  height: 23px;
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 0 4px;
  background: var(--face);
  box-shadow:
    inset 1px 1px var(--dark),
    inset -1px -1px var(--white),
    inset 2px 2px var(--shadow),
    inset -2px -2px var(--light);
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task-btn.hidden { display: none; }

/* When the app window is minimised the taskbar button pops back out (raised). */
.task-btn.raised {
  box-shadow:
    inset -1px -1px var(--dark),
    inset 1px 1px var(--white),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
}

.taskbar-spacer { flex: 1; }

.clock {
  height: 21px;
  padding: 3px 8px 0;
  font-size: 11px;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white);
}

/* ── Start menu ──────────────────────────────────────────────────────────── */
.start-menu {
  position: fixed;
  left: 2px;
  bottom: 30px;
  width: 198px;
  display: none;
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow:
    inset 1px 1px var(--light),
    inset -1px -1px var(--shadow),
    4px 4px 0 rgba(0, 0, 0, 0.25);
  padding: 2px;
  z-index: 60;
}

.start-menu.open { display: flex; }

.start-banner {
  width: 22px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
}

.start-items { flex: 1; display: flex; flex-direction: column; }

.start-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 11px;
}

.start-item:hover { background: var(--navy); color: #fff; }

.start-sep {
  height: 2px;
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--white);
  margin: 3px 2px;
}

/* A modal dialog turns the menu bar and toolbar into an inert backdrop,
   Win95-style - but the title-bar buttons (minimize / maximize / close) stay
   live on purpose: locking them while a dialog is up is infuriating when you
   just want to minimise the window or quit. */
.app.modal-open .menu-bar,
.app.modal-open .toolbar {
  pointer-events: none;
}

.app.modal-open .menu-label {
  color: var(--disabled);
}

/* ── Native (WebView2) embedded mode ────────────────────────────────────── */
body.embedded { background: #000; }

body.embedded .desktop { padding: 0; background: #000; }

body.embedded .desktop-icons,
body.embedded .taskbar {
  display: none !important;
}

body.embedded .app {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  transform: none !important;
  border-width: 0 !important;
}

body.embedded .app.maximized {
  height: 100vh !important;
}

/* ── Animation ───────────────────────────────────────────────────────────── */
@keyframes dialog-in {
  from { opacity: 0.3; transform: translate(-50%, -52%); }
  to   { opacity: 1;   transform: translate(-50%, -50%); }
}

@keyframes card-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════════════
   v1.2 FX shell — overlay, phase juice, state classes.
   Contract: #app carries inline custom props --fx-combo (0..20),
   --fx-danger (0..1), --fx-heat (0..5), --fx-lives (0..3), --fx-wave (1..99);
   body toggles phase-menu/playing/paused/draft/dawn/gameover plus
   fx-combo-hot, fx-danger, fx-low-life, fx-light and transient fx-milestone.
   Only transform, opacity and box-shadow are animated. No blur, no modern
   gradients. The overlay sits above the canvas and below .modal-layer (5).
   ══════════════════════════════════════════════════════════════════════════ */

/* ── FX overlay ──────────────────────────────────────────────────────────── */
.fx-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.12s steps(2, end);
}

.fx-glow,
.fx-vignette,
.fx-scanlines,
.fx-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Gold edge from combo/heat, red edge from danger. Cheap: one static shadow. */
.fx-glow {
  box-shadow:
    inset 0 0 34px rgba(255, 255, 0, calc(var(--fx-combo, 0) * 0.014 + var(--fx-heat, 0) * 0.012)),
    inset 0 0 52px rgba(255, 0, 0, calc(var(--fx-danger, 0) * 0.22));
}

.fx-glow::after,
.fx-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

#fxGlow::after {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), inset 0 0 70px rgba(255, 255, 0, 0.5);
}

.fx-vignette {
  box-shadow:
    inset 0 0 64px rgba(0, 0, 0, 0.5),
    inset 0 0 12px rgba(0, 0, 0, 0.42);
}

/* CRT scanlines: one repeating 1px/1px pattern, moved with transform only. */
.fx-scanlines {
  top: -4px;
  height: calc(100% + 4px);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.14) 1px,
    rgba(0, 0, 0, 0.14) 2px
  );
  animation: fx-scan 4s steps(4, end) infinite;
  will-change: transform;
}

@keyframes fx-scan {
  from { transform: translateY(0); }
  to   { transform: translateY(4px); }
}

/* Signal fleck: inline 2x2 SVG checker, low opacity, opacity-steps flicker. */
.fx-noise {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%23ffffff'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23ffffff'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 4px 4px;
  image-rendering: pixelated;
  opacity: 0.03;
  animation: fx-noise 0.8s steps(2, end) infinite;
}

@keyframes fx-noise {
  0%, 100% { opacity: 0.02; }
  50%      { opacity: 0.045; }
}

/* ── State: combo / danger / low life ───────────────────────────────────── */
.fx-combo-hot #fxGlow {
  box-shadow:
    inset 0 0 36px rgba(255, 255, 0, min(0.5, calc(0.05 + var(--fx-combo, 0) * 0.022 + var(--fx-heat, 0) * 0.01))),
    inset 0 0 60px rgba(255, 0, 0, calc(var(--fx-danger, 0) * 0.3));
}

.fx-danger #fxGlow {
  box-shadow:
    inset 0 0 30px rgba(255, 0, 0, min(0.5, calc(0.12 + var(--fx-danger, 0) * 0.3))),
    inset 0 0 70px rgba(255, 0, 0, calc(var(--fx-danger, 0) * 0.22));
}

.fx-danger .fx-vignette::after {
  box-shadow: inset 0 0 34px rgba(255, 0, 0, 0.55);
  opacity: 0.24;
}

.fx-low-life .fx-vignette::after {
  box-shadow: inset 0 0 40px rgba(255, 0, 0, 0.65);
  opacity: 0.32;
}

/* Slow red/black title-bar blink while one life is left. */
.title-bar { position: relative; }

.fx-low-life .title-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #ff0000;
  opacity: 0;
  pointer-events: none;
  animation: fx-title-alarm 1.6s steps(2, end) infinite;
}

@keyframes fx-title-alarm {
  0%, 100% { opacity: 0; }
  50%      { opacity: 0.8; }
}

/* ── Phase states ───────────────────────────────────────────────────────── */
.phase-paused .fx-overlay,
.phase-draft .fx-overlay { opacity: 0.85; }

.phase-dawn .fx-overlay { opacity: 0.9; }

.phase-gameover .fx-vignette::after {
  box-shadow: inset 0 0 42px rgba(255, 0, 0, 0.7), inset 0 0 10px rgba(255, 0, 0, 0.5);
  animation: fx-red-pulse 1.2s steps(2, end) infinite;
}

.phase-dawn .fx-vignette::after {
  box-shadow: inset 0 0 50px rgba(255, 255, 0, 0.45);
  animation: fx-gold-pulse 2.4s steps(2, end) infinite;
}

@keyframes fx-red-pulse {
  0%, 100% { opacity: 0.28; }
  50%      { opacity: 0.8; }
}

@keyframes fx-gold-pulse {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 0.55; }
}

/* One-shot milestone flash. JS adds .fx-milestone to body for ~0.6s. */
.fx-milestone #fxGlow::after {
  animation: fx-milestone 0.6s steps(6, end) both;
}

@keyframes fx-milestone {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  100% { opacity: 0; }
}

/* A modal dialog dims the effects layer a touch (Win95 inert frame). */
#app.modal-open .fx-overlay { opacity: 0.72; }

/* ── Status bar ─────────────────────────────────────────────────────────── */
.status-bar .status-panel { min-width: 0; }

#statusCombo {
  flex: 0 1 auto;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.fx-combo-hot #statusCombo {
  font-weight: 700;
  color: #808000;
  animation: combo-pulse 0.9s steps(2, end) infinite;
}

.fx-danger #statusCombo { color: #ff0000; }

@keyframes combo-pulse {
  0%, 100% { box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white); }
  50%      { box-shadow: inset 1px 1px #808000, inset -1px -1px #ffff00; }
}

.status-panel.flash-score {
  animation: flash-score 0.3s steps(2, end) both;
}

@keyframes flash-score {
  0%   { box-shadow: inset 0 0 0 24px #ffffff; }
  100% { box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--white); }
}

/* ── Draft card juice ───────────────────────────────────────────────────── */
.draft-card {
  --edge: transparent;
  box-shadow:
    inset 4px 0 0 var(--edge),
    inset 1px 1px var(--white),
    inset -1px -1px var(--shadow);
  transition: transform 0.08s steps(2, end);
}

.draft-card.boon   { --edge: #00a000; }
.draft-card.gambit { --edge: #808000; }
.draft-card.hex    { --edge: #800080; }

.draft-card:hover,
.draft-card:focus-visible {
  animation: none;
  transform: translateY(-2px);
  box-shadow:
    2px 2px 0 #000000,
    inset 4px 0 0 var(--edge),
    inset 1px 1px var(--white),
    inset -1px -1px var(--shadow);
}

/* Rarity gets a hard 1px double outline, stepped not smooth. */
.draft-card:has(.rare),
.draft-card.rare {
  outline: 1px solid #800080;
  outline-offset: -3px;
}

.draft-card:has(.rare)::after,
.draft-card.rare::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid #c000c0;
  pointer-events: none;
  animation: rare-blink 0.9s steps(2, end) infinite;
}

@keyframes rare-blink {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

/* UPGRADE / NEW chips the Lead may append inside a draft card. */
.draft-card .tag-new,
.draft-card .tag-up {
  align-self: flex-start;
  padding: 0 3px 1px;
  background: #ffff00;
  color: #000000;
  border: 1px solid #000000;
  font-size: 9px;
  font-weight: 700;
  line-height: 11px;
  letter-spacing: 0.5px;
}

.draft-card .tag-up { background: #008080; color: #ffffff; }

.draft-card.picked {
  outline: 2px solid #ffff00;
  outline-offset: -3px;
  animation: draft-picked 0.22s steps(3, end) both;
}

@keyframes draft-picked {
  0%   { transform: translateY(0); box-shadow: inset 0 0 0 3px #ffffff; }
  50%  { transform: translateY(-3px); }
  100% { transform: translateY(0); box-shadow: inset 0 0 0 3px #ffff00; }
}

/* ── Dialog polish ──────────────────────────────────────────────────────── */
.dialog-title { position: relative; overflow: hidden; }

.dialog.show .dialog-title::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: #ffffff;
  opacity: 0.4;
  transform: scaleX(0);
  transform-origin: left center;
  animation: dialog-sweep 0.18s steps(4, end) both;
}

@keyframes dialog-sweep {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── Reduced-effects mode (.fx-light toggled by View > Effects) ─────────── */
.fx-light .fx-scanlines,
.fx-light .fx-noise { display: none; }

.fx-light #fxGlow { box-shadow: none; }

.fx-light .fx-vignette {
  box-shadow:
    inset 0 0 28px rgba(0, 0, 0, 0.38),
    inset 0 0 8px rgba(0, 0, 0, 0.3);
}

.fx-light #fxGlow::after,
.fx-light .fx-vignette::after { animation: none !important; }

/* ── Accessibility ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fx-scanlines,
  .fx-noise { animation: none !important; }

  .fx-noise { opacity: 0.02; }

  #fxGlow::after,
  .fx-vignette::after,
  .fx-low-life .title-bar::after,
  .fx-combo-hot #statusCombo,
  .status-panel.flash-score,
  .draft-card.picked,
  .draft-card:has(.rare)::after,
  .draft-card.rare::after,
  .dialog.show .dialog-title::after { animation: none !important; }

  .dialog.show { animation: none; }

  .draft-card:nth-child(n) { animation: none; }

  .fx-overlay,
  .draft-card { transition: none; }
}
