/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --bg:          #111;
  --panel:       #141617;
  --deep:        #101416;
  --border:      #3f474b;
  --border-dim:  #20282c;
  --text:        #d7d7d7;
  --muted:       #7f8b93;
  --green:       #8ee38e;
  --yellow:      #ffd166;
  --orange:      #ff9e64;
  --red:         #ff5d73;
  --pink:        #ff8fab;
  --blue:        #9cdcfe;
  --cyan:        #64dfdf;
  --purple:      #b7a6ff;
  --lime:        #d4ff00;
  --green-muted: #95d36e;
  --font:        "Courier New", Courier, monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  overflow: hidden;
}

/* ==================
   SCREEN CONTAINERS
   ================== */
.v2-screen {
  display: none;
  width: 100%;
}

.v2-screen.active {
  display: flex;
  flex-direction: column;
}

#screen-lobby.active {
  align-items: center;
  justify-content: center;
  height: 100vh;
}

#screen-waiting.active {
  height: 100vh;
  overflow: hidden;
}

#screen-game.active {
  display: block;
  height: 100vh;
  overflow: hidden;
}

/* ==================
   LOBBY SCREEN
   ================== */
.v2-lobby-logo {
  font-size: 20px;
  letter-spacing: 0.18em;
  color: var(--green);
  margin-bottom: 32px;
  font-weight: 700;
}

.v2-lobby-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 320px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.v2-lobby-title {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 4px;
}

.v2-lobby-panel label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.v2-lobby-panel input {
  background: var(--deep);
  border: 1px solid var(--border-dim);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 120ms;
}

.v2-lobby-panel input:focus {
  border-color: var(--border);
}

.v2-lobby-btns {
  display: flex;
  gap: 8px;
}

.v2-lobby-btns button { flex: 1; }

.v2-lobby-panel button {
  background: var(--deep);
  border: 1px solid var(--border-dim);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.v2-lobby-panel button:hover {
  border-color: var(--border);
  background: #1a2226;
}

.v2-btn-primary {
  background: #173a52 !important;
  border-color: #4fc3f7 !important;
  color: #ecf9ff !important;
  font-weight: 700 !important;
  padding: 10px !important;
}

.v2-lobby-status {
  font-size: 11px;
  color: var(--green);
  text-align: center;
}

/* ==================
   WAITING SCREEN
   ================== */
#screen-waiting.active {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.v2-waiting-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  gap: 22px;
  min-height: 0;
  overflow-y: auto;
}

.v2-waiting-status {
  text-align: center;
}

.v2-waiting-room-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.v2-waiting-counters {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
}

.v2-waiting-count-num {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.v2-waiting-count-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.v2-waiting-sep {
  color: var(--border);
  font-size: 16px;
}

.v2-waiting-ready-num {
  color: var(--green);
  font-size: 22px;
  font-weight: 700;
}

.v2-waiting-ready-total {
  color: var(--muted);
  font-size: 18px;
}

.v2-waiting-list-wrap {
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border-dim);
  background: var(--panel);
}

.v2-waiting-list-header {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-dim);
  background: var(--deep);
}

.v2-waiting-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-dim);
}

.v2-waiting-player-row:last-child {
  border-bottom: none;
}

.v2-waiting-player-dot {
  font-size: 11px;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.v2-waiting-player-dot.ready { color: var(--green); }
.v2-waiting-player-dot.wait  { color: var(--border); }

.v2-player-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.v2-player-tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border: 1px solid var(--border-dim);
  color: var(--muted);
}

.v2-player-tag.host  { border-color: var(--yellow);      color: var(--yellow); }
.v2-player-tag.me    { border-color: var(--blue);         color: var(--blue); }
.v2-player-tag.bot   { border-color: var(--muted);        color: var(--muted); }
.v2-player-tag.ready { border-color: var(--green);        color: var(--green); }
.v2-player-tag.wait  { border-color: var(--border-dim);   color: var(--muted); }

.v2-waiting-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.v2-waiting-actions-row {
  display: flex;
  gap: 8px;
}

