/**
 * tabletop.css
 * Stylesheet for RPM Tabletop UI & Scryfall Overlay Modal
 * 
 * Part of RPM Multiplayer - Feature 7
 * Document ID: SPEC-RPM-UI-007
 */

@import url('https://cdn.jsdelivr.net/npm/mana-font@latest/css/mana.min.css');

:root {
  /* Palette */
  --bg-tabletop: #0d1117;
  --bg-surface: #161b22;
  --bg-surface-elevated: #21262d;
  --bg-drawer: #1a1f26;
  --border-subtle: #30363d;
  --border-focus: #58a6ff;

  /* Priority & Status Colors */
  --color-priority-active: #2ea043;
  --color-priority-glow: rgba(46, 160, 67, 0.4);
  --color-locked: #da3633;
  --color-alarm-warning: #d29922;
  --color-alarm-danger: #f85149;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-retro: "Press Start 2P", "Courier New", monospace;

  /* Sizing & Transitions */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease-out;

  /* Z-Index Registry */
  --z-board: 10;
  --z-stack: 30;
  --z-alarm-banner: 40;
  --z-chat-bar: 50;
  --z-staged-chip: 60;
  --z-modal-backdrop: 1000;
  --z-modal-dialog: 1001;
}

/* ==========================================================================
   Base Tabletop Layout
   ========================================================================== */

#tabletop-container,
.tabletop-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-tabletop);
  color: #c9d1d9;
  font-family: var(--font-sans);
  box-sizing: border-box;
  overflow-x: hidden;
  position: relative;
  padding: 8px;
  gap: 10px;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* ==========================================================================
   Boards (Opponent & Active Player)
   ========================================================================== */

.tabletop-board {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.board-opponent {
  order: 1;
}

.tabletop-stack-container {
  order: 2;
}

.board-player {
  order: 3;
}

.tabletop-chat-bar {
  order: 4;
}

/* Priority Glow on Player Board */
.board-player.priority-held {
  border-color: var(--color-priority-active);
  box-shadow: 0 0 12px var(--color-priority-glow);
}

/* ==========================================================================
   Summary Bar
   ========================================================================== */

.board-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
}

.summary-identity-group,
.summary-resources-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #f0f6fc;
  font-size: 0.95rem;
}

.player-avatar {
  font-size: 1.1rem;
}

.player-badge.active-turn::after {
  content: '⚡';
  margin-left: 4px;
  font-size: 0.85rem;
}

.life-badge,
.life-controller {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1rem;
  color: #f0f6fc;
}

.life-badge .heart-icon {
  color: #f85149;
}

.btn-life {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: #f0f6fc;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-life:hover {
  background: #30363d;
  border-color: var(--border-focus);
}

.counter-badges {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #8b949e;
}

.counter-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Land Mana Bar */
.land-mana-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.mana-pip-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mana-pip-group.tapped-group {
  opacity: 0.5;
}

/* Floating Mana Pool */
.floating-mana-pool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mana-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(88, 166, 255, 0.15);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: #f0f6fc;
}

/* ==========================================================================
   Accordion Zone Drawers
   ========================================================================== */

.zone-drawers-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zone-drawer {
  background: var(--bg-drawer);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.zone-drawer-header {
  padding: 4px 6px;
}

.zone-drawer-badge {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: #c9d1d9;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.zone-drawer-badge:hover {
  background: #30363d;
  color: #f0f6fc;
}

.zone-drawer[data-expanded="true"] .zone-drawer-badge {
  border-color: var(--border-focus);
  background: #238636;
  color: #ffffff;
}

.drawer-chevron {
  font-size: 0.75rem;
  transition: transform var(--transition-fast);
}

.zone-drawer[data-expanded="true"] .drawer-chevron {
  transform: rotate(90deg);
}

.zone-drawer-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal), opacity var(--transition-fast), padding var(--transition-fast);
  opacity: 0;
  padding: 0 12px;
}

.zone-drawer[data-expanded="true"] .zone-drawer-body {
  max-height: 420px;
  overflow-y: auto;
  opacity: 1;
  padding: 8px 12px 12px 12px;
}

