/* =========================================================
   Claw & Dagger — prototype styling, v2 "living room" pass
   Priority: tactical clarity over beauty (but now with beauty).
   ========================================================= */

:root {
  /* ---- Core UI ---- */
  --bg: #261f1a;
  --panel: #3a322b;
  --panel-edge: #4d4239;
  --ink: #241a10;
  --text: #efe7da;
  --text-dim: #b8ab99;
  --cream: #f8efdd;
  --gold: #f7c437;

  /* ---- Clans (cartoon board palette — keep warm, do NOT swap for dossier cyan) ---- */
  --blue: #4f8ef7;
  --blue-dark: #2b5cb8;
  --blue-deep: #1e3f80;
  --orange: #f59135;
  --orange-dark: #c2640f;
  --orange-deep: #8f4a0a;

  /* ---- Terrain ---- */
  --wood-a: #d9b98a;
  --wood-b: #cfae7e;
  --wood-line: #b8945f;
  --rug-a: #b65c4a;
  --rug-b: #a85342;
  --under: #3d342a;

  /* ---- Status / Actions ---- */
  --good: #3fae5c;   /* move */
  --leap: #9d6bf2;   /* pounce leap */
  --danger: #e25c4a; /* attack / revealed */
  --knock: #f0a23c;  /* knock */

  /* ---- Dossier wrapper layer (menus, pass screen, marketing — NOT the board) ----
     Reserved for the classified-dossier UI. Cyan/navy belong here, never on the
     warm cartoon board. See ART-DIRECTION.md "Two palettes". */
  --dossier-navy: #0b2238;
  --dossier-navy-deep: #081622;
  --dossier-cyan: #30d5e8;
  --manila: #f0dfb8;
  --stamp-red: #b9392f;
  --sunbeam: #ffd86b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, #3a3027 0%, var(--bg) 55%, #1c1612 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

#app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

/* ===== Header ===== */
#header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 2px 14px;
}
#header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--cream);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
#header .amp {
  color: var(--orange);
  display: inline-block;
  transform: rotate(-8deg) scale(1.15);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 18px rgba(245, 145, 53, 0.35);
}
#phase-banner {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-style: italic;
}
.title-paw {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-left: 8px;
  transform: rotate(20deg);
  opacity: 0.9;
}
.title-paw svg { width: 100%; height: 100%; display: block; }

/* ===== Layout ===== */
#main {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}
#board-wrap { flex: 0 0 auto; }

/* Opt-in board coordinates (A–H / 1–8). Absolute label strips so the board keeps
   its own width + aspect-ratio sizing. Hidden (and zero-footprint) by default. */
.coord-rows, .coord-cols { display: none; }
#board-wrap.show-coords {
  position: relative;
  padding-left: 16px;
  padding-bottom: 15px;
}
#board-wrap.show-coords .coord-rows,
#board-wrap.show-coords .coord-cols {
  display: flex;
  position: absolute;
  color: var(--text-dim);
  font: 700 0.6rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
  user-select: none;
}
#board-wrap.show-coords .coord-rows {
  left: 0; top: 0; bottom: 15px; width: 16px;
  flex-direction: column; justify-content: space-around; align-items: center;
}
#board-wrap.show-coords .coord-cols {
  left: 16px; right: 0; bottom: 0; height: 15px;
  flex-direction: row; justify-content: space-around; align-items: center;
}
.coord-toggle {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 0.8rem; color: var(--text-dim); cursor: pointer;
}
#side-panel {
  flex: 1 1 280px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Board ===== */
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(90vmin, 760px);
  aspect-ratio: 1;
  border: 6px solid #4a321f;
  outline: 3px solid #241a10;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(0, 0, 0, 0.18);
}

