/* ============================================
   ClawValley Spectator — Stardew Valley Theme
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --parchment: #FDF4E3;
  --parchment-dark: #E8D4AC;
  --parchment-light: #FFF8F0;
  --wood-dark: #5C3A1E;
  --wood-med: #A0722B;
  --wood-light: #B8863E;
  --wood-highlight: #C4A060;
  --panel-bg: #FDF4E3;
  --panel-border: #6B4226;
  --text-dark: #3B2412;
  --text-med: #5C3A1E;
  --text-light: #8B6914;
  --green-accent: #5EA030;
  --green-dark: #3D6B1E;
  --blue-accent: #4A90D9;
  --red-accent: #D94A4A;
  --orange-accent: #D98A2B;
  --gold-accent: #DAA520;
  --cyan-accent: #4AC8D9;
  --health-bar: #E04040;
  --energy-bar: #40A0E0;
  --hunger-bar: #E09030;
  --online-green: #50C050;
  --offline-gray: #888;
  --night-overlay: rgba(10, 10, 48, 0.35);

  /* Wood grain shadow: layered insets to simulate plank texture */
  --shadow-wood: inset 0 2px 4px rgba(0,0,0,0.35), inset 0 -1px 3px rgba(255,255,255,0.12), inset 0 1px 0 rgba(255,255,255,0.08);
  --shadow-panel: 3px 3px 0 rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.1);

  /* Enhanced wood plank border simulation with more visible grain */
  --wood-grain-bg: repeating-linear-gradient(
    90deg,
    rgba(92,58,30,0.08) 0px,
    rgba(92,58,30,0.0) 1px,
    rgba(92,58,30,0.05) 3px,
    rgba(92,58,30,0.0) 5px,
    rgba(92,58,30,0.1) 8px,
    rgba(92,58,30,0.0) 10px,
    rgba(139,105,20,0.04) 12px
  );
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: var(--parchment);
  color: var(--text-dark);
  image-rendering: pixelated;
}

/* --- Header (thick wood-plank feel) --- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 12px;
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, #8B5E33 0%, #6B4226 30%, #5C3A1E 60%, #4A2E16 100%);
  border-bottom: 4px solid #3B1F0E;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -2px 4px rgba(0,0,0,0.3);
  z-index: 10;
  position: relative;
}

/* Horizontal grain lines on header */
#header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 3px,
      rgba(0,0,0,0.04) 3px,
      rgba(0,0,0,0.04) 4px,
      transparent 4px,
      transparent 8px,
      rgba(255,255,255,0.03) 8px,
      rgba(255,255,255,0.03) 9px
    );
  pointer-events: none;
  border-radius: inherit;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

/* Embossed/engraved "ClawValley" title */
.game-title {
  font-size: 16px;
  color: #FFD700;
  text-shadow:
    2px 2px 0 #3B1F0E,
    0 0 8px rgba(255,215,0,0.3),
    0 -1px 0 rgba(255,255,255,0.15),
    0 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 8px;
  color: #C4A060;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tick-frame {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #3B1F0E;
  border: 2px solid #A0722B;
  border-radius: 4px;
  padding: 4px 10px;
  box-shadow: var(--shadow-wood);
}

.tick-label {
  font-size: 7px;
  color: #B8863E;
  letter-spacing: 1px;
}

#tick-counter {
  font-size: 12px;
  color: #FFD700;
  min-width: 40px;
  text-align: center;
}

.day-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #3B1F0E;
  border: 2px solid #A0722B;
  border-radius: 4px;
  padding: 4px 8px;
  box-shadow: var(--shadow-wood);
  transition: background 0.5s;
}

.day-indicator.night {
  background: #1A1A3A;
  border-color: #4A4A8A;
}

#day-icon {
  font-size: 14px;
}

#day-text {
  font-size: 8px;
  color: #FFD700;
}

.day-indicator.night #day-text {
  color: #8888CC;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-label {
  font-size: 7px;
  color: #B8863E;
  letter-spacing: 1px;
}

#api-url {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  width: 180px;
  padding: 4px 6px;
  background: #3B1F0E;
  color: #FFD700;
  border: 2px solid #A0722B;
  border-radius: 3px;
  outline: none;
}

#api-url:focus {
  border-color: #FFD700;
}

/* Connect button — embossed/carved wood look */
.wood-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 5px 10px;
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, #B8863E 0%, #A0722B 40%, #8B6020 100%);
  color: #FFF3E0;
  border: 2px solid #5C3A1E;
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5), 0 -1px 0 rgba(255,255,255,0.1);
  box-shadow:
    0 2px 0 #3B1F0E,
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -1px 2px rgba(0,0,0,0.2);
  transition: all 0.1s;
  position: relative;
}