/* Cards List Inside Drawers */
.cards-flow-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.card-item {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 130px;
  max-width: 200px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  gap: 6px;
}

.card-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-item.card-tapped {
  opacity: 0.6;
  border-style: dashed;
}

.card-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f0f6fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-cost {
  display: inline-flex;
  gap: 2px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.card-typeline-short {
  font-size: 0.75rem;
  color: #8b949e;
}

.card-stats-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f0f6fc;
}

.card-quick-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.btn-card-action {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: #c9d1d9;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-card-action:hover {
  background: #30363d;
  color: #ffffff;
}

/* Fog-of-War Masked Cards */
.card-item.card-facedown {
  background: linear-gradient(135deg, #1f242c 0%, #161b22 100%);
  border: 1px dashed var(--border-subtle);
  min-height: 64px;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.card-item.card-facedown:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-subtle);
}

.card-back-pattern {
  font-size: 1.8rem;
  color: #8b949e;
  opacity: 0.6;
}

.deck-count-indicator {
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: #8b949e;
}

/* ==========================================================================
   Region B: The Stack & 15-Second Alarm Banner
   ========================================================================== */

.tabletop-stack-container {
  background: rgba(22, 27, 34, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #f0f6fc;
}

.stack-alarm-banner {
  background: linear-gradient(180deg, #2b1d1d 0%, #1a0f0f 100%);
  border: 2px solid var(--color-alarm-danger);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 0 15px rgba(248, 81, 73, 0.4);
  animation: pulseAlarm 1.2s infinite alternate;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-alarm-banner.held {
  border-color: var(--color-alarm-warning);
  box-shadow: 0 0 15px rgba(210, 153, 34, 0.4);
  animation: none;
}

@keyframes pulseAlarm {
  0% { box-shadow: 0 0 8px rgba(248, 81, 73, 0.3); }
  100% { box-shadow: 0 0 20px rgba(248, 81, 73, 0.7); }
}

.alarm-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.alarm-label {
  font-family: var(--font-retro);
  font-size: 0.78rem;
  color: var(--color-alarm-danger);
  letter-spacing: 0.5px;
}

.stack-alarm-banner.held .alarm-label {
  color: var(--color-alarm-warning);
}

.alarm-actions {
  display: flex;
  gap: 8px;
}

.btn-pass-priority,
.btn-hold-respond {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-pass-priority {
  background: #238636;
  color: #ffffff;
  border-color: #2ea043;
}

.btn-pass-priority:hover {
  background: #2ea043;
}

.btn-hold-respond {
  background: #9e6a03;
  color: #ffffff;
  border-color: #bb8009;
}

.btn-hold-respond:hover {
  background: #bb8009;
}

.alarm-progress-bar {
  height: 6px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
}

.alarm-progress-fill {
  height: 100%;
  width: 100%;
  background: var(--color-alarm-danger);
  transition: width 0.1s linear, background-color 0.25s ease;
}

.alarm-progress-fill.status-safe {
  background: var(--color-priority-active);
}

.alarm-progress-fill.status-warning {
  background: var(--color-alarm-warning);
}

.alarm-progress-fill.status-danger {
  background: var(--color-alarm-danger);
}

.stack-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.stack-item:hover {
  border-color: var(--border-focus);
}

.stack-item.stack-item-top {
  border-color: #f0883e;
  box-shadow: 0 0 8px rgba(240, 136, 62, 0.4);
}

.stack-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stack-seq-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: #30363d;
  color: #f0f6fc;
}

.stack-item-top .stack-seq-badge {
  background: #bd561d;
}

.stack-item-name {
  font-weight: 600;
  color: #f0f6fc;
  font-size: 0.9rem;
}

.stack-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: #8b949e;
}

/* ==========================================================================
   Region D: Dual-Channel Chat Bar
   ========================================================================== */

.tabletop-chat-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-chat-bar);
}

.chat-header-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #8b949e;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tab-btn:hover {
  color: #f0f6fc;
}