.tile {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  /* wood planks */
  background:
    repeating-linear-gradient(0deg,
      transparent 0 22%, rgba(0,0,0,0.07) 22% 23%,
      transparent 23% 47%, rgba(0,0,0,0.07) 47% 48%,
      transparent 48% 72%, rgba(0,0,0,0.07) 72% 73%,
      transparent 73% 100%),
    var(--wood-a);
}
.tile.tile-alt {
  background:
    repeating-linear-gradient(0deg,
      transparent 0 30%, rgba(0,0,0,0.07) 30% 31%,
      transparent 31% 61%, rgba(0,0,0,0.07) 61% 62%,
      transparent 62% 100%),
    var(--wood-b);
}

/* Faint clan tints on home rows */
.tile.home-blue { box-shadow: inset 0 0 0 200px rgba(79, 142, 247, 0.09); }
.tile.home-orange { box-shadow: inset 0 0 0 200px rgba(245, 145, 53, 0.10); }

/* Hover feedback on interactive tiles */
.tile:not(.terrain-furniture):not(.terrain-blocker):hover {
  filter: brightness(1.07);
}

/* The rug under the central furniture */
.tile.rug {
  background:
    repeating-linear-gradient(45deg,
      rgba(255, 235, 200, 0.10) 0 6px, transparent 6px 14px),
    var(--rug-a);
  box-shadow: inset 0 0 0 1px rgba(60, 20, 12, 0.25);
}
.tile.rug.tile-alt {
  background:
    repeating-linear-gradient(45deg,
      rgba(255, 235, 200, 0.10) 0 6px, transparent 6px 14px),
    var(--rug-b);
}

.tile.terrain-furniture,
.tile.terrain-furniture.tile-alt {
  background: var(--rug-a);
  cursor: default;
}
.tile.terrain-underFurniture,
.tile.terrain-underFurniture.tile-alt {
  background: var(--under);
  box-shadow: inset 0 6px 18px rgba(0, 0, 0, 0.65);
}
.tile.terrain-blocker,
.tile.terrain-blocker.tile-alt {
  cursor: default;
}

/* Terrain art fills the tile */
.terrain-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.terrain-art svg { width: 100%; height: 100%; display: block; }
.terrain-art-looseObject { inset: 8%; }
.terrain-art-blocker { inset: 4%; }

/* Setup zone */
.tile.setup-zone {
  outline: 2px dashed rgba(120, 170, 255, 0.4);
  outline-offset: -3px;
}
.tile.setup-valid {
  outline: 3px solid var(--good);
  outline-offset: -3px;
  box-shadow: inset 0 0 16px rgba(63, 174, 92, 0.45);
}

/* Legal move markers (SVG paw prints, claws, arcs, starbursts) */
.move-marker {
  position: absolute;
  inset: 18%;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  animation: bob 1.2s ease-in-out infinite;
}
.move-marker svg { width: 100%; height: 100%; display: block; }
.tile.legal-attack .move-marker,
.tile.legal-knock .move-marker {
  inset: 10%;
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4%); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.88); opacity: 0.75; }
}

.tile.selected {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
  z-index: 2;
  box-shadow: inset 0 0 18px rgba(247, 196, 55, 0.4);
}
.tile.selected .piece {
  animation: card-idle 1.6s ease-in-out infinite;
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.5);
}

/* Living cards: your own cats gently "breathe" (animated on the inner art so it
   never fights the card's slide/selection transforms). Enemy cards stay still —
   inscrutable. Staggered by tile parity so they don't bob in lockstep. */
@keyframes card-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2%) scale(1.02) rotate(-0.6deg); }
}
@keyframes card-idle {
  0%, 100% { transform: translateY(-7%) scale(1.06); }
  50% { transform: translateY(-11%) scale(1.06); }
}
.piece.mine .piece-art { animation: card-breathe 3.4s ease-in-out infinite; }
.tile:nth-child(2n) .piece.mine .piece-art { animation-delay: -1.7s; }
.tile:nth-child(3n) .piece.mine .piece-art { animation-duration: 3.9s; }

/* Hover affordance (pointer devices) — brightness/shadow only, so it composes
   with the breathe/slide transforms instead of fighting them. */
