/* ===== GAME VIEW ===== */

.game {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr minmax(220px, 320px);
  grid-template-rows: auto 1fr;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

@media (max-width: 980px) {
  .game {
    grid-template-columns: 1fr;
    padding: 8px;
  }
  .game__deck-col,
  .game__side-col {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: center;
  }
}

.game__topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px;
}

.game__deck-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 4px;
  position: relative;
}

.game__board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.game__side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 4px;
}

/* Clock */
.clock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--f-display);
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--c-text-dim);
  background: linear-gradient(160deg, rgba(15, 28, 32, 0.85) 0%, rgba(8, 18, 22, 0.85) 100%);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 22px;
  min-width: 130px;
  transition: all 0.25s ease;
}

.clock--active {
  color: var(--c-gold-bright);
  border-color: var(--c-gold-spark);
  box-shadow: 0 0 0 1px var(--c-gold-spark), 0 4px 16px rgba(255, 200, 100, 0.25);
}

.clock--low { color: #ff8866; border-color: #aa4433; }

/* Board frame: dark gradient + decorative gold ring (same for all piece sets).
   The actual playing surface (cg-board) gets its background-image set below. */
.board-frame {
  position: relative;
  width: min(70vh, 90vw, 640px);
  aspect-ratio: 1;
  padding: 24px;
  background: linear-gradient(160deg, #1f3a3b 0%, #0d1f20 100%);
  border: 2px solid var(--c-border);
  border-radius: 14px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.6),
    inset 0 0 40px rgba(255, 200, 100, 0.06);
}

.board-frame::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 200, 110, 0.15);
  border-radius: 10px;
  pointer-events: none;
}

#board.cg-wrap,
#train-board.cg-wrap,
#wt-board.cg-wrap {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Default board: warrior-themed SVG. Darker cream + deep teal squares with
   radial vignette and star ornaments for that hand-painted feel. Tiles 4x4
   across the 8x8 grid (each tile = 2x2 chess squares). */
.cg-wrap cg-board {
  background-color: #345252 !important;
  background-image: url("../img/board-warriors.svg") !important;
  background-size: 25% 25% !important;
  background-repeat: repeat !important;
}

/* ===== Classical set: same warrior SVG board (in-theme look) ===== */
body[data-piece-set="classical"] .cg-wrap cg-board {
  background-color: #345252 !important;
  background-image: url("../img/board-warriors.svg") !important;
  background-size: 25% 25% !important;
  background-repeat: repeat !important;
}

/* ===== Training Ground: always SVG checker, regardless of piece set ===== */
body[data-piece-set] .training__center .cg-wrap cg-board {
  background-color: #d6c79a !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><rect width='100' height='100' fill='%23d6c79a'/><rect x='100' y='100' width='100' height='100' fill='%23d6c79a'/><rect x='100' y='0' width='100' height='100' fill='%232f5757'/><rect x='0' y='100' width='100' height='100' fill='%232f5757'/><path d='M50 25L57 43L75 50L57 57L50 75L43 57L25 50L43 43Z' fill='%231f3a3b' opacity='0.18'/><path d='M150 125L157 143L175 150L157 157L150 175L143 157L125 150L143 143Z' fill='%231f3a3b' opacity='0.18'/><path d='M150 25L157 43L175 50L157 57L150 75L143 57L125 50L143 43Z' fill='%23b8a373' opacity='0.32'/><path d='M50 125L57 143L75 150L57 157L50 175L43 157L25 150L43 143Z' fill='%23b8a373' opacity='0.32'/></svg>") !important;
  background-size: 25% 25% !important;
  background-repeat: repeat !important;
}

/* Selected / last-move / check highlights in our gold palette */
.cg-wrap cg-board square.last-move {
  background-color: rgba(255, 200, 100, 0.45) !important;
}
.cg-wrap cg-board square.last-move.dark {
  background-color: rgba(180, 140, 60, 0.55) !important;
}
.cg-wrap cg-board square.selected {
  background-color: rgba(255, 215, 130, 0.55) !important;
}
.cg-wrap cg-board square.move-dest {
  background: radial-gradient(circle, rgba(255, 215, 130, 0.55) 18%, transparent 22%) !important;
}
.cg-wrap cg-board square.move-dest.oc {
  background: radial-gradient(circle, transparent 50%, rgba(255, 80, 60, 0.6) 52%, rgba(255, 80, 60, 0.6) 68%, transparent 70%) !important;
}
.cg-wrap cg-board square.check {
  background: radial-gradient(circle, rgba(255, 80, 60, 0.85) 0%, rgba(255, 80, 60, 0.5) 40%, transparent 70%) !important;
}


/* Hide chessground's built-in coords - we render our own strips around all 4 sides */
.cg-wrap coords { display: none !important; }

