/* PINFORGE Wave 2 — Dark Horological Brass Clockwork Forge UI
 * Strict Invariants:
 *  - ZERO pill radii anywhere (max 3px beveled watchmaker corners + chamfered clip-paths)
 *  - >= 12px rendered text floor everywhere
 *  - >= 44x44px touch targets for interactive controls
 *  - Zero external CDN URLs or remote fonts
 *  - Strict Frame Law: zero floating HUD over the 1280x860 board canvas
 */

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

:root {
  --bg: #080b10;
  --panel: #131822;
  --panel-raised: #1b2230;
  --gunmetal: #1c222d;
  --iron-dark: #0c1018;
  --border: #2f394c;
  --border-brass: #9b7638;
  --brass: #d8ae5e;
  --brass-bright: #fde68a;
  --brass-deep: #6b4e1e;
  --molten: #ff8c3b;
  --signal: #4ee4ff;
  --pass: #34d399;
  --fail: #ff5c77;
  --warn: #f59e0b;
  --ink: #f4f1e8;
  --ink-dim: #b4bece;
  --font-display: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

body.high-contrast {
  --bg: #000000;
  --panel: #0d121b;
  --panel-raised: #162030;
  --border: #7c8da6;
  --border-brass: #fde047;
  --brass: #fde047;
  --brass-bright: #ffffff;
  --molten: #ffae42;
  --signal: #5ef2ff;
  --ink: #ffffff;
  --ink-dim: #e2e8f0;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #121826 0%, #080b10 80%);
}

/* ================================================================
   COMPACT TOP BRASS ARCH BAR (46px desktop, >= 44px touch targets)
   ================================================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 1px 10px;
  background: linear-gradient(180deg, #1b2231 0%, #101520 100%);
  border-bottom: 2px solid var(--border-brass);
  box-shadow: inset 0 -1px 0 rgba(253, 230, 138, 0.22), 0 4px 16px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  z-index: 30;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-crest-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
}

.brand-crest-logo {
  display: block;
  height: 28px;
  width: auto;
  max-width: 112px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.78));
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brass-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

/* Riveted Mechanical Brass RUN | DAILY Switch */
.mode-switch {
  display: inline-flex;
  border: 1.5px solid var(--border-brass);
  background: #0a0e16;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}

.mode-btn {
  border: 0;
  min-height: 44px;
  min-width: 48px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.mode-btn:hover {
  color: var(--brass-bright);
}

.mode-btn.active {
  background: linear-gradient(180deg, #e7c06d 0%, #a8762c 100%);
  color: #161006;
  box-shadow: inset 0 1px 0 rgba(255, 250, 224, 0.65);
}

/* Vault Lockplate Boss Seal HP Bar */
.seal-lockplate {
  flex: 1;
  max-width: 460px;
  min-width: 150px;
  padding: 2px 10px 4px;
  background: linear-gradient(180deg, #161c28 0%, #0d111a 100%);
  border: 1px solid var(--border-brass);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

.seal-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.seal-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seal-hp-text {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.seal-bar-track {
  position: relative;
  width: 100%;
  height: 11px;
  border-radius: 2px;
  background: #080b11;
  border: 1px solid var(--border-brass);
  overflow: hidden;
}

.seal-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c2550b 0%, #ff8c3b 52%, #fde68a 100%);
  transition: width 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.seal-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(8, 11, 16, 0.85);
  box-shadow: 1px 0 0 rgba(253, 230, 138, 0.45);
  pointer-events: none;
}

.tick-33 { left: 33.33%; }
.tick-66 { left: 66.66%; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Engraved Brass Scrap Plaque (ZERO pill radius) */
.scrap-plaque {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #241b10 0%, #15100a 100%);
  border: 1.5px solid var(--brass);
  border-radius: 2px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  font-size: 13px;
  font-weight: 800;
  color: var(--brass-bright);
}

.scrap-icon {
  color: var(--molten);
}

.scrap-label {
  font-size: 12px;
  color: var(--brass);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brass-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 9px;
  border-radius: 2px;
  border: 1px solid var(--border-brass);
  background: linear-gradient(180deg, #212838 0%, #131824 100%);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  transition: border-color 110ms ease, background 110ms ease, transform 90ms ease;
}

.brass-tool-btn:hover,
.brass-tool-btn:focus-visible {
  border-color: var(--brass-bright);
  background: linear-gradient(180deg, #2d3548 0%, #1a2130 100%);
  outline: none;
}

.brass-tool-btn:active {
  transform: scale(0.96);
}

.brass-tool-btn.accent-btn {
  background: linear-gradient(180deg, #e7c06d 0%, #b58333 100%);
  color: #161006;
  border-color: var(--brass-bright);
}

.tool-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ================================================================
   WORKSPACE GRID — SLIM 178px RAILS + MASSIVE 1280x860 BOARD
   ================================================================ */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) 178px;
  gap: 8px;
  padding: 6px 8px;
  overflow: hidden;
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-brass) transparent;
}

/* Riveted Watchmaker Brass Plaque Card (9-slice ui-plaque-frame.png) */
.plaque-card {
  position: relative;
  background-color: #111620;
  background-clip: padding-box;
  border-style: solid;
  border-width: 7px;
  border-color: var(--border-brass);
  border-image-source: url("./assets/ui/ui-plaque-frame.png");
  border-image-slice: 60 fill;
  border-image-width: 14px;
  border-image-repeat: stretch;
  border-radius: 2px;
  padding: 6px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.48);
}

.plaque-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(155, 118, 56, 0.35);
}

.plaque-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--brass);
  font-weight: 700;
}

.rail-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}

/* ---------- LEFT RAIL: ANALOG BRASS CHAIN PRESSURE DIAL ---------- */
.dial-card.fever-active {
  border-color: var(--molten);
  box-shadow: inset 0 0 18px rgba(255, 140, 59, 0.25), 0 0 14px rgba(255, 140, 59, 0.35);
}

.fever-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: #160c04;
  background: linear-gradient(90deg, #ff8c3b, #fde68a);
  padding: 1px 5px;
  border-radius: 2px;
}

.dial-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.chain-dial-svg {
  width: 100%;
  max-width: 152px;
  height: auto;
  display: block;
}

.dial-needle {
  transform-origin: 80px 88px;
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dial-readout {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding-top: 2px;
}

.chain-big {
  font-size: 24px;
  font-weight: 800;
  color: var(--brass-bright);
  line-height: 1;
}

.dial-card.fever-active .chain-big {
  color: var(--molten);
}

.mult-tag {
  font-size: 12px;
  font-weight: 800;
  color: var(--signal);
}

/* Score & Mechanism Counters */
.score-plaque {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(155, 118, 56, 0.3);
}

.micro-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brass);
}

.score-big {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-dim);
}