@media (hover: hover) {
  .tile:not(.terrain-furniture):not(.terrain-blocker):hover .piece {
    filter: brightness(1.07);
    box-shadow: 0 6px 13px rgba(0, 0, 0, 0.5);
  }
}

/* ===== Pieces: little trading cards ===== */
.piece {
  position: relative;
  z-index: 1;
  width: 88%;
  height: 90%;
  border-radius: 14%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--cream);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  overflow: visible;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.piece.blue { border: 3px solid var(--blue-dark); }
.piece.orange { border: 3px solid var(--orange-dark); }

.piece-art {
  width: 86%;
  height: 70%;
  margin-top: 3%;
  display: block;
}
.piece-art svg { width: 100%; height: 100%; display: block; }

.piece-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(7px, 1.35vmin, 11px);
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  padding: 1px 0 2px;
  border-radius: 0 0 8% 8%;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}
.piece.blue .piece-label { background: var(--blue-dark); }
.piece.orange .piece-label { background: var(--orange-dark); }

/* Colorblind-safe ownership: a shape glyph, not color alone.
   Circle = Blue clan, triangle = Orange clan. */
.clan-glyph {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 3px;
  vertical-align: middle;
  background: #fff;
}
.clan-glyph.blue { border-radius: 50%; }
.clan-glyph.orange { clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }

.piece-rank {
  position: absolute;
  top: -7%;
  right: -7%;
  width: clamp(13px, 2.6vmin, 20px);
  height: clamp(13px, 2.6vmin, 20px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 1.6vmin, 12px);
  font-weight: 900;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Hidden enemies: darker card, mystery cat-back */
.piece.hidden-piece {
  background: #2e2835;
}
.piece.hidden-piece.blue { border-color: var(--blue-deep); }
.piece.hidden-piece.orange { border-color: var(--orange-deep); }
.piece.hidden-piece .piece-label {
  background: #221c28;
  color: #8f859c;
}

.badge {
  position: absolute;
  width: clamp(12px, 2.6vmin, 18px);
  height: clamp(12px, 2.6vmin, 18px);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
  z-index: 2;
}
.badge svg { width: 100%; height: 100%; display: block; }
.stun-badge { top: -8%; left: -8%; }
.hide-badge { bottom: 8%; left: -10%; }
.revealed-badge { top: -8%; left: -8%; }
.stun-badge ~ .revealed-badge { top: auto; bottom: 8%; right: -10%; left: auto; }

/* Cache marker on a tile (sits behind/beside a piece) */
.cache-marker {
  position: absolute;
  inset: 12%;
  pointer-events: none;
}
.cache-marker svg { width: 100%; height: 100%; display: block; }
/* if a piece is also on the tile, tuck the cache into the corner */
.cache-marker:has(+ .piece),
.piece ~ .cache-marker {
  inset: auto 2% 2% auto;
  width: 40%;
  height: 40%;
}

/* ===== Side panel ===== */
.panel-box {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.panel-box h2 { margin: 0 0 2px; font-size: 1.2rem; font-weight: 800; }
.panel-box h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}
#turn-number { color: var(--text-dim); font-size: 0.85rem; }

h2.blue, .clan-label.blue { color: var(--blue); }
h2.orange, .clan-label.orange { color: var(--orange); }

.hint { color: var(--text-dim); font-size: 0.86rem; margin: 4px 0; }
.hint-empty { display: flex; align-items: center; gap: 10px; }
.hint-art { width: 46px; height: 46px; flex: 0 0 auto; opacity: 0.6; }
.hint-art svg { width: 100%; height: 100%; display: block; }
.ability { font-size: 0.9rem; margin: 6px 0; }
.ability-note { font-size: 0.84rem; color: var(--text-dim); margin: 4px 0; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-art {
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  background: var(--cream);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--panel-edge);
}
.detail-art.blue { border-color: var(--blue-dark); }
.detail-art.orange { border-color: var(--orange-dark); }
.detail-art svg { width: 100%; height: 100%; display: block; padding: 4px; }
.detail-portrait { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-name { font-weight: 800; font-size: 1.05rem; }
.detail-rank {
  display: block;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Setup tray */
#tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.tray-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 5px;
  border-radius: 9px;
  border: 2px solid transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.tray-item.blue { background: var(--blue-dark); }
.tray-item.orange { background: var(--orange-dark); }
.tray-item.placed { opacity: 0.25; cursor: default; box-shadow: none; }
.tray-item.tray-selected {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(247, 196, 55, 0.55);
}
.tray-art {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  background: var(--cream);
  border-radius: 7px;
  padding: 2px;
}
.tray-art svg { width: 100%; height: 100%; display: block; }
.tray-rank {
  font-size: 0.72rem;
  font-weight: 900;
  background: var(--gold);
  color: var(--ink);
  border-radius: 50%;
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Buttons: chunky cartoon push-buttons */
.big-btn {
  display: block;
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  border: none;
  border-radius: 12px;
  background: var(--good);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a7a40, 0 6px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big-btn:hover:not(:disabled) { filter: brightness(1.08); }
.big-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2a7a40, 0 2px 6px rgba(0, 0, 0, 0.35);
}
.big-btn:disabled {
  background: #5a5248;
  color: #968b7c;
  cursor: default;
  box-shadow: 0 4px 0 #3e382f;
}
.big-btn.btn-blue {
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-deep), 0 6px 12px rgba(0, 0, 0, 0.35);
}
.big-btn.btn-blue:active { box-shadow: 0 1px 0 var(--blue-deep), 0 2px 6px rgba(0, 0, 0, 0.35); }
.big-btn.btn-orange {
  background: var(--orange);
  box-shadow: 0 4px 0 var(--orange-deep), 0 6px 12px rgba(0, 0, 0, 0.35);
}
.big-btn.btn-orange:active { box-shadow: 0 1px 0 var(--orange-deep), 0 2px 6px rgba(0, 0, 0, 0.35); }
.big-btn.btn-knock {
  background: var(--knock);
  color: var(--ink);
  box-shadow: 0 4px 0 #b06f1a, 0 6px 12px rgba(0, 0, 0, 0.35);
  margin-top: 10px;
}
.big-btn.btn-knock:active { box-shadow: 0 1px 0 #b06f1a, 0 2px 6px rgba(0, 0, 0, 0.35); }
.big-btn.btn-knock-cancel {
  background: #5a5248;
  box-shadow: 0 4px 0 #3e382f, 0 6px 12px rgba(0, 0, 0, 0.35);
  margin-top: 10px;
}
.big-btn.btn-knock-cancel:active { box-shadow: 0 1px 0 #3e382f, 0 2px 6px rgba(0, 0, 0, 0.35); }

.small-btn {
  padding: 6px 10px;
  margin: 2px 4px 2px 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: #4a4138;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.small-btn:hover { filter: brightness(1.15); }
.small-btn:active { transform: translateY(2px); box-shadow: none; }
.small-btn.danger { background: #6e3429; border-color: #8f4538; }

#dev-box .dev-toggle {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  cursor: pointer;
}

/* Graveyard */
.grave-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  margin: 4px 0;
  min-height: 26px;
}
.clan-label { font-weight: 800; font-size: 0.85rem; min-width: 58px; }
.grave-piece {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: var(--cream);
  border-radius: 6px;
  padding: 1px;
  margin-right: 3px;
  opacity: 0.85;
}
.grave-piece svg { width: 100%; height: 100%; display: block; }

/* Combat log */
#combat-log {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-entry {
  font-size: 0.82rem;
  color: var(--text-dim);
  border-left: 3px solid var(--panel-edge);
  padding-left: 8px;
}
.log-entry:first-child { color: var(--text); border-left-color: var(--orange); }

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  /* fully opaque: privacy requirement */
  background:
    radial-gradient(ellipse 100% 80% at 50% 20%, #352c24 0%, var(--bg) 60%, #17120e 100%);
}
#gameover-screen {
  background: rgba(38, 31, 26, 0.82);
  backdrop-filter: blur(4px);
}

.overlay-card {
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  border-radius: 20px;
  padding: 36px 48px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65);
}
.overlay-card h2 {
  margin: 12px 0 6px;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--cream);
}
.overlay-card p { color: var(--text-dim); margin: 0 0 24px; font-style: italic; }
.overlay-card .pass-latest {
  font-style: normal;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 8px 12px;
  margin: -10px 0 22px;
}
.gameover-stats {
  font-style: normal !important;
  font-size: 0.85rem;
  color: var(--gold) !important;
  margin: -14px 0 22px !important;
}
.debrief {
  text-align: left;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 4px 0 14px;
}
.debrief-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
  padding: 3px 0;
}
.debrief-row span { color: var(--text-dim); }
.debrief-row b { color: var(--text); }
.debrief-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Rules card */
#rules-screen { background: rgba(38, 31, 26, 0.88); backdrop-filter: blur(4px); }
.rules-card { max-width: 540px; text-align: left; }
.rules-card h2 { text-align: center; }
.rules-list {
  margin: 14px 0 24px;
  padding: 0 0 0 4px;
  list-style: none;
}
.rules-list li {
  font-size: 0.92rem;
  color: var(--text);
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.rules-list li:last-child { border-bottom: none; }
.rules-kbd {
  font-size: 0.82rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 18px;
}
.paw-art { line-height: 0; }
.overlay-cat {
  display: inline-block;
  width: 110px;
  height: 110px;
  vertical-align: middle;
}
.overlay-cat svg { width: 100%; height: 100%; display: block; }
.overlay-cat-small { width: 70px; height: 70px; margin-left: -14px; }
.overlay-cat.overlay-cat-big { width: 170px; height: 170px; }

/* ===== Action feedback ===== */
@keyframes fx-pop {
  0% { transform: scale(0.6); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.tile.fx-pop .piece,
.tile.fx-pop .terrain-art {
  animation: fx-pop 0.38s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes board-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(4px, -3px); }
  60% { transform: translate(-3px, -2px); }
  80% { transform: translate(2px, 2px); }
}
#board.board-shake { animation: board-shake 0.35s ease; }

/* A cat that was just exposed pops and flashes (CP06). */
@keyframes reveal-pop {
  0% { transform: scale(0.72); filter: brightness(1.7); }
  60% { transform: scale(1.12); filter: brightness(1.15); }
  100% { transform: scale(1); filter: none; }
}
.piece.just-revealed { animation: reveal-pop 280ms ease-out; }

/* Respect reduced-motion: keep state clarity, drop the movement (CP06). */
@media (prefers-reduced-motion: reduce) {
  .move-marker,
  .tile.fx-pop .piece,
  .tile.fx-pop .terrain-art,
  #board.board-shake,
  .piece.just-revealed,
  .piece.mine .piece-art,
  .tile.selected .piece { animation: none !important; }
  .piece, .tile.selected .piece { transition: none !important; }
  .tile.selected .piece { transform: translateY(-6%) scale(1.06) !important; } /* static lift, no bob */
}

/* ===== Pass screen: classified vault / privacy firewall (CP07) ===== */
#pass-screen {
  background:
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    repeating-linear-gradient(90deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    radial-gradient(ellipse 90% 75% at 50% 26%, #143049 0%, var(--dossier-navy) 55%, var(--dossier-navy-deep) 100%);
}
#pass-screen .overlay-card {
  position: relative;
  background: var(--manila);
  color: #2c2417;
  border: 1px solid #cbb583;
  border-radius: 3px 14px 12px 12px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.75);
  padding: 42px 44px 34px;
  overflow: visible;
}
/* manila folder tab */
#pass-screen .overlay-card::before {
  content: "EYES ONLY";
  position: absolute;
  top: -21px;
  left: 22px;
  height: 22px;
  padding: 0 16px;
  background: var(--manila);
  border: 1px solid #cbb583;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: #7a6638;
  font: 700 0.6rem/22px ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 2.5px;
}
/* red rotated CLASSIFIED stamp */
#pass-screen .overlay-card::after {
  content: "CLASSIFIED";
  position: absolute;
  top: 22px;
  right: 14px;
  transform: rotate(10deg);
  color: var(--stamp-red);
  border: 3px solid var(--stamp-red);
  border-radius: 5px;
  padding: 2px 8px;
  font: 900 0.78rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 1px;
  opacity: 0.8;
}
/* faint vault padlock watermark */
.pass-seal {
  position: absolute;
  bottom: 14px;
  right: 16px;
  width: 86px;
  height: 86px;
  color: var(--dossier-navy);
  opacity: 0.07;
  pointer-events: none;
}
#pass-screen h2 { color: #241a10; font-size: 1.35rem; }
#pass-screen .overlay-card p { color: #5f4f33; font-style: italic; }
#pass-screen .pass-latest {
  font-style: normal;
  background: rgba(0, 0, 0, 0.06);
  color: #4a3d27;
  border-left: 3px solid var(--stamp-red);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
}
/* incoming agent's taped case photo */
#pass-screen .paw-art {
  display: inline-block;
  background: #fff;
  padding: 7px;
  border: 1px solid #d9c79a;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
  transform: rotate(-2deg);
  margin-bottom: 10px;
}
#pass-screen.pass-blue .paw-art { box-shadow: 0 0 0 2px var(--blue), 0 6px 14px rgba(0, 0, 0, 0.3); }
#pass-screen.pass-orange .paw-art { box-shadow: 0 0 0 2px var(--orange), 0 6px 14px rgba(0, 0, 0, 0.3); }
#pass-screen .overlay-cat-big { width: 132px; height: 132px; display: block; }