.tab-btn.active {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: #f0f6fc;
}

.chat-messages-container {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg-tabletop);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.chat-msg {
  display: flex;
  align-items: baseline;
  gap: 6px;
  word-break: break-word;
}

.chat-msg-sender {
  font-weight: 600;
  color: #58a6ff;
  font-size: 0.8rem;
}

.chat-msg-text {
  color: #f0f6fc;
}

/* Staged Action Confirmation Chip */
.staged-chip-overlay {
  position: relative;
}

.staged-action-chip {
  background: linear-gradient(135deg, #1b2838 0%, #171d25 100%);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease;
  flex-wrap: wrap;
  gap: 10px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chip-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chip-action-type {
  font-size: 0.75rem;
  font-weight: 700;
  color: #58a6ff;
  text-transform: uppercase;
}

.chip-description {
  font-size: 0.9rem;
  color: #f0f6fc;
}

.chip-actions {
  display: flex;
  gap: 6px;
}

.chip-btn {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast);
}

.chip-btn.btn-confirm {
  background: #238636;
  color: #ffffff;
}

.chip-btn.btn-confirm:hover {
  background: #2ea043;
}

.chip-btn.btn-edit {
  background: #1f6feb;
  color: #ffffff;
}

.chip-btn.btn-edit:hover {
  background: #388bfd;
}

.chip-btn.btn-cancel {
  background: #30363d;
  color: #c9d1d9;
}

.chip-btn.btn-cancel:hover {
  background: #484f58;
  color: #ffffff;
}

/* Chat Input Row */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.priority-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.priority-lock-badge.locked {
  background: rgba(218, 54, 51, 0.15);
  color: var(--color-locked);
  border: 1px solid var(--color-locked);
}

.priority-lock-badge.unlocked {
  background: rgba(46, 160, 67, 0.15);
  color: var(--color-priority-active);
  border: 1px solid var(--color-priority-active);
}

.chat-input-field {
  flex: 1;
  background: var(--bg-tabletop);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #f0f6fc;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input-field:focus {
  border-color: var(--border-focus);
}

.chat-input-field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #161b22;
}

.mic-dictation-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #c9d1d9;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.mic-dictation-btn:hover {
  background: #30363d;
  color: #f0f6fc;
}

.mic-dictation-btn.recording {
  border-color: #f85149;
  color: #f85149;
  animation: pulseMic 1s infinite alternate;
}

@keyframes pulseMic {
  0% { box-shadow: 0 0 4px rgba(248, 81, 73, 0.4); }
  100% { box-shadow: 0 0 10px rgba(248, 81, 73, 0.8); }
}

.mic-dictation-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.send-btn {
  background: #238636;
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.send-btn:hover {
  background: #2ea043;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: #30363d;
}

/* ==========================================================================
   Region E: Scryfall Card Overlay Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-backdrop.visible {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
}

.modal-card-dialog {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  z-index: var(--z-modal-dialog);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: #f0f6fc;
}

.modal-card-layout {
  display: flex;
  gap: 24px;
}

.modal-image-col {
  flex: 0 0 250px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-image-wrapper {
  width: 100%;
}

.modal-card-image {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  display: block;
}

.modal-details-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 28px;
  gap: 10px;
}

.modal-card-name {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #f0f6fc;
}

.modal-mana-cost {
  display: inline-flex;
  gap: 3px;
  font-size: 1.1rem;
}

.modal-typeline {
  font-size: 0.95rem;
  color: #8b949e;
  font-style: italic;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 4px 0;
}

.modal-oracle-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #c9d1d9;
  white-space: pre-line;
}

.modal-stats-row {
  display: flex;
  justify-content: flex-end;
}

.modal-pt-loyalty {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f0f6fc;
  padding: 4px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.modal-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  gap: 10px;
  flex-wrap: wrap;
}

.modal-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-modern-legal {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid #2ea043;
}

.modal-set-info {
  font-size: 0.8rem;
  color: #8b949e;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 768px) {
  .modal-card-dialog {
    padding: 16px;
  }

  .modal-card-layout {
    flex-direction: column;
    align-items: center;
  }

  .modal-image-col {
    flex: 0 0 auto;
    max-width: 220px;
  }

  .modal-details-col {
    width: 100%;
  }

  .board-summary-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-resources-group {
    width: 100%;
    justify-content: space-between;
  }

  .stack-item {
    flex-wrap: wrap;
  }

  .chat-input-row {
    flex-wrap: wrap;
  }

  .chat-input-field {
    width: 100%;
    order: 2;
  }

  .priority-lock-badge {
    order: 1;
  }

  .mic-dictation-btn,
  .send-btn {
    order: 3;
  }
}

@media (max-width: 480px) {
  #tabletop-container,
  .tabletop-root {
    padding: 4px;
    gap: 8px;
  }

  .tabletop-board {
    padding: 8px 10px;
  }

  .card-item {
    min-width: 110px;
    flex: 1 1 130px;
  }

  .alarm-info-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .alarm-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-card-dialog {
    padding: 14px 10px;
  }

  .summary-identity-group,
  .summary-resources-group {
    gap: 8px;
  }
}

/* ==========================================================================
   Feature 14: Unified Platform, Nav Tabs, Views & Popovers
   ========================================================================== */

/* Top-Level Header Nav Tabs */
.header-nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px;
}