.wood-btn:hover {
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, #C4A060 0%, #B8863E 40%, #A0722B 100%);
}

.wood-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 #3B1F0E,
    inset 0 2px 3px rgba(0,0,0,0.3);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #3B1F0E;
  transition: background 0.3s;
}

.status-dot.online {
  background: var(--online-green);
  box-shadow: 0 0 6px rgba(80,192,80,0.5);
}

.status-dot.offline {
  background: var(--offline-gray);
}

.status-dot.connecting {
  background: var(--orange-accent);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Main Layout --- */
#main {
  display: flex;
  height: calc(100vh - 52px);
}

/* --- Map Container --- */
#map-container {
  flex: 7;
  position: relative;
  background: #2A3A1A;
  overflow: hidden;
  cursor: grab;
  border-right: 4px solid #3B1F0E;
  touch-action: none; /* Prevent browser scroll/zoom on touch — we handle it */
}

#map-container:active {
  cursor: grabbing;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#map-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
  pointer-events: none;
}

/* Coords display with wood-frame background */
#coords-display {
  font-size: 9px;
  line-height: 1;
  min-width: 58px;
  text-align: center;
  color: #FFD700;
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, #6B4226 0%, #5C3A1E 100%);
  padding: 6px 10px;
  border-radius: 4px;
  border: 2px solid #A0722B;
  box-shadow:
    var(--shadow-wood),
    2px 2px 4px rgba(0,0,0,0.3);
  position: relative;
}

/* Corner nail dots on coords display */
#coords-display::before,
#coords-display::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, #8B8B8B 40%, #5C5C5C 100%);
  border-radius: 50%;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.2);
}

#coords-display::before {
  top: 3px;
  left: 3px;
}

#coords-display::after {
  top: 3px;
  right: 3px;
}

/* --- Info Panel --- */
#info-panel {
  flex: 0 0 320px;
  width: 320px;
  min-width: 280px;
  max-width: 400px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: none;
  overflow: hidden;
}

/* --- Tabs (wooden tabs nailed to frame) --- */
#tab-bar {
  display: flex;
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, #6B4226 0%, #5C3A1E 100%);
  border-bottom: 3px solid #3B1F0E;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 8px 4px;
  background: transparent;
  color: #B8863E;
  border: none;
  border-right: 2px solid #3B1F0E;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  position: relative;
}

.tab-btn:last-child {
  border-right: none;
}

.tab-btn:hover {
  background: rgba(255,215,0,0.1);
  color: #FFD700;
}

/* Active tab: looks like a wooden tab nailed to the panel */
.tab-btn.active {
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, var(--panel-bg) 60%, #E8D4AC 100%);
  color: var(--text-dark);
  box-shadow:
    inset 0 -3px 0 var(--panel-bg),
    inset 0 2px 3px rgba(0,0,0,0.1);
  margin-bottom: -3px;
  padding-bottom: 11px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* Nail dots on active tab */
.tab-btn.active::before,
.tab-btn.active::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, #8B8B8B 40%, #5C5C5C 100%);
  border-radius: 50%;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.3);
  top: 5px;
}

.tab-btn.active::before {
  left: 6px;
}

.tab-btn.active::after {
  right: 6px;
}

/* --- Tab Content --- */
.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Panel Sections (wood-plank frame) --- */
.panel-section {
  background: var(--parchment-light);
  border: 4px solid transparent;
  border-image: linear-gradient(135deg, #6B4226 0%, #8B5E33 50%, #6B4226 100%) 1;
  border-radius: 4px;
  padding: 10px;
  position: relative;
  box-shadow:
    var(--shadow-panel),
    inset 0 2px 0 rgba(255,255,255,0.25),
    inset 0 -2px 3px rgba(0,0,0,0.12);
  /* Enhanced wood grain texture */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(92,58,30,0.025) 0px,
      transparent 2px,
      rgba(92,58,30,0.015) 4px,
      transparent 6px
    ),
    linear-gradient(180deg, rgba(255,255,255,0.4) 0%, transparent 8px);
  background-size: 8px 100%, 100% 100%;
}

/* Corner nail dots on panel sections (4 corners) */
.panel-section::before,
.panel-section::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: radial-gradient(circle at 40% 40%, #ABABAB 20%, #7B7B7B 50%, #5B5B5B 80%, #3B3B3B 100%);
  border-radius: 50%;
  box-shadow:
    inset -1px -1px 0 rgba(255,255,255,0.3),
    inset 1px 1px 1px rgba(0,0,0,0.4),
    0 1px 2px rgba(0,0,0,0.3);
  z-index: 1;
}