.stat-row strong {
  color: var(--ink);
}

/* Relic Rack Plaques (Chamfered Brass Medallion Sockets) */
.relic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.relic-slot {
  min-height: 50px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: #0b0f17;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 3px;
  text-align: center;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
}

.relic-slot.filled {
  border-color: var(--brass);
  background: linear-gradient(160deg, #282014 0%, #121722 100%);
}

.relic-slot.curse {
  border-color: var(--fail);
}

.relic-sym {
  font-size: 16px;
  line-height: 1.1;
}

.relic-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- CENTER PROTECTED BOARD STAGE (1280 x 860) ---------- */
.board-stage {
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  background: #06080d;
  border-radius: 3px;
  border: 2px solid var(--border-brass);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.85), 0 0 24px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  position: relative;
}

#gameCanvas {
  display: block;
  width: min(100cqw, calc(100cqh * 1280 / 860));
  height: min(100cqh, calc(100cqw * 860 / 1280));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1280 / 860;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}

/* ---------- RIGHT RAIL: BEARING HOPPER & STEAM FLIPPER ---------- */
.bearing-rack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rack-slot {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 5px 8px;
  border-radius: 2px;
  border: 1.5px solid var(--border);
  background: linear-gradient(180deg, #121824 0%, #0b0f17 100%);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  transition: border-color 110ms ease, background 110ms ease, transform 90ms ease;
}

.rack-slot:hover {
  border-color: var(--brass);
}

.rack-slot.selected {
  border-color: var(--brass-bright);
  background: linear-gradient(180deg, #2c2315 0%, #1a140c 100%);
  box-shadow: inset 0 0 0 1px rgba(253, 230, 138, 0.35);
}

.rack-orb-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.bearing-desc {
  margin: 6px 0 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-dim);
  min-height: 32px;
}

/* Painted Brass Plaque Primary Button */
.brass-plaque-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 24px;
  border: 0;
  border-radius: 2px;
  background: transparent url("./assets/ui/ui-btn-brass.png") center / 100% 100% no-repeat;
  color: #160e05;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 0 rgba(255, 245, 210, 0.62);
  cursor: pointer;
  transition: filter 120ms ease, transform 90ms ease;
}