/* ===== Start menu ===== */
#start-screen {
  background:
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    repeating-linear-gradient(90deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    radial-gradient(ellipse 90% 75% at 50% 26%, #143049 0%, var(--dossier-navy) 55%, var(--dossier-navy-deep) 100%);
}
.start-card { max-width: 440px; text-align: center; position: relative; }
.start-card .pass-seal { color: var(--cream); opacity: 0.06; }
.start-keyart {
  display: block;
  width: calc(100% + 32px);
  height: 116px;
  margin: -20px -16px 6px;
  border-radius: 12px 12px 0 0;
  object-fit: cover;
  object-position: center 78%;
  background: #6b4a2e;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 26%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 26%, #000 100%);
}
.start-title { margin: 4px 0 2px; font-size: 2rem; font-weight: 900; color: var(--cream); letter-spacing: 0.5px; }
.start-title .amp { color: var(--orange); }
.start-tag { color: var(--text-dim) !important; font-style: italic; margin: 0 0 20px !important; font-size: 0.88rem; }
.start-group { margin: 0 0 16px; text-align: left; }
.start-label { display: block; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 6px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-btn {
  flex: 1 1 auto; min-width: 88px; padding: 9px 12px;
  font: inherit; font-size: 0.85rem; font-weight: 700;
  border: 2px solid var(--panel-edge); border-radius: 9px;
  background: #4a4138; color: var(--text); cursor: pointer;
}
.opt-btn:hover { filter: brightness(1.12); }
.opt-btn.selected { border-color: var(--gold); background: #5a4f3f; box-shadow: inset 0 0 0 1px var(--gold); }
.start-card .big-btn { margin-top: 8px; }

/* ===== 60-second briefing ===== */
#briefing-screen {
  background:
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    repeating-linear-gradient(90deg, transparent 0 33px, rgba(48, 213, 232, 0.05) 33px 34px),
    radial-gradient(ellipse 90% 75% at 50% 26%, #143049 0%, var(--dossier-navy) 55%, var(--dossier-navy-deep) 100%);
}
.briefing-card { max-width: 480px; text-align: left; }
.briefing-card h2 { text-align: center; }
.brief-list { list-style: none; padding: 0; margin: 16px 0 22px; }
.brief-list li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.92rem; color: var(--text);
}
.brief-list li:last-child { border-bottom: none; }
.brief-ico { font-size: 1.35rem; flex: 0 0 auto; line-height: 1.2; }
.brief-list b { color: var(--cream); }

.train-btn {
  display: block; width: 100%; margin-top: 10px; padding: 9px;
  font: inherit; font-size: 0.85rem; font-weight: 700;
  color: var(--gold); background: transparent;
  border: 2px dashed var(--panel-edge); border-radius: 10px; cursor: pointer;
}
.train-btn:hover { border-color: var(--gold); }
.creator-credit {
  display: inline-block;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  text-underline-offset: 3px;
}
.creator-credit:hover,
.creator-credit:focus-visible { color: var(--cream); }
#auto-place { display: block; width: 100%; margin-bottom: 8px; }

/* ===== Toast ===== */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  background: #1d1814;
  color: var(--text);
  border: 2px solid var(--panel-edge);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}

/* Dev art gallery (?dev=art) */
.ag-wrap { width: 100%; }
.ag-wrap h2 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin: 18px 0 8px; }
.ag-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.ag-cell {
  margin: 0; width: 104px; background: var(--cream);
  border: 2px solid var(--panel-edge); border-radius: 10px; padding: 6px; text-align: center;
}
.ag-art { width: 90px; height: 90px; margin: 0 auto; }
.ag-art svg { width: 100%; height: 100%; display: block; }
.ag-cell figcaption { font-size: 0.72rem; font-weight: 700; color: var(--ink); margin-top: 4px; }