.panel-section::before {
  top: 4px;
  left: 4px;
  /* Add bottom-left nail using box-shadow trick */
  box-shadow:
    inset -1px -1px 0 rgba(255,255,255,0.3),
    inset 1px 1px 1px rgba(0,0,0,0.4),
    0 1px 2px rgba(0,0,0,0.3),
    0 calc(100% - 14px) 0 0 #7B7B7B,
    0 calc(100% - 14px) 0 0 #7B7B7B;
}

.panel-section::after {
  top: 4px;
  right: 4px;
  /* Add bottom-right nail */
  box-shadow:
    inset -1px -1px 0 rgba(255,255,255,0.3),
    inset 1px 1px 1px rgba(0,0,0,0.4),
    0 1px 2px rgba(0,0,0,0.3);
}

.section-title {
  font-size: 8px;
  color: var(--wood-dark);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--parchment-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.stat-label {
  font-size: 7px;
  color: var(--text-med);
}

.stat-value {
  font-size: 8px;
  color: var(--text-dark);
}

.online-text { color: var(--online-green); }
.offline-text { color: var(--offline-gray); }

/* Resource pixel icon squares (10x10px) */
.res-wood::before { content: ''; display: inline-block; width: 10px; height: 10px; background: #8B5E3C; margin-right: 4px; border: 1px solid #5C3A1E; vertical-align: middle; image-rendering: pixelated; }
.res-stone::before { content: ''; display: inline-block; width: 10px; height: 10px; background: #8B8B8B; margin-right: 4px; border: 1px solid #5C5C5C; vertical-align: middle; image-rendering: pixelated; }
.res-food::before { content: ''; display: inline-block; width: 10px; height: 10px; background: #D94A4A; margin-right: 4px; border: 1px solid #A03030; vertical-align: middle; image-rendering: pixelated; }
.res-iron::before { content: ''; display: inline-block; width: 10px; height: 10px; background: #5C5C5C; margin-right: 4px; border: 1px solid #3C3C3C; vertical-align: middle; image-rendering: pixelated; }
.res-gold::before { content: ''; display: inline-block; width: 10px; height: 10px; background: #DAA520; margin-right: 4px; border: 1px solid #A07A10; vertical-align: middle; image-rendering: pixelated; }

/* --- Scrollable Lists --- */
.scrollable-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Wood-colored scrollbars */
.scrollable-list::-webkit-scrollbar,
.tab-content::-webkit-scrollbar {
  width: 6px;
}

.scrollable-list::-webkit-scrollbar-track,
.tab-content::-webkit-scrollbar-track {
  background: var(--parchment-dark);
  border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb,
.tab-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #B8863E, #A0722B);
  border-radius: 3px;
  border: 1px solid var(--wood-dark);
}

.scrollable-list::-webkit-scrollbar-thumb:hover,
.tab-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #C4A060, #B8863E);
}

.empty-state {
  font-size: 8px;
  color: var(--text-light);
  text-align: center;
  padding: 24px 8px;
  opacity: 0.7;
}

/* --- Agent Cards --- */
.agent-card {
  background: var(--parchment-light);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 1px 1px 0 rgba(0,0,0,0.15);
}

.agent-card:hover {
  background: #FFF8EB;
  border-color: var(--gold-accent);
  transform: translateX(2px);
}

.agent-card.offline-agent {
  opacity: 0.55;
}

.agent-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.agent-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.3);
}

.agent-name {
  font-size: 7px;
  color: var(--text-dark);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-status-icon {
  font-size: 6px;
}

.agent-pos {
  font-size: 6px;
  color: var(--text-light);
}

.agent-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar-icon {
  font-size: 6px;
  color: var(--text-med);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.pixel-bar {
  flex: 1;
  height: 6px;
  background: #3B1F0E;
  border: 1px solid #2A1008;
  position: relative;
  image-rendering: pixelated;
}

.pixel-bar-fill {
  height: 100%;
  transition: width 0.5s;
}

.pixel-bar-fill.health { background: var(--health-bar); }
.pixel-bar-fill.energy { background: var(--energy-bar); }
.pixel-bar-fill.hunger { background: var(--hunger-bar); }

.bar-value {
  font-size: 6px;
  color: var(--text-med);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

/* --- Chat Messages --- */
.chat-msg {
  background: var(--parchment-light);
  border: 2px solid var(--parchment-dark);
  border-radius: 4px;
  border-top-left-radius: 0;
  padding: 6px 8px;
  position: relative;
}

.chat-msg::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 8px;
  height: 8px;
  background: var(--parchment-light);
  border-left: 2px solid var(--parchment-dark);
  border-top: 2px solid var(--parchment-dark);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chat-sender {
  font-size: 7px;
  font-weight: bold;
  margin-bottom: 2px;
}

.chat-text {
  font-size: 7px;
  color: var(--text-med);
  line-height: 1.5;
  word-break: break-word;
}

.chat-time {
  font-size: 6px;
  color: var(--text-light);
  text-align: right;
  margin-top: 2px;
}

/* --- Activity Feed --- */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 6px;
  background: var(--parchment-light);
  border: 1px solid var(--parchment-dark);
  border-radius: 3px;
  border-left: 3px solid var(--wood-light);
  transition: border-left-color 0.2s, box-shadow 0.2s;
}

/* Subtle left-border glow on hover */
.activity-item:hover {
  box-shadow: -2px 0 8px rgba(218,165,32,0.25);
  border-left-color: var(--gold-accent);
}

.activity-item.event-gather { border-left-color: var(--green-accent); }
.activity-item.event-craft { border-left-color: var(--gold-accent); }
.activity-item.event-build { border-left-color: var(--blue-accent); }
.activity-item.event-trade_completed,
.activity-item.event-trade_proposed { border-left-color: var(--cyan-accent); }
.activity-item.event-death { border-left-color: var(--red-accent); }
.activity-item.event-move { border-left-color: var(--text-light); }

.activity-item.event-gather:hover { box-shadow: -2px 0 8px rgba(94,160,48,0.3); border-left-color: var(--green-accent); }
.activity-item.event-craft:hover { box-shadow: -2px 0 8px rgba(218,165,32,0.3); border-left-color: var(--gold-accent); }
.activity-item.event-build:hover { box-shadow: -2px 0 8px rgba(74,144,217,0.3); border-left-color: var(--blue-accent); }
.activity-item.event-death:hover { box-shadow: -2px 0 8px rgba(217,74,74,0.3); border-left-color: var(--red-accent); }

.activity-icon {
  font-size: 10px;
  flex-shrink: 0;
  line-height: 1;
}

.activity-body {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 7px;
  color: var(--text-dark);
  line-height: 1.4;
  word-break: break-word;
}

.activity-tick {
  font-size: 6px;
  color: var(--text-light);
  margin-top: 1px;
}

/* --- Night mode body class --- */
body.night-mode {
  --parchment: #D8C8A8;
  --panel-bg: #C8B898;
  --parchment-light: #E0D0B0;
}

body.night-mode #map-container {
  background: #0A1A0A;
}

/* --- Agent Profile Panel --- */
.agent-profile {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.back-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  background: var(--parchment-dark);
  color: var(--text-dark);
  border: 2px solid var(--panel-border);
  border-radius: 3px;
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.15s;
}

.back-btn:hover {
  background: var(--wood-light);
  color: #FFF3E0;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.profile-name {
  font-size: 10px;
  color: var(--text-dark);
  flex: 1;
}

.profile-pos {
  font-size: 7px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 4px;
  background: var(--parchment);
  border-radius: 2px;
}

.inv-name {
  font-size: 7px;
  color: var(--text-dark);
  text-transform: capitalize;
}

.inv-qty {
  font-size: 7px;
  color: var(--text-light);
}

/* --- Filter Buttons --- */
.filter-bar {
  display: flex;
  gap: 3px;
  padding: 4px 0;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 3px 6px;
  background: var(--parchment-dark);
  color: var(--text-med);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: var(--wood-light);
  color: #FFF3E0;
}

.filter-btn.active {
  background: var(--wood-dark);
  color: #FFD700;
  border-color: var(--wood-light);
}

/* --- Flash Animation --- */
@keyframes flash {
  0% { background: rgba(255, 215, 0, 0.3); }
  100% { background: transparent; }
}

.activity-flash {
  animation: flash 1.5s ease-out;
}

/* --- Chat Whisper Styling --- */
.chat-whisper {
  opacity: 0.75;
  border-style: dashed;
}

.chat-whisper .chat-text {
  font-style: italic;
  color: var(--text-light);
}

/* --- Leaderboard Rankings --- */
#tab-ranks {
  gap: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--parchment-dark);
}

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

.rank-badge {
  font-size: 10px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.rank-num {
  font-size: 7px;
  color: var(--text-light);
}

.rank-name {
  font-size: 7px;
  color: var(--text-dark);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  font-size: 6px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* --- Responsive tweaks --- */
@media (max-width: 900px) {
  #info-panel {
    min-width: 220px;
  }
  .tab-btn {
    font-size: 6px;
    padding: 6px 2px;
  }
}

/* --- Combat --- */
.combat-text {
  color: #E63946;
  font-weight: bold;
}

/* --- Agent Profile Modal --- */
.agent-profile-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 12, 5, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-modal-content {
  background:
    var(--wood-grain-bg),
    linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment) 100%);
  border: 4px solid var(--wood-dark);
  border-radius: 6px;
  padding: 16px 20px;
  min-width: 300px;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-close-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.profile-close-btn:hover {
  color: var(--red-accent);
}

.profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.profile-status-dot.online {
  background: var(--online-green);
  box-shadow: 0 0 4px rgba(80,192,80,0.5);
}

.profile-status-dot.offline {
  background: var(--offline-gray);
}

.agent-status-label {
  font-size: 7px;
  color: var(--text-light);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
}

.inv-grid-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  background: var(--parchment);
  border: 1px solid var(--parchment-dark);
  border-radius: 3px;
}

/* --- Leaderboard Online Indicators --- */
.rank-online .rank-name {
  font-weight: bold;
  color: var(--text-dark);
}

.rank-online-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--online-green);
  box-shadow: 0 0 3px rgba(80,192,80,0.5);
  margin-right: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Hide drawer handle on desktop */