.v2-waiting-bot-btn {
  background: var(--deep);
  border: 1px solid var(--border-dim);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: border-color 120ms, color 120ms;
}

.v2-waiting-bot-btn:hover {
  border-color: var(--border);
  color: var(--text);
}

.v2-btn-ready {
  flex: 1;
  background: var(--deep);
  border: 1px solid var(--green-muted);
  color: var(--green-muted);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 120ms;
}

.v2-btn-ready:hover {
  background: #1a2c1a;
}

.v2-btn-start {
  width: 100%;
  background: #173a52;
  border: 1px solid #4fc3f7;
  color: #ecf9ff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  cursor: pointer;
  letter-spacing: 0.12em;
  transition: background 120ms;
  text-align: center;
}

.v2-btn-start:hover {
  background: #1e4d6e;
}

/* ==================
   HEADER (shared)
   ================== */
.v2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  min-height: 44px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.v2-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  overflow: hidden;
}

.v2-header-logo {
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.1em;
  font-size: 13px;
  white-space: nowrap;
}

.v2-header-room { color: var(--muted); white-space: nowrap; }
.v2-header-dot  { color: var(--green); }
.v2-header-meta { color: var(--muted); white-space: nowrap; }

.btn-copy-link {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  padding: 4px 7px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}
.btn-copy-link:hover {
  color: var(--text);
  border-color: var(--border-dim);
}

.v2-header-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.v2-header-right button {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  padding: 4px 7px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}

.v2-header-right button:hover {
  color: var(--text);
  border-color: var(--border-dim);
}

.v2-header-right .btn-leave-room {
  color: var(--red);
  border-color: transparent;
  opacity: 0.75;
}
.v2-header-right .btn-leave-room:hover {
  color: var(--red);
  border-color: var(--red);
  opacity: 1;
}

/* ==================
   GAME LAYOUT (desktop ≥641px)
   ================== */
.v2-app {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: 44px 76px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Explicit grid placement */
.v2-app > .v2-header     { grid-column: 1 / -1; grid-row: 1; }
.v2-app > .v2-opponents  { grid-column: 1 / -1; grid-row: 2; }
.v2-app > .v2-left-col   { grid-column: 1;       grid-row: 3; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.v2-app > .v2-actions    { grid-column: 2;       grid-row: 3; min-height: 0; }
/* Mobile-only elements hidden on desktop */
.v2-app > .v2-turn-row  { display: none; }
.v2-app > .v2-log-bar   { display: none; }

/* Left col: feed + hand shrink to content, log fills remaining height */
.v2-left-col .v2-game-feed  { flex-shrink: 0; }
.v2-left-col .v2-hand-strip { flex-shrink: 0; border-top: 1px solid var(--border-dim); }
.v2-left-col .v2-log-panel  { flex: 1; min-height: 0; }

/* ---- Opponents Strip ---- */
.v2-opponents {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border-dim);
  align-items: stretch;
}

/* Direction badge — first child of opponents strip */
.v2-opp-direction {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px 0 4px;
  border-right: 1px solid var(--border-dim);
  margin-right: 4px;
  flex-shrink: 0;
  user-select: none;
}

.v2-opp-dir-arrow {
  font-size: 24px;
  line-height: 1;
  color: var(--purple);
  font-weight: 700;
}

/* Direction arrows — left and right ends of opponents strip */
.v2-opp-dir-side {
  align-self: center;
  flex-shrink: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--purple);
  user-select: none;
  padding: 0 6px;
  line-height: 1;
}

/* Direction badge — centered between left/right player groups */
.v2-opp-dir-center {
  align-self: center;
  flex-shrink: 0;
  padding: 4px 12px;
  border: 1px solid rgba(183, 166, 255, 0.35);
  background: rgba(183, 166, 255, 0.07);
  color: var(--purple);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  min-width: 48px;
  text-align: center;
  letter-spacing: 0;
}

.v2-opp-card {
  min-width: 140px;
  max-width: 180px;
  padding: 6px 10px;
  background: var(--deep);
  border: 1px solid #263036;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
}

