/* ==========================================================================
 * TWELVE JANGGI (十二将棋) — Carved Obsidian/Gold & Crimson/Ivory Arena
 * ========================================================================== */

.tj-arena {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(290px, 430px) minmax(240px, 1fr);
  gap: 22px;
  align-items: start;
  padding: 6px 4px 20px;
}

@media (max-width: 820px) {
  .tj-arena {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
}

/* Scoreboard & Match Banner */
.tj-top-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-radius: var(--tg-radius-md);
  background: linear-gradient(135deg, rgba(24, 18, 28, 0.92), rgba(10, 12, 20, 0.96));
  border: 1px solid var(--tg-border-strong);
  box-shadow: var(--tg-shadow-card);
}

.tj-score-pips {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tj-side-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.tj-side-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.tj-side-dot.is-p0 {
  background: linear-gradient(135deg, #ff5470, #b91c1c);
  box-shadow: 0 0 10px rgba(255, 46, 84, 0.7);
}

.tj-side-dot.is-p1 {
  background: linear-gradient(135deg, #fff0c2, #c99632);
  box-shadow: 0 0 10px rgba(228, 185, 91, 0.7);
}

.tj-pip-row {
  display: inline-flex;
  gap: 5px;
}

.tj-pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  transition: transform 0.25s var(--tg-ease), background 0.25s;
}

.tj-pip.is-won.is-p0 {
  background: radial-gradient(circle at 35% 30%, #ff8da1, #d91b3a);
  border-color: #ff94a8;
  box-shadow: 0 0 12px rgba(255, 46, 84, 0.8);
  transform: scale(1.1);
}

.tj-pip.is-won.is-p1 {
  background: radial-gradient(circle at 35% 30%, #fff6d9, #e4b95b);
  border-color: #fff0c2;
  box-shadow: 0 0 12px rgba(228, 185, 91, 0.8);
  transform: scale(1.1);
}

/* Try Rule Survival Countdown Banner */
.tj-try-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(217, 27, 58, 0.25), rgba(245, 158, 11, 0.28), rgba(217, 27, 58, 0.25));
  border: 1px solid rgba(255, 102, 128, 0.75);
  color: #fff3d1;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 13.5px;
  box-shadow: 0 0 30px rgba(217, 27, 58, 0.35);
  animation: tj-try-pulse 1.1s ease-in-out infinite;
}

@keyframes tj-try-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 46, 84, 0.35); border-color: rgba(255, 102, 128, 0.75); }
  50% { box-shadow: 0 0 36px rgba(245, 158, 11, 0.65); border-color: #fff0c2; }
}

.tj-round-toast {
  grid-column: 1 / -1;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(228, 185, 91, 0.14);
  border: 1px solid rgba(228, 185, 91, 0.45);
  color: var(--tg-gold-bright);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* Board Column (Opponent Dock -> Board -> My Dock) */
.tj-board-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Prisoner Dock */
.tj-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  min-height: 70px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(18, 20, 32, 0.94), rgba(9, 10, 16, 0.98));
  border: 1px solid var(--tg-border);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.6);
}

.tj-dock.is-active-turn {
  border-color: var(--tg-gold);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(228, 185, 91, 0.16);
}

.tj-dock-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 78px;
}

.tj-dock-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--tg-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.tj-dock-sub {
  font-size: 10.5px;
  color: var(--tg-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tj-dock-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.tj-dock-empty {
  font-size: 11.5px;
  color: var(--tg-ink-faint);
  font-style: italic;
}

/* Carved Rosewood & Obsidian 3x4 Board Frame */
.tj-board-frame {
  position: relative;
  padding: 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(228, 185, 91, 0.16), transparent 65%),
    linear-gradient(165deg, #271a16 0%, #140e12 52%, #0b090e 100%);
  border: 2px solid rgba(228, 185, 91, 0.55);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.78),
    inset 0 1px 0 rgba(255, 240, 194, 0.28),
    inset 0 0 40px rgba(0, 0, 0, 0.7);
}

.tj-board-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  aspect-ratio: 3 / 4;
}