.drawer-handle {
  display: none;
}

/* ============================================
   Mobile Layout — Bottom Drawer
   ============================================ */
@media (max-width: 768px) {
  /* --- Header: compact --- */
  #header {
    height: 40px;
    padding: 0 8px;
  }

  .game-title {
    font-size: 11px;
    letter-spacing: 1px;
  }

  .subtitle {
    display: none;
  }

  .header-right {
    display: none;
  }

  .header-center {
    gap: 8px;
  }

  .tick-frame {
    padding: 3px 6px;
    gap: 4px;
  }

  .tick-label {
    font-size: 6px;
  }

  #tick-counter {
    font-size: 10px;
    min-width: 30px;
  }

  .day-indicator {
    padding: 3px 6px;
    gap: 3px;
  }

  #day-icon {
    font-size: 11px;
  }

  #day-text {
    font-size: 7px;
  }

  /* --- Main layout: stacked column --- */
  #main {
    flex-direction: column;
    height: calc(100vh - 44px);
  }

  /* --- Map: full screen minus header and collapsed tab bar --- */
  #map-container {
    flex: none;
    width: 100%;
    height: calc(100vh - 40px - 44px);
    border-right: none;
  }

  /* --- Info panel: fixed bottom drawer --- */
  #info-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44px;
    max-width: none;
    min-width: auto;
    flex: none;
    border-top: 4px solid #3B1F0E;
    border-radius: 12px 12px 0 0;
    z-index: 20;
    transition: height 0.3s ease;
    overflow: hidden;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
  }

  #info-panel.drawer-open {
    height: 55vh;
  }

  /* --- Drawer handle --- */
  .drawer-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }

  .drawer-handle-bar {
    width: 36px;
    height: 4px;
    background: #A0722B;
    border-radius: 2px;
  }

  /* --- Tab bar: touch-friendly --- */
  #tab-bar {
    border-bottom: 2px solid #3B1F0E;
  }

  .tab-btn {
    padding: 10px 6px;
    font-size: 7px;
  }

  .tab-btn.active {
    padding-bottom: 12px;
    margin-bottom: -2px;
  }

  /* --- Tab content: hidden when collapsed, scrollable when open --- */
  .tab-content.active {
    max-height: calc(55vh - 44px - 16px);
    overflow-y: auto;
  }

  #info-panel:not(.drawer-open) .tab-content {
    display: none !important;
  }

  /* --- Agent profile modal: mobile-friendly --- */
  .profile-modal-content {
    min-width: auto;
    max-width: 95vw;
    width: 90vw;
    padding: 12px 14px;
  }

  /* --- Coords overlay: don't overlap drawer --- */
  #map-overlay {
    bottom: 4px;
    left: 4px;
  }
}