.v2-opp-card.current {
  border-color: var(--yellow);
  background: rgba(255,209,102,0.08);
}

.v2-opp-card.out {
  opacity: 0.38;
  filter: grayscale(1);
}

.v2-opp-turn-label {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 13px;
  line-height: 1;
  color: var(--yellow);
  filter: drop-shadow(0 0 3px rgba(255,209,102,0.6));
}

.v2-opp-turns {
  font-size: 13px;
  font-weight: 600;
  color: var(--orange);
}

.v2-opp-name {
  font-size: 16px;
  line-height: 1.4;
  color: #d7e0e7;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 155px;
  flex-shrink: 0;
}
.v2-opp-name--md { font-size: 13px; }
.v2-opp-name--lg { font-size: 11px; }

.v2-opp-card.current .v2-opp-name { color: var(--yellow); }

.v2-opp-count {
  font-size: 14px;
  color: var(--muted);
}

/* ---- Game Feed (desktop left col) ---- */
.v2-game-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  overflow: hidden;
}

/* ---- Turn Box ---- */
.v2-turn-box {
  padding: 10px 14px;
  border: 1px solid #263036;
  background: #0f1416;
  font-size: 16px;
  color: var(--blue);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  overflow-wrap: break-word;
  min-width: 0;
}

.v2-turn-box.v2-turn-mine {
  border-color: var(--yellow);
  background: linear-gradient(180deg, rgba(255,209,102,0.14), rgba(10,14,12,0.98));
  color: #fff3c9;
  font-weight: 700;
}

.v2-turn-name {
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* ---- Last Action ---- */
.v2-last-action {
  display: none; /* hidden temporarily (user: too cluttered) — remove this line to restore */
  font-size: 15px;
  color: #ecf9ff;
  padding: 9px 12px;
  flex-shrink: 0;
  border: 1px solid rgba(79, 195, 247, 0.22);
  background: rgba(79, 195, 247, 0.05);
  border-left: 3px solid #4fc3f7;
  line-height: 1.45;
}

/* deck-row removed — info shown in Actions DECK INFO section */

/* ---- Log Panel (bottom row, desktop) ---- */
.v2-log-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
}

.v2-log-panel-label {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 28px;
  min-height: 28px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.v2-log-panel-label:hover { color: var(--text); }

/* ---- Log ---- */
.v2-log {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  font-size: 15px;
}

.v2-log-row {
  display: grid;
  grid-template-columns: 46px 60px 1fr;
  gap: 4px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-dim);
  align-items: baseline;
}

.v2-log-row:last-child { border-bottom: none; }

.v2-log-turn   { color: var(--muted); font-size: 13px; }
.v2-log-player { color: var(--text); font-weight: 600; }
.v2-log-text   { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.v2-log-badge  {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid currentColor;
  background: #11161a;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.v2-log-badge--plain {
  border: none;
  background: none;
  padding: 0;
}
.v2-log-detail { color: var(--muted); font-size: 13px; }

/* ---- Actions Panel ---- */
.v2-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  background: var(--panel);
}

.v2-section-label {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.v2-context-box {
  padding: 8px;
  border: 1px solid #263036;
  background: var(--deep);
}

.v2-context-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.v2-context-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.v2-context-hint {
  color: var(--muted);
  font-size: 14px;
}

.v2-target-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.v2-chip {
  padding: 5px 12px;
  border: 1px solid #3f555f;
  background: #11161a;
  color: #c9d1d9;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  transition: border-color 120ms, background 120ms, color 120ms;
}

.v2-chip:hover { border-color: var(--border); }

.v2-chip.active {
  border-color: var(--yellow);
  background: rgba(255,209,102,0.1);
  color: #fff0c2;
}

.v2-btn-play {
  width: 100%;
  padding: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--deep);
  color: var(--text);
  transition: border-color 120ms, background 120ms, color 120ms, opacity 120ms;
}

.v2-btn-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.v2-btn-play.ready {
  border-color: #4fc3f7;
  background: #173a52;
  color: #ecf9ff;
}