.tj-cell {
  position: relative;
  border-radius: 11px;
  background: linear-gradient(160deg, rgba(28, 25, 36, 0.94), rgba(14, 14, 22, 0.98));
  border: 1.5px solid rgba(228, 185, 91, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s, transform 0.16s;
}

/* Territory Color Grading */
.tj-cell.is-terr-p1 {
  background:
    radial-gradient(circle at 50% 25%, rgba(228, 185, 91, 0.2), transparent 72%),
    linear-gradient(180deg, rgba(44, 34, 20, 0.9), rgba(20, 17, 14, 0.96));
  border-color: rgba(228, 185, 91, 0.42);
}

.tj-cell.is-terr-p0 {
  background:
    radial-gradient(circle at 50% 75%, rgba(217, 27, 58, 0.22), transparent 72%),
    linear-gradient(180deg, rgba(38, 16, 24, 0.9), rgba(18, 10, 15, 0.96));
  border-color: rgba(217, 27, 58, 0.44);
}

.tj-cell-coord {
  position: absolute;
  top: 4px;
  left: 6px;
  font-family: var(--tg-font-mono);
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.tj-cell.is-last-from {
  box-shadow: inset 0 0 0 2px rgba(228, 185, 91, 0.32);
}

.tj-cell.is-last-to {
  box-shadow: inset 0 0 0 2px rgba(255, 240, 194, 0.65), 0 0 18px rgba(228, 185, 91, 0.22);
}

.tj-cell.is-selected {
  border-color: #fff0c2;
  box-shadow: 0 0 0 2px rgba(255, 240, 194, 0.7), 0 0 26px rgba(228, 185, 91, 0.45);
}

.tj-cell.is-legal {
  cursor: pointer;
  border-color: rgba(34, 211, 238, 0.85);
  box-shadow: inset 0 0 22px rgba(34, 211, 238, 0.22), 0 0 18px rgba(34, 211, 238, 0.35);
}

.tj-cell.is-legal::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.95) 0%, rgba(34, 211, 238, 0.25) 60%, transparent 100%);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.85);
  pointer-events: none;
  animation: tj-legal-bob 1.2s ease-in-out infinite;
}

.tj-cell.is-legal.is-capture {
  border-color: #ff2e54;
  box-shadow: inset 0 0 24px rgba(255, 46, 84, 0.32), 0 0 22px rgba(255, 46, 84, 0.5);
}

.tj-cell.is-legal.is-capture::after {
  width: 86%;
  height: 86%;
  border-radius: 10px;
  background: transparent;
  border: 2.5px dashed #ff5474;
  box-shadow: 0 0 16px rgba(255, 46, 84, 0.7);
}

@keyframes tj-legal-bob {
  0%, 100% { transform: scale(0.88); opacity: 0.8; }
  50% { transform: scale(1.14); opacity: 1; }
}

/* ==========================================================================
 * Carved Wooden/Obsidian Janggi Piece Tile with Directional Dots
 * ========================================================================== */

.tj-piece {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: transform 0.18s var(--tg-ease), box-shadow 0.18s var(--tg-ease);
}

/* Seat 0: Crimson & Ivory Lacquered Tile */
.tj-piece.is-owner-0 {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(155deg, #fff5e6 0%, #ebd6b5 52%, #c9a777 100%);
  border: 2px solid #d91b3a;
  color: #960a22;
  box-shadow:
    0 5px 0 #5b0918,
    0 10px 22px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 0 12px rgba(217, 27, 58, 0.18);
}

/* Seat 1: Obsidian & Championship Gold Tile */
.tj-piece.is-owner-1 {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 240, 194, 0.18), transparent 55%),
    linear-gradient(155deg, #282c3f 0%, #151826 58%, #0a0c14 100%);
  border: 2px solid #e4b95b;
  color: #ffe8a3;
  box-shadow:
    0 5px 0 #05060a,
    0 10px 22px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 240, 194, 0.35),
    inset 0 0 14px rgba(228, 185, 91, 0.2);
}