/* ===== Weather Section ===== */
#weather-section {
  background: linear-gradient(135deg, rgba(135,206,235,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 12px;
}

/* ===== Alliance Cards ===== */
.alliance-card {
  background: rgba(139, 69, 19, 0.2);
  border: 2px solid #8B4513;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
}

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

.alliance-name {
  font-weight: bold;
  color: #FFD700;
}

.alliance-member-count {
  font-size: 0.8em;
  color: #aaa;
}

.alliance-leader {
  font-size: 0.85em;
  color: #ccc;
  margin-bottom: 6px;
}

.alliance-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.alliance-member {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.8em;
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ===== Progression Cards ===== */
.progression-card {
  background: rgba(75, 0, 130, 0.2);
  border: 2px solid #4B0082;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
}

.progression-card.offline-agent {
  opacity: 0.6;
}

.prog-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.prog-rank {
  font-size: 0.8em;
  color: #FFD700;
  min-width: 24px;
}

.prog-name {
  flex: 1;
  font-weight: bold;
}

.prog-level {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #000;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: bold;
  font-size: 0.85em;
}

.prog-xp-bar {
  height: 16px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  margin-bottom: 6px;
}

.prog-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #9400D3 0%, #FF00FF 100%);
  transition: width 0.3s ease;
}

.prog-xp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7em;
  color: #fff;
  text-shadow: 1px 1px 1px #000;
  white-space: nowrap;
}