.brass-plaque-btn:hover:not(:disabled) {
  filter: brightness(1.14);
  transform: translateY(-1px);
}

.brass-plaque-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.brass-plaque-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* Steam Flipper Pressure Gauge & Trigger */
.flipper-card.is-ready {
  border-color: var(--brass-bright);
}

.flipper-card.is-firing {
  border-color: var(--signal);
  box-shadow: inset 0 0 16px rgba(78, 228, 255, 0.22), 0 0 14px rgba(78, 228, 255, 0.3);
}

.steam-gauge-track {
  width: 100%;
  height: 10px;
  border-radius: 2px;
  background: #080b11;
  border: 1px solid var(--border-brass);
  overflow: hidden;
  margin-bottom: 8px;
}

.steam-gauge-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #4ee4ff 55%, #fde68a 100%);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 80ms linear;
}

.flipper-card.is-firing .steam-gauge-fill {
  background: linear-gradient(90deg, #ff8c3b 0%, #fde68a 100%);
}

.flipper-trigger-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  min-height: 46px;
  padding: 6px 10px;
  border-radius: 2px;
  border: 1.5px solid var(--signal);
  background: linear-gradient(180deg, #163042 0%, #0d1c29 100%);
  color: var(--ink);
  cursor: pointer;
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  transition: filter 110ms ease, transform 90ms ease, border-color 110ms ease;
}

.flipper-trigger-btn:hover:not(:disabled) {
  filter: brightness(1.16);
  border-color: var(--brass-bright);
}

.flipper-trigger-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.flipper-trigger-btn:disabled {
  opacity: 0.45;
  border-color: var(--border);
  cursor: not-allowed;
}

.flipper-btn-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--signal);
}

.flipper-btn-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
}

/* Status & Records Plaque */
.temper-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--brass-bright);
}

.temper-tag.is-sweet {
  color: var(--molten);
}

.seal-hint {
  font-size: 12px;
  line-height: 1.38;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

.retention-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.retention-cell {
  background: #0b0f17;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.retention-label {
  font-size: 12px;
  color: var(--ink-dim);
  font-weight: 700;
}

.retention-val {
  font-size: 14px;
  color: var(--brass-bright);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 2px;
  border: 1.5px solid var(--border-brass);
  background: linear-gradient(180deg, #212838 0%, #121723 100%);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  transition: border-color 110ms ease, filter 110ms ease;
}

.secondary-btn:hover:not(:disabled) {
  border-color: var(--brass-bright);
  filter: brightness(1.1);
}

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

/* ================================================================
   FOUNDRY BLUEPRINT MODALS (WORKSHOP, CODEX, PAUSE, END)
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 90;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  border-radius: 3px;
  padding: 18px 20px;
  box-shadow: 0 28px 68px rgba(0, 0, 0, 0.78);
}

/* Foundry Blueprint Workbench Surface + Painted Brass Plaque Border */
.blueprint-panel {
  background-color: #0e1420;
  background-image:
    linear-gradient(rgba(78, 228, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78, 228, 255, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(19, 27, 42, 0.94) 0%, rgba(10, 14, 22, 0.98) 100%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
  background-clip: padding-box;
  border-style: solid;
  border-width: 12px;
  border-color: var(--brass);
  border-image-source: url("./assets/ui/ui-plaque-frame.png");
  border-image-slice: 60;
  border-image-width: 22px;
  border-image-repeat: stretch;
}

.compact-panel {
  max-width: 500px;
  text-align: center;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--signal);
}

.modal-title {
  margin: 3px 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
}

.modal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.4;
}

.large-scrap {
  padding: 7px 14px;
  font-size: 15px;
}

.shop-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.shop-section h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
}

.sec-note {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
}

.shop-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.offer-grid {
  display: grid;
  gap: 8px;
}

.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.offer-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 76px;
  padding: 10px 11px;
  border-radius: 2px;
  border: 1.5px solid var(--border-brass);
  background: linear-gradient(180deg, rgba(22, 29, 43, 0.95) 0%, rgba(12, 16, 25, 0.98) 100%);
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  transition: border-color 110ms ease, transform 100ms ease, filter 110ms ease;
}