.tj-piece.is-promoted {
  animation: tj-promote-glow 2s ease-in-out infinite;
}

@keyframes tj-promote-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.4)); }
  50% { filter: drop-shadow(0 0 12px rgba(255, 224, 130, 0.85)); }
}

.tj-piece.is-clickable:hover {
  transform: translateY(-2px) scale(1.03);
}

.tj-piece-hanja {
  font-family: "Noto Serif SC", "Songti SC", "Playfair Display", Georgia, serif;
  font-size: clamp(24px, 4.4vw, 34px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.tj-piece.is-owner-1 .tj-piece-hanja {
  text-shadow: 0 0 12px rgba(228, 185, 91, 0.55), 0 2px 3px rgba(0, 0, 0, 0.8);
}

.tj-piece-sub {
  font-family: var(--tg-font-mono);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.72;
  margin-top: 2px;
  text-transform: uppercase;
}

/* Etched Directional Movement Dots on all 8 compass positions */
.tj-dir-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
}

.tj-piece.is-owner-0 .tj-dir-dot {
  background: radial-gradient(circle at 35% 30%, #ff6b86, #b30d2b);
  box-shadow: 0 0 5px rgba(217, 27, 58, 0.75);
}

.tj-piece.is-owner-1 .tj-dir-dot {
  background: radial-gradient(circle at 35% 30%, #fff8dc, #e4b95b);
  box-shadow: 0 0 6px rgba(228, 185, 91, 0.9);
}

/* 8 compass coordinates (relative to visual tile orientation) */
.tj-dir-dot[data-dir="-1,-1"] { top: 5px; left: 5px; }
.tj-dir-dot[data-dir="-1,0"]  { top: 4px; left: 50%; transform: translateX(-50%); }
.tj-dir-dot[data-dir="-1,1"]  { top: 5px; right: 5px; }
.tj-dir-dot[data-dir="0,-1"]  { top: 50%; left: 4px; transform: translateY(-50%); }
.tj-dir-dot[data-dir="0,1"]   { top: 50%; right: 4px; transform: translateY(-50%); }
.tj-dir-dot[data-dir="1,-1"]  { bottom: 5px; left: 5px; }
.tj-dir-dot[data-dir="1,0"]   { bottom: 4px; left: 50%; transform: translateX(-50%); }
.tj-dir-dot[data-dir="1,1"]   { bottom: 5px; right: 5px; }

/* Compact Prisoner Tray Tile */
.tj-dock-tile {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 9px;
}

.tj-dock-tile .tj-piece-hanja {
  font-size: 20px;
}

.tj-dock-tile .tj-piece-sub {
  display: none;
}

.tj-dock-tile .tj-dir-dot {
  width: 5px;
  height: 5px;
}

.tj-dock-tile.is-selected {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 0 0 2.5px #22d3ee, 0 0 20px rgba(34, 211, 238, 0.65);
}

/* Right Tactical Info Column */
.tj-side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tj-card {
  padding: 15px 16px;
  border-radius: var(--tg-radius-md);
  background: var(--tg-glass);
  border: 1px solid var(--tg-border);
  box-shadow: var(--tg-shadow-card);
}

.tj-card-title {
  font-family: var(--tg-font-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tg-gold);
  margin: 0 0 10px;
}

.tj-status-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-ink);
  margin: 0;
}

.tj-legend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.tj-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--tg-ink-muted);
}

.tj-legend-chip {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Serif SC", Georgia, serif;
  font-weight: 900;
  font-size: 15px;
  background: rgba(228, 185, 91, 0.15);
  border: 1px solid rgba(228, 185, 91, 0.45);
  color: var(--tg-gold-bright);
  flex: none;
}

.tj-log-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.tj-log-chip {
  font-family: var(--tg-font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tj-log-chip.is-p0 {
  border-color: rgba(217, 27, 58, 0.45);
  color: #ffa3b5;
}

.tj-log-chip.is-p1 {
  border-color: rgba(228, 185, 91, 0.45);
  color: #fff0c2;
}