.v2-btn-draw {
  width: 100%;
  padding: 8px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--deep);
  color: var(--text);
  transition: border-color 120ms, background 120ms;
}

.v2-btn-draw:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.v2-btn-draw:not(:disabled):hover { background: #1a2226; }

.v2-deck-info {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.8;
}

.v2-deck-info span {
  color: var(--text);
  font-weight: 600;
}

/* ---- Hand Strip ---- */
.v2-hand-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.v2-hand-card {
  border: 1px solid #2a3236;
  border-left: 3px solid var(--card-color, var(--border));
  background: var(--deep);
  min-height: 38px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  width: 100%;
  position: relative;
  font-family: var(--font);
  transition: border-color 120ms, background 120ms, box-shadow 120ms, opacity 120ms;
}

.v2-hand-card:hover { background: #1a2226; }

.v2-hand-card:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.v2-hand-card.selected {
  background: color-mix(in srgb, var(--card-color, var(--border)) 12%, #101416);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-color, var(--border)) 18%, transparent);
}

.v2-hand-card.combo-highlight {
  outline: 2px solid var(--card-color, var(--border));
  outline-offset: -2px;
  background: color-mix(in srgb, var(--card-color, var(--border)) 10%, #101416);
}

.v2-hand-card.dim { opacity: 0.75; }

.v2-hand-card .v2-card-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.v2-hand-quick-play {
  padding: 2px 9px;
  border: 1px solid var(--green);
  background: rgba(142, 227, 142, 0.12);
  color: var(--green);
  font-size: 11px;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  line-height: 1.4;
  pointer-events: auto;
  margin-left: auto;
}

.v2-card-info-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-dim);
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font);
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  pointer-events: auto;
  transition: color 120ms, border-color 120ms;
}
.v2-card-info-btn:hover { color: var(--text); border-color: var(--border); }

.v2-card-index {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
  min-width: 16px;
}

.v2-card-name {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid currentColor;
  background: #11161a;
  font-size: 13px;
  font-weight: 700;
  color: var(--card-color, var(--text));
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ==================
   MOBILE (≤640px)
   ================== */
@media (max-width: 640px) {
  .v2-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* dissolve left-col so children join the flex flow directly */
  .v2-app > .v2-left-col { display: contents; }

  .v2-app > .v2-header {
    height: 48px;
    min-height: 48px;
    order: 1;
  }

  .v2-app > .v2-opponents {
    height: 64px;
    min-height: 64px;
    order: 2;
  }

  /* game-feed + log-panel (inside left-col → direct child via contents) */
  .v2-app .v2-game-feed  { display: none; order: 3; }
  .v2-app .v2-log-panel  { display: none; order: 9; }

  .v2-app > .v2-turn-row {
    display: block;
    padding: 8px;
    flex-shrink: 0;
    order: 4;
  }

  .v2-app > .v2-actions {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 8px;
    flex-shrink: 0;
    overflow-y: visible;
    order: 5;
  }

  /* hand-strip → 2-column grid on mobile */
  .v2-app .v2-hand-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    height: auto;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    order: 6;
  }

  .v2-app .v2-hand-card {
    min-height: 44px;
    width: 100%;
  }

  .v2-app .v2-card-name {
    white-space: normal;
    word-break: break-word;
  }

  .v2-app > .v2-log-panel { display: none; order: 7; }

  .v2-app > .v2-log-bar {
    display: flex;
    flex-direction: column;
    min-height: 44px;
    max-height: 44px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--panel);
    cursor: pointer;
    overflow: hidden;
    transition: max-height 200ms ease;
    order: 8;
  }

  .v2-app > .v2-log-bar {
    display: flex;
    flex-direction: column;
    min-height: 44px;
    max-height: 44px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--panel);
    cursor: pointer;
    overflow: hidden;
    transition: max-height 200ms ease;
  }

  .v2-app > .v2-log-bar.expanded {
    max-height: 200px;
    overflow-y: auto;
  }

  .v2-log-bar-label {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 44px;
    min-height: 44px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.1em;
    flex-shrink: 0;
    user-select: none;
  }

  .v2-log-bar-content {
    overflow-y: auto;
    flex: 1;
    display: none;
  }

  .v2-app > .v2-log-bar.expanded .v2-log-bar-content {
    display: block;
  }

  /* ---- Compact everything to fit 1 screen ---- */
  .v2-app > .v2-opponents {
    height: 56px;
    min-height: 56px;
  }

  .v2-app > .v2-turn-row {
    padding: 5px 8px;
  }

  .v2-app > .v2-actions {
    padding: 6px 8px;
    gap: 5px;
  }

  .v2-app .v2-section-label {
    font-size: 11px;
    margin-bottom: 2px;
  }

  .v2-app .v2-context-box {
    padding: 5px 8px;
  }

  .v2-app .v2-context-name { font-size: 13px; margin-bottom: 2px; }
  .v2-app .v2-context-hint { font-size: 12px; }
  .v2-app .v2-context-empty { font-size: 11px; }

  /* DECK INFO → single inline row instead of 3 stacked lines */
  .v2-app .v2-deck-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0 14px;
    font-size: 12px;
    line-height: 1.5;
  }

  .v2-app .v2-btn-play { padding: 8px 10px; font-size: 12px; }
  .v2-app .v2-btn-draw { padding: 6px 10px; font-size: 12px; }

  .v2-app .v2-hand-card {
    min-height: 38px;
  }

  .v2-app .v2-hand-quick-play {
    font-size: 10px;
    padding: 2px 6px;
  }

  .v2-app .v2-hand-strip {
    gap: 5px;
    padding: 6px 8px;
  }
}