/* Custom coord strips around the board frame */
.board-coords {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.board-coords > div {
  position: absolute;
  display: flex;
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--c-gold-bright);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  text-transform: uppercase;
}
.board-coords__top, .board-coords__bottom {
  left: 26px;
  right: 26px;
  height: 22px;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
}
.board-coords__top    { top: 1px; }
.board-coords__bottom { bottom: 1px; }
.board-coords__left, .board-coords__right {
  top: 26px;
  bottom: 26px;
  width: 22px;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
.board-coords__left  { left: 1px; }
.board-coords__right { right: 1px; }
.board-coords span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Deck stack */
.deck-stack {
  position: relative;
  width: 110px;
  height: 158px;
  cursor: default;
}

.deck-stack.is-empty { opacity: 0.4; filter: grayscale(0.6); }

.deck-stack__card {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform var(--t-medium);
}
.deck-stack__card img { width: 100%; height: 100%; display: block; }

.deck-stack__label {
  margin-top: 14px;
  text-align: center;
  font-family: var(--f-display);
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
}

.deck-stack__count {
  display: block;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--c-gold-bright);
  margin-top: 6px;
}

/* ===== CARD REVEAL OVERLAY ===== */
.card-reveal {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: radial-gradient(ellipse at center, rgba(20, 40, 42, 0.9), rgba(5, 12, 14, 0.95));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.card-reveal.is-open      { opacity: 1; pointer-events: auto; }
.card-reveal.is-dissolving { opacity: 0; transform: scale(1.04); transition: opacity 0.55s ease, transform 0.55s ease; }

.card-reveal__header {
  font-family: var(--f-display);
  font-size: 13px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
  margin-bottom: 24px;
  text-align: center;
}

.card-reveal__scene {
  position: relative;
  width: clamp(220px, 60vw, 300px);
  aspect-ratio: 220 / 316;
  perspective: 1600px;
  cursor: pointer;
  outline: none;
  animation: cardRise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(40px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.card-reveal__card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.card-reveal__card.is-flipped { transform: rotateY(180deg); }

.card-reveal__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 60px rgba(255, 200, 100, 0.1);
  transform: translateZ(0);
}

.card-reveal__face img {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.card-reveal__face--front { transform: rotateY(180deg) translateZ(0); }

.card-reveal__hint {
  position: absolute;
  inset: auto 0 -34px 0;
  text-align: center;
  font-family: var(--f-display);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
  pointer-events: none;
  animation: hintPulse 1.6s ease-in-out infinite;
  transition: opacity 0.3s ease;
}

.card-reveal.is-flipped .card-reveal__hint {
  opacity: 0;
  animation: none;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.85; }
}

.card-reveal__info {
  margin-top: 38px;
  max-width: 400px;
  width: 100%;
  background: linear-gradient(160deg, rgba(31, 58, 59, 0.92), rgba(13, 31, 32, 0.92));
  border: 1px solid var(--c-gold-spark);
  border-radius: 10px;
  padding: 20px 22px 18px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease 0.4s, transform 0.45s ease 0.4s;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 200, 100, 0.08);
  pointer-events: none;
}

.card-reveal.is-flipped .card-reveal__info {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.card-reveal__name {
  font-family: var(--f-display);
  font-size: 18px;
  letter-spacing: 0.12em;
  color: var(--c-gold-bright);
  margin: 0 0 10px;
  font-weight: 600;
}

.card-reveal__desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--c-text);
  margin: 0 0 18px;
}

.card-reveal__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.card-reveal__btn {
  min-width: 130px;
  font-size: 13px;
  padding: 12px 24px;
}