.nav-tab {
  background: var(--bg-surface);
  color: #94a3b8;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-tab:hover:not(.tab-locked) {
  background: var(--bg-surface-elevated);
  color: #f8fafc;
  border-color: var(--border-focus);
}

.nav-tab.active {
  background: #1e293b;
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.nav-tab.tab-locked {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: #ef4444;
  color: #f87171;
}

/* View Host & Panes */
.rpm-view-host {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
}

.view-pane {
  width: 100%;
  height: 100%;
}

/* Hand Floating Popover (INV-1-TAP) */
.player-hand-grid {
  padding-top: 38px !important;
}

.hand-card-chip {
  position: relative;
}

.hand-card-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid #38bdf8;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 10px rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: var(--z-staged-chip);
  white-space: nowrap;
}

.btn-popover-action {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-popover-action:hover {
  background: #1d4ed8;
}

.btn-popover-inspect {
  background: #334155;
  color: #f8fafc;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-popover-close {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-popover-close:hover {
  color: #ef4444;
}

/* Battlefield Strips */
.player-battlefield-strips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.battlefield-strip {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.strip-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
}

.strip-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.battlefield-card-chip {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: #f1f5f9;
}

.battlefield-card-chip.tapped {
  opacity: 0.6;
  transform: rotate(5deg);
}

/* Perk Upkeep Dormancy (INV-PERK-UI-1) */
.command-emblem-badge.dormant {
  background: #334155;
  color: #94a3b8;
  border: 1px dashed #64748b;
}

.command-emblem-badge.active {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* Pre-Game d20 Roll-Off Overlay (INV-TURNSORT-1) */
.roll-off-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-staged-chip);
}

