:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #131b2e;
  --bg-card: #0f172a;
  --border-color: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #00f0ff;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
  --card-portrait-width: 90px;
  --card-portrait-height: 125px;
  --card-landscape-width: 130px;
  --card-landscape-height: 75px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER NAVBAR ==================== */
#main-header {
  height: 54px;
  background: #0f172a;
  border-bottom: 2px solid #00f0ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2rem;
  position: relative;
  z-index: 1000;
}

.logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: #00f0ff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title-box h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #00f0ff;
  letter-spacing: -0.5px;
}

.role-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  background: #1e293b;
  color: #00f0ff;
  border: 1px solid #00f0ff;
}

.header-controls-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #94a3b8;
}

.header-control-item select {
  background: #0f172a;
  border: 1px solid #334155;
  color: #ffffff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  font-weight: bold;
  max-width: 160px;
}

.btn-header {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-header:hover {
  background: #0369a1;
}

/* Hamburger Menu Button & Dropdown */
.hamburger-menu-container {
  position: relative;
}

.hamburger-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  border: 2px solid #00f0ff;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
}

.hamburger-btn span {
  width: 20px;
  height: 2px;
  background-color: #00f0ff;
  border-radius: 2px;
}

.hamburger-btn:hover {
  background: #1e293b;
}

.hamburger-dropdown {
  position: absolute;
  top: 50px;
  right: 10px;
  width: 240px;
  background: #0f172a;
  border: 2px solid #00f0ff;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  display: none;
  flex-direction: column;
  padding: 8px 0;
  z-index: 99999;
}

.hamburger-dropdown.show {
  display: flex !important;
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: #ffffff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.9rem;
  text-align: left;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
}

.dropdown-item:hover {
  background: #1e293b;
  color: #00f0ff;
}

.dropdown-divider {
  border: 0;
  border-top: 1px solid #334155;
  margin: 6px 0;
}

/* ==================== MAIN APP CONTAINER ==================== */
#app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 54px);
  min-height: calc(100vh - 54px);
  max-height: calc(100vh - 54px);
  position: relative;
  overflow: hidden;
}

/* ==================== RIGHT SIDEBAR ==================== */
#sidebar-right {
  width: 260px;
  height: 100%;
  max-height: 100%;
  background: #131b2e;
  border-left: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-box {
  border-bottom: 1px solid #1e293b;
  padding: 10px;
}

.tracker-box {
  background: #131b2e;
}

.score-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-label {
  font-size: 0.75rem;
  font-weight: bold;
  color: #94a3b8;
}

.score-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-val {
  font-size: 1rem;
  font-weight: 800;
  color: #00f0ff;
}

.btn-score {
  width: 24px;
  height: 24px;
  border: 1px solid #334155;
  border-radius: 4px;
  background: #1e293b;
  color: #ffffff;
  font-weight: bold;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-score:hover {
  background: #334155;
  color: #00f0ff;
}

.btn-xs {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
}

.btn-xs:hover {
  background: #0369a1;
}

/* Chat Box */
.chat-box-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #1e293b;
  background: #131b2e;
}

.box-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #00f0ff;
  text-transform: uppercase;
  margin-bottom: 6px;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
  max-height: 250px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 6px;
  color: #cbd5e1;
}

#chat-input-form {
  display: flex;
  gap: 4px;
}

#chat-input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  color: #ffffff;
  border-radius: 4px;
  padding: 6px;
  font-size: 0.75rem;
}

/* Deck Area Box (Bottom Left) */
.deck-area-box {
  height: 125px;
  border-bottom: none;
  background: #131b2e;
  display: flex;
  flex-direction: column;
}

.deck-stack {
  width: 90px;
  height: 75px;
  border: 2px solid #00f0ff;
  border-radius: 6px;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 240, 255, 0.2);
  margin-top: 4px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.deck-stack:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 240, 255, 0.4);
}

.deck-count {
  font-size: 1.2rem;
  font-weight: 800;
  color: #00f0ff;
}

/* ==================== CENTER PLAYFIELD & HAND COLUMN ==================== */
#playfield-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#playfield-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0a0f1d;
  padding: 15px;
}

#playfield {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  min-height: 100%;
}

