/* The debug panel (type debug() in the console), possess banner, spy mode. Kept from
   the previous UI verbatim; it reads the legacy token names, aliased here onto the
   new palette (they used to live in tokens.css). */
:root {
  --gold-dim: color-mix(in srgb, var(--gold) 70%, #000);
  --gold-light: var(--gold-hi);
  --gold-glow: color-mix(in srgb, var(--gold) 35%, transparent);
  --bg-deepest: #000;
  --border-subtle: var(--panel-rim);
  --text-primary: var(--text);
  --text-secondary: var(--text-dim);
  --radius-md: var(--radius);
  --radius-lg: calc(var(--radius) + 6px);
  --danger: var(--mult);
}

/* online: what this browser does not have, and why */
.debug-hidden-note { color: var(--text-secondary); font-style: italic; }
.debug-log { font-family: 'IBM Plex Mono', Consolas, monospace; font-size: 0.66rem; line-height: 1.5; color: var(--text-secondary); }
.debug-log .in { color: var(--gold-light); }

.debug-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 24px));
  max-height: 85vh;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(230, 184, 76, 0.07), transparent 70%),
    linear-gradient(180deg, rgba(14, 30, 21, 0.98), rgba(6, 15, 10, 0.98));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text-primary);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 40px var(--gold-glow);
}

.debug-panel.hidden { display: none; }

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.5rem 0.45rem 1rem;
  background: linear-gradient(145deg, var(--gold-hi), var(--gold) 45%, var(--gold-dim));
  color: var(--bg-deepest);
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 2px;
  flex: none;
  cursor: grab;
  user-select: none;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}
.debug-header:active { cursor: grabbing; }
.debug-header small { display: inline-block; margin-left: 0.35rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: rgba(0, 0, 0, 0.16); }
.debug-header small:empty { display: none; }

.btn-debug-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.18);
  color: var(--bg-deepest);
  font-weight: 900;
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, transform 0.1s;
}
.btn-debug-close:hover { background: rgba(0, 0, 0, 0.32); }
.btn-debug-close:active { transform: translateY(1px); }
.btn-debug-close:focus-visible { outline: 2px solid var(--bg-deepest); outline-offset: 1px; }

/* the tabs: one segmented bar, scrolls sideways if it ever has to */
.debug-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  margin: 0;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.debug-tabs::-webkit-scrollbar { display: none; }