.roll-off-box {
  background: #1e293b;
  border: 2px solid #38bdf8;
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.roll-off-title {
  margin: 0 0 8px 0;
  font-size: 1.3rem;
  color: #38bdf8;
}

.roll-off-status {
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.roll-off-results {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.roll-result-chip {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.roll-player {
  font-size: 0.8rem;
  color: #94a3b8;
}

.roll-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: #facc15;
}

/* Concede Confirmation Modal (INV-LOCKOUT-1) */
.concede-modal-backdrop,
.auth-modal-backdrop,
.deck-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  opacity: 1;
  pointer-events: auto;
}

/* Seating Grid (INV-LOBBY-2) */
.lobby-seating-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.lobby-seat-pod {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.lobby-seat-pod.ready {
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

.lobby-seat-pod.empty {
  border-style: dashed;
}

.lobby-seat-pod.bot-seat {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.08);
}

.seat-empty-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.btn-seat-bot {
  background: #7e22ce;
  color: #fff;
  border: 1px solid #a855f7;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-seat-bot:hover {
  background: #9333ea;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.btn-remove-bot {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1px solid #ef4444;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 8px;
}

.btn-remove-bot:hover {
  background: #991b1b;
  color: #fff;
}

.btn-leave-seat {
  background: #334155;
  color: #cbd5e1;
  border: 1px solid #475569;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 8px;
}

.btn-leave-seat:hover {
  background: #475569;
  color: #fff;
}

/* Auth Registration Gate View (INV-AUTH-1) */
.auth-view-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 24px;
}

.auth-card {
  background: #1e293b;
  border: 2px solid #38bdf8;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-shield {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.auth-header h2 {
  font-size: 1.4rem;
  color: #f8fafc;
  margin: 0 0 6px 0;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0;
}

.auth-error-banner {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.auth-success-banner {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid #22c55e;
  color: #86efac;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form label {
  display: block;
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.auth-form label .required {
  color: #ef4444;
}

.auth-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #f8fafc;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.auth-input:focus {
  border-color: #38bdf8;
  outline: none;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.auth-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.auth-actions button {
  flex: 1;
}

.btn-dev-bypass {
  background: #059669;
  color: #fff;
  border: 1px solid #10b981;
}

.btn-dev-bypass:hover {
  background: #10b981;
}

.otp-section {
  margin-top: 20px;
}

.auth-divider {
  border: none;
  border-top: 1px solid #334155;
  margin: 16px 0;
}

.otp-input-group {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.otp-code-input {
  letter-spacing: 4px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Starter Archetypes Section (INV-ONBOARD-1) */
.onboarding-gate-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.onboarding-gate-banner h3 {
  margin: 0 0 6px 0;
  color: #fbbf24;
  font-size: 1.1rem;
}

.onboarding-gate-banner p {
  margin: 0;
  color: #fde68a;
  font-size: 0.9rem;
  line-height: 1.4;
}

.starter-archetypes-container {
  margin-bottom: 24px;
}

.starter-archetypes-container h3 {
  color: #f8fafc;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.starter-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.starter-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.starter-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.starter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.starter-header h4 {
  margin: 0;
  font-size: 1rem;
  color: #f8fafc;
}

.starter-colors {
  font-size: 0.75rem;
  font-weight: 700;
  background: #0f172a;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
}

.starter-archetype-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin: 0 0 10px 0;
}

.starter-preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.chip-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 0.7rem;
  padding: 2px 6px;
  color: #94a3b8;
}

.btn-select-starter {
  width: 100%;
  font-size: 0.85rem;
  padding: 8px 12px;
}

/* ==========================================================================
   Feature 16: Lobby Hub & Spectator Directory, Battle Mechanics & Phase Strip
   ========================================================================== */

/* Turn Phase Marker Strip (INV-PHASE-1) */
.phase-track-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
}

.phase-step-list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.phase-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  background: #1e293b;
  border: 1px solid #334155;
  transition: all 0.25s ease;
  user-select: none;
}

.phase-step:hover:not(.active) {
  border-color: #64748b;
  color: #cbd5e1;
}

.phase-step.active,
.phase-step.phase-active-step {
  color: #f0fdf4;
  background: #0284c7;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
  animation: pulseStepGlow 1.6s infinite alternate;
}

@keyframes pulseStepGlow {
  0% {
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.85);
    transform: scale(1.05);
  }
}

.btn-next-phase {
  background: #059669;
  color: #ffffff;
  border: 1px solid #10b981;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-next-phase:hover {
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-next-phase:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Arena Warning Banner (INV-LAND-1) */
.arena-warning-banner {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  animation: slideDown 0.2s ease;
}

/* Synchronized 3-Second Countdown Button (INV-COUNTDOWN-1) */
.btn-countdown-active {
  background: #f59e0b !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  border-color: #fbbf24 !important;
  animation: pulseCountdown 0.9s infinite alternate !important;
  letter-spacing: 0.3px;
}

@keyframes pulseCountdown {
  0% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
  }
  100% {
    transform: scale(1.03);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.9);
  }
}