/* ==================
   ACTION POPUP OVERLAY
   ================== */
.v2-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.v2-popup-overlay.hidden { display: none; }

.v2-popup {
  width: min(640px, 96vw);
  background: #141617;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  animation: popup-in 180ms ease-out both;
}

@keyframes popup-in {
  from { transform: translateY(10px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.v2-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.v2-popup-badge {
  padding: 3px 9px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.v2-popup-badge.nope    { color: var(--red); }
.v2-popup-badge.attack  { color: var(--orange); }
.v2-popup-badge.favor   { color: var(--green); }

.v2-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.v2-popup-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.v2-popup-effect {
  font-size: 20px;
  font-weight: 700;
  color: var(--orange);
  padding: 12px;
  border: 1px solid rgba(255, 158, 100, 0.25);
  background: rgba(255, 158, 100, 0.06);
  text-align: center;
  letter-spacing: 0.06em;
}

/* Countdown timer bar */
.v2-popup-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.v2-popup-timer-track {
  flex: 1;
  height: 4px;
  background: var(--border-dim);
  overflow: hidden;
}

.v2-popup-timer-bar {
  height: 100%;
  background: var(--red);
  width: 100%;
  animation: timer-drain var(--nope-timer-duration, 5s) linear forwards;
}

@keyframes timer-drain {
  from { width: 100%; }
  to   { width: 0%; }
}

.v2-popup-timer-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--yellow);
  min-width: 24px;
  text-align: right;
}

/* Hand in popup (for favor) */
.v2-popup-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.v2-popup-hand {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.v2-popup-hand .v2-hand-card {
  min-height: 38px;
  width: 100%;
}

/* Popup action buttons */
.v2-popup-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border-dim);
  padding-top: 14px;
}

.v2-popup-actions button {
  flex: 1;
  padding: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--deep);
  color: var(--text);
  transition: border-color 120ms, background 120ms;
}

