/* territory.css — loaded only on /territory */

.tb-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 1.5rem 1rem 3rem;
  min-height: 80vh;
  user-select: none;
  -webkit-user-select: none;
}

.tb-header { text-align: center; }

.tb-title {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
  background: linear-gradient(90deg, #8fd8ff 0%, #ffffff 45%, #b08cff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tb-subtitle { margin: 0; color: #aab; font-size: 0.95rem; }

/* ── Mode toggle ─────────────────────────────────────────────────────────── */

.tb-modes { display: flex; gap: 0.5rem; }

.tb-mode-btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  color: #ccd;
  background: transparent;
  border: 2px solid #34406a;
  border-radius: 999px;
  cursor: pointer;
}

.tb-mode-btn[aria-pressed="true"] { color: #0d1226; background: #c9d4ff; border-color: #c9d4ff; font-weight: 700; }
.tb-mode-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Scoreboard ──────────────────────────────────────────────────────────── */

.tb-scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 440px);
}

.tb-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 2px solid transparent;
}

.tb-team-icewings { color: #8fd8ff; border-color: #2c7fb0; background: rgba(60, 160, 220, 0.12); }
.tb-team-nightwings { color: #c3a6ff; border-color: #6b45b8; background: rgba(120, 80, 220, 0.14); }
.tb-team-name { font-size: 0.85rem; letter-spacing: 0.04em; }
.tb-team-score { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }

.tb-turn-line { margin: 0; color: #ccd; text-align: center; }
#tb-turn[data-team="icewings"] { color: #8fd8ff; }
#tb-turn[data-team="nightwings"] { color: #c3a6ff; }

/* ── Board ───────────────────────────────────────────────────────────────── */

.tb-board-wrapper { position: relative; }

/* 11 tracks: dot, box, dot, box, ... dot (BOXES = 5). */
.tb-board {
  --dot: 14px;
  --box: clamp(34px, 11vw, 64px);
  display: grid;
  grid-template-columns: repeat(5, var(--dot) var(--box)) var(--dot);
  grid-template-rows: repeat(5, var(--dot) var(--box)) var(--dot);
  padding: 14px;
  border-radius: 12px;
  border: 2px solid #34406a;
  background: #0d1226;
  box-shadow: 0 0 32px rgba(110, 140, 255, 0.18);
}

.tb-dot {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #e8ecff;
  z-index: 2;
}

.tb-line {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
}

/* The visible bar is a pseudo-element so the click target can be wider than the stroke. */
.tb-line::after {
  content: "";
  position: absolute;
  border-radius: 3px;
  background: rgba(150, 165, 220, 0.18);
  transition: background 0.15s ease;
}

.tb-line-h { height: var(--dot); }
.tb-line-h::after { left: 2px; right: 2px; top: 3px; bottom: 3px; }
.tb-line-v { width: var(--dot); }
.tb-line-v::after { top: 2px; bottom: 2px; left: 3px; right: 3px; }

.tb-line:hover:not(:disabled)::after,
.tb-line:focus-visible::after { background: rgba(255, 255, 255, 0.55); }
.tb-line:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.tb-turn-icewings .tb-line:hover:not(:disabled)::after { background: #8fd8ff; }
.tb-turn-nightwings .tb-line:hover:not(:disabled)::after { background: #b08cff; }

.tb-line:disabled { cursor: default; }
.tb-board[data-waiting] .tb-line { cursor: progress; }
.tb-board[data-waiting] .tb-line:hover:not(:disabled)::after { background: rgba(150, 165, 220, 0.18); }
.tb-line.drawn::after { background: #e8ecff; }
.tb-line.by-icewings::after { background: #5cc4f5; }
.tb-line.by-nightwings::after { background: #9b6dff; }

/* ── Boxes ───────────────────────────────────────────────────────────────── */

.tb-box {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: background 0.3s ease;
}

.tb-box.owned-icewings { background: rgba(80, 180, 240, 0.45); color: #e8f8ff; }
.tb-box.owned-nightwings { background: rgba(130, 90, 230, 0.5); color: #efe6ff; }

/* ── Win Overlay ─────────────────────────────────────────────────────────── */

.tb-win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 20, 0.92);
  border-radius: 12px;
  z-index: 10;
}

/* Must come after .tb-win so display:none overrides display:flex */
.tb-hidden { display: none; }

.tb-win-inner { text-align: center; padding: 1.5rem; }
.tb-win-heading { margin: 0 0 0.5rem; font-size: 1.6rem; color: #fff; }
.tb-win-detail { margin: 0 0 1.2rem; color: #bcd; }

.tb-replay-btn {
  padding: 0.6rem 1.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #0d1226;
  background: linear-gradient(90deg, #8fd8ff, #b08cff);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.tb-replay-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