.prog-recipes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.prog-recipe {
  font-size: 1.1em;
  cursor: help;
}

.prog-recipe-more {
  font-size: 0.75em;
  color: #aaa;
  padding: 2px 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
}

/* ===== Enhanced Coordinates Display ===== */
#coords-display {
  min-width: 200px;
  white-space: nowrap;
}

/* ===== Resource Legend (hover help) ===== */
.resource-legend {
  position: absolute;
  bottom: 40px;
  left: 10px;
  background: rgba(0,0,0,0.7);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.75em;
  color: #fff;
  display: flex;
  gap: 12px;
}

.resource-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.resource-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.resource-dot.wood { background: #8B4513; }
.resource-dot.stone { background: #808080; }
.resource-dot.food { background: #32CD32; }
.resource-dot.iron { background: #A0A0A0; }
.resource-dot.gold { background: #FFD700; }

/* === Phase 1: Score Deltas === */
.score-delta-up { color: #4ade80; font-size: 0.75em; font-weight: bold; margin-left: 4px; }
.score-delta-down { color: #ef4444; font-size: 0.75em; font-weight: bold; margin-left: 4px; }
.rank-sparkline { padding: 0 0 4px 28px; line-height: 0; }

/* === Phase 1: Bot Personality Cards === */
.agent-avatar { font-size: 1.2em; margin-right: 4px; }
.agent-title {
  font-size: 0.65em;
  color: #a78bfa;
  font-style: italic;
  margin-left: 4px;
  white-space: nowrap;
}
.agent-catchphrase {
  font-size: 0.7em;
  color: #94a3b8;
  font-style: italic;
  padding: 2px 0 4px 22px;
  line-height: 1.3;
}
.agent-strengths, .profile-strengths {
  display: flex;
  gap: 4px;
  padding: 4px 0 2px 22px;
  flex-wrap: wrap;
}
.strength-tag {
  font-size: 0.6em;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Profile modal personality */
.profile-avatar { font-size: 1.6em; margin-right: 6px; }
.profile-title {
  font-size: 0.8em;
  color: #a78bfa;
  font-style: italic;
  margin-left: 6px;
}
.profile-catchphrase {
  font-size: 0.85em;
  color: #94a3b8;
  font-style: italic;
  padding: 4px 0 8px 0;
  text-align: center;
}

/* === Phase 1: Milestone Toasts === */
.milestone-toast {
  background: rgba(0, 0, 0, 0.92);
  border: 2px solid #f59e0b;
  border-radius: 10px;
  padding: 12px 24px;
  color: #fef3c7;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  min-width: 220px;
  max-width: 400px;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
  animation: milestoneSlideIn 0.4s ease-out;
}
.milestone-text { font-size: 15px; }
.milestone-sub {
  font-size: 11px;
  color: #d97706;
  font-weight: normal;
  margin-top: 4px;
}
@keyframes milestoneSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========================================
   Phase 2: Story & Drama Styles
   ======================================== */

/* Story Section */
.story-section {
  margin-bottom: 12px;
}

.story-stat-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.story-stat {
  font-size: 11px;
  color: #fbbf24;
}

.story-headlines {
  margin-bottom: 10px;
}

.story-headline {
  padding: 6px 10px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  border-left: 3px solid #fbbf24;
  color: #e5e7eb;
}

.story-timeline {
  max-height: 200px;
  overflow-y: auto;
}

.story-event {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.story-event-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.story-event-text {
  flex: 1;
  color: #d1d5db;
}

.story-event-time {
  color: #6b7280;
  font-size: 10px;
  flex-shrink: 0;
}

/* Comeback Alerts */
.comeback-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comeback-item {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(251, 191, 36, 0.1));
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
}

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

.comeback-challenger {
  font-weight: bold;
  color: #f87171;
  font-size: 13px;
}

.comeback-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #fbbf24;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
}

.comeback-detail {
  font-size: 11px;
  color: #9ca3af;
}

.comeback-time {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
}

.comeback-toast {
  border-left-color: #ef4444 !important;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(0, 0, 0, 0.9)) !important;
}

/* Rivalry Tracker */
.rivalry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rivalry-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.rivalry-names {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 6px;
}

.rivalry-vs {
  color: #6b7280;
  font-size: 10px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rivalry-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
  background: rgba(0, 0, 0, 0.3);
}

.rivalry-bar-fill {
  height: 100%;
  transition: width 1s ease;
}

.rivalry-scores {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #9ca3af;
}

.rivalry-gap {
  color: #6b7280;
  font-style: italic;
}

/* Lead History */
.lead-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lead-crown {
  font-size: 14px;
}

.lead-name {
  flex: 1;
  font-weight: bold;
  color: #fbbf24;
}

.lead-score {
  color: #9ca3af;
  font-size: 11px;
}

.lead-time {
  color: #6b7280;
  font-size: 10px;
}

/* === Phase 3: Building Tooltip === */
.building-tooltip {
  position: absolute;
  z-index: 100;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 40, 0.95));
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 140px;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 8px rgba(251, 191, 36, 0.15);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #e5e7eb;
  transition: opacity 0.15s ease;
}

.building-tooltip.hidden {
  display: none;
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 6px;
}

.tooltip-header #tooltip-icon {
  font-size: 14px;
}

.tooltip-header #tooltip-name {
  color: #fbbf24;
  font-size: 9px;
  text-transform: capitalize;
}

.tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tooltip-label {
  color: #9ca3af;
}

.tooltip-row span:last-child {
  color: #d1d5db;
  text-align: right;
}

/* Mobile: tooltips appear on tap */
@media (max-width: 768px) {
  .building-tooltip {
    font-size: 7px;
    min-width: 120px;
    padding: 6px 10px;
  }
  .tooltip-header #tooltip-name {
    font-size: 8px;
  }
}

/* ── Thought Bubbles ── */
.thought-bubble {
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #93c5fd;
  position: relative;
  animation: thoughtFadeIn 0.5s ease-out;
}

.thought-bubble::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 8px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(59, 130, 246, 0.3);
}

.thought-emoji {
  font-size: 13px;
  margin-right: 2px;
}

.thought-text {
  font-style: italic;
  color: #bfdbfe;
}

@keyframes thoughtFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Thought feed in activity panel */
.thought-feed-item {
  padding: 4px 8px;
  border-left: 2px solid rgba(59, 130, 246, 0.4);
  margin: 3px 0;
  font-size: 11px;
  color: #93c5fd;
}

.thought-feed-agent {
  font-weight: bold;
  color: #60a5fa;
}

/* Mobile responsive thought bubbles */
@media (max-width: 768px) {
  .thought-bubble {
    font-size: 10px;
    padding: 4px 8px;
  }
  .thought-emoji {
    font-size: 11px;
  }
}

/* Tier badges for diminishing returns scoring */
.tier-badge {
  display: inline-block;
  font-size: 0.6em;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 4px;
}
.tier-newcomer { background: #374151; color: #9ca3af; }
.tier-settler { background: #1e3a5f; color: #60a5fa; }
.tier-tycoon { background: #4a2d0a; color: #fbbf24; }
.tier-mogul { background: #3b0764; color: #c084fc; }

/* ============================================
   Mobile Responsive — Phase 1-2 Features
   ============================================ */
@media (max-width: 768px) {
  /* Score delta indicators */
  .score-delta {
    font-size: 9px;
    padding: 1px 3px;
  }
  .score-delta.positive { color: #22c55e; }
  .score-delta.negative { color: #ef4444; }

  /* Sparklines — smaller on mobile */
  .sparkline-container {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
  }
  .sparkline-container svg {
    width: 48px;
    height: 14px;
  }

  /* Personality cards — stacked layout on mobile */
  .personality-card {
    flex-direction: column;
    padding: 6px 8px;
    gap: 4px;
  }
  .personality-card .emoji {
    font-size: 20px;
  }
  .personality-card .title {
    font-size: 9px;
  }
  .personality-card .catchphrase {
    font-size: 8px;
    display: none; /* Hide catchphrase on mobile to save space */
  }
  .personality-card .strengths {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
  }
  .personality-card .strength-tag {
    font-size: 7px;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
  }

  /* Milestone toasts — full width on mobile */
  .milestone-toast {
    position: fixed;
    top: 44px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 200;
    text-align: center;
  }

  /* Comeback alert toasts */
  .comeback-toast {
    position: fixed;
    bottom: 52px;
    left: 8px;
    right: 8px;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    z-index: 190;
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    color: white;
    animation: slideUp 0.4s ease;
  }

  /* Story tab — full-width on mobile */
  .story-container {
    padding: 8px;
  }
  .story-container .recap-headline {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .story-container .recap-event {
    font-size: 10px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  .story-container .recap-time {
    font-size: 8px;
    color: #6b7280;
    margin-right: 6px;
  }

  /* Rivalry tracker — compact bars */
  .rivalry-pair {
    padding: 4px 8px;
    margin-bottom: 4px;
  }
  .rivalry-pair .names {
    font-size: 9px;
    display: flex;
    justify-content: space-between;
  }
  .rivalry-pair .bar-container {
    height: 6px;
    border-radius: 3px;
    background: #1f2937;
    overflow: hidden;
    margin-top: 2px;
  }
  .rivalry-pair .bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
  }
  .rivalry-pair .gap-sparkline svg {
    width: 40px;
    height: 10px;
  }
  .rivalry-pair .lead-changes {
    font-size: 8px;
    color: #9ca3af;
  }

  /* Leadership history — compact timeline */
  .leadership-history {
    padding: 4px 8px;
  }
  .leadership-entry {
    font-size: 9px;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .leadership-entry .crown { font-size: 10px; }
  .leadership-entry .name { font-weight: 600; }
  .leadership-entry .duration {
    font-size: 8px;
    color: #6b7280;
    margin-left: auto;
  }
}

/* Mobile touch targets — ensure tappable elements are ≥44px */
@media (max-width: 768px) {
  .tab-btn, .nav-btn, .drawer-handle {
    min-height: 44px;
    min-width: 44px;
  }
  /* Tap-to-show tooltips (touch devices lack hover) */
  .building-tooltip.tap-active {
    display: block !important;
    pointer-events: auto;
  }
}

/* Slide-up animation for mobile toasts */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === Share Card Button === */
.share-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #e2e8f0;
  border: 1px solid rgba(124,58,237,0.5);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  transition: all 0.2s;
}
.share-card-btn:hover {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,58,237,0.4);
}
.share-card-btn:active {
  transform: translateY(0);
}

/* === Activity Sub-Tabs === */
.sub-tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 6px;
  background: rgba(15,23,42,0.4);
  border-radius: 6px;
}
.sub-tab-btn {
  flex: 1;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}
.sub-tab-btn.active {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.3);
  color: #60a5fa;
}
.sub-tab-btn:hover:not(.active) {
  background: rgba(148,163,184,0.1);
  color: #e2e8f0;
}
.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

/* === Journal Agent Selector === */
.journal-agent-select {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.journal-agent-select select {
  flex: 1;
  padding: 6px 8px;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(148,163,184,0.2);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
}
.wood-btn.small {
  padding: 4px 10px;
  font-size: 10px;
}

/* === Share Card in Leaderboard === */
.leaderboard-share {
  display: inline-block;
  margin-left: 8px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 14px;
}
.leaderboard-share:hover {
  opacity: 1;
}

@media (max-width: 768px) {
  .share-card-btn {
    font-size: 9px;
    padding: 4px 8px;
  }

}
/* === FINAL SIDEBAR FIX (cleaned up) === */
#main {
  display: flex !important;
  height: calc(100vh - 52px) !important;
  overflow: hidden !important;
}

#info-panel {
  flex: 0 0 320px !important;
  width: 320px !important;
  display: flex !important;
  flex-direction: column !important;
  height: calc(100vh - 52px) !important;
  max-height: calc(100vh - 52px) !important;
  overflow: hidden !important;
}

#tab-bar {
  flex-shrink: 0 !important;
}

.tab-content {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.tab-content.active {
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

/* === FIX: Tab bar overflow === */
#tab-bar {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  max-height: 40px !important;
  min-height: 40px !important;
  flex-shrink: 0 !important;
}

.tab-btn {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* === FIX: Force tab-bar to 40px with clip === */
#tab-bar {
  height: 40px !important;
  max-height: 40px !important;
  min-height: 40px !important;
  overflow: hidden !important;
}