.v2-popup-actions button:hover { background: #1a2226; }

.v2-btn-nope-action {
  border-color: var(--red) !important;
  color: var(--red) !important;
  font-weight: 700 !important;
}
.v2-btn-nope-action:hover { background: rgba(255,93,115,0.08) !important; }

.v2-btn-confirm-popup {
  border-color: #4fc3f7 !important;
  background: #173a52 !important;
  color: #ecf9ff !important;
}
.v2-btn-confirm-popup:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.v2-btn-leave-confirm {
  border-color: var(--red) !important;
  color: var(--red) !important;
  font-weight: 700 !important;
}
.v2-btn-leave-confirm:hover { background: rgba(255,93,115,0.08) !important; }

/* ---- Info modal button in header ---- */
.btn-info-modal {
  background: none;
  border: 1px solid var(--border-dim);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 9px;
  transition: color 120ms, border-color 120ms;
}
.btn-info-modal:hover { color: var(--text); border-color: var(--border); }

/* ---- Direction indicator in right column ---- */
.v2-direction-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-dim);
  background: var(--deep);
  margin-bottom: 4px;
}
.v2-direction-arrow {
  font-size: 28px;
  font-weight: 700;
  color: var(--purple);
  line-height: 1;
  min-width: 30px;
  text-align: center;
}
.v2-direction-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
}

/* ---- Action play button inside hand card ---- */
.v2-hand-action-play {
  margin-left: auto;
  padding: 2px 9px;
  border: 1px solid #4fc3f7;
  background: rgba(79, 195, 247, 0.12);
  color: #4fc3f7;
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  line-height: 1.4;
  cursor: pointer;
  pointer-events: auto;
  transition: background 120ms;
}
.v2-hand-action-play:hover { background: rgba(79, 195, 247, 0.22); }

/* ---- Info modal tabs & panels ---- */
.v2-info-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 10px;
}
.v2-info-tab {
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid var(--border-dim);
  background: none;
  color: var(--muted);
  transition: color 120ms, border-color 120ms, background 120ms;
}
.v2-info-tab.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(100, 223, 223, 0.08);
}
.v2-info-tab:hover:not(.active) { color: var(--text); border-color: var(--border); }
.v2-info-panel {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#info-panel-cards {
  display: block;
}

.v2-info-cards-grid {
  display: grid;
  grid-template-columns: auto 60px 1fr;
  gap: 0 12px;
  align-items: start;
}

.v2-info-card-name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
}

.v2-info-cards-grid .v2-info-card-desc {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
}

.v2-info-cards-grid > *:nth-last-child(-n+3) {
  border-bottom: none;
}

.v2-info-card-count {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.v2-info-card-count-cell {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#info-panel-cards .v2-info-card-item {
  border: 1px solid var(--border-dim);
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

#info-panel-cards .v2-info-card-item:last-child {
  border-bottom: 1px solid var(--border-dim);
}
.v2-info-rule {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
}
.v2-info-rule:last-child { border-bottom: none; }
.v2-info-card-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
  flex-wrap: wrap;
}
.v2-info-card-item:last-child { border-bottom: none; }
.v2-info-card-item .v2-card-name { flex-shrink: 0; }
.v2-info-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}

/* ==================
   NUCLEAR OVERLAY
   ================== */
.nuclear-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 77, 0, 0.12), rgba(10, 4, 2, 0.94) 60%),
    rgba(10, 4, 2, 0.92);
  padding: 24px;
  z-index: 1100;
}

.nuclear-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px 28px 24px;
  border: 1px solid #CC3D00;
  background: linear-gradient(180deg, rgba(30, 10, 2, 0.97), rgba(12, 4, 2, 0.99));
  box-shadow:
    0 0 0 1px rgba(255, 77, 0, 0.1),
    0 0 48px rgba(255, 77, 0, 0.12),
    0 16px 48px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: nuclear-panel-in 0.3s ease-out both;
}

.nuclear-art {
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.nuclear-art-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 160px;
  height: 160px;
}

.nuclear-symbol {
  font-size: 80px;
  line-height: 1;
  color: #FF4D00;
  animation: nuclear-spin 3s linear infinite;
  filter: drop-shadow(0 0 18px rgba(255, 77, 0, 0.45));
}

.nuclear-ring {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 2px solid rgba(255, 77, 0, 0.25);
  animation: nuclear-ring-pulse 1.4s ease-in-out infinite alternate;
}