/* Visible keyboard focus (a11y). Mouse clicks don't trigger :focus-visible. */
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.tile:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
  z-index: 4;
}

/* Visually-hidden, screen-reader-only (live region, labels). */
.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;
}

/* High-contrast preference: stronger text, visible grid, bolder borders. */
@media (prefers-contrast: more) {
  :root {
    --text: #ffffff;
    --text-dim: #ece1cd;
    --panel-edge: #9a8c75;
  }
  .tile { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55); }
  .piece.blue, .piece.orange { border-width: 4px; }
  .piece-label { text-shadow: 0 0 2px #000, 0 1px 1px #000; }
  .panel-box { border-width: 2px; }
  .log-entry { color: var(--text); }
  :focus-visible, .tile:focus-visible { outline-width: 4px; }
}

/* Windows High Contrast / forced-colors: lean on system colors. */
@media (forced-colors: active) {
  .tile { border: 1px solid CanvasText; }
  .piece { forced-color-adjust: none; }
  :focus-visible, .tile:focus-visible { outline: 3px solid Highlight; }
}

.hidden { display: none !important; }

/* Narrow screens: stack the panel under the board, reclaim width, fit overlays. */
@media (max-width: 780px) {
  #app { padding: 10px 10px 28px; }
  #main { gap: 12px; }
  #side-panel { max-width: none; width: 100%; }
  #board { width: min(94vw, 560px); }

  #header { gap: 8px 12px; padding: 6px 2px 10px; align-items: center; }
  #header h1 { font-size: 1.5rem; }
  #phase-banner { flex-basis: 100%; order: 4; font-size: 0.84rem; margin-top: -2px; }

  /* Overlays must never exceed the viewport on a phone. */
  .overlay-card { max-width: calc(100vw - 26px); padding: 28px 22px; }
  .rules-card { max-height: 84vh; overflow-y: auto; }
  #pass-screen .overlay-card { padding: 34px 22px 26px; }
  .overlay-cat.overlay-cat-big { width: 104px; height: 104px; }
  .pass-seal { width: 64px; height: 64px; }
}

@media (max-width: 430px) {
  #header h1 { font-size: 1.3rem; }
  #board { width: 96vw; }
  .small-btn { padding: 5px 8px; font-size: 0.75rem; }
  .rules-list li { font-size: 0.85rem; padding: 4px 0; }
  .panel-box { padding: 10px 12px; }
  #pass-screen .overlay-card::after { top: 16px; right: 10px; font-size: 0.68rem; }
}