/* Mode Selector Cards (INV-HUB-1) */
.lobby-hub-header {
  margin-bottom: 20px;
}

.lobby-hub-header h2 {
  font-size: 1.35rem;
  color: #f8fafc;
  margin: 0 0 6px 0;
}

.lobby-hub-header p {
  color: #94a3b8;
  font-size: 0.9rem;
  margin: 0;
}

.lobby-mode-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.lobby-mode-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
}

.lobby-mode-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.lobby-mode-card h4 {
  margin: 0;
  font-size: 1.05rem;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-mode-card p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.4;
  flex: 1;
}

/* Spectator Directory (INV-SPEC-1) */
.spectator-directory-section {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 28px;
}

.spectator-directory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.spectator-directory-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.spectator-table-wrapper {
  overflow-x: auto;
}

.spectator-table {
  width: 100%;
  border-collapse: collapse;
}

.spectator-table th {
  background: #1e293b;
  color: #94a3b8;
  text-align: left;
  padding: 10px 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
}

.spectator-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #1e293b;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.spectator-table tr:hover td {
  background: rgba(30, 41, 59, 0.5);
}

.btn-spectate-match {
  background: #0284c7;
  color: #ffffff;
  border: 1px solid #38bdf8;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-spectate-match:hover {
  background: #0369a1;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.btn-exit-spectator {
  background: #334155;
  color: #f8fafc;
  border: 1px solid #64748b;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-exit-spectator:hover {
  background: #475569;
  border-color: #94a3b8;
}

.spectator-watermark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid #0284c7;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   FEATURE 17: Opponent Land Strip, Tapped Rotation, Mana Pips, Card Modal
   ========================================================================== */

.opponent-lands-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm, 6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.opponent-lands-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 0 2px;
}

.mana-avail-summary {
  font-size: 0.72rem;
  color: #38bdf8;
}

.opponent-lands-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 42px;
}

.opponent-land-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 88px;
  height: 38px;
  padding: 0 8px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #f1f5f9;
  cursor: pointer;
  user-select: none;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out, border-color 0.2s ease, box-shadow 0.2s ease;
}

.opponent-land-card:hover {
  border-color: rgba(56, 189, 248, 0.8);
  transform: scale(1.04);
}

.opponent-land-card.is-tapped,
.opponent-land-card.card-tapped,
.battlefield-card-chip.is-tapped,
.battlefield-card-chip.card-tapped {
  opacity: 0.62;
  filter: grayscale(20%) contrast(95%);
  border-color: rgba(255, 255, 255, 0.18);
}

.opponent-land-card.is-tapped:hover {
  opacity: 0.82;
}

.land-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tap-badge {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-left: auto;
}

/* Card Overlay Skeleton Shimmer */
.card-modal-skeleton-shimmer {
  animation: modal-shimmer 1.5s infinite linear;
  background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  background-size: 200% 100%;
}

@keyframes modal-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 3D Dice Canvas Viewport Overlay (INV-DICE-3D-1) */
#dice-canvas {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: transparent;
  opacity: 1;
  transition: opacity 0.4s ease-out;
}

#dice-canvas.is-fading {
  opacity: 0;
}

#dice-canvas canvas,
#dice-canvas .dice-box-canvas {
  background: transparent;
  width: 100%;
  height: 100%;
}

/* Interactive Dice Shaker HUD (Touch-Hold & Shake) */
.dice-shaker-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  user-select: none;
}

.shaker-aura {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(124, 58, 237, 0.45) 0%, rgba(30, 27, 75, 0.75) 60%, rgba(15, 23, 42, 0) 100%);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  will-change: transform, left, top;
  transition: opacity 0.15s ease;
}