.nuclear-ring-2 {
  width: 140px;
  height: 140px;
  border-color: rgba(255, 77, 0, 0.12);
  animation-delay: 0.35s;
  animation-duration: 1.8s;
}

.nuclear-label {
  color: #FF6B35;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.nuclear-title {
  color: #FF4D00;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: 0 0 22px rgba(255, 77, 0, 0.4);
  animation: nuclear-title-flicker 2.2s ease-in-out infinite alternate;
}

.nuclear-actor {
  color: #FF4D00;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border: 1px solid rgba(255, 77, 0, 0.15);
  background: rgba(255, 77, 0, 0.05);
}

.nuclear-message {
  color: #FFAD8A;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
}

@keyframes nuclear-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes nuclear-ring-pulse {
  from { transform: scale(0.94); opacity: 0.5; }
  to   { transform: scale(1.06); opacity: 1; }
}

@keyframes nuclear-title-flicker {
  0%   { opacity: 1; }
  88%  { opacity: 1; }
  90%  { opacity: 0.6; }
  92%  { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes nuclear-panel-in {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* ==================
   EXPLODE OVERLAY
   ================== */
.explode-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 120, 70, 0.16), rgba(12, 16, 14, 0.92) 58%),
    rgba(8, 10, 9, 0.9);
  padding: 24px;
  z-index: 1200;
}

.explode-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px 24px;
  border: 1px solid #d6ad52;
  background: linear-gradient(180deg, rgba(46, 29, 8, 0.96), rgba(22, 15, 6, 0.98));
  box-shadow: 0 0 0 1px rgba(255, 204, 102, 0.14), 0 16px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.explode-art {
  display: grid;
  place-items: center;
  margin-bottom: 2px;
}

.explode-art-svg {
  width: min(220px, 58vw);
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}

.explode-burst {
  transform-origin: 120px 88px;
  animation: explode-pulse 950ms ease-in-out infinite alternate;
}

.explode-bomb {
  transform-origin: 120px 102px;
  animation: explode-float 1400ms ease-in-out infinite alternate;
}

.explode-safe-mark,
.explode-failed-mark {
  opacity: 0;
}

.explode-phase {
  color: #ffd27a;
  letter-spacing: 0.16em;
  font-size: 13px;
}

.explode-message {
  color: #fff3cf;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 700;
}

.explode-memorial {
  color: #ffe9ea;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255, 120, 132, 0.16);
  animation: explode-memorial-fade 1.5s ease-in-out both;
}

.explode-countdown {
  color: #ffd166;
  font-size: 64px;
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.35);
}

.explode-overlay.is-saved .explode-panel {
  border-color: #4f9a68;
  background: linear-gradient(180deg, rgba(15, 32, 20, 0.96), rgba(10, 18, 12, 0.98));
  box-shadow: 0 0 0 1px rgba(111, 227, 142, 0.12), 0 16px 48px rgba(0, 0, 0, 0.45);
}

.explode-overlay.is-saved .explode-burst,
.explode-overlay.is-saved .explode-bomb {
  opacity: 0.16;
}

.explode-overlay.is-saved .explode-safe-mark {
  opacity: 1;
}

.explode-overlay.is-saved .explode-phase {
  color: #9ff0b4;
}

.explode-overlay.is-saved .explode-countdown {
  color: #8ee38e;
  text-shadow: 0 0 18px rgba(142, 227, 142, 0.25);
}

.explode-overlay.is-failed .explode-panel {
  border-color: #d65f5f;
  background: linear-gradient(180deg, rgba(56, 12, 16, 0.98), rgba(22, 8, 10, 0.99));
  box-shadow: 0 0 0 1px rgba(255, 93, 115, 0.16), 0 16px 48px rgba(0, 0, 0, 0.5);
}

.explode-overlay.is-failed .explode-burst {
  animation-duration: 500ms;
  transform: scale(1.14);
  filter: saturate(1.18) brightness(1.08);
}

.explode-overlay.is-failed .explode-bomb {
  opacity: 0;
}

