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

:root {
  --bg: #261f1a;
  --panel: #3a322b;
  --panel-edge: #4d4239;
  --ink: #241a10;
  --text: #efe7da;
  --text-dim: #b8ab99;
  --blue: #4f8ef7;
  --blue-dark: #2b5cb8;
  --blue-deep: #1e3f80;
  --orange: #f59135;
  --orange-dark: #c2640f;
  --orange-deep: #8f4a0a;
  --cream: #f8efdd;
  --wood-a: #d9b98a;
  --wood-b: #cfae7e;
  --wood-line: #b8945f;
  --rug-a: #b65c4a;
  --rug-b: #a85342;
  --under: #3d342a;
  --good: #3fae5c;
  --leap: #9d6bf2;
  --danger: #e25c4a;
  --knock: #f0a23c;
  --gold: #f7c437;
}

* { 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: 1180px;
  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; }
#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(86vmin, 640px);
  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 {
  transform: translateY(-6%) scale(1.06);
  box-shadow: 0 7px 12px 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); }

.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;
  font-size: clamp(10px, 2vmin, 15px);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
  z-index: 2;
}
.stun-badge { top: -8%; left: -8%; }
.hide-badge { bottom: 10%; left: -10%; }
.revealed-badge { top: -8%; left: -8%; font-size: clamp(9px, 1.7vmin, 13px); }
.stun-badge + .revealed-badge { top: auto; bottom: 10%; left: -10%; }

/* 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: 52px;
  height: 52px;
  flex: 0 0 auto;
  background: var(--cream);
  border-radius: 10px;
  padding: 4px;
  border: 2px solid var(--panel-edge);
}
.detail-art svg { width: 100%; height: 100%; 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;
}

/* 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; }
.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; }

/* ===== 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);
}

.hidden { display: none !important; }

/* Narrow screens: stack the panel under the board */
@media (max-width: 780px) {
  #side-panel { max-width: none; }
}