.debug-tab {
  flex: 1 0 auto;
  min-height: 34px;
  padding: 0.4rem 0.7rem;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.debug-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.debug-tab.active {
  color: var(--bg-deepest);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: var(--gold-dim);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.debug-tab:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }

.debug-body {
  padding: 0.7rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  font-size: 0.8rem;
  line-height: 1.4;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.debug-body::-webkit-scrollbar { width: 6px; }
.debug-body::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

/* a section: a soft card with a gold header */
.debug-section {
  margin-bottom: 0.65rem;
  padding: 0.6rem 0.65rem 0.65rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-subtle);
}
.debug-section:last-child { margin-bottom: 0; }

.debug-section-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 0.55rem;
  padding: 0 0 0.45rem;
  border-bottom: 1px solid var(--border-subtle);
}
.debug-section-title::before {
  content: '';
  flex: none;
  width: 4px;
  height: 0.85rem;
  border-radius: 2px;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

/* card chips: small face-up cards, suits in their colors */
.debug-card {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  min-width: 2.1rem;
  justify-content: center;
  background: linear-gradient(180deg, #fbf7ec, #ece4d0);
  color: #1d1a14;
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  margin: 2px;
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', Consolas, monospace;
  font-weight: 700;
  line-height: 1.2;
  cursor: default;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.debug-card .suit { font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', sans-serif; }
.debug-card .suit.hearts, .debug-card .suit.diamonds { color: #c8231f; }
.debug-card .suit.clubs, .debug-card .suit.spades { color: #1d1a14; }
.debug-card:hover { transform: translateY(-1px); }

.debug-card.removable { cursor: pointer; }
.debug-card.removable:hover {
  background: linear-gradient(180deg, #ffe3e1, #f5c4c0);
  border-color: var(--danger);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(224, 69, 63, 0.35);
}

.debug-controls {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.debug-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.74rem;
}
.debug-controls-row > span:first-child { font-size: 0.74rem; }

.debug-select,
.debug-panel input[type=number] {
  min-height: 32px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  outline: none;
  flex: 1;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.debug-select:hover { border-color: rgba(230, 184, 76, 0.45); }
.debug-select:focus,
.debug-select:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-glow); }
.debug-select option { background: #0f1f16; color: var(--text-primary); }

.btn-debug {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 32px;
  background: linear-gradient(180deg, rgba(230, 184, 76, 0.16), rgba(230, 184, 76, 0.07));
  border: 1px solid var(--gold-dim);
  color: var(--gold-light);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.btn-debug:hover { background: linear-gradient(180deg, rgba(230, 184, 76, 0.3), rgba(230, 184, 76, 0.16)); border-color: var(--gold); }
.btn-debug:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.btn-debug:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.debug-controls > .btn-debug { width: 100%; }

.btn-debug.danger {
  background: linear-gradient(180deg, rgba(224, 69, 63, 0.18), rgba(224, 69, 63, 0.08));
  border-color: rgba(224, 69, 63, 0.5);
  color: #ff8a84;
}
.btn-debug.danger:hover { background: linear-gradient(180deg, rgba(224, 69, 63, 0.32), rgba(224, 69, 63, 0.16)); border-color: var(--danger); }

/* checkboxes and the win rate range: the game's gold */
.debug-panel input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.debug-check { cursor: pointer; padding: 0.2rem 0; }
.debug-panel .gold-range { height: 28px; }
.debug-panel .debug-controls-row .btn-debug + span,
.debug-panel .debug-controls-row .bot-badge { font-size: 0.68rem; }

.debug-player-hand {
  margin-bottom: 0.45rem;
  padding: 0.5rem 0.55rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
}
.debug-player-hand:last-child { margin-bottom: 0; }

.debug-player-label {
  font-weight: 700;
  font-size: 0.76rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.debug-turn-indicator {
  color: var(--gold);
  font-size: 0.82rem;
}

.debug-hidden-note { font-size: 0.7rem; }

/* Debug restore pill (minimized state) */
.debug-restore-pill {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  left: 1rem;
  z-index: 2001;
  min-height: 40px;
  background: linear-gradient(145deg, var(--gold-hi), var(--gold) 45%, var(--gold-dim));
  color: var(--bg-deepest);
  border: none;
  border-radius: 20px;
  padding: 0.45rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 12px var(--gold-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.debug-restore-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 20px var(--gold-glow);
}

.debug-restore-pill.hidden { display: none; }

/* a phone: a sheet along the bottom, the top of the table stays in view; it scrolls inside */
@media (max-width: 640px) {
  .debug-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: min(68vh, 640px);
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .debug-header { padding: 0.4rem 0.45rem 0.4rem 0.9rem; font-size: 0.76rem; letter-spacing: 1.5px; }
  .btn-debug-close { min-width: 44px; height: 44px; }
  .debug-tab { min-height: 38px; }
  .btn-debug, .debug-select, .debug-panel input[type=number] { min-height: 36px; }
}

/* ============================= FREEZE BANNER ============================= */
.freeze-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  background: linear-gradient(135deg, rgba(100, 180, 255, 0.15), rgba(140, 200, 255, 0.1));
  border-bottom: 2px solid rgba(100, 180, 255, 0.5);
  color: #8ec8ff;
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  animation: freeze-pulse 2s ease-in-out infinite;
}

.freeze-icon-inline {
  font-size: 0.7rem;
  margin-right: 0.3rem;
  letter-spacing: 1px;
}

@keyframes freeze-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* ============================= POSSESS BANNER ============================= */
#possess-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 0.4rem 1rem;
  background: linear-gradient(135deg, rgba(240, 192, 48, 0.12), rgba(240, 192, 48, 0.06));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
}

.possess-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ============================= FROZEN TURN INDICATOR ============================= */
.frozen-turn {
  color: #8ec8ff;
  font-weight: 800;
  letter-spacing: 2px;
  animation: freeze-pulse 2s ease-in-out infinite;
}

/* ============================= SPY MODE ============================= */
.spy-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 0.3rem;
}

.spy-card {
  display: inline-block;
  background: rgba(240, 192, 48, 0.12);
  border: 1px solid var(--gold-dim);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--gold-light);
  font-family: 'IBM Plex Mono', Consolas, monospace;
}

/* ============================= CONTROLLED OPPONENT ============================= */
.opponent-card.controlled {
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow), inset 0 0 6px var(--gold-glow);
}

.ctrl-badge {
  font-size: 0.55rem;
  font-weight: 900;
  color: var(--gold);
  background: rgba(240, 192, 48, 0.15);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  letter-spacing: 1px;
  vertical-align: middle;
}

/* ============================= RESPONSIVE ============================= */

/* Tablet & small desktop */