.explode-overlay.is-failed .explode-failed-mark {
  opacity: 1;
  animation: explode-fail-burst 480ms ease-out infinite alternate;
}

.explode-overlay.is-failed .explode-phase {
  color: #ff9e9e;
}

.explode-overlay.is-failed .explode-message {
  color: #ffd9dd;
}

.explode-overlay.is-failed .explode-countdown {
  color: #FF2D55;
  text-shadow: 0 0 20px rgba(255, 45, 85, 0.38);
}

.explode-overlay.is-failed .explode-memorial {
  color: #fff3f4;
  text-shadow: 0 0 22px rgba(255, 45, 85, 0.22);
}

@keyframes explode-pulse {
  from { transform: scale(0.96); opacity: 0.85; }
  to   { transform: scale(1.04); opacity: 1; }
}

@keyframes explode-float {
  from { transform: translateY(0); }
  to   { transform: translateY(-3px); }
}

@keyframes explode-fail-burst {
  from { transform: scale(0.96); opacity: 0.72; }
  to   { transform: scale(1.06); opacity: 1; }
}

@keyframes explode-memorial-fade {
  0%   { opacity: 0; transform: translateY(8px) scale(0.98); }
  18%  { opacity: 1; transform: translateY(0) scale(1); }
  82%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-6px) scale(1.01); }
}

/* ==================
   SPECTATOR MEMORIAL
   ================== */
.spectator-memorial {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2200;
  pointer-events: none;
}

.spectator-memorial-text {
  padding: 16px 28px;
  border: 1px solid rgba(255, 109, 121, 0.36);
  background: rgba(18, 7, 9, 0.78);
  color: #fff1f2;
  font-size: clamp(22px, 4vw, 40px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 22px rgba(255, 93, 115, 0.2);
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.3);
  animation: explode-memorial-fade 1.5s ease-in-out both;
}

/* ==================
   V2 BANNER & TIMEOUT
   ================== */
.v2-banner {
  position: fixed;
  inset: 0;
  z-index: 1500;
  overflow-y: auto;
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 24px 16px 20px;
  background: var(--deep);
  border-top: 1px solid var(--yellow);
  border-bottom: 1px solid var(--border-dim);
  font-family: var(--font);
}

.v2-banner.hidden { display: none; }

.v2-banner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 440px;
}

.v2-banner-eyebrow {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.v2-banner-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 2px;
}

.v2-banner-trophy {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.55));
}

.v2-banner-winner {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--yellow);
  text-shadow: 0 0 14px rgba(255, 209, 102, 0.45);
  animation: v2-winner-pulse 2.4s ease-in-out infinite;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

@keyframes v2-winner-pulse {
  0%, 100% { text-shadow: 0 0 10px rgba(255, 209, 102, 0.35); }
  50%       { text-shadow: 0 0 22px rgba(255, 209, 102, 0.65); }
}

.v2-banner-wins-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.v2-banner-roster-panel {
  width: 100%;
  border: 1px solid var(--border-dim);
  background: var(--panel);
}

.v2-rematch-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.v2-rematch-counter {
  font-size: 11px;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

.v2-rematch-btn {
  padding: 4px 14px;
  border: 1px solid var(--green);
  background: rgba(142, 227, 142, 0.18);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}
.v2-rematch-btn:hover:not(:disabled) { background: rgba(142, 227, 142, 0.32); }
.v2-rematch-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.v2-ready-toggle-btn {
  padding: 4px 14px;
  border: 1px solid rgba(142, 227, 142, 0.5);
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, border-color 0.15s;
}
.v2-ready-toggle-btn:hover { background: rgba(142, 227, 142, 0.15); }
.v2-ready-toggle-btn.active {
  background: rgba(142, 227, 142, 0.28);
  border-color: var(--green);
}

.v2-timeout-notice {
  padding: 4px 10px;
  font-size: 12px;
  text-align: center;
  background: rgba(156, 220, 254, 0.06);
  color: #9cdcfe;
  border-bottom: 1px solid rgba(156, 220, 254, 0.15);
}

.v2-timeout-notice.hidden { display: none; }