/* ===== CARD TOAST (auto-resolve notification) ===== */
.card-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 220;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(160deg, rgba(31, 58, 59, 0.96), rgba(13, 31, 32, 0.96));
  border: 1px solid var(--c-gold-spark);
  border-radius: 10px;
  padding: 10px 18px 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 24px rgba(255, 200, 100, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateX(-50%) translateY(-24px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
  pointer-events: none;
}

.card-toast.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.card-toast.is-closing {
  opacity: 0;
  transform: translateX(-50%) translateY(-16px);
}

.card-toast__face {
  width: 40px;
  height: 58px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.card-toast__face img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-toast__side {
  font-family: var(--f-display);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
}

.card-toast__name {
  font-family: var(--f-display);
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--c-gold-bright);
  margin-top: 3px;
  font-weight: 600;
}

/* ===== DRAW BUTTON (manual draw prompt) =====
   Pinned to the top of the viewport so the player notices the cue before
   they try to drag a piece. Sits below the topbar, centered horizontally. */
.draw-btn {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 230;
  padding: 14px 30px;
  font-size: 13px;
  letter-spacing: 0.2em;
  overflow: visible;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 36px rgba(255, 200, 110, 0.25);
  animation: drawBtnPop 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes drawBtnPop {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.draw-btn__label { position: relative; z-index: 1; }

.draw-btn__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 8px;
  border: 1px solid var(--c-gold-spark);
  animation: drawPulse 1.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes drawPulse {
  0%, 100% { opacity: 0.4; transform: scale(1);    }
  50%      { opacity: 1;   transform: scale(1.06); }
}

/* Open Hand variant: optional draw, subtler styling */
.draw-btn--optional {
  background: linear-gradient(160deg, rgba(31, 58, 59, 0.85), rgba(13, 31, 32, 0.85));
  border-color: rgba(255, 200, 110, 0.4);
}

.draw-btn--optional .draw-btn__pulse {
  border-color: rgba(255, 200, 110, 0.35);
  animation-duration: 2.4s;
}

/* ===== TARGET-SELECT BANNER (rare card piece-pick prompt) ===== */
.target-banner {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 240;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  background: linear-gradient(160deg, rgba(70, 50, 120, 0.95), rgba(35, 20, 70, 0.95));
  border: 1px solid #a78bfa;
  border-radius: 10px;
  padding: 12px 22px;
  text-align: center;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6), 0 0 30px rgba(167, 139, 250, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
  pointer-events: none;
}

.target-banner.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.target-banner__title {
  font-family: var(--f-display);
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #d4b3ff;
  font-weight: 600;
}

.target-banner__sub {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: #b8a3e6;
  margin-top: 3px;
}

/* ===== TWIN STRIKE BANNER (two-moves-per-turn prompt) ===== */
.twin-strike-banner {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 240;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  background: linear-gradient(160deg, rgba(70, 50, 120, 0.95), rgba(35, 20, 70, 0.95));
  border: 1px solid #a78bfa;
  border-radius: 10px;
  padding: 12px 22px;
  text-align: center;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6), 0 0 30px rgba(167, 139, 250, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.twin-strike-banner.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.twin-strike-banner__title {
  font-family: var(--f-display);
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #d4b3ff;
  font-weight: 600;
}
.twin-strike-banner__sub {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: #b8a3e6;
}
.twin-strike-banner__btn {
  margin-top: 4px;
  background: rgba(167, 139, 250, 0.18);
  color: #e9dcff;
  border: 1px solid rgba(167, 139, 250, 0.6);
  border-radius: 6px;
  padding: 5px 14px;
  font-family: var(--f-display);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.twin-strike-banner__btn:hover {
  background: rgba(167, 139, 250, 0.3);
  border-color: #c9b3ff;
}
.twin-strike-banner__btn:active {
  transform: translateY(1px);
}

/* Move history */
.move-history {
  background: rgba(8, 18, 22, 0.6);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--c-text);
}

.move-history__title {
  font-family: var(--f-display);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
  margin: 0 0 8px;
  text-align: center;
  font-weight: 500;
}

.move-history__list {
  display: grid;
  grid-template-columns: 24px 1fr 1fr;
  gap: 2px 8px;
}

.move-history__num {
  color: var(--c-text-dim);
  font-size: 11px;
  text-align: right;
}

/* Game controls */
.game__controls { display: flex; flex-direction: column; gap: 8px; }
.game__controls .btn { width: 100%; padding: 10px; font-size: 12px; }

/* Endgame overlay */
.endgame {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 18, 22, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.endgame.is-open { opacity: 1; pointer-events: auto; }

.endgame__panel {
  background: linear-gradient(160deg, #1f3a3b 0%, #0d1f20 100%);
  border: 1px solid var(--c-gold-spark);
  border-radius: 12px;
  padding: 36px 32px;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

.endgame__panel h2 {
  font-family: var(--f-display);
  font-size: 22px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-gold-bright);
  margin: 0 0 8px;
}

.endgame__panel p {
  font-size: 14px;
  color: var(--c-text);
  margin: 0 0 24px;
}

.endgame__panel .actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== DECK SHUFFLE INTRO ANIMATION ===== */
.deck-shuffle-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(8, 18, 22, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.deck-shuffle-overlay.is-running,
.deck-shuffle-overlay.is-fading {
  pointer-events: auto;
}

.deck-shuffle-overlay.is-running { opacity: 1; }
.deck-shuffle-overlay.is-fading  { opacity: 0; }

.deck-shuffle-stage {
  position: relative;
  width: 180px;
  height: 252px;
}

.deck-shuffle-card {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  --i: 0;
  --total: 14;
  --angle: calc((var(--i) - var(--total) / 2) * 12deg);
  --x: calc((var(--i) - var(--total) / 2) * 18px);
  animation: shuffleCard 1.9s cubic-bezier(0.5, 0.05, 0.4, 1) both;
  animation-delay: calc(var(--i) * 0.04s);
}

.deck-shuffle-card img { width: 100%; height: 100%; display: block; }

@keyframes shuffleCard {
  0% {
    transform: translateX(0) rotate(0) scale(0.92);
    opacity: 0;
  }
  20% {
    transform: translateX(0) rotate(0) scale(1);
    opacity: 1;
  }
  45% {
    transform: translateX(var(--x)) rotate(var(--angle)) scale(1);
  }
  75% {
    transform: translateX(var(--x)) rotate(var(--angle)) scale(1);
  }
  100% {
    transform: translateX(0) rotate(0) scale(1);
    opacity: 1;
  }
}

.deck-shuffle-label {
  margin-top: 28px;
  font-family: var(--f-display);
  font-size: 13px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--c-gold-bright);
  animation: pulseLabel 1.4s ease-in-out infinite;
}

@keyframes pulseLabel {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}