.shaker-aura.shaker-burst {
  animation: shaker-burst-anim 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes shaker-burst-anim {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

.shaker-dice-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 60px;
  position: relative;
}

.shaker-die {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  will-change: transform;
  transition: transform 0.08s ease-out;
}

.shaker-die.die-tens {
  background: linear-gradient(135deg, #8b5cf6, #581c87);
  border: 2px solid #fbbf24;
  color: #fef08a;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.shaker-die.die-ones {
  background: linear-gradient(135deg, #06b6d4, #0e7490);
  border: 2px solid #f87171;
  color: #fef2f2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.shaker-die.die-d20 {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border: 2px solid #fef3c7;
  color: #ffffff;
  font-size: 1.25rem;
}

.shaker-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  margin-top: 4px;
}




/* ==========================================================================
   FEATURE 19, 20 & 21: UI MODALS, DRAWERS & TWO-TIER PHASE STYLING
   ========================================================================== */

.hidden,
.mulligan-modal-backdrop.hidden,
.search-modal-backdrop.hidden,
.target-modal-backdrop.hidden,
.damage-assign-backdrop.hidden,
.permanent-action-drawer.hidden {
  display: none !important;
}

/* 1. London Mulligan Modal */
.mulligan-modal-backdrop,
.search-modal-backdrop,
.target-modal-backdrop,
.damage-assign-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 29, 0.82);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.mulligan-modal-panel,
.search-modal-panel,
.target-modal-panel,
.damage-assign-panel {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f3f4f6;
}

.mulligan-modal-header,
.search-modal-header,
.target-modal-header,
.damage-assign-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #1f2937;
}

.mulligan-title-wrap,
.search-title-row,
.target-title-row,
.assign-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.mulligan-title,
.search-modal-title,
.target-modal-title,
.damage-assign-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f9fafb;
}

.mulligan-badge {
  background: #3b82f6;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.mulligan-instructions,
.target-instructions {
  color: #9ca3af;
  font-size: 0.875rem;
  margin: 0;
}

.mulligan-cards-grid,
.search-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
  max-height: 55vh;
}

.mulligan-card-item,
.search-card-item {
  position: relative;
  background: #1f2937;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mulligan-card-item:hover,
.search-card-item:hover {
  transform: translateY(-4px);
  border-color: #60a5fa;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.mulligan-card-item.selected-bottom,
.search-card-item.selected {
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

.search-card-item.selected {
  border-color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

.bottom-order-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.search-selected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.mulligan-card-img,
.search-card-img {
  width: 100%;
  height: auto;
  display: block;
}

.mulligan-card-name,
.search-card-name {
  padding: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #111827;
}

.mulligan-actions,
.search-modal-footer,
.target-modal-footer,
.damage-assign-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #1f2937;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* 2. Target Selector Modal */
.target-candidates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  max-height: 55vh;
  overflow-y: auto;
}

.target-candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  background: #1f2937;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.15s ease;
}

.target-candidate-item.legal {
  cursor: pointer;
  border-color: rgba(16, 185, 129, 0.4);
}

.target-candidate-item.legal:hover {
  background: #1e3a2f;
  border-color: #10b981;
  transform: translateX(4px);
}

.target-candidate-item.illegal {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.target-item-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.target-item-sub {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-left: 8px;
}

.badge-legal {
  background: #059669;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-illegal {
  background: #dc2626;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* 3. Permanent Action Drawer */
.permanent-action-drawer {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 9900;
  width: 90%;
  max-width: 480px;
  padding: 16px;
  animation: slideUp 0.2s ease-out;
}

.drawer-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f9fafb;
}

.drawer-card-type {
  font-size: 0.8rem;
  color: #9ca3af;
}

.drawer-btn-close {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 1.4rem;
  cursor: pointer;
}

.drawer-ability-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2937;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

/* 4. Two-Tier Phase Breadcrumb */
.two-tier-phase-bar {
  display: flex;
  flex-direction: column;
  background: #111827;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}

.overarching-phases-row {
  display: flex;
  background: #1f2937;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.overarching-tab {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
}

.overarching-tab.active {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
  border-bottom: 2px solid #3b82f6;
}

.subphases-row {
  display: flex;
  padding: 4px 8px;
  gap: 6px;
  overflow-x: auto;
}

.subphase-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9ca3af;
  background: #1f2937;
}

.subphase-badge.current {
  color: #ffffff;
  background: #2563eb;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}