.offer-card:hover:not(:disabled) {
  border-color: var(--brass-bright);
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.offer-card.purchased {
  opacity: 0.45;
  cursor: default;
}

.offer-card:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.offer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.offer-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.offer-pin-thumb {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.offer-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.offer-cost {
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--brass-bright);
  white-space: nowrap;
}

.offer-desc {
  font-size: 12px;
  line-height: 1.38;
  color: var(--ink-dim);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(155, 118, 56, 0.35);
}

.modal-footer .brass-plaque-btn {
  width: auto;
  min-width: 210px;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.end-stat {
  background: #0d121c;
  border: 1px solid var(--border-brass);
  border-radius: 2px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}

.end-stat span {
  font-size: 12px;
  color: var(--ink-dim);
  font-weight: 700;
}

.end-stat strong {
  font-size: 18px;
  color: var(--brass-bright);
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.codex-item {
  border: 1px solid var(--border-brass);
  background: #0d121c;
  border-radius: 2px;
  padding: 10px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}

.codex-item.locked {
  opacity: 0.55;
}

/* ================================================================
   RESPONSIVE BREAKPOINTS (360x640, 390x844, 800x450 -> 1920x1080)
   ================================================================ */
@media (max-width: 1080px) and (min-width: 901px) {
  .workspace {
    grid-template-columns: 162px minmax(0, 1fr) 162px;
    gap: 6px;
    padding: 5px 6px;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 6px;
    padding: 6px;
    overflow-y: auto;
  }

  .board-stage {
    container-type: normal;
    aspect-ratio: 1280 / 860;
    width: min(100%, calc((100dvh - 196px) * 1280 / 860));
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    margin: 0 auto;
  }

  #gameCanvas {
    width: 100%;
    height: 100%;
  }

  .left-rail {
    display: none;
  }

  .right-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 172px;
    gap: 6px;
    overflow: visible;
  }

  .status-card,
  .bearing-desc {
    display: none;
  }

  .hopper-card {
    padding: 7px 8px;
  }

  .bearing-rack {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 6px;
  }

  .rack-slot {
    flex-direction: column;
    justify-content: center;
    padding: 4px 2px;
    min-height: 44px;
    gap: 2px;
    text-align: center;
  }

  .drop-btn {
    min-height: 44px;
    padding: 8px 10px;
  }

  .flipper-card {
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .three-col,
  .two-col,
  .shop-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .top-bar {
    flex-wrap: wrap;
    padding: 4px 6px;
    gap: 4px;
  }

  .brand-crest-logo {
    height: 22px;
    max-width: 64px;
  }

  .brand-name {
    font-size: 13px;
    letter-spacing: 0.08em;
  }

  .mode-btn {
    min-width: 44px;
    padding: 0 7px;
  }

  .seal-lockplate {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    padding: 3px 8px;
  }

  .scrap-label,
  #codexBtn,
  #contrastBtn,
  .tool-text {
    display: none;
  }

  .brass-tool-btn {
    padding: 0 6px;
  }

  .right-rail {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .flipper-card {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .flipper-card .plaque-head {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .flipper-card .steam-gauge-track {
    flex: 1;
    margin-bottom: 0;
  }

  .flipper-trigger-btn {
    width: auto;
    min-width: 116px;
    padding: 6px 10px;
  }

  .flipper-btn-key {
    display: none;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .brass-plaque-btn,
  .modal-footer .secondary-btn {
    width: 100%;
  }
}

@media (max-height: 540px) and (min-width: 901px) {
  .top-bar {
    min-height: 44px;
  }

  .workspace {
    padding: 4px 6px;
    gap: 6px;
  }

  .plaque-card {
    padding: 6px 8px;
  }

  .relic-slot {
    min-height: 40px;
  }

  .bearing-desc,
  .seal-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .seal-bar-fill,
  .dial-needle,
  .steam-gauge-fill,
  .offer-card,
  .brass-plaque-btn,
  .brass-tool-btn,
  .flipper-trigger-btn,
  .rack-slot {
    transition: none !important;
  }
}