.field-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.player-tag {
  font-size: 1.3rem;
  font-weight: 800;
  position: absolute;
  right: 10px;
  color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-p1 {
  top: 0px;
}

.tag-p2 {
  bottom: 0px;
}

/* Grid Rows */
.grid-row {
  display: grid;
  grid-template-columns: repeat(5, 140px);
  gap: 14px;
  align-items: center;
  justify-items: center;
}

.slot {
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #0f172a;
}

/* Red Slots (Portrait) */
.red-slot {
  width: 130px;
  height: 125px;
  border: 2px solid #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Green Slots (Landscape) */
.green-slot {
  width: 130px;
  height: 75px;
  border: 2px solid #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.neutral-divider {
  height: 2px;
  background: #1e293b;
  margin: 4px 0;
}

/* Canvas Overlay */
#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* ==================== BOTTOM HAND AREA ==================== */
#hand-area-container {
  height: 145px;
  min-height: 145px;
  max-height: 145px;
  flex: 0 0 145px;
  margin-top: auto;
  border-top: 2px solid #00f0ff;
  background: #131b2e;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

.hand-bar-scroll {
  height: 100%;
  flex: 1;
  display: flex !important;
  flex-direction: row !important;
  gap: 12px;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  align-items: center;
  padding: 4px 6px;
  width: 100%;
}

/* ==================== CARD RENDERED ITEMS ==================== */
.card-item {
  width: var(--card-portrait-width);
  height: var(--card-portrait-height);
  border: 2px solid #000000;
  border-radius: 6px;
  background: #090d16;
  position: absolute !important;
  z-index: 50;
  overflow: hidden;
  cursor: grab;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  user-select: none;
}

/* Face Down Card Back State */
.card-item.face-down, .hand-card.face-down, .gallery-card-item.face-down {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #090d16 100%) !important;
  border: 2px solid #3b82f6 !important;
  box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.4) !important;
}

.card-item.face-down *, .hand-card.face-down *, .gallery-card-item.face-down * {
  display: none !important;
}

.card-item.face-down::after, .hand-card.face-down::after, .gallery-card-item.face-down::after {
  content: '🎴';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  opacity: 0.8;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.7));
  display: block !important;
}

.hand-card, .gallery-card-item {
  width: var(--card-portrait-width);
  height: var(--card-portrait-height);
  border: 2px solid #000000;
  border-radius: 6px;
  background: #090d16;
  position: relative !important;
  display: inline-block !important;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.card-item.card-deterrent, .hand-card.card-deterrent, .gallery-card-item.card-deterrent {
  width: var(--card-landscape-width) !important;
  height: var(--card-landscape-height) !important;
}

/* Layer 1: Art Image */
.card-art-img {
  position: absolute;
  top: 22px;
  left: 4px;
  width: calc(100% - 8px);
  height: 52px;
  object-fit: cover;
  border-radius: 3px;
  z-index: 1;
}

.card-item.card-deterrent .card-art-img, .hand-card.card-deterrent .card-art-img, .gallery-card-item.card-deterrent .card-art-img {
  top: 20px;
  left: 4px;
  width: calc(100% - 8px);
  height: 42px;
}

/* Layer 2: PNG Frame Overlay Template */
.png-frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 5;
}

/* Layer 3: Faction Emblem Badge Socket */
.emblem-badge-overlay {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  object-fit: contain;
  z-index: 15;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8));
}

/* Center-Right Power Badge */
.center-right-power-badge {
  position: absolute;
  top: 76px;
  right: 4px;
  background: #dc2626;
  color: #ffffff;
  font-weight: 900;
  font-size: 0.55rem;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid #fee2e2;
  z-index: 15;
  box-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Layer 4: Content Overlay */
.card-content-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
}

/* Top Header Bar */
.card-top-header {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(100% - 6px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 13, 22, 0.9);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.card-name-text {
  font-size: 0.55rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.card-type-subtext {
  display: none;
}

.card-cost-top-right {
  font-size: 0.6rem;
  font-weight: 900;
  color: #22c55e;
  text-shadow: 0 1px 2px #000000;
}

/* Bottom Text Panel */
.card-bottom-text-panel {
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: calc(100% - 6px);
  max-height: 44px;
  background: rgba(15, 23, 42, 0.92);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 2px 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.card-description-text {
  font-size: 0.45rem;
  color: #94a3b8;
  line-height: 1.1;
  max-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-abilities-list {
  font-size: 0.45rem;
  color: #f8fafc;
  line-height: 1.1;
  overflow: hidden;
}

.card-abilities-list ul {
  padding-left: 10px;
}

.card-abilities-list li {
  margin-bottom: 1px;
}

/* ==================== INSPECTOR MODAL OVERLAY ==================== */
.inspector-modal {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 99999;
  width: 250px;
  background: #0f172a;
  border: 2px solid #00f0ff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  padding: 14px;
}

.inspector-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* Dragging Hand Card Clone Avatar */
.dragging-hand-card-clone {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  opacity: 0.9;
  transform: scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 240, 255, 0.5);
  transition: none;
}

/* ==================== SERVER BROWSER MODAL ==================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 29, 0.85);
  backdrop-filter: blur(8px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog-large {
  width: 780px;
  max-width: 92vw;
  background: #0f172a;
  border: 2px solid #00f0ff;
  border-radius: 12px;
  box-shadow: 0 15px 50px rgba(0, 240, 255, 0.25);
  padding: 20px;
}

.room-entry-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #131b2e;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}

.room-entry-card:hover {
  border-color: #00f0ff;
}
