/* Special-mission mode: auth (js/modes/auth.js) — challenge lamps, HQ key + answer strip, the field's
   A = B check, and the enemy listening post (intercepts, candidate keys, the forger's bet). */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas: "ex ex" "desk enemy";
  gap: 12px;
  align-items: start;
  min-width: 0;
}
.auth-exchange { grid-area: ex; }
.auth-desk { grid-area: desk; }
.auth-enemy { grid-area: enemy; }
.auth h2 { font-family: var(--f-stencil); font-size: 17px; line-height: 1.15; letter-spacing: .05em; text-transform: uppercase; color: var(--khaki); }
.auth-sub { display: block; margin-top: 2px; font-family: var(--f-type); font-size: 12.5px; line-height: 1.35; color: var(--khaki-dim); }
.auth-tag, .auth-col-tag { font-weight: 500; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
.auth-col-tag { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.auth-col-tag b { font-family: var(--f-mono); font-weight: normal; font-size: 13px; letter-spacing: 0; color: var(--khaki); }
.auth-dim, .auth-none { font-family: var(--f-type); font-size: 12.5px; font-style: normal; color: var(--khaki-dim); opacity: .8; }
.auth-err { font-family: var(--f-type); font-size: 12.5px; font-style: normal; color: var(--bad); }
.auth svg { width: 1em; height: 1em; vertical-align: -2px; }
.auth-keyword { color: var(--brass); white-space: nowrap; }

/* small lamps (intercepts, tallies, status line) */
.auth .tile.lamp.sm, .auth-status .tile.lamp.sm { width: 16px; height: 16px; margin: 1px; border-width: 1.5px; }
.auth .tile.lamp.sm b { display: none; }
.auth-status .tile.lamp { vertical-align: -3px; }

/* ------------------------------------------------------------------ the exchange: field → HQ → field check */
.auth-exchange {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1.25fr) 34px minmax(0, 1fr);
  align-items: stretch;
}
.auth-st {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #11150c, #1a2013);
  border: 1px solid #070905;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .05);
}
.auth-st header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.auth-st header .auth-sub { margin: 0; }
.auth-hq { background: linear-gradient(180deg, #1d1a10, #24200f); border-color: #0c0a04; }
.auth-check { background: var(--paper-bg, var(--paper)); background-color: var(--paper); border-color: #6d6146; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .06), 0 3px 8px rgba(0, 0, 0, .45); }
.auth-check .auth-tag { color: var(--ink-red); }
.auth-check .auth-sub { color: #5d5640; }

.auth-wire { position: relative; display: grid; place-items: center; }
.auth-wire i { position: absolute; left: 2px; right: 8px; top: 50%; height: 3px; margin-top: -1px; background: repeating-linear-gradient(90deg, var(--khaki-dim) 0 6px, transparent 6px 10px); opacity: .55; }
.auth-wire::after { content: ''; position: absolute; right: 2px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left: 8px solid var(--khaki-dim); border-right: 0; opacity: .7; }
.auth-wire span { position: relative; margin-top: 30px; font-family: var(--f-type); font-size: 10px; color: var(--khaki-dim); opacity: .7; writing-mode: vertical-rl; transform: rotate(180deg); }
.testing .auth-wire i { animation: auth-wire 0.7s linear infinite; opacity: .9; }
@keyframes auth-wire { to { background-position: 10px 0; } }

/* clickable lamps with their shape underneath */
.auth-lamps { display: flex; flex-wrap: wrap; gap: 6px; }
.auth-lamp {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 3px 3px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.auth-lamp:hover { border-color: rgba(216, 201, 155, .25); background: rgba(255, 255, 255, .03); }
.auth-lamp:focus-visible { outline: 2px solid var(--lamp); outline-offset: 1px; }
.auth-lamp .tile.lamp { margin: 0; }
.auth-lamp.key .tile.lamp { box-shadow: 0 0 0 2px var(--brass), 0 2px 3px rgba(0, 0, 0, .5); }
.auth-lamp.key .tile.lamp.lit { box-shadow: 0 0 0 2px var(--brass), 0 0 12px rgba(255, 210, 87, .85); }
.testing .auth-lamp { cursor: default; }
.auth-roll { align-self: flex-start; }

.auth-out { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 38px; padding-top: 6px; border-top: 1px dashed rgba(216, 201, 155, .2); }
.auth-out-tag { font-family: var(--f-ui); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--khaki-dim); }
.auth-out-lamps { display: inline-flex; flex-wrap: wrap; align-items: center; }
.auth-out-lamps .tile.lamp { width: 26px; height: 26px; }
.forging .auth-hq { opacity: .55; filter: grayscale(.6); }

/* the field's comparison */
.auth-cmp { display: flex; flex-direction: column; gap: 4px; }
.auth-cmp > div { display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.auth-ab { grid-row: 1 / 3; font-family: var(--f-stencil); font-size: 22px; color: var(--ink); text-align: center; }
.auth-cmp-who { font-family: var(--f-type); font-size: 11px; line-height: 1.1; color: #6d6650; }
.auth-cmp-lamps { display: flex; flex-wrap: wrap; min-height: 26px; }
.auth-cmp-lamps .tile.lamp { width: 22px; height: 22px; margin: 1px 2px 1px 0; }
.auth-cmp-lamps .tile.lamp b { font-size: 10px; }
.auth-check .auth-none { color: #6d6650; }
.forging .auth-cmp > div:first-child .auth-cmp-who { color: var(--ink-red); font-weight: bold; }

.auth-verdict { display: grid; place-items: center; min-height: 40px; }
.auth-stamp {
  --rot: -6deg;
  --stamp: #4f7a22;
  padding: 4px 12px 2px;
  font-family: var(--f-stencil);
  font-size: 16px;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  max-width: 100%;
  color: var(--stamp);
  border: 3px double var(--stamp);
  border-radius: 6px;
  transform: rotate(var(--rot));
  animation: slam .35s cubic-bezier(.2, .9, .3, 1.2) both;
  -webkit-mask-image: var(--grunge);
  mask-image: var(--grunge);
  -webkit-mask-size: 160px;
  mask-size: 160px;
}
.auth-stamp.bad { --stamp: var(--ink-red); --rot: 5deg; }
.auth-stamp.warn { --stamp: #a8741a; --rot: -3deg; }

/* ------------------------------------------------------------------ HQ desk (strip editor) */
.auth-desk { min-width: 0; }
.auth-desk-head .btn-chip { white-space: nowrap; flex: none; }
.auth-desk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 0 2px 8px; }
.auth .strip-tray { margin-bottom: 8px; }
.auth .strip-tray-lit, .auth .strip-locked-chip { display: none; }

/* key tiles: hatched like a sealed envelope, with a brass key tag (tray, strip, pickers, briefing) */
.auth[data-keys~="blue"] .tpl-cell.var.c-blue, .auth[data-keys~="orange"] .tpl-cell.var.c-orange,
.auth[data-keys~="green"] .tpl-cell.var.c-green, .auth[data-keys~="purple"] .tpl-cell.var.c-purple,
.auth[data-keys~="red"] .tpl-cell.var.c-red, .auth[data-keys~="teal"] .tpl-cell.var.c-teal,
.auth[data-keys~="pink"] .tpl-cell.var.c-pink, .auth[data-keys~="sand"] .tpl-cell.var.c-sand,
.auth-brief[data-keys~="blue"] .tpl-cell.var.c-blue, .auth-brief[data-keys~="orange"] .tpl-cell.var.c-orange,
.auth-brief[data-keys~="green"] .tpl-cell.var.c-green, .auth-brief[data-keys~="purple"] .tpl-cell.var.c-purple,
.auth-brief[data-keys~="red"] .tpl-cell.var.c-red, .auth-brief[data-keys~="teal"] .tpl-cell.var.c-teal,
.auth-brief[data-keys~="pink"] .tpl-cell.var.c-pink, .auth-brief[data-keys~="sand"] .tpl-cell.var.c-sand,
body[data-auth-keys~="blue"] .strip-pop .tpl-cell.var.c-blue, body[data-auth-keys~="orange"] .strip-pop .tpl-cell.var.c-orange,
body[data-auth-keys~="green"] .strip-pop .tpl-cell.var.c-green, body[data-auth-keys~="purple"] .strip-pop .tpl-cell.var.c-purple,
body[data-auth-keys~="red"] .strip-pop .tpl-cell.var.c-red, body[data-auth-keys~="teal"] .strip-pop .tpl-cell.var.c-teal,
body[data-auth-keys~="pink"] .strip-pop .tpl-cell.var.c-pink, body[data-auth-keys~="sand"] .strip-pop .tpl-cell.var.c-sand,
body[data-auth-keys~="blue"] .strip-ghost .tpl-cell.var.c-blue, body[data-auth-keys~="orange"] .strip-ghost .tpl-cell.var.c-orange,
body[data-auth-keys~="green"] .strip-ghost .tpl-cell.var.c-green, body[data-auth-keys~="purple"] .strip-ghost .tpl-cell.var.c-purple,
body[data-auth-keys~="red"] .strip-ghost .tpl-cell.var.c-red, body[data-auth-keys~="teal"] .strip-ghost .tpl-cell.var.c-teal,
body[data-auth-keys~="pink"] .strip-ghost .tpl-cell.var.c-pink, body[data-auth-keys~="sand"] .strip-ghost .tpl-cell.var.c-sand {
  position: relative;
  overflow: visible;
  background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, .2) 0 2px, transparent 2px 5px);
}
.auth[data-keys~="blue"] .tpl-cell.var.c-blue::after, .auth[data-keys~="orange"] .tpl-cell.var.c-orange::after,
.auth[data-keys~="green"] .tpl-cell.var.c-green::after, .auth[data-keys~="purple"] .tpl-cell.var.c-purple::after,
.auth[data-keys~="red"] .tpl-cell.var.c-red::after, .auth[data-keys~="teal"] .tpl-cell.var.c-teal::after,
.auth[data-keys~="pink"] .tpl-cell.var.c-pink::after, .auth[data-keys~="sand"] .tpl-cell.var.c-sand::after,
.auth-brief[data-keys~="blue"] .tpl-cell.var.c-blue::after, .auth-brief[data-keys~="orange"] .tpl-cell.var.c-orange::after,
.auth-brief[data-keys~="green"] .tpl-cell.var.c-green::after, .auth-brief[data-keys~="purple"] .tpl-cell.var.c-purple::after,
.auth-brief[data-keys~="red"] .tpl-cell.var.c-red::after, .auth-brief[data-keys~="teal"] .tpl-cell.var.c-teal::after,
.auth-brief[data-keys~="pink"] .tpl-cell.var.c-pink::after, .auth-brief[data-keys~="sand"] .tpl-cell.var.c-sand::after,
body[data-auth-keys~="blue"] .strip-pop .tpl-cell.var.c-blue::after, body[data-auth-keys~="orange"] .strip-pop .tpl-cell.var.c-orange::after,
body[data-auth-keys~="green"] .strip-pop .tpl-cell.var.c-green::after, body[data-auth-keys~="purple"] .strip-pop .tpl-cell.var.c-purple::after,
body[data-auth-keys~="red"] .strip-pop .tpl-cell.var.c-red::after, body[data-auth-keys~="teal"] .strip-pop .tpl-cell.var.c-teal::after,
body[data-auth-keys~="pink"] .strip-pop .tpl-cell.var.c-pink::after, body[data-auth-keys~="sand"] .strip-pop .tpl-cell.var.c-sand::after,
body[data-auth-keys~="blue"] .strip-ghost .tpl-cell.var.c-blue::after, body[data-auth-keys~="orange"] .strip-ghost .tpl-cell.var.c-orange::after,
body[data-auth-keys~="green"] .strip-ghost .tpl-cell.var.c-green::after, body[data-auth-keys~="purple"] .strip-ghost .tpl-cell.var.c-purple::after,
body[data-auth-keys~="red"] .strip-ghost .tpl-cell.var.c-red::after, body[data-auth-keys~="teal"] .strip-ghost .tpl-cell.var.c-teal::after,
body[data-auth-keys~="pink"] .strip-ghost .tpl-cell.var.c-pink::after, body[data-auth-keys~="sand"] .strip-ghost .tpl-cell.var.c-sand::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brass) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='5' cy='8' r='3.2' fill='none' stroke='%232a2414' stroke-width='2.2'/%3E%3Cpath d='M8 8h7M12.4 8v3' stroke='%232a2414' stroke-width='2.2' fill='none'/%3E%3C/svg%3E") center / 10px no-repeat;
  box-shadow: 0 0 0 1px #2a2414, 0 1px 2px rgba(0, 0, 0, .5);
  pointer-events: none;
}

/* ------------------------------------------------------------------ enemy listening post */
.auth-enemy {
  position: relative;
  padding: 12px 14px 12px;
  border-radius: 6px;
  background:
    repeating-linear-gradient(-45deg, rgba(181, 69, 47, .05) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, #1d140e, #170f0b);
  border: 1px dashed rgba(224, 97, 74, .45);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .6);
}
.auth-enemy h2 { color: #e9a08e; }
.auth-enemy .auth-col-tag { color: #d77c66; }
.auth-enemy-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.auth-ear { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; color: #e9a08e; background: rgba(181, 69, 47, .18); border: 1px solid rgba(224, 97, 74, .5); }
.auth-ear svg { width: 22px; height: 22px; vertical-align: 0; }
.auth-enemy-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "cands cands" "log bet";
  gap: 12px 14px;
  align-items: start;
}
.auth-cands { grid-area: cands; }
.auth-intercepts { grid-area: log; }
.auth-forge { grid-area: bet; }

.auth-intercepts ol { list-style: none; display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; }
.auth-intercepts li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; background: rgba(0, 0, 0, .3); animation: auth-in .3s ease-out; }
.auth-intercepts li.auth-idle { display: block; padding: 0; background: none; font-family: var(--f-type); font-size: 12.5px; line-height: 1.4; color: var(--khaki-dim); }
.auth-intercepts li.auth-idle b { color: var(--khaki); font-weight: normal; }
.auth-ix { font-family: var(--f-mono); font-size: 12px; color: #d77c66; }
.auth-ic, .auth-ir { display: inline-flex; flex-wrap: nowrap; flex: none; }
.auth-arrow { color: var(--khaki-dim); }
.auth-unk { font-family: var(--f-mono); font-size: 12px; letter-spacing: .1em; color: var(--khaki-dim); opacity: .7; }
@keyframes auth-in { from { opacity: 0; transform: translateX(-8px); } }

/* every key the enemy still believes possible */
.auth-grid { display: grid; grid-template-columns: repeat(4, minmax(0, max-content)); gap: 5px; }
.auth-grid.dense { grid-template-columns: repeat(8, minmax(0, max-content)); gap: 3px; }
.auth-key {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 4px 5px;
  border-radius: 3px;
  background: #2a2216;
  border: 1px solid #0a0805;
  transition: opacity .35s, filter .35s;
}
.auth-key i { display: block; width: 7px; height: 7px; border-radius: 50%; background: #1b1a12; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .8); }
.auth-key i.on { background: var(--lamp); box-shadow: 0 0 4px rgba(255, 210, 87, .7); }
.auth-grid.dense .auth-key { padding: 3px; gap: 1px; }
.auth-grid.dense .auth-key i { width: 5px; height: 5px; }
.auth-key.out { opacity: .22; filter: grayscale(1); }
.auth-key.out::after { content: ''; position: absolute; left: -1px; right: -1px; top: 50%; height: 2px; margin-top: -1px; background: var(--bad); transform: rotate(-14deg); }
.auth-key.struck { animation: auth-strike .5s ease-out; }
@keyframes auth-strike { 0% { opacity: 1; filter: none; background: #7a2a1c; } 100% { opacity: .22; } }
.auth-key.truth { opacity: 1; filter: none; box-shadow: 0 0 0 2px var(--brass), 0 0 10px rgba(201, 162, 74, .6); z-index: 1; }

/* the forger's bet: surviving keys grouped by the answer they predict */
.auth-tally { display: flex; flex-direction: column; gap: 4px; }
.auth-bet { display: grid; grid-template-columns: auto minmax(30px, 1fr) auto; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 4px; }
.auth-bet.pick { background: rgba(224, 97, 74, .16); box-shadow: inset 0 0 0 1px rgba(224, 97, 74, .5); }
.auth-bet-r { display: inline-flex; }
.auth-bar { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, .4); overflow: hidden; }
.auth-bar i { display: block; height: 100%; background: #c9604a; animation: auth-bar .6s ease-out; }
.auth-bet-n { font-family: var(--f-mono); font-size: 11.5px; color: var(--khaki-dim); white-space: nowrap; }
@keyframes auth-bar { from { width: 0; } }

.auth-status { min-height: 1.4em; margin: -2px 0 10px; padding: 6px 10px; border-left: 3px solid rgba(224, 97, 74, .5); background: rgba(0, 0, 0, .25); font-family: var(--f-type); font-size: 13px; line-height: 1.45; color: var(--khaki); }
.auth-status:empty { display: none; }
.auth-status.bad { color: #f08a72; }
.auth-status.good { color: var(--ok); }
.auth-status b { color: #fff3cf; font-weight: normal; }

/* ------------------------------------------------------------------ briefing card */
.auth-brief { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; }
.auth-brief > div { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.auth-brief-tag { min-width: 76px; font-family: var(--f-ui); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-red); }
.auth-brief small { font-size: 13px; opacity: .85; }
.auth-brief .tpl-cell.mini { margin-right: 3px; }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ex" "enemy" "desk"; }
}
@media (max-width: 700px) {
  .auth-exchange { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "field check" "hq hq"; gap: 8px; }
  .auth-field { grid-area: field; }
  .auth-hq { grid-area: hq; }
  .auth-check { grid-area: check; }
  .auth-wire { display: none; }
  .auth-st { padding: 8px 10px 10px; }
  .auth-st .auth-lamps { gap: 0; }
  .auth-lamp { padding: 3px 2px 2px; }
  .auth-st header .auth-sub { font-size: 11.5px; }
  .auth-stamp { font-size: 12px; padding: 3px 8px 1px; white-space: normal; text-align: center; }
  .auth-enemy { padding: 10px; }
  .auth-enemy-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cands" "log" "bet"; gap: 10px; }
  .auth-grid.dense .auth-key { padding: 2px; }
  .auth-grid.dense { gap: 2px; }
}

/* ------------------------------------------------------------------ jammer (A3) */
.auth .tile.lamp.auth-jammed, .auth-status .tile.lamp.auth-jammed { position: relative; overflow: visible; outline: 2px solid var(--bad); outline-offset: 1px; }
.auth .tile.lamp.auth-jammed::after {
  content: '';
  position: absolute;
  right: -6px;
  top: -7px;
  width: 11px;
  height: 11px;
  background: var(--bad);
  clip-path: polygon(55% 0, 15% 55%, 45% 55%, 35% 100%, 85% 40%, 55% 40%);
}
.auth .tile.lamp.sm.auth-jammed { outline-width: 1.5px; }
.auth .tile.lamp.sm.auth-jammed::after { width: 8px; height: 8px; right: -4px; top: -5px; }
.auth-wire.jammed i { background: repeating-linear-gradient(90deg, var(--bad) 0 4px, transparent 4px 7px); opacity: .7; }
.auth-bolt { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -22px 0 0 -9px; color: var(--bad); filter: drop-shadow(0 0 4px rgba(224, 97, 74, .7)); }
.auth-bolt svg { width: 18px; height: 18px; }
.testing .auth-bolt { animation: auth-zap .5s steps(2) infinite; }
@keyframes auth-zap { 50% { opacity: .35; } }
.auth-cmp-note { min-height: 1.2em; margin: 2px 0 0 28px; font-family: var(--f-type); font-size: 11.5px; line-height: 1.2; color: #6d6650; }
.auth-cmp-note:empty { display: none; }
.auth-sends { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(224, 97, 74, .35); font-family: var(--f-ui); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #e9a08e; }
.auth-sends > span:first-child { margin-right: 2px; white-space: nowrap; }
@media (max-width: 700px) {
  .auth-cmp-note { margin-left: 0; grid-column: 1 / -1; }
}

/* ------------------------------------------------------------------ the mole (A4) and forged orders (A6) */
.auth-lamp.leaked { position: relative; border-color: rgba(224, 97, 74, .7); background: rgba(181, 69, 47, .18); }
.auth-lamp.leaked::after {
  content: 'MOLE';
  position: absolute;
  left: 50%;
  bottom: -12px;
  transform: translateX(-50%);
  padding: 0 3px;
  font-family: var(--f-ui);
  font-size: 9px;
  letter-spacing: .1em;
  color: #fff3e8;
  background: var(--red);
  border-radius: 2px;
}
.auth-lamps.forged { padding: 2px; border-radius: 6px; box-shadow: 0 0 0 2px rgba(224, 97, 74, .65); background: rgba(181, 69, 47, .15); }
.auth-status .tpl-cell.mini { vertical-align: -4px; }
