/* Warbarons Game UI Styles */
/* Fantasy/Strategy game aesthetic */

:root {
  /* Color palette — old Warbarons parchment theme */
  --bg-dark: #c4a46a;
  --bg-medium: #d4b87a;
  --bg-light: #e0ca96;
  --bg-panel: rgba(0, 0, 0, 0.12);

  --accent-gold: #8a6c2f;
  --accent-gold-light: #a67c1a;
  --accent-blue: #2e5fa1;
  --accent-green: #3a7a2e;
  --accent-red: #9a2a1a;

  --text-primary: #3f320c;
  --text-secondary: #6b5530;
  --text-muted: #746444;

  --border-color: #b39e71;
  --border-gold: #8a7649;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

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

/* Prevent accidental text selection across the game UI */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/* Re-enable selection for text inputs, textareas, chat, and code/pre blocks */
input, textarea, [contenteditable="true"],
.chat-messages, .chat-input, .game-chat-messages, .game-chat-input,
.forum-post-content, .message-content, pre, code {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

html, body {
  height: 100%;
  font-family: Arial, Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  background-color: #2a1a08;
  color: #3f320c;
  text-shadow: 1px 1px 1px #f1e4c8;
  overflow: hidden;
  font-weight: 600;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Loading screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #2a1a08;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loading-screen.hidden {
  display: none;
}

.loading-content {
  text-align: center;
  width: 300px;
}

.loading-logo {
  font-size: 2.8rem;
  font-weight: bold;
  color: #d4a030;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
  margin-bottom: var(--spacing-xl);
  letter-spacing: 2px;
}

.loading-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #5a4a2a;
  margin-bottom: var(--spacing-md);
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a67c1a 0%, #d4a030 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-status {
  color: #b39e71;
  font-size: 0.9rem;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #2a1a08;
  background-image: url('/interface4/main_back.png');
}

/* Top bar */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-lg);
  background-image: url('/interface4/main_background.png');
  background-color: #c4a46a;
  border-bottom: 2px solid #8a7649;
  border-top: 1px solid #f5e2b8;
  height: 48px;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#top-bar.hidden {
  display: none;
}

/* Site footer — appended inside scene scroll area */
.site-footer {
  text-align: center;
  padding: 10px;
  margin-top: 20px;
  font-size: 11px;
  color: #8a7649;
  border-top: 1px solid #c4a46a;
  background-image: url('/interface4/main_background.png');
  background-color: #d4b87a;
  flex-shrink: 0;
}

.site-footer a {
  color: #6b4c20;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer .footer-sep {
  margin: 0 8px;
  opacity: 0.5;
}

.top-bar-left .logo {
  font-size: 1.3rem;
  font-weight: bold;
  color: #5a3a0a;
  text-shadow: 1px 1px 0px #f5e2b8;
  letter-spacing: 2px;
}

.top-bar-center {
  display: flex;
  gap: var(--spacing-sm);
}

#main-nav {
  display: flex;
  gap: var(--spacing-xs);
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #6b5530;
  padding: var(--spacing-xs) var(--spacing-md);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: var(--transition-fast);
  border-radius: 3px;
}

.nav-btn:hover {
  color: #3f320c;
  background: rgba(255, 255, 255, 0.25);
  border-color: #b39e71;
}

.nav-btn.active {
  color: #3a1e00;
  border-color: #8a7649;
  background: rgba(255, 255, 255, 0.3);
  border-bottom: 2px solid #6b4510;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

#user-info {
  color: #5a3a0a;
  font-weight: bold;
}

/* Scene container */
#scene-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Scene transitions */
.scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.scene.active {
  opacity: 1;
  transform: scale(1);
}

.scene.exiting {
  opacity: 0;
  transform: scale(1.02);
}

/* Map Editor Scene - override flex layout like game view */
#scene-map-editor {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  border: 1px solid #8a7649;
  background: linear-gradient(180deg, #f5e2b8 0%, #d9c48e 100%);
  color: #3f320c;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition-fast);
  border-radius: 3px;
  min-width: 80px;
  text-shadow: 0px 1px 0px #f5e2b8;
}

.btn:hover {
  background: linear-gradient(180deg, #fffce7 0%, #e8d5a8 100%);
  border-color: #6b4510;
  color: #3a1e00;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #d4a030 0%, #a67c1a 100%);
  color: #fff;
  border-color: #8a6c2f;
  text-shadow: 0px 1px 1px rgba(0,0,0,0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #e0b040 0%, #c09030 100%);
  color: #fff;
}

.btn-success {
  background: linear-gradient(180deg, #5a9a3a 0%, #3a7a2e 100%);
  color: white;
  border-color: #4a8a34;
  text-shadow: 0px 1px 1px rgba(0,0,0,0.3);
}

.btn-success:hover {
  background: linear-gradient(180deg, #6aaa4a 0%, #5a9a3a 100%);
  color: white;
}

.btn-small {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.85rem;
  min-width: auto;
  border-width: 1px;
}

.btn-xs {
  padding: 1px 6px;
  font-size: 0.7rem;
  min-width: auto;
  border-width: 1px;
}

.btn-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: white;
}

/* Form elements */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: #fffce7;
  border: 1px solid #b39e71;
  border-top-color: #8a7649;
  border-left-color: #8a7649;
  border-radius: 3px;
  color: #3f320c;
  font-size: 13px;
  transition: var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: #6b4510;
  box-shadow: 0 0 0 2px rgba(138, 118, 73, 0.3);
}

.form-input::placeholder {
  color: #a09070;
}

/* Panels and cards */
.panel {
  
  background: radial-gradient(ellipse at center, rgba(250, 237, 186, 0.7) 50%, rgba(181, 145, 0, 0.175) 100%), 
  url(/interface4/main_background.png);
  background-color: #c4a46a;
  border: 0px solid transparent;
  border-image-source: url(/interface4/frame_new.png);
  border-image-slice: 120;          /* px into the source image for corners/edges */
  border-image-width: 60px;         /* rendered border width on screen */
  border-image-outset: 10px;        /* push frame outward past the div edge */
  border-image-repeat: round;     /* stretch edges to fill, no tiling */
  image-rendering: auto;     /* disable smoothing/interpolation */
  box-shadow: none;
  padding: var(--spacing-lg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}


.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid #b39e71;
  margin-bottom: var(--spacing-md);
}

.panel-title {
  font-size: 14px;
  color: #3a1e00;
  font-weight: bold;
}

.card {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #b39e71;
  border-radius: 4px;
  padding: var(--spacing-md);
  transition: var(--transition-fast);
}

.card:hover {
  background: rgba(255, 255, 255, 0.35);
  border-color: #8a7649;
}

.card-clickable {
  cursor: pointer;
}

/* Main Menu Scene */
.main-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: var(--spacing-xl);
}

.main-menu-container {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.main-menu-title {
  font-size: 2.5rem;
  color: #d4a030;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
  margin-bottom: var(--spacing-xl);
  letter-spacing: 4px;
}

.main-menu-subtitle {
  color: #b39e71;
  margin-bottom: var(--spacing-xl);
  font-style: italic;
}

.auth-forms {
  background-image: url('/interface4/main_background.png');
  background-color: #c4a46a;
  border: 2px solid #8a7649;
  border-radius: 5px;
  padding: var(--spacing-xl);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.auth-tabs {
  display: flex;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-lg);
}

.auth-tab {
  flex: 1;
  padding: var(--spacing-sm);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8a7a5a;
  cursor: pointer;
  font-weight: bold;
  transition: var(--transition-fast);
}

.auth-tab:hover {
  color: #3f320c;
}

.auth-tab.active {
  color: #3a1e00;
  border-bottom-color: #6b4510;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form .btn {
  width: 100%;
  margin-top: var(--spacing-md);
}

.auth-error {
  color: var(--accent-red);
  font-size: 0.9rem;
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: rgba(231, 76, 60, 0.1);
  border-radius: 4px;
  display: none;
}

.auth-error.visible {
  display: block;
}

/* Lobby Hub Scene */
.lobby-hub {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.lobby-main {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.lobby-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.lobby-list {
  flex: 1;
  overflow-y: auto;
}

/* Lobby list row layout */
.lobby-item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 50px 70px 90px 50px 70px;
  gap: var(--spacing-sm);
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: var(--spacing-xs);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lobby-item-row:hover {
  background: var(--bg-light);
}

.lobby-item-row.lobby-locked {
  border-left: 3px solid var(--accent-gold);
}

.lobby-col-names {
  overflow: hidden;
}

.lobby-gamename {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-mapname {
  font-size: 13px;
  font-weight: bold;
  color: var(--accent-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-col-map {
  display: flex;
  justify-content: center;
}

.lobby-map-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-dark);
}

.lobby-col-players {
  text-align: center;
}

.lobby-player-count {
  font-size: 15px;
  font-weight: bold;
  color: var(--text-primary);
}

.lobby-gamemode {
  margin-top: 2px;
}

.gamemode-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 3px;
  text-transform: uppercase;
  text-shadow: none;
}

.gamemode-badge.ffa {
  background: #2d5a27;
  color: #8fbc8f;
}

.gamemode-badge.one-v-one {
  background: #5a3d27;
  color: #deb887;
}

.gamemode-badge.team {
  background: #27415a;
  color: #87ceeb;
}

.lobby-col-features {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.lobby-icon {
  font-size: 14px;
  cursor: help;
}

.lobby-col-days {
  text-align: center;
}

.lobby-days-value {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
}

.lobby-days-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.lobby-col-join {
  display: flex;
  justify-content: center;
}

.lobby-actions {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-panel);
  border-radius: 8px;
}

/* Game list */
.game-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.game-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-item-name {
  font-weight: 500;
}

.game-item-status {
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.game-item-status.your-turn {
  background: var(--accent-green);
  color: white;
  text-shadow: 0 0 0 black;
}

.game-item-status.waiting {
  background: var(--text-muted);
  color: var(--text-primary);
}

/* Notifications */
#notifications {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  z-index: 1000;
}

.notification {
  padding: var(--spacing-md) var(--spacing-lg);
  background-image: url('/interface4/main_background.png');
  background-color: #c4a46a;
  border: 1px solid #8a7649;
  border-radius: 4px;
  animation: slideIn var(--transition-normal);
  max-width: 300px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.notification.success {
  border-color: var(--accent-green);
}

.notification.error {
  border-color: var(--accent-red);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* XP toast - brief floating notification after battle */
.xp-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #ffd700;
  font-size: 18px;
  font-weight: bold;
  padding: 12px 24px;
  border-radius: 8px;
  border: 2px solid #ffd700;
  z-index: 10000;
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.xp-toast-fade {
  opacity: 0;
}

/* ========================
   Warpedia (Wiki) Layout
   ======================== */
.wiki-layout {
  display: flex;
  height: 460px;
  max-height: 460px;
}

.wiki-sidebar {
  width: 180px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #8a7649;
  padding: 4px 0;
}

.wiki-index-item {
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #5a3a0a;
}

.wiki-index-item:hover {
  background: rgba(138, 118, 73, 0.2);
}

.wiki-index-item.wiki-index-active {
  background: rgba(138, 118, 73, 0.35);
  font-weight: bold;
}

.wiki-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #3a2a10;
}

.wiki-content h2, .wiki-content h3 {
  color: #5a3a0a;
  margin: 12px 0 6px 0;
}

.wiki-content img {
  max-width: 100%;
}

.wiki-unit-card {
  border: 1px solid #c4a46a;
  padding: 10px;
  margin: 8px 0;
  background: rgba(255,255,255,0.15);
}

.wiki-unit-card h3 {
  margin: 0 0 6px 0;
  font-size: 15px;
}

.wiki-unit-stats {
  border-collapse: collapse;
}

.wiki-unit-stats td {
  padding: 1px 2px;
}

.wiki-item-card {
  border: 1px solid #c4a46a;
  padding: 10px;
  margin: 8px 0;
  background: rgba(255,255,255,0.15);
}

/* Warpedia standalone page (community section) */
.warpedia-page {
  display: flex;
  height: 100%;
}

.warpedia-sidebar {
  width: 200px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #8a7649;
  background-image: url('/interface4/main_background.png');
  background-color: #d4b87a;
  padding: 8px 0;
}

.warpedia-nav-item {
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #5a3a0a;
}

.warpedia-nav-item:hover {
  background: rgba(138, 118, 73, 0.25);
}

.warpedia-nav-item.warpedia-nav-active {
  background: rgba(138, 118, 73, 0.4);
  font-weight: bold;
}

.warpedia-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  font-size: 14px;
  line-height: 1.7;
  color: #3a2a10;
  background: radial-gradient(ellipse at center, rgba(250, 237, 186, 0.7) 50%, rgba(181, 145, 0, 0.175) 100%),
    url(/interface4/main_background.png);
  background-color: #c4a46a;
}

.warpedia-content h2, .warpedia-content h3 {
  color: #5a3a0a;
  margin: 14px 0 8px 0;
}

.warpedia-content img {
  max-width: 100%;
}

/* ========================
   City Overview Popup
   ======================== */
.city-overview-layout {
  display: flex;
  height: 460px;
}

.city-overview-minimap {
  width: 310px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  overflow: hidden;
}

.city-overview-minimap canvas {
  border: 1px solid #8a7649;
  max-width: 300px;
  max-height: 400px;
  object-fit: contain;
  position: relative;
  z-index: 10;
  cursor: pointer;
}

.city-overview-bank {
  margin-top: 8px;
  font-weight: bold;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.city-overview-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.city-overview-row {
  border: 1px solid #c4a46a;
  background: rgba(255,255,255,0.1);
  margin: 0 0 4px 0;
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
}

.city-overview-row:hover {
  background: rgba(138, 118, 73, 0.2);
}

.city-overview-row table {
  width: 100%;
  border-collapse: collapse;
}

.city-overview-row td {
  padding: 1px 3px;
  vertical-align: top;
}

.city-overview-prod-selected {
  outline: 2px solid #5a3a0a;
}

/* City overview sprite buttons from miscpanels.png */
div.cancelvector_small        { width:13px; height:12px; background: url('/interface4/miscpanels.png') -613px -129px; float:left; cursor:pointer; margin-right:5px; }
div.cancelvector_small:hover  { width:13px; height:12px; background: url('/interface4/miscpanels.png') -628px -129px; float:left; cursor:pointer; margin-right:5px; }
div.setvector_small1          { width:33px; height:12px; background: url('/interface4/miscpanels.png') -577px -144px; float:left; cursor:pointer; }
div.setvector_small2          { width:33px; height:12px; background: url('/interface4/miscpanels.png') -577px -129px; float:left; cursor:pointer; }
div.movevector_small1         { width:33px; height:12px; background: url('/interface4/miscpanels.png') -614px -144px; float:left; cursor:pointer; }
div.movevector_small2         { width:33px; height:12px; background: url('/interface4/miscpanels.png') -614px -158px; float:left; cursor:pointer; }
div.buywall_small             { width:11px; height:12px; background: url('/interface4/miscpanels.png') -578px -159px; float:left; margin-right:4px; cursor:pointer; }
div.buywall_small:hover       { width:11px; height:12px; background: url('/interface4/miscpanels.png') -592px -159px; float:left; margin-right:4px; cursor:pointer; }
div.sellwall_small            { width:11px; height:12px; background: url('/interface4/miscpanels.png') -578px -174px; float:left; margin-right:4px; cursor:pointer; }
div.sellwall_small:hover      { width:11px; height:12px; background: url('/interface4/miscpanels.png') -592px -174px; float:left; margin-right:4px; cursor:pointer; }
div.gotocity_small            { width:12px; height:18px; background: url('/interface4/miscpanels.png') -313px -5px; float:left; margin-left:4px; cursor:pointer; }
div.gotocity_small:hover      { width:12px; height:18px; background: url('/interface4/miscpanels.png') -296px -5px; float:left; margin-left:4px; cursor:pointer; }

/* ========================
   Diplomacy Popup
   ======================== */
.diplomacy-layout {
  display: flex;
  height: 460px;
}

.diplomacy-minimap {
  width: 310px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
}

.diplomacy-minimap canvas {
  border: 1px solid #8a7649;
  max-width: 300px;
  max-height: 400px;
}

.diplomacy-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.diplomacy-section {
  border: solid 1px #8a7649;
  margin-bottom: 8px;
}

.diplomacy-section-header {
  font-weight: bold;
  font-size: 12px;
  padding: 5px 8px;
  background-color: #d6b25f;
  display: flex;
  align-items: center;
  gap: 6px;
}

.diplomacy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  background-color: #d6b25f;
  border-spacing: 1px;
}

.diplomacy-table td {
  padding: 3px 6px;
  vertical-align: middle;
  background-color: #f2d593;
  border: 1px solid #d6b25f;
}

.diplomacy-header-row td {
  background-color: #e5c374;
  padding: 3px 6px;
  font-size: 11px;
  text-align: center;
}

.diplomacy-table select {
  font-size: 11px;
  padding: 2px;
  background: #f6dca4;
  border: 1px solid #8a7649;
  color: #3a1e00;
}

/* Diplomacy icons */
.diplomacy-icon { background: url('/interface4/miscpanels.png') -253px -1px; width: 25px; height: 25px; flex-shrink: 0; }
.accept { background: url('/interface4/miscpanels.png') -204px -1px; width: 25px; height: 25px; float: left; cursor: pointer; }
.deny { background: url('/interface4/miscpanels.png') -146px -1px; width: 25px; height: 25px; float: left; cursor: pointer; }

/* Replay minimap */
.replay-minimap {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
  border-left: 2px solid #8a7649;
  border-bottom: 2px solid #8a7649;
  cursor: pointer;
  image-rendering: pixelated;
  background: #1a3070;
}

/* Lobby badges — matching game-lobby-type style */
.lobby-badge {
  display: inline-block;
  background: var(--bg-light);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 10px;
}

@keyframes turnToastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

.turn-toast:hover {
  background: linear-gradient(135deg, #4a3a20, #6a4d2a) !important;
  border-color: #a8820f !important;
}

.turn-toast-icon {
  margin-right: 6px;
}

/* Modal */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#modal-overlay.hidden {
  display: none;
}

#modal-content {
  background-image: url('/interface4/main_background.png');
  background-color: #c4a46a;
  border: 2px solid #8a7649;
  border-radius: 5px;
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay .modal-content {
  background-image: url('/interface4/main_background.png');
  background-color: #c4a46a;
  border: 2px solid #8a7649;
  border-radius: 5px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Utility classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-gold {
  color: var(--accent-gold);
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--accent-green);
}

.text-danger {
  color: var(--accent-red);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

/* ============================================
   COMMUNITY FEATURES STYLES
   ============================================ */

/* User nav icons */
#user-nav {
  display: flex;
  gap: var(--spacing-xs);
  margin-right: var(--spacing-md);
}

.nav-btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.nav-btn-icon:hover {
  color: var(--accent-gold);
}

.nav-btn-icon .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-red);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Messages Scene */
.messages-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--spacing-md);
  height: 100%;
  padding: var(--spacing-md);
}

.messages-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.messages-tabs {
  display: flex;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.tab-btn {
  flex: 1;
  padding: var(--spacing-sm);
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn.active {
  background: var(--accent-gold);
  color: var(--bg-dark);
  border-color: var(--accent-gold);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
}

.message-item {
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
}

.message-item:hover {
  background: var(--bg-light);
}

.message-item.unread {
  background: rgba(74, 144, 217, 0.1);
  border-left: 3px solid var(--accent-blue);
}

.message-item.selected {
  background: var(--bg-light);
  border-left: 3px solid var(--accent-gold);
}

.message-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
}

.message-from {
  font-weight: bold;
  color: var(--text-primary);
}

.message-time {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.message-subject {
  color: var(--text-secondary);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
}

.message-view {
  padding: var(--spacing-md);
  height: 100%;
  overflow-y: auto;
}

.message-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.message-title {
  font-size: 1.2rem;
  margin-bottom: var(--spacing-sm);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.message-body {
  line-height: 1.6;
  margin-bottom: var(--spacing-md);
}

.message-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.autocomplete-suggestions {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 100;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-light);
}

.message-replies {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.reply-item {
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.reply-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
}

/* Friends Scene */
.friends-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--spacing-md);
  height: 100%;
  padding: var(--spacing-md);
  min-width: 1024px;
  max-width: 1200px;
  margin: 0 auto;
}

.friends-list {
  overflow-y: auto;
}

.friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.friend-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--accent-green);
}

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

.friend-name {
  font-weight: bold;
}

.friend-country {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.friend-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.request-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.search-results {
  margin-top: var(--spacing-sm);
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

/* Chat Scene */
.chat-container {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: var(--spacing-md);
  height: 100%;
  padding: var(--spacing-md);
  min-width: 1024px;
  max-width: 1200px;
  margin: 0 auto;
}

.chat-main .panel {
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.chat-message {
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.chat-message.own {
  background: rgba(74, 144, 217, 0.1);
  border-radius: 4px;
}

.chat-username {
  color: var(--accent-gold);
  font-weight: bold;
  margin-right: var(--spacing-sm);
}

.chat-text {
  color: var(--text-primary);
}

.chat-time {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: var(--spacing-sm);
}

.chat-input-area {
  display: flex;
  gap: var(--spacing-sm);
  padding-top: var(--spacing-sm);
}

.chat-input-area input {
  flex: 1;
}

/* Teams Scene */
.teams-container {
  height: 100%;
  padding: var(--spacing-md);
  max-width: 1200px;
  margin: 0 auto;
}

#teams-list-view,
#teams-detail-view {
  min-width: 1024px;
}

.teams-list {
  overflow-y: auto;
}

.team-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
}

.team-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.team-tag {
  font-weight: bold;
  font-size: 0.85rem;
}

.team-name {
  font-weight: bold;
}

.team-members-count {
  color: var(--text-muted);
}

/* Team detail layout — members left, info+wall right */
.team-detail-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--spacing-md);
}

.team-detail-left {
  min-width: 0;
}

.team-detail-right {
  min-width: 0;
}

/* Team info panel */
.team-message {
  font-style: italic;
  padding: var(--spacing-sm) var(--spacing-md);
}

.team-info-stats {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 12px;
  color: var(--text-muted);
}

.team-actions {
  display: flex;
  gap: 8px;
  padding: var(--spacing-sm) var(--spacing-md);
}

/* Members table */
.team-members-table {
  width: 100%;
}

.team-member-row {
  padding: 6px var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.team-member-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-member-line2 {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 26px;
  padding-top: 2px;
}

.team-member-line3 {
  display: flex;
  gap: 4px;
  padding-left: 26px;
  padding-top: 3px;
}

.team-member-leader-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.team-member-name {
  flex: 1;
  font-weight: bold;
  min-width: 0;
}

.team-member-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Join requests */
.team-requests-section {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
}

.team-requests-section h3 {
  padding: 0 var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.team-request-row {
  display: flex;
  align-items: center;
  padding: 6px var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}

.team-request-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* Back button */
.team-back-btn {
  cursor: pointer;
  margin-bottom: var(--spacing-sm);
  color: var(--accent-blue);
  font-weight: bold;
}

.team-back-btn:hover {
  text-decoration: underline;
}

/* Settings form (leader panel below members) */
.team-settings-form {
  padding: var(--spacing-sm) 0;
}

.team-settings-form .form-group {
  margin-bottom: 8px;
}

/* Tournaments Scene */
.tournaments-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: var(--spacing-md);
  height: 100%;
  padding: var(--spacing-md);
}

.tournament-filters {
  display: flex;
  gap: var(--spacing-xs);
}

.filter-btn {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}

.filter-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.tournaments-list {
  overflow-y: auto;
}

.tournament-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
}

.tournament-name {
  font-weight: bold;
  margin-bottom: var(--spacing-xs);
}

.tournament-meta {
  display: flex;
  gap: var(--spacing-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tournament-type {
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.tournament-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.status-open { background: var(--accent-green); color: white; }
.status-active { background: var(--accent-blue); color: white; }
.status-complete { background: var(--text-muted); color: white; }

.tournament-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.info-value {
  font-weight: bold;
}

.tournament-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.player-tag {
  background: var(--bg-light);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.tournament-activity {
  margin-top: var(--spacing-md);
}

.activity-item {
  padding: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.activity-type {
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: var(--spacing-sm);
  font-size: 0.8rem;
}

/* Tournament Detail / Bracket View */
.tournament-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--spacing-md);
  grid-column: 1 / -1; /* span full width when inside tournament grid */
}

.tournament-detail-header {
  flex-shrink: 0;
  margin-bottom: var(--spacing-sm);
}

.tournament-back-link {
  display: inline-block;
  color: var(--accent-blue);
  cursor: pointer;
  margin-bottom: var(--spacing-sm);
  font-size: 0.9rem;
}

.tournament-back-link:hover {
  text-decoration: underline;
}

.tournament-detail-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.tournament-detail-title h2 {
  margin: 0;
  font-size: 1.3rem;
}

.tournament-info-bar {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tournament-info-bar span {
  white-space: nowrap;
}

/* Panel wrapper for bracket area */
.bracket-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Bracket viewport — drag-pannable area */
.bracket-viewport {
  flex: 1 1 0;
  overflow: hidden;
  cursor: grab;
  position: relative;
  min-height: 0;
  user-select: none;
}

.bracket-viewport.dragging {
  cursor: grabbing;
}

/* Prevent native image drag inside brackets */
.bracket-viewport img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

.bracket-content {
  display: flex;
  gap: 40px;
  position: relative;
  min-width: fit-content;
  padding: var(--spacing-lg);
}

.bracket-section-label {
  font-size: 1rem;
  font-weight: bold;
  padding: var(--spacing-sm) var(--spacing-lg);
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-gold);
  margin-bottom: var(--spacing-sm);
  background: var(--bg-medium);
}

.bracket-round {
  display: flex;
  flex-direction: column;
  min-width: 190px;
  flex-shrink: 0;
}

.bracket-round-header {
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
  white-space: nowrap;
}

.bracket-round-map {
  text-align: center;
  margin-bottom: var(--spacing-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bracket-round-minimap {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  image-rendering: pixelated;
}

.bracket-round-map-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.bracket-round-map-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

.bracket-match {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: var(--spacing-sm);
  overflow: hidden;
}

.bracket-entry {
  padding: 4px 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  min-height: 24px;
}

.bracket-entry:first-child {
  border-bottom: 1px solid var(--border-color);
}

.bracket-entry.winner {
  color: var(--accent-gold);
  font-weight: bold;
}

.bracket-entry.loser {
  opacity: 0.5;
}

.bracket-entry.playing {
  background: rgba(46, 95, 161, 0.1);
}

.bracket-entry.placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.bracket-entry-name {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bracket-entry-name .flag {
  flex-shrink: 0;
}

/* Vertical player list for team games */
.bracket-entry-players {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bracket-player-line {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  font-size: 0.8rem;
  line-height: 1.3;
}

.bracket-player-line .flag {
  flex-shrink: 0;
}

/* Team abbreviation badge */
.bracket-team-abbr {
  font-size: 0.7rem;
  font-weight: bold;
  flex-shrink: 0;
  margin-right: 1px;
}


.bracket-connector-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Double elimination separator */
.bracket-separator {
  width: 100%;
  border-top: 2px solid var(--border-gold);
  margin: var(--spacing-md) 0;
}

/* Single entry in final (bye / champion) */
.bracket-champion {
  background: var(--bg-light);
  border: 2px solid var(--accent-gold);
  border-radius: 4px;
  padding: 6px 10px;
  font-weight: bold;
  color: var(--accent-gold);
  text-align: center;
}

/* Leaderboard Scene */
.leaderboard-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--spacing-md);
  height: 100%;
  padding: var(--spacing-md);
  max-width: 1200px;
  margin: 0 auto;
}

.leaderboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.leaderboard-filters .filter-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: var(--spacing-xs) var(--spacing-sm);
}

.leaderboard-filters .radio-label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.leaderboard-filters .radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.leaderboard-table {
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-medium);
  color: var(--text-muted);
  font-weight: normal;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.data-table tr:hover {
  background: var(--bg-light);
}

.data-table tr.highlight {
  background: rgba(201, 162, 39, 0.1);
}

.rank-cell {
  font-weight: bold;
  color: var(--accent-gold);
}

.data-table .col-rank { width: 55px; }
.data-table .col-narrow { width: 55px; }
.data-table .col-rating { width: 70px; }
.data-table .col-alliance { width: 120px; }

.rating-cell {
  font-weight: bold;
}

.wins-cell {
  color: var(--accent-green);
}

.losses-cell {
  color: var(--accent-red);
}

.streak-cell.positive {
  color: var(--accent-green);
}

.streak-cell.negative {
  color: var(--accent-red);
}

.player-link {
  color: var(--accent-blue);
  cursor: pointer;
}

.player-link:hover {
  text-decoration: underline;
}

.country-flag {
  margin-left: var(--spacing-xs);
  font-size: 0.9rem;
}

.top-section {
  margin-bottom: var(--spacing-md);
}

.top-section h4 {
  color: var(--text-muted);
  margin-bottom: var(--spacing-sm);
}

.top-player-item {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--border-color);
}

.top-rank {
  color: var(--accent-gold);
  font-weight: bold;
  width: 30px;
}

.my-ranking-grid {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm);
  background: var(--bg-medium);
  border-radius: 4px;
}

.ranking-type {
  font-weight: bold;
}

.ranking-position {
  color: var(--accent-gold);
  font-size: 1.2rem;
}

.ranking-rating {
  color: var(--text-muted);
}

/* Previous Seasons */
.season-list {
  max-height: 300px;
  overflow-y: auto;
}

.season-item {
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--accent-blue);
}

.season-item:hover {
  background: var(--bg-light);
  text-decoration: underline;
}

.season-type-filters {
  display: flex;
  gap: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.season-type-filters .radio-label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.season-type-filters .radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.stats-table {
  width: 100%;
  margin-top: var(--spacing-sm);
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: var(--spacing-xs) var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.stats-table th {
  color: var(--text-muted);
  font-weight: normal;
}

/* Game Card Styles */
.game-card {
  padding: var(--spacing-md);
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-sm);
}

.game-info .game-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.game-info .game-meta {
  font-size: 0.85rem;
}

.game-item-status {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
}

.game-item-status.your-turn {
  background: var(--accent-green);
  color: white;
  animation: pulse 2s infinite;
}

.game-item-status.waiting {
  background: var(--bg-light);
  color: var(--text-muted);
}

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

.game-card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

/* Player Shields */
.player-shields {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.player-shield {
  width: 28px;
  height: 32px;
  background: var(--player-color, #666);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform var(--transition-fast);
}

.player-shield.is-me {
  border: 2px solid var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.player-shield.has-turn {
  animation: turnPulse 1.5s infinite;
}


@keyframes turnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.player-shield .turn-indicator {
  position: absolute;
  top: -8px;
  font-size: 10px;
  color: var(--accent-gold);
}

.player-shield .me-indicator {
  font-size: 10px;
  color: white;
  text-shadow: 0 0 2px black;
}

.player-shield .skull-indicator {
  font-size: 14px;
}

.player-shield.eliminated {
  opacity: 0.6;
  filter: grayscale(0.8);
}

/* Timer and Missed Turns */
.game-timer-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.time-left {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: bold;
}

.time-left.urgent {
  color: var(--accent-red);
}

.time-left.expired {
  color: var(--accent-red);
  font-weight: bold;
}

.missed-turns {
  display: flex;
  gap: 2px;
}

.miss-dot {
  font-size: 12px;
  color: var(--text-muted);
}

.miss-dot.missed {
  color: var(--accent-red);
}

.game-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
}

/* Game View Scene - Replicating original layout */
.game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-dark);
}

.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border-gold);
  height: 40px;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.btn-game {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 12px;
  cursor: pointer;
  border-radius: 3px;
}

.btn-game:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
}

.game-title-text {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent-gold);
}

#turn-info {
  font-size: 1rem;
  color: var(--text-primary);
}

#gold-display {
  color: var(--accent-gold);
  font-weight: bold;
}

#timer-display {
  color: var(--text-secondary);
}

#timer-display.expired {
  color: var(--accent-red);
}

.game-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Panel - Quick Buttons */
.panel-left {
  width: 48px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: var(--spacing-xs);
  gap: var(--spacing-xs);
}

.side-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
}

.side-btn:hover {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* Map Viewport */
.map-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: #1a1a2e;
}

.map-viewport:active {
  cursor: grabbing;
}

.map-content {
  position: absolute;
  top: 0;
  left: 0;
}

.map-bigtile {
  image-rendering: pixelated;
}

/* Right Panel */
.panel-right {
  width: 220px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: var(--spacing-sm);
  gap: var(--spacing-sm);
}

/* Minimap */
.minimap-panel {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px;
}

.minimap-inner {
  position: relative;
}

.minimap-inner canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Magnifier defined in game-view section below */

/* Player Shields */
.shields-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: var(--spacing-xs);
  background: var(--bg-dark);
  border-radius: 4px;
}

.shields-panel .player-shield {
  width: 24px;
  height: 28px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  text-shadow: 1px 1px 1px black;
}

.shields-panel .player-shield.blue { background: #4a90d9; }
.shields-panel .player-shield.red { background: #e74c3c; }
.shields-panel .player-shield.green { background: #2ecc71; }
.shields-panel .player-shield.orange { background: #f39c12; }
.shields-panel .player-shield.purple { background: #9b59b6; }
.shields-panel .player-shield.teal { background: #1abc9c; }
.shields-panel .player-shield.pink { background: #e91e63; }
.shields-panel .player-shield.brown { background: #795548; }
.shields-panel .player-shield.gray { background: #607d8b; }
.shields-panel .player-shield.neutral { background: #888; }

.shields-panel .player-shield.is-me {
  box-shadow: 0 0 6px var(--accent-gold);
}

.shields-panel .player-shield.has-turn {
  animation: shieldPulse 1s infinite;
}

.shields-panel .player-shield.eliminated {
  opacity: 0.5;
  filter: grayscale(1);
}

@keyframes shieldPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Unit Selection Slots */
.unit-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.unit-slot {
  aspect-ratio: 1;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.unit-slot:hover {
  border-color: var(--accent-gold);
}

.slot-number {
  font-size: 10px;
  color: var(--text-muted);
  position: absolute;
  bottom: 2px;
  right: 4px;
}

/* Group Area */
.group-area {
  min-height: 60px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.action-btn {
  padding: 8px 4px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.action-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
  border-color: var(--accent-gold);
}

.action-btn.primary {
  background: var(--accent-green);
  color: white;
  grid-column: span 2;
}

.action-btn.primary:hover {
  background: #3da047;
}

.action-btn.active {
  background: var(--accent-gold);
  color: var(--bg-dark);
  border-color: var(--accent-gold-light);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.5);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bottom Bar */
.game-bottombar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  height: 32px;
}

.tile-info, .unit-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Map Objects */
.map-city {
  position: absolute;
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.map-city::before {
  content: '';
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid rgba(0,0,0,0.5);
}

.map-city.player-0::before { background: #888; }
.map-city.player-1::before { background: #4a90d9; }
.map-city.player-2::before { background: #e74c3c; }
.map-city.player-3::before { background: #2ecc71; }
.map-city.player-4::before { background: #f39c12; }
.map-city.player-5::before { background: #9b59b6; }
.map-city.player-6::before { background: #1abc9c; }
.map-city.player-7::before { background: #e91e63; }
.map-city.player-8::before { background: #795548; }

.map-city.capital::before {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.city-label {
  position: absolute;
  bottom: -2px;
  font-size: 9px;
  color: white;
  text-shadow: 1px 1px 1px black;
  white-space: nowrap;
}

.city-income {
  position: absolute;
  top: 8px;
  font-size: 11px;
  font-weight: bold;
  color: var(--accent-gold);
  text-shadow: 1px 1px 1px black;
}

/* Map Units */
.map-unit {
  position: absolute;
  width: 64px;
  height: 64px;
  pointer-events: auto;
  cursor: pointer;
  background-repeat: no-repeat;
  z-index: 50;
}

/* Player color indicator ring */
.unit-player-indicator {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.5);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.map-unit.player-0 .unit-player-indicator { background: #888; }
.map-unit.player-1 .unit-player-indicator { background: #4a90d9; }
.map-unit.player-2 .unit-player-indicator { background: #e74c3c; }
.map-unit.player-3 .unit-player-indicator { background: #2ecc71; }
.map-unit.player-4 .unit-player-indicator { background: #f39c12; }
.map-unit.player-5 .unit-player-indicator { background: #9b59b6; }
.map-unit.player-6 .unit-player-indicator { background: #1abc9c; }
.map-unit.player-7 .unit-player-indicator { background: #e91e63; }
.map-unit.player-8 .unit-player-indicator { background: #795548; }

.unit-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 2;
}

/* Fallback unit icon (when sprite not available) */
.unit-type {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  z-index: 1;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* ============================================= */
/* GAME LOADING SCREEN                           */
/* ============================================= */

.game-loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a12;
  background-image: url('/interface4/main_back.png');
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.5s ease;
}

.game-loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.game-loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.game-loading-logo {
  max-width: 300px;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(0,0,0,0.8));
}

.game-loading-title {
  font-size: 36px;
  color: #f4e3c2;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8), 0 0 20px rgba(212,175,55,0.3);
  font-weight: bold;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.game-loading-bar-container {
  width: 320px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  border: 1px solid #392f1f;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.game-loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #8b6914, #d4af37, #f4d03f);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(212,175,55,0.4);
}

.game-loading-status {
  color: #a89060;
  font-size: 14px;
  letter-spacing: 1px;
}

.game-ui-container {
  display: contents;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.95);
  color: var(--text-primary);
  gap: var(--spacing-md);
  z-index: 100;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================
   Unit Selection System
   ======================== */

/* Selected unit wrapper */
div.selecteddiv {
  position: relative;
  width: 64px;
  height: 64px;
}

/* Selection indicators (from original interface) */
/* Unscoped rules for PixiJS TextureManager probe */
div.select2 {
  background: url('/interface4/miscpanels.png') -651px -128px;
  width: 64px;
  height: 64px;
}
div.select3 {
  background: url('/interface4/miscpanels.png') -256px -64px;
  width: 64px;
  height: 64px;
}
/* Scoped rules for DOM rendering */
.game-view-scene div.select2 {
  position: absolute;
  float: left;
  z-index: 1700;
  top: 0;
  left: 0;
}

.game-view-scene div.select3 {
  position: absolute;
  float: left;
  z-index: 1700;
  top: 0;
  left: 0;
}

/* Path counter indicators (movement path display) */
div.pathcounter {
  width: 64px;
  height: 64px;
  background: url('/interface4/basepopup.png') -64px -0px;
  font-size: 16px;
  color: #FFFFFF;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
  font-family: arial;
  font-weight: bold;
  cursor: default;
  position: absolute;
  z-index: 999;
  text-align: left;
  padding: 4px 0 0 6px;
  box-sizing: border-box;
  top: 0;
  left: 0;
}

div.pathcounter2 {
  width: 64px;
  height: 64px;
  background: url('/interface4/basepopup.png') -0px -0px;
  font-size: 16px;
  color: #DDDDDD;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
  font-family: arial;
  font-weight: bold;
  cursor: default;
  position: absolute;
  z-index: 999;
  text-align: left;
  padding: 4px 0 0 6px;
  box-sizing: border-box;
  top: 0;
  left: 0;
}

/* Fog of War overlay */
div.fow {
  background-image: url(/interface4/darkbox.png);
  width: 64px;
  height: 64px;
  position: absolute;
  z-index: 300;
  top: 0;
  left: 0;
}

/* Unit slot selection */
.unit-slot.selected {
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 0 2px var(--accent-gold), 0 0 10px rgba(201, 162, 39, 0.5);
}

.unit-slot.filled {
  background: rgba(0, 0, 0, 0.3);
}

.unit-slot .slot-unit {
  position: absolute;
  width: 64px;
  height: 64px;
  top: 0;
  left: 0;
}

.unit-slot .slot-hp {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.8);
  color: #4caf50;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
}

/* ========================
   City Selection Menu
   ======================== */

#cityselectmenu {
  position: absolute;
  background-image: url('/interface4/dropdownbg.png');
  background-color: #f6dca4;
  border-top: solid 1px #f6e1a6;
  border-left: solid 1px #f6e1a6;
  border-right: solid 1px #8a7649;
  border-bottom: solid 1px #8a7649;
  padding: 4px;
  z-index: 1000;
  display: none;
  min-width: 120px;
}

#cityselectmenu .marker {
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background-color 0.15s;
}

#cityselectmenu .marker:hover {
  background: var(--bg-light);
}

/* ========================
   City/Building Popups
   ======================== */

/* City popup overlay - now handled by Popup component (popup.css) */
/* Legacy ID-based styles removed to avoid conflicts with .wb-popup-overlay */

/* City popup container using CSS grid for ornate borders */
.city-popup-container {
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  grid-template-rows: 26px auto 26px;
  width: 650px;
  min-height: 450px;
}

/* City popup body content */
.city-popup-body {
  padding: 20px 15px 15px 15px;
  max-height: 350px;
  overflow-y: auto;
}

/* City popup tabs */
.city-popup-tabs {
  display: flex;
  border-bottom: 2px solid #5a3d2b;
  margin: 25px 15px 0 15px;
}

.city-popup-tab {
  flex: 1;
  padding: 10px 15px;
  background: transparent;
  border: none;
  color: #5f3b1a;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0px 1px 1px #faf2e1;
}

.city-popup-tab:hover {
  background: rgba(201, 162, 39, 0.2);
}

.city-popup-tab.active {
  background: rgba(201, 162, 39, 0.3);
  border-bottom: 3px solid #c9a227;
  margin-bottom: -2px;
}

/* City popup footer */
.city-popup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-top: 1px solid #5a3d2b;
  margin-top: 10px;
}

.city-popup-gold {
  font-size: 14px;
  font-weight: bold;
  color: #5f3b1a;
  text-shadow: 0px 1px 1px #faf2e1;
}

.city-popup-gold::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background: url('/interface4/icon_gold.png') center/contain no-repeat;
  vertical-align: middle;
  margin-right: 5px;
}

.city-popup-buttons {
  display: flex;
  gap: 10px;
}

.city-popup-btn {
  padding: 8px 25px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  background: url('/interface4/basepopup.png') -6px -123px;
  color: #5f3b1a;
  text-shadow: 0px 1px 1px #faf2e1;
  min-width: 80px;
  height: 32px;
}

.city-popup-btn:hover {
  filter: brightness(1.1);
}

.city-popup-btn.cancel {
  background-position: -6px -123px;
}

.city-popup-btn.ok {
  background-position: -6px -123px;
}

/* City info styling inside popup */
.city-popup-body .city-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(90, 61, 43, 0.3);
  color: #5f3b1a;
  font-size: 14px;
}

.city-popup-body .city-stat-row label {
  font-weight: bold;
  color: #5f3b1a;
  text-shadow: 0px 1px 1px #faf2e1;
}

.city-popup-body .city-stat-row span {
  color: #3d2817;
}

.city-popup-body input[type="text"] {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #5a3d2b;
  padding: 5px 10px;
  color: #3d2817;
  border-radius: 3px;
  width: 150px;
}

.city-popup-body h4 {
  color: #5f3b1a;
  font-size: 16px;
  margin: 15px 0 10px 0;
  text-shadow: 0px 1px 1px #faf2e1;
  border-bottom: 1px solid #5a3d2b;
  padding-bottom: 5px;
}

.city-popup-body .upgrade-btn {
  padding: 5px 12px;
  background: url('/interface4/basepopup.png') -6px -123px;
  border: none;
  color: #5f3b1a;
  font-weight: bold;
  cursor: pointer;
  font-size: 12px;
}

.city-popup-body .upgrade-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Legacy support - old building-popup class (city-popup now uses Popup component) */
.building-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-panel);
  border: 3px solid var(--border-gold);
  border-radius: 8px;
  min-width: 400px;
  min-height: 300px;
  z-index: 1000;
  display: none;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  background: linear-gradient(to bottom, rgba(201, 162, 39, 0.3), transparent);
  border-bottom: 1px solid var(--border-gold);
}

.popup-header h3 {
  color: var(--accent-gold);
  margin: 0;
}

.popup-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

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

.popup-content {
  padding: var(--spacing-lg);
}

/* ========================
   Group Handling Area
   ======================== */

.group-area {
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  min-height: 40px;
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-xs);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.group-area .group-unit {
  width: 32px;
  height: 32px;
  background: var(--bg-dark);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.group-area .group-unit:hover {
  outline: 1px solid var(--accent-gold);
}

/* ========================
   Popup Overlay System
   ======================== */

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.popup-container {
  background: linear-gradient(to bottom, #2a2a4e, #1a1a2e);
  border: 3px solid var(--border-gold);
  border-radius: 8px;
  min-width: 350px;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  background: linear-gradient(to bottom, rgba(201, 162, 39, 0.3), transparent);
  border-bottom: 1px solid var(--border-gold);
  border-radius: 5px 5px 0 0;
}

.popup-header h3 {
  color: var(--accent-gold);
  margin: 0;
  font-size: 1.3rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.popup-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 8px;
}

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

.popup-body {
  padding: var(--spacing-lg);
}

.popup-footer {
  padding: var(--spacing-md);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
}

.btn-popup {
  padding: 10px 24px;
  background: var(--accent-gold);
  color: var(--bg-dark);
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-popup:hover {
  background: var(--accent-gold-light);
}

.btn-popup.secondary {
  background: var(--bg-light);
  color: var(--text-primary);
}

.btn-popup.secondary:hover {
  background: var(--border-color);
}

/* City Popup Specifics */
.city-popup-content {
  min-width: 400px;
}

.city-info-section {
  margin-bottom: var(--spacing-md);
}

.city-stats {
  display: grid;
  gap: var(--spacing-sm);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  color: var(--text-primary);
  font-weight: bold;
}

.city-production-section {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.city-production-section h4 {
  color: var(--accent-gold);
  margin: 0 0 var(--spacing-sm) 0;
}

.current-production {
  background: var(--bg-dark);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 4px;
  margin-bottom: var(--spacing-md);
}

.production-queue {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
}

.production-option {
  width: 64px;
  height: 64px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.production-option:hover {
  border-color: var(--accent-gold);
}

.production-option.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.5);
}

/* ========================
   Ship Conversion Popup
   ======================== */

.ship-convert-grid {
  font-weight: bold;
  font-size: 14px;
}

.btn-popup.primary {
  background: var(--accent-green);
  color: white;
}

.btn-popup.primary:hover {
  background: #2ecc71;
}

.btn-popup.disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

/* ========================
   Hero Popup System
   ======================== */

/* Hero inspect popup container */
/* hero-inspect-popup uses the standard big popup (990x550) */

/* Minimap column - floated left beside the hero table */
.hero-minimap-col {
  float: left;
  width: 302px;
}

/* Hero table matching old layout */
.hero_table1 { width: 612px; float: left; }
.hero_tdwidth1 { width: 90px; }
.hero_tdwidth2 { width: 150px; }
.hero_tdwidth3 { width: 455px; }
.hero_tdwidth4 { width: 55px; }
.hero_tdwidth5 { width: 65px; }
.hero_tdwidth6 { width: 100px; }
.hero_tdheight1 { height: 16px; }
.hero_tdheight2 { height: 17px; }
.hero_table2 { width: 120px; margin: 45px 0px 0px 20px; }
.hero_table3 { width: 120px; margin: 0px 0px 0px 20px; }
.hero_div1 { margin-top: 4px; margin-left: 13px; }
.hero_div2 { width: 200px; max-height: 390px; height: 390px; margin: 24px 0px 0px 10px; font-size: 14px; }
.hero_margintop { margin-top: -6px; }
.hero_margin { margin: 2px; }

/* Base text style used in hero/city popups */
.basetext { color: #5f3b1a; font-weight: bold; font-size: 12px; }

/* Progress bar matching old version */
.progressback { border: solid 1px; background: url('/interface4/progressback.gif'); width: 152px; height: 21px; margin: 5px 0 5px 0; }
.progressfront { background: url('/interface4/progressfront.gif'); width: 35%; height: 21px; float: left; }

/* Ground slots container below minimap */
.hero_groundslots { float: left; width: 300px; margin-left: 3px; margin-top: 8px; color: #5f3b1a; font-weight: bold; font-size: 12px; }

/* Tab content area */
.hero-tab-content {
  padding: 5px 0 0 8px;
  min-height: 350px;
  clear: both;
  color: #5f3b1a;
  font-weight: bold;
  font-size: 14px;
}

.hero-tab-content.hidden {
  display: none;
}

/* Skills Section */
.skills-section h4 {
  color: #5f3b1a;
  margin: 0;
  padding: 0;
  text-decoration: underline;
  text-align: center;
}

.skills-table {
  width: 445px;
  margin-top: 5px;
  margin-left: 8px;
  border-collapse: collapse;
  color: #5f3b1a;
  font-weight: bold;
  font-size: 14px;
}

.skill-row td {
  padding: 2px 4px;
  vertical-align: middle;
}

/* skill-icon class removed - using baseicon/wbaseicon from icons.css instead */

.skill-controls {
  display: flex;
  gap: 2px;
  align-items: center;
}

.skill-info, .ability-info {
  color: #5f3b1a;
  font-size: 13px;
}

.skill-limit {
  color: #5f3b1a;
  font-size: 13px;
}

.item-bonus {
  color: #850000;
}

/* Equipment Section - uses equip-* classes defined above */

/* Abilities Section */
.abilities-section {
  color: #5f3b1a;
  font-weight: bold;
  font-size: 14px;
}

.ability-points {
  color: #5f3b1a;
  font-weight: bold;
  margin-bottom: var(--spacing-md);
}

.abilities-table {
  width: 425px;
  margin-top: 5px;
  margin-left: 10px;
  border-collapse: collapse;
}

.ability-row td {
  padding: 6px 4px;
  vertical-align: middle;
}

.ability-controls {
  display: flex;
  gap: 2px;
  align-items: center;
  width: 65px;
}

/* Droppable highlights */
.drop_active {
  border-color: var(--accent-gold) !important;
  background: rgba(201, 162, 39, 0.2) !important;
}

/* Hero frame styles - using heroes.png sprite sheet */
.heroknightframe { background: url(/units/set2/heroes.png) -0px -130px; width: 150px; height: 150px; }
.heroamazonframe { background: url(/units/set2/heroes.png) -306px -130px; width: 150px; height: 150px; }
.herodreadknightframe { background: url(/units/set2/heroes.png) -153px -130px; width: 150px; height: 150px; }
.herohorselordframe { background: url(/units/set2/heroes.png) -762px -130px; width: 150px; height: 150px; }
.herobarbarianframe { background: url(/units/set2/heroes.png) -458px -130px; width: 150px; height: 150px; }
.heroassassinframe { background: url(/units/set2/heroes.png) -610px -130px; width: 150px; height: 150px; }
.herorangerframe { background: url(/units/set2/heroes.png) -0px -280px; width: 150px; height: 150px; }
.herodwarfframe { background: url(/units/set2/heroes.png) -153px -280px; width: 150px; height: 150px; float: left; margin: 1px 5px 5px 5px; border: solid 1px; }
.herosorceressframe { background: url(/units/set2/heroes.png) -458px -280px; width: 150px; height: 150px; float: left; margin: 1px 5px 5px 5px; border: solid 1px; }

/* Hero frame by ID */
.heroframe50 { background: url(/units/set2/heroes.png) -0px -130px; width: 150px; height: 150px; }
.heroframe51 { background: url(/units/set2/heroes.png) -306px -130px; width: 150px; height: 150px; }
.heroframe52 { background: url(/units/set2/heroes.png) -153px -130px; width: 150px; height: 150px; }
.heroframe53 { background: url(/units/set2/heroes.png) -762px -130px; width: 150px; height: 150px; }
.heroframe54 { background: url(/units/set2/heroes.png) -458px -130px; width: 150px; height: 150px; }
.heroframe55 { background: url(/units/set2/heroes.png) -610px -130px; width: 150px; height: 150px; }
.heroframe56 { background: url(/units/set2/heroes.png) -0px -280px; width: 150px; height: 150px; }
.heroframe57 { background: url(/units/set2/heroes.png) -153px -280px; width: 150px; height: 150px; }
.heroframe58 { background: url(/units/set2/heroes.png) -458px -280px; width: 150px; height: 150px; }

/* Small hero frames for browse/list views */
.heroknightframe_small { background: url(/units/set2/heroesframesmall.png) -0px -0px; width: 75px; height: 75px; }
.heroamazonframe_small { background: url(/units/set2/heroesframesmall.png) -150px -0px; width: 75px; height: 75px; }
.herodreadknightframe_small { background: url(/units/set2/heroesframesmall.png) -75px -0px; width: 75px; height: 75px; }
.herohorselordframe_small { background: url(/units/set2/heroesframesmall.png) -300px -75px; width: 75px; height: 75px; }
.herobarbarianframe_small { background: url(/units/set2/heroesframesmall.png) -225px -0px; width: 75px; height: 75px; }
.heroassassinframe_small { background: url(/units/set2/heroesframesmall.png) -300px -0px; width: 75px; height: 75px; }
.herorangerframe_small { background: url(/units/set2/heroesframesmall.png) -0px -75px; width: 75px; height: 75px; }
.herodwarfframe_small { background: url(/units/set2/heroesframesmall.png) -75px -75px; width: 75px; height: 75px; }
.herosorceressframe_small { background: url(/units/set2/heroesframesmall.png) -225px -75px; width: 75px; height: 75px; }

/* Big hero portraits */
.heropaladin_big { background: url(/units/set2/heroes.png) -0px -0px; width: 128px; height: 128px; }
.heroamazon_big { background: url(/units/set2/heroes.png) -256px -0px; width: 128px; height: 128px; }
.herodreadknight_big { background: url(/units/set2/heroes.png) -128px -0px; width: 128px; height: 128px; }
.herobarbarian_big { background: url(/units/set2/heroes.png) -384px -0px; width: 128px; height: 128px; }
.herohorselord_big { background: url(/units/set2/heroes.png) -640px -0px; width: 128px; height: 128px; }
.heroassassin_big { background: url(/units/set2/heroes.png) -512px -0px; width: 128px; height: 128px; }
.heroranger_big { background: url(/units/set2/heroes.png) -260px -450px; width: 128px; height: 128px; }
.herodwarf_big { background: url(/units/set2/heroes.png) -0px -450px; width: 128px; height: 128px; }
.herosorceress_big { background: url(/units/set2/heroes.png) -768px -0px; width: 128px; height: 128px; }

/* Hero popup buttons - matching old hero-pop.png sprite */
.hero_add { width: 21px; height: 21px; background: url('/interface4/hero-pop.png') -97px -2px; float: left; cursor: pointer; }
.hero_sub { width: 21px; height: 21px; background: url('/interface4/hero-pop.png') -68px -2px; float: left; margin-right: 5px; cursor: pointer; }

/* Browse arrows - hero-pop.png sprite */
.browseleft { width: 30px; height: 24px; background: url('/interface4/hero-pop.png') -31px -0px; float: left; cursor: pointer; }
.browseright { width: 30px; height: 24px; background: url('/interface4/hero-pop.png') -0px -0px; float: right; cursor: pointer; }

/* Equipment slot sprites - hero-pop.png */
.hero-equip-slot.helm { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -3px -86px; }
.hero-equip-slot.armour { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -174px -86px; }
.hero-equip-slot.shield { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -60px -29px; }
.hero-equip-slot.weapon { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -3px -29px; }
.hero-equip-slot.ring { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -117px -29px; }
.hero-equip-slot.boots { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -117px -86px; }
.itemslot_backpack { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -174px -29px; }
.itemslot_ground { width: 56px; height: 56px; background: url('/interface4/hero-pop.png') -60px -86px; }

/* Equipment tab layout */
.equip-tab-layout { display: flex; gap: 8px; }
.equip-stats-col { width: 200px; overflow-y: auto; font-size: 14px; color: #5f3b1a; font-weight: bold; }
.equip-hero-col { position: relative; width: 250px; min-height: 385px; }
.equip-hero-body { position: absolute; top: 30px; left: 60px; }
.equip-slot-helm { position: absolute; top: 0px; left: 92px; }
.equip-slot-armour { position: absolute; top: 10px; left: 0px; }
.equip-slot-weapon { position: absolute; top: 100px; left: 0px; }
.equip-slot-ring { position: absolute; top: 165px; left: 0px; }
.equip-slot-boots { position: absolute; top: 185px; left: 92px; }
.equip-slot-shield { position: absolute; top: 30px; left: 185px; }
.equip-backpack { margin-top: 8px; color: #5f3b1a; font-weight: bold; font-size: 12px; }
.equip-backpack-slots { display: flex; gap: 3px; margin-top: 3px; }
.equip-backpack-inline { position: absolute; top: 255px; left: 0; width: 100%; color: #5f3b1a; font-weight: bold; font-size: 12px; }
.equip-backpack-grid { display: grid; grid-template-columns: repeat(3, 56px); gap: 3px; margin-top: 3px; }
.equip-ground { margin-top: 8px; color: #5f3b1a; font-weight: bold; font-size: 12px; }
.equip-ground-slots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.hero_marginleft { margin-left: 3px; }

/* Skill/ability icon layout (unique to game-ui, not in icons.css) */
.skill-icon, .ability-icon {
  width: 48px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 14px;
  font-weight: bold;
  padding-right: 4px;
}

/* ============================================= */
/* ORIGINAL WARBARONS INTERFACE                   */
/* ============================================= */

/* Base body styles for game view */
body.game-view {
  background-color: #e3e3e3;
  font-family: arial;
  margin: 0;
  text-shadow: 0px 1px 1px #faf2e1;
  font-size: 12px;
  background-image: url('/interface4/main_background.png');
  overflow: hidden;
  color: #3f320c; /* Default dark brown text */
  /* Scrollbar color variables - change here to update all scrollbars */
  --scrollbar-track: #f1dbab;
  --scrollbar-thumb: #f6efe2;
  --scrollbar-thumb-hover: #e8dfd0;
}

/* Global scrollbar styling for game view */
body.game-view *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.game-view *::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

body.game-view *::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

body.game-view *::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox scrollbar */
body.game-view * {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

html, body { height: 100%; }

/* Game View Scene - override flex layout */
.scene.game-view-scene {
  display: block;
  overflow: hidden;
  background-color: #e3e3e3;
  background-image: url('/interface4/main_background.png');
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: #3f320c; /* Default dark brown text */
}

/* Two column layout - matching original exactly */
/* leftCol uses overflow:hidden to fill remaining space after rightCol floats right */
.game-view-scene .leftCol {
  overflow: hidden;
  height: 100%;
  padding: 3px;
}

.game-view-scene .rightCol {
  float: right;
  width: 302px;
  margin: 3px 3px 3px 2px; /* Original margin */
  background-image: url('/interface4/main_background.png');
  height: 100%;
  overflow-y: auto;
}

/* Map container - matching original map.css */
.game-view-scene #outerDiv {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: move;
  /* Original border gives inset look */
  border-top: solid 1px #392f1f;
  border-left: solid 1px #392f1f;
  border-right: solid 1px #f4e3c2;
  border-bottom: solid 1px #f4e3c2;
  box-sizing: border-box;
}

.game-view-scene #innerDiv {
  position: relative;
  left: 0px;
  top: 0px;
  z-index: 0; /* Creates stacking context - terrain z-indices are contained within */
  background-color: #379488;
}

.game-view-scene #popWar {
  position: absolute;
}

/* div.war position: absolute is set in markers.css */

/* Dark overlay */
.game-view-scene div.dark {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 800;
  background: url('/interface4/darkbox.png');
  position: fixed;
  display: none;
}

/* ============================================= */
/* LEFT SIDE PANEL                                */
/* ============================================= */

/* Matching original - floats on top of map at top:3px */
.if_uppermidleftpanel {
  width: 72px;
  padding-left: 2px;
  position: absolute;
  top: 3px;
  left: 3px;
  background: url('/interface4/y-panels.png') -77px -0px;
  z-index: 5;
}

/* Matching original - floats on top of map at bottom:3px */
.if_lowermidleftpanel {
  width: 72px;
  padding-left: 2px;
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: url('/interface4/y-panels.png') -77px -0px;
  z-index: 5;
}

.if_topleftpanel {
  width: 72px;
  position: absolute;
  bottom: 146px;
  left: 3px;
  background: url('/interface4/mainpanels.png') -206px -257px;
  padding-top: 4px;
  padding-left: 2px;
  z-index: 5;
}

.if_bottomleftpanel {
  width: 74px;
  height: 3px;
  position: absolute;
  top: 250px;
  left: 3px;
  background: url('/interface4/mainpanels.png') -206px -262px;
  z-index: 5;
}

/* Resource info icons - dark text color for yellow background */
.if_goldsites { width: 64px; height: 30px; background: url(/interface4/mainpanels.png) -213px -156px; float: left; margin-left: -2px; margin-top: 4px; text-align: right; font-size: 12px; font-weight: bold; padding: 0px 4px 0px 0px; color: #5f3b1a; text-shadow: 0px 1px 1px #faf2e1; }
.if_treasury { width: 64px; height: 30px; background: url(/interface4/mainpanels.png) -213px -216px; float: left; margin-left: -2px; margin-top: 4px; text-align: right; font-size: 12px; font-weight: bold; padding: 0px 4px 0px 0px; color: #5f3b1a; text-shadow: 0px 1px 1px #faf2e1; }
.if_castle { width: 64px; height: 30px; background: url(/interface4/mainpanels.png) -213px -126px; float: left; margin-left: -2px; margin-top: 6px; text-align: right; font-size: 12px; font-weight: bold; padding: 0px 4px 0px 0px; color: #5f3b1a; text-shadow: 0px 1px 1px #faf2e1; }
.if_income { width: 64px; height: 30px; background: url(/interface4/mainpanels.png) -213px -186px; float: left; margin-left: -2px; margin-top: 6px; margin-bottom: 4px; text-align: right; font-size: 12px; font-weight: bold; padding: 0px 4px 0px 0px; color: #5f3b1a; text-shadow: 0px 1px 1px #faf2e1; }

/* ============================================= */
/* RESOLUTION INFO BAR (transparent status bar)   */
/* ============================================= */
.game-view-scene #resolutionInfo {
  padding: 2px 0 0 5px;
  width: 400px;
  font: normal 10px sans-serif;
  position: relative;
  background-image: url('/interface4/contentback.png');
  margin-top: -25px;
  margin-left: 130px;
  height: 24px;
  text-align: left;
  float: left;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  color: #3f320c; /* Dark brown text */
  z-index: 100;
}

/* ============================================= */
/* MINIMAP                                        */
/* ============================================= */

.game-view-scene .if_minicontainer {
  width: 300px;
  height: 300px;
  background-color: #000 !important;
  background-image: none !important;
  border-top: solid 1px #392f1f;
  border-left: solid 1px #392f1f;
  border-right: solid 1px #f4e3c2;
  border-bottom: solid 1px #f4e3c2;
  float: left;
}

.game-view-scene .minimap {
  width: 300px;
  height: 300px;
  position: relative;
  overflow: hidden;
  background: #000 !important;
  background-image: none !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Hide prerendered minimap image - it's only used as a source for canvas drawing */
.game-view-scene .minimap img.minimap-prerendered,
.game-view-scene .minimap img {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
}

.game-view-scene .minimapinner {
  /* Don't stretch - use natural canvas size set via inline style */
  display: block;
  /* Position relative so magnifier can be positioned correctly */
  position: relative;
  /* Ensure no background stretching */
  background: transparent !important;
  /* Don't let any rules stretch the canvas - inline styles take priority */
  max-width: 300px;
  max-height: 300px;
}

/* Ensure canvas inside minimap isn't stretched by percentage rules */
.game-view-scene .minimap canvas.minimapinner {
  /* Inline styles will set exact px dimensions - this just prevents percent-based stretching */
  max-width: 100%;
  max-height: 100%;
}

/* Matching original map.css #magnifier */
.game-view-scene .magnifier {
  position: absolute;
  left: 0px;
  top: 0px;
  z-index: 1001;
  background-color: transparent;
  border: solid white 1px;
  pointer-events: none;
}

/* ============================================= */
/* TURN INFO                                      */
/* ============================================= */

#IDshields {
  padding-top: 3px;
}

.if_turninfo {
  float: left;
  text-align: center;
  width: 300px;
  height: 30px;
  line-height: 30px;
  border-top: solid 1px #392f1f;
  border-left: solid 1px #392f1f;
  border-right: solid 1px #f4e3c2;
  border-bottom: solid 1px #f4e3c2;
  background-image: url(/interface4/dropdownbg.png);
}

.menutopic_right {
  font-family: arial, sans-serif;
  color: #3f320c;
  font-size: 14px;
  margin-left: 4px;
  margin-right: 4px;
  font-weight: bold;
  line-height: 30px;
  display: inline-block;
  vertical-align: middle;
}

/* ============================================= */
/* UNIT SELECTION SLOTS - Exact original layout   */
/* ============================================= */

/* EXACT match to original - no extra properties */
.if_unitunselected {
  position: relative;
  width: 72px;
  height: 100px;
  float: left;
  background: url(/interface4/mainpanels.png) -563px -217px;
  margin: 1px 2px 1px 1px;
  font-size: 10px;
  color: #3f320c; /* Dark brown text */
}

.if_unitselected {
  position: relative;
  width: 72px;
  height: 100px;
  float: left;
  background: url(/interface4/mainpanels.png) -563px -217px;
  margin: 1px 2px 1px 1px;
  font-size: 10px;
  color: #3f320c; /* Dark brown text */
}

/* Selected unit slot - unit sprite gets black border with larger size */
.if_unitselected .unit-display > div {
  border: solid 2px #000;
  border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  margin: 2px 0px 0px 2px;
  width: 66px !important;
  height: 66px !important;
}

/* Unselected unit slot - no border, extra margin to compensate */
.if_unitunselected .unit-display > div {
  border: none;
  margin: 3px 0px 1px 4px;
}

/* EXACT match - position only, font inherits from parent */
.if_unitslotcount {
  position: absolute;
  left: 6px;
  top: 2px;
}

/* Unit stats - positioned at bottom of slot */
.unit-stats {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  line-height: 1.2;
}

/* ============================================= */
/* GROUP AREA - Exact original positioning        */
/* ============================================= */

.if_grouparea {
  padding: 6px;
  position: absolute;
  width: 138px;
  height: 49px;
  float: left;
  border: solid 0px;
  right: 89px;
  top: 444px;
  background: url(/interface4/mainpanels.png) -142px -2px;
}

/* ============================================= */
/* ACTION BUTTONS - Original float layout         */
/* ============================================= */

/* Main action buttons - all use float layout like original */
div.move1 { background: url('/interface4/mainpanels.png') -484px -146px; width: 67px; height: 35px; margin-left: 1px; margin-bottom: 5px; margin-right: 6px; cursor: pointer; float: left; }
div.move2 { background: url('/interface4/mainpanels.png') -484px -181px; width: 67px; height: 35px; margin-left: 1px; margin-bottom: 5px; margin-right: 6px; cursor: pointer; float: left; }

div.fightorder1 { background: url('/interface4/miscpanels.png') -0px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }
div.fightorder2 { background: url('/interface4/miscpanels.png') -67px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }

div.unselect1 { background: url('/interface4/mainpanels.png') -350px -215px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }
div.unselect2 { background: url('/interface4/mainpanels.png') -350px -249px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }

div.groupstats1 { background: url('/interface4/miscpanels.png') -135px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }
div.groupstats2 { background: url('/interface4/miscpanels.png') -202px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }

div.stop1 { background: url('/interface4/mainpanels.png') -282px -215px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }
div.stop2 { background: url('/interface4/mainpanels.png') -282px -249px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }

div.attention1 { background: url('/interface4/mainpanels.png') -282px -145px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }
div.attention2 { background: url('/interface4/mainpanels.png') -282px -180px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }

div.nextunit1 { background: url('/interface4/mainpanels.png') -550px -145px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }
div.nextunit2 { background: url('/interface4/mainpanels.png') -550px -180px; width: 67px; height: 35px; margin-bottom: 5px; margin-right: 8px; cursor: pointer; float: left; }

div.endturn1 { background: url('/interface4/mainpanels.png') -416px -145px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }
div.endturn2 { background: url('/interface4/mainpanels.png') -416px -180px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }

/* EXACT match - no cursor property */
.btn_notes1 { background: url('/interface4/miscpanels.png') -270px -196px; width: 67px; height: 35px; float: left; margin-left: 1px; margin-bottom: 5px; margin-right: 6px; margin-top: 1px; }
.btn_notes2 { background: url('/interface4/miscpanels.png') -337px -196px; width: 67px; height: 35px; float: left; margin-left: 1px; margin-bottom: 5px; margin-right: 6px; margin-top: 1px; cursor: pointer; }

.btn_groupmove1 { background: url('/interface4/miscpanels.png') -541px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }
.btn_groupmove2 { background: url('/interface4/miscpanels.png') -608px -195px; width: 67px; height: 35px; margin-bottom: 6px; margin-right: 8px; cursor: pointer; float: left; }

/* EXACT match - no cursor property (scoped to game view to avoid conflict with mapeditor.css) */
.game-view-scene .btn_grid1 { background: url('/interface4/mapeditor.png') -0px -36px; width: 68px; height: 36px; float: left; }
.game-view-scene .btn_grid2 { background: url('/interface4/mapeditor.png') -68px -36px; width: 68px; height: 36px; float: left; cursor: pointer; }

/* Toggle buttons */
.togglefightorder1 { background: url(/interface4/miscpanels.png) -330px -2px; width: 20px; height: 24px; position: absolute; top: 342px; right: 285px; cursor: pointer; }
.togglefightorder2 { background: url(/interface4/miscpanels.png) -352px -2px; width: 20px; height: 24px; position: absolute; top: 342px; right: 285px; cursor: pointer; }

.toggletrackplayer1 { background: url(/interface4/miscpanels.png) -334px -43px; width: 20px; height: 24px; position: absolute; top: 343px; right: 260px; cursor: pointer; }
.toggletrackplayer2 { background: url(/interface4/miscpanels.png) -359px -43px; width: 20px; height: 24px; position: absolute; top: 343px; right: 260px; cursor: pointer; }

/* ============================================= */
/* SIDE BUTTONS (Left panel)                      */
/* ============================================= */

.sidechat1 { background: url('/interface4/mainpanels.png') -418px -0px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }
.sidechat2 { background: url('/interface4/mainpanels.png') -418px -36px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }

.sidebattle1 { background: url('/interface4/mainpanels.png') -282px -0px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }
.sidebattle2 { background: url('/interface4/mainpanels.png') -282px -36px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }

.sidecity1 { background: url('/interface4/mainpanels.png') -486px -0px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }
.sidecity2 { background: url('/interface4/mainpanels.png') -486px -36px; width: 68px; height: 36px; margin-bottom: 6px; cursor: pointer; margin-left: -2px; float: left; }

/* .sidewiki1, .sidewiki2 — defined in city.css */

.buyhero1 { background: url('/interface4/mainpanels.png') -350px -0px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.buyhero2 { background: url('/interface4/mainpanels.png') -350px -36px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.buyheroactive { background: url('/interface4/mainpanels.png') -350px -36px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_dock1 { background: url('/interface4/mainpanels.png') -350px -73px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_dock2 { background: url('/interface4/mainpanels.png') -350px -109px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_dockactive { background: url('/interface4/dockactive.gif') no-repeat 0 0; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_ruin1 { background: url('/interface4/mainpanels.png') -554px -73px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_ruin2 { background: url('/interface4/mainpanels.png') -554px -109px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_ruinactive { background: url('/interface4/ruinactive.gif') no-repeat 0 0; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_temple1 { background: url('/interface4/mainpanels.png') -214px -54px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_temple2 { background: url('/interface4/mainpanels.png') -214px -90px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_templeactive { background: url('/interface4/templeactive.gif') no-repeat 0 0; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_empty1 { background: url('/interface4/mainpanels.png') -418px -73px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_empty2 { background: url('/interface4/mainpanels.png') -418px -109px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_tower1 { background: url('/interface4/mainpanels.png') -486px -73px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_tower2 { background: url('/interface4/mainpanels.png') -486px -109px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_toweractive { background: url('/interface4/toweractive.gif') no-repeat 0 0; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

.btn_trigger1 { background: url('/interface4/mainpanels.png') -554px -146px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_trigger2 { background: url('/interface4/mainpanels.png') -554px -182px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.btn_triggeractive { background: url('/interface4/triggeractive.gif') no-repeat 0 0; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

/* Group/Ungroup buttons */
.button_group1 { width: 65px; height: 34px; background: url('/interface4/mainpanels.png') -281px -284px; cursor: pointer; }
.button_group2 { width: 65px; height: 34px; background: url('/interface4/mainpanels.png') -281px -318px; cursor: pointer; }
.button_ungroup1 { width: 65px; height: 34px; background: url('/interface4/mainpanels.png') -410px -286px; cursor: pointer; }
.button_ungroup2 { width: 65px; height: 34px; background: url('/interface4/mainpanels.png') -410px -320px; cursor: pointer; }

.diplomacy1 { background: url('/interface4/mainpanels.png') -554px -0px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }
.diplomacy2 { background: url('/interface4/mainpanels.png') -554px -36px; width: 68px; height: 36px; margin-bottom: 4px; cursor: pointer; margin-left: -2px; float: left; }

/* ============================================= */
/* TOP MENU                                       */
/* ============================================= */

/* Matching original - position absolute, floats on top of map */
#topmenupos {
  position: absolute;
  z-index: 5;
  top: 3px;
  left: 5px;
  border-bottom: solid 1px #392f1f;
  border-left: solid 1px #f4e3c2;
  border-right: solid 1px #392f1f;
  background-image: url(/interface4/main_background.png);
  width: 620px;
  height: 20px;
  text-align: left;
  float: left;
}

.topmenu-item {
  position: relative;
  float: left; /* Side by side like original .menutopic */
  padding: 0 12px;
  cursor: pointer;
  font-weight: bold;
  color: #3f320c;
  font-size: 14px; /* Original uses 14px */
  margin-left: 5px;
  margin-right: 5px;
}

.topmenu-item:hover {
  background-color: #e2b852;
}

.menu-label {
  line-height: 20px;
}

.game-view-scene .dropmenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background-image: url(/interface4/dropdownbg.png);
  border-top: solid 1px #f6e1a6;
  border-left: solid 1px #f6e1a6;
  border-right: solid 1px #8a7649;
  border-bottom: solid 1px #8a7649;
  box-shadow: 0 10px 10px 0 #333;
  min-width: 150px;
}

.menu-option {
  padding: 5px 10px;
  color: #3f320c;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
}

.menu-option:hover {
  background-color: #e2b852;
}

.game-title-text {
  font-weight: bold;
  color: #3f320c;
  font-size: 14px;
}

/* ============================================= */
/* STATUS INDICATORS                              */
/* ============================================= */

div.observer { width: 52px; height: 52px; position: absolute; right: 360px; top: 50px; background: url(/interface4/mainpanels.png) -86px -2px; border: solid 3px; display: none; }
div.freeze { width: 52px; height: 52px; position: absolute; right: 360px; top: 50px; background: url(/interface4/mainpanels.png) -152px -209px; border: solid 3px; display: none; }
div.activeturn { width: 52px; height: 52px; position: absolute; right: 360px; top: 50px; background: url(/interface4/mainpanels.png) -152px -155px; border: solid 3px; display: none; }

.fullscreen {
  position: absolute;
  bottom: 10px;
  left: 80px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background: url(/interface4/miscpanels.png) -655px -71px;
  z-index: 5;
}

/* ============================================= */
/* LOADING OVERLAY                                */
/* ============================================= */

.if_darkboxwait {
  width: 100%;
  height: 100%;
  position: fixed;
  display: none;
  z-index: 1100;
  background-image: url('/interface4/waiting.gif');
  color: #fff;
  font-size: 18px;
  background-repeat: no-repeat;
  background-position: center;
}

.if_darkboxwait span {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -85px;
  margin-top: -40px;
  border: solid 1px;
  width: 170px;
  height: 60px;
  border-color: #DDDDAA;
  padding-top: 5px;
}

/* ============================================= */
/* TILE INFO PANEL                                */
/* ============================================= */

.tile-info-panel {
  position: absolute;
  bottom: 10px;
  left: 130px;
  background-image: url(/interface4/dropdownbg.png);
  border: solid 1px #8a7649;
  padding: 5px 10px;
  font-weight: bold;
  color: #3f320c;
  z-index: 5;
}

/* ============================================= */
/* SHIELD MARKERS                                 */
/* ============================================= */

/* Shield icons - add margin-right for spacing between shields */
.shield_tiny0 { background: url(/interface4/mainpanels.png) -159px -80px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny1 { background: url(/interface4/mainpanels.png) -175px -56px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny2 { background: url(/interface4/mainpanels.png) -191px -56px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny3 { background: url(/interface4/mainpanels.png) -192px -80px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny4 { background: url(/interface4/mainpanels.png) -159px -103px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny5 { background: url(/interface4/mainpanels.png) -176px -102px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny6 { background: url(/interface4/mainpanels.png) -193px -103px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny7 { background: url(/interface4/mainpanels.png) -159px -127px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.shield_tiny8 { background: url(/interface4/mainpanels.png) -156px -56px; float: left; height: 22px; width: 15px; margin-right: 2px; }
.tinydead { background: url(/interface4/mainpanels.png) -176px -80px; width: 16px; height: 22px; float: left; background-repeat: no-repeat; margin-right: 2px; }
/* .playerMe, .playerActive, .playerInActive, .playerDone — defined in markers.css */

/* ============================================= */
/* TAVERN POPUP                                   */
/* ============================================= */

#tavern-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tavern-popup.hidden {
  display: none;
}

.tavern-popup-content {
  width: 700px;
  max-width: 95%;
  background-image: url(/interface4/dropdownbg.png);
  border-top: solid 2px #f6e1a6;
  border-left: solid 2px #f6e1a6;
  border-right: solid 2px #8a7649;
  border-bottom: solid 2px #8a7649;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.tavern-header {
  background: linear-gradient(to bottom, #5a4a30, #3a2a10);
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: solid 1px #8a7649;
}

.tavern-header h3 {
  margin: 0;
  color: #f6e1a6;
  font-size: 16px;
  text-shadow: 1px 1px 2px #000;
}

.tavern-body {
  padding: 15px;
}

.tavern-layout {
  display: flex;
  gap: 15px;
}

.tavern-hero-select {
  width: 200px;
  flex-shrink: 0;
}

.tavern-hero-preview {
  width: 180px;
  flex-shrink: 0;
  text-align: center;
}

.tavern-hero-details {
  flex: 1;
}

.tavern-section-title {
  font-weight: bold;
  color: #3f320c;
  font-size: 13px;
  margin-bottom: 10px;
  border-bottom: solid 1px #8a7649;
  padding-bottom: 5px;
}

.tavern-hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tavern-hero-btn {
  background-image: url(/interface4/dropdownbg.png);
  border: solid 1px #8a7649;
  padding: 5px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tavern-hero-btn:hover {
  background-color: rgba(226, 184, 82, 0.3);
}

.tavern-hero-btn.selected {
  border-color: #f6e1a6;
  background-color: rgba(226, 184, 82, 0.5);
  box-shadow: inset 0 0 5px rgba(246, 225, 166, 0.5);
}

.hero-frame-small {
  width: 48px;
  height: 48px;
  margin: 0 auto 3px;
  background-size: cover;
}

.hero-type-name {
  font-size: 9px;
  color: #3f320c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-preview-frame {
  background: rgba(0, 0, 0, 0.2);
  border: solid 1px #8a7649;
  padding: 10px;
  margin-bottom: 10px;
}

.hero-portrait-large {
  width: 128px;
  height: 128px;
  margin: 0 auto;
  background-size: cover;
}

.hero-preview-stats {
  text-align: left;
  background: rgba(0, 0, 0, 0.1);
  padding: 8px;
  border: solid 1px #8a7649;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #3f320c;
  padding: 2px 0;
}

.stat-label {
  font-weight: bold;
}

.stat-value {
  color: #5a4a30;
}

.tavern-field {
  margin-bottom: 12px;
}

.tavern-field label {
  display: block;
  font-weight: bold;
  color: #3f320c;
  font-size: 12px;
  margin-bottom: 4px;
}

.tavern-field input {
  width: 100%;
  padding: 6px 8px;
  border: solid 1px #8a7649;
  background: #f9f3e3;
  color: #3f320c;
  font-size: 13px;
}

.tavern-field input:focus {
  outline: none;
  border-color: #f6e1a6;
  background: #fff;
}

.hero-class-bonuses {
  background: rgba(0, 0, 0, 0.1);
  padding: 8px;
  border: solid 1px #8a7649;
  font-size: 11px;
  color: #3f320c;
}

.bonus-item {
  padding: 2px 0;
  padding-left: 12px;
  position: relative;
}

.bonus-item::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #8a7649;
}

.tavern-cost, .tavern-gold {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 5px 0;
  border-bottom: solid 1px #ddd5c0;
}

.cost-label, .gold-label {
  font-weight: bold;
  color: #3f320c;
}

.cost-value {
  color: #8b4513;
  font-weight: bold;
}

.cost-value.cannot-afford {
  color: #cc0000;
}

.gold-value {
  color: #c9a227;
  font-weight: bold;
}

.tavern-footer {
  background: linear-gradient(to bottom, #4a3a20, #3a2a10);
  padding: 10px 15px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: solid 1px #8a7649;
}

.btn-popup {
  padding: 6px 16px;
  border: solid 1px #8a7649;
  background: linear-gradient(to bottom, #d4c4a0, #b4a480);
  color: #3f320c;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-popup:hover {
  background: linear-gradient(to bottom, #e4d4b0, #c4b490);
}

.btn-popup:active {
  background: linear-gradient(to bottom, #b4a480, #d4c4a0);
}

.btn-popup.primary {
  background: linear-gradient(to bottom, #c9a227, #a08020);
  border-color: #e6c84a;
  color: #3a1e00;
}

.btn-popup.primary:hover {
  background: linear-gradient(to bottom, #e6c84a, #c9a227);
}

.btn-popup:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hero portrait (large) sprites from heroes.png */
.hero-portrait.heroknightframe { background: url('/heroes/heroes.png') 0 0; width: 128px; height: 128px; }
.hero-portrait.heroamazonframe { background: url('/heroes/heroes.png') -128px 0; width: 128px; height: 128px; }
.hero-portrait.herodreadknightframe { background: url('/heroes/heroes.png') -256px 0; width: 128px; height: 128px; }
.hero-portrait.herohorselordframe { background: url('/heroes/heroes.png') -384px 0; width: 128px; height: 128px; }
.hero-portrait.herobarbarianframe { background: url('/heroes/heroes.png') -512px 0; width: 128px; height: 128px; }
.hero-portrait.heroassassinframe { background: url('/heroes/heroes.png') 0 -128px; width: 128px; height: 128px; }
.hero-portrait.herorangerframe { background: url('/heroes/heroes.png') -128px -128px; width: 128px; height: 128px; }
.hero-portrait.herodwarfframe { background: url('/heroes/heroes.png') -256px -128px; width: 128px; height: 128px; }
.hero-portrait.herosorceressframe { background: url('/heroes/heroes.png') -384px -128px; width: 128px; height: 128px; }

/* Large portrait for tavern preview */
.hero-portrait-large.heroknightframe { background: url('/heroes/heroes.png') 0 0; }
.hero-portrait-large.heroamazonframe { background: url('/heroes/heroes.png') -128px 0; }
.hero-portrait-large.herodreadknightframe { background: url('/heroes/heroes.png') -256px 0; }
.hero-portrait-large.herohorselordframe { background: url('/heroes/heroes.png') -384px 0; }
.hero-portrait-large.herobarbarianframe { background: url('/heroes/heroes.png') -512px 0; }
.hero-portrait-large.heroassassinframe { background: url('/heroes/heroes.png') 0 -128px; }
.hero-portrait-large.herorangerframe { background: url('/heroes/heroes.png') -128px -128px; }
.hero-portrait-large.herodwarfframe { background: url('/heroes/heroes.png') -256px -128px; }
.hero-portrait-large.herosorceressframe { background: url('/heroes/heroes.png') -384px -128px; }

/* ============================================
   BATTLE POPUP STYLES (Original Warbarons Style)
   ============================================ */

/* Battle popup overlay - now handled by Popup component (popup.css) */
/* Legacy ID-based styles removed to avoid conflicts with .wb-popup-overlay */

/* Popup container using CSS grid for borders */
.battle-popup-container {
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  grid-template-rows: 26px 498px 26px;
  width: 990px;
  height: 550px;
}

/* Popup border pieces (div-based) */
.pop-border { background-repeat: repeat; }
.pop-border-tl { grid-area: 1 / 1 / 2 / 2; background: url('/interface4/popup_tl.png') no-repeat; }
.pop-border-t { grid-area: 1 / 2 / 2 / 3; background: url('/interface4/popup_t.png') repeat-x; }
.pop-border-tr { grid-area: 1 / 3 / 2 / 4; background: url('/interface4/popup_tr.png') no-repeat; }
.pop-border-l { grid-area: 2 / 1 / 3 / 2; background: url('/interface4/popup_l.png') repeat-y; }
.pop-border-r { grid-area: 2 / 3 / 3 / 4; background: url('/interface4/popup_r.png') repeat-y; }
.pop-border-bl { grid-area: 3 / 1 / 4 / 2; background: url('/interface4/popup_bl.png') no-repeat; }
.pop-border-b { grid-area: 3 / 2 / 4 / 3; background: url('/interface4/popup_b.png') repeat-x; }
.pop-border-br { grid-area: 3 / 3 / 4 / 4; background: url('/interface4/popup_br.png') no-repeat; }

/* Main popup content area */
.pop-content {
  grid-area: 2 / 2 / 3 / 3;
  background-image: url('/interface4/dropdownbg.png');
  position: relative;
  overflow: visible;
}

/* Popup header box */
.pop-header-box {
  width: 414px;
  height: 63px;
  background: url('/interface4/basepopup.png') -285px -56px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -10px;
  text-align: center;
  font-family: Copperplate, Copperplate Gothic Light, fantasy;
  color: #2f2419;
  font-size: 26px;
  font-weight: bold;
  line-height: 45px;
  text-shadow: 1px 1px 1px #f4eedf;
  z-index: 1000;
}

/* Close button for popup */
.pop-close-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  height: 22px;
  width: 21px;
  background: url('/interface4/basepopup.png') -666px -31px;
  cursor: pointer;
  border: 0;
  z-index: 20;
}
.pop-close-btn:hover { background: url('/interface4/basepopup.png') -666px -7px; }

/* Legacy table-based popup support */
.battle-popup-table { margin: auto; }
.pop_tl { height: 26px; width: 26px; background: url('/interface4/popup_tl.png'); }
.pop_t { height: 26px; background: url('/interface4/popup_t.png'); }
.pop_tr { height: 26px; width: 26px; background: url('/interface4/popup_tr.png'); }
.pop_l { width: 26px; background: url('/interface4/popup_l.png'); }
.pop_c { height: 498px; width: 938px; background-image: url('/interface4/dropdownbg.png'); position: relative; color: #2f2419; text-shadow: 1px 1px 1px #f4eedf; }
.pop_r { width: 26px; background: url('/interface4/popup_r.png'); }
.pop_bl { height: 26px; width: 26px; background: url('/interface4/popup_bl.png'); }
.pop_b { height: 26px; background: url('/interface4/popup_b.png'); }
.pop_br { height: 26px; width: 26px; background: url('/interface4/popup_br.png'); }

.pop_header {
  width: 414px;
  height: 63px;
  background: url('/interface4/basepopup.png') -285px -56px;
  position: absolute;
  left: 288px;
  top: -8px;
  text-align: center;
  font-family: Copperplate, Copperplate Gothic Light, fantasy;
  color: #2f2419;
  font-size: 26px;
  font-weight: bold;
  line-height: 55px;
  text-shadow: 1px 1px 1px #f4eedf;
}

.pop_close {
  position: absolute;
  top: 6px;
  left: 900px;
  height: 22px;
  width: 21px;
  background: url('/interface4/basepopup.png') -666px -31px;
  cursor: pointer;
  border: 0;
}
.pop_close:hover { background: url('/interface4/basepopup.png') -666px -7px; }

/* Popup container positioning */
.pop_table {
  display: none;
  z-index: 950;
  top: 50%;
  left: 50%;
  margin-left: -495px;
  margin-top: -275px;
  text-align: center;
  position: fixed;
  width: 990px;
  height: 550px;
}

.pop_footer {
  width: 371px;
  height: 49px;
  background: url('/interface4/basepopup.png') -292px -4px;
  position: absolute;
  left: 310px;
  top: 512px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pop_headlinetext {
  font-family: Copperplate, 'Copperplate Gothic Light', fantasy;
  font-size: 26px;
  color: #2f2419;
  text-shadow: 1px 1px 1px #f4eedf;
  font-weight: bold;
  margin-top: 8px;
}

.okpopupcontent {
  padding: 15px;
  overflow: hidden;
}

/* Dark overlay behind popups */
.darkbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('/interface4/darkbox.png');
  z-index: 900;
}

/* ============================================
   HERO OFFER POPUP STYLES
   ============================================ */

/* Hero offer overlay - now handled by Popup component (popup.css) */
/* Legacy ID-based styles removed to avoid conflicts with .wb-popup-overlay */

/* Hero offer popup container using CSS grid for borders */
.hero-offer-popup-container {
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  grid-template-rows: 26px 480px 26px;
  width: 990px;
  height: 532px;
}

/* Main layout inside popup (3 column) */
.hero-offer-layout {
  display: flex;
  flex-direction: row;
  height: 100%;
  padding: 25px 15px 15px 15px;
}

/* Left section: Minimap and Bank */
.hero-offer-minimap-section {
  width: 302px;
  flex-shrink: 0;
}

.hero-offer-bank {
  font-size: 14px;
  font-weight: bold;
  color: #5f3b1a;
  text-shadow: 0px 1px 1px #faf2e1;
  padding: 5px;
  display: flex;
  gap: 8px;
}

.hero-offer-gold-value {
  color: #c9a227;
}

/* Center section: Hero selection with scroller */
.hero-offer-select-section {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-offer-portrait-large {
  margin-bottom: 10px;
}

.hero-offer-portrait-large > div {
  box-shadow: 1px 1px 4px #000;
}

/* Explicit sizing for hero frames in offer popup - coordinates from ver102/css/units_20120510.css */
.hero-offer-portrait-large .heroknightframe { background: url('/units/set2/heroes.png') -0px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .heroamazonframe { background: url('/units/set2/heroes.png') -306px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herodreadknightframe { background: url('/units/set2/heroes.png') -153px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herohorselordframe { background: url('/units/set2/heroes.png') -762px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herobarbarianframe { background: url('/units/set2/heroes.png') -458px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .heroassassinframe { background: url('/units/set2/heroes.png') -610px -130px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herorangerframe { background: url('/units/set2/heroes.png') -0px -280px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herodwarfframe { background: url('/units/set2/heroes.png') -153px -280px; width: 150px; height: 150px; }
.hero-offer-portrait-large .herosorceressframe { background: url('/units/set2/heroes.png') -458px -280px; width: 150px; height: 150px; }

/* Scroll section with arrows and hero frames */
.hero-offer-scroll-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 280px;
}

.hero-offer-scroll-up,
.hero-offer-scroll-down {
  width: 98px;
  height: 32px;
  cursor: pointer;
  background-repeat: no-repeat;
}

.hero-offer-scroll-up {
  background: url('/interface4/updown.png') 0px -162px;
}

.hero-offer-scroll-down {
  background: url('/interface4/updown.png') 0px 0px;
}

.hero-offer-scroll-up:hover,
.hero-offer-scroll-down:hover {
  filter: brightness(1.2);
}

.hero-offer-scroll-viewport {
  width: 170px;
  height: 230px;
  overflow: hidden;
}

.hero-offer-scroll-content {
  width: 170px;
  transition: top 0.4s ease;
  position: relative;
  top: 0;
}

/* Hero frames side by side in rows (2 per row) - 75px each with 4px total margin = 79px x 2 = 158px per row */
.hero-offer-scroll-content > div {
  box-shadow: 1px 1px 2px #000;
  cursor: pointer;
  margin: 2px;
  float: left !important;
  display: block;
}

.hero-offer-scroll-content > div:hover {
  filter: brightness(1.1);
  box-shadow: 2px 2px 6px #000;
}

/* Right section: Hero info */
.hero-offer-info-section {
  flex: 1;
  padding-left: 20px;
  font-size: 14px;
  font-weight: bold;
  color: #5f3b1a;
  text-shadow: 0px 1px 1px #faf2e1;
  overflow-y: auto;
}

.hero-offer-instruction {
  font-size: 16px;
  margin-bottom: 15px;
}

.hero-offer-hero-name {
  font-size: 20px;
  margin-bottom: 10px;
  color: #3d2815;
}

.hero-offer-name-input {
  margin-bottom: 15px;
}

.hero-offer-name-input label {
  display: inline-block;
  width: 50px;
}

.hero-offer-name-input input {
  width: 150px;
  padding: 4px 8px;
  font-size: 14px;
  border: 1px solid #5a3d2b;
  background: #faf2e1;
  color: #3d2815;
}

.hero-offer-cost-row,
.hero-offer-level-row {
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
}

.hero-offer-cost-value {
  background: url('/icons/icons.png') no-repeat 1px -243px;
  width: 66px;
  height: 26px;
  display: inline-block;
  text-align: right;
  padding-right: 5px;
  font-size: 14px;
  font-weight: bold;
  line-height: 28px;
  color: #5f3b1a;
}

.hero-offer-allies-section {
  margin-top: 20px;
}

.hero-offer-allies-label {
  margin-bottom: 10px;
}

.hero-offer-allies-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.hero-offer-allies-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 10px;
}

.hero-offer-allies-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Footer with OK/Cancel buttons */
.hero-offer-footer {
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  width: 371px;
  height: 49px;
  background: url('/interface4/basepopup.png') -292px -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.hero-offer-btn {
  background: url('/interface4/basepopup.png') -130px -48px;
  background-color: #dab676;
  width: 151px;
  height: 36px;
  border: none;
  cursor: pointer;
  color: #5f3b1a;
  font-weight: bold;
  font-size: 18px;
  font-family: sans-serif;
  line-height: 28px;
  margin-top: 6px;
}

.hero-offer-btn:active {
  background: url('/interface4/basepopup.png') -130px -4px;
  background-color: #dab676;
}

.hero-offer-btn.disabled {
  background: url('/interface4/basepopup.png') -130px -90px;
  background-color: #dab676;
  cursor: not-allowed;
}

.hero-offer-btn.disabled:active {
  background: url('/interface4/basepopup.png') -130px -90px;
}

/* OK/Cancel buttons */
button.ok1 {
  background: url('/interface4/basepopup.png') 0px -56px;
  width: 80px;
  height: 35px;
  border: none;
  cursor: pointer;
  color: #3d310a;
  font-weight: bold;
  font-size: 14px;
}

button.ok1:hover {
  background: url('/interface4/basepopup.png') 0px -91px;
}

button.notok {
  background: url('/interface4/basepopup.png') 0px -56px;
  width: 80px;
  height: 35px;
  border: none;
  cursor: not-allowed;
  opacity: 0.5;
  color: #3d310a;
  font-weight: bold;
  font-size: 14px;
}

/* Hero offer popup styles */
.hero_content1 { width: 160px; height: 460px; }
.hero_content2 { width: 160px; height: 300px; }
.hero_content3 { width: 160px; height: 230px; overflow: hidden; }
.hero_scroller { width: 170px; height: 540px; transition: transform 0.3s ease; }
.hero_herodata { margin-left: 5px; width: 435px; height: 450px; }
.hero_fontsize { font-size: 14px; line-height: 1.4; }
.hero_bank { width: 130px; padding-top: 3px; font-size: 14px; }
.hero_lineheight { line-height: 24px; }

/* Up/down arrows for hero scroller */
.uparrow {
  width: 75px;
  height: 30px;
  background: url('/interface4/miscpanels.png') -0px -0px;
  cursor: pointer;
  float: left;
  margin-left: 2px;
}

.downarrow {
  width: 75px;
  height: 30px;
  background: url('/interface4/miscpanels.png') -75px -0px;
  cursor: pointer;
  float: left;
  margin-left: 2px;
}

/* City info in popup - center column */
.cty_info2 { width: 305px; padding: 5px; float: left; }
.cty_info3 { margin-bottom: 5px; border: solid 0px; }
div.popup_minimap { width: 100%; box-sizing: border-box; aspect-ratio: 1; border: solid black 1px; background-color: #000000; float: left; margin-bottom: 5px; }
div.popup_minimap canvas { width: 100%; height: 100%; }

/* Vectoring toggle button */
div.vectortogg1 { width: 67px; height: 35px; background: url('/interface4/miscpanels.png') -448px 0px; float: left; margin: 0px 0px 10px 0px; cursor: pointer; }
div.vectortogg2 { width: 67px; height: 35px; background: url('/interface4/miscpanels.png') -448px -35px; float: left; margin: 0px 0px 10px 0px; cursor: pointer; }
div.vectortogg1:hover, div.vectortogg2:hover { filter: brightness(1.2); }

/* Gold cost icon */
.mbaseicon.cost {
  background: url('/interface4/mainpanels.png') -0px -287px;
  width: 70px;
  height: 30px;
  display: inline-block;
  text-align: center;
  line-height: 30px;
  font-weight: bold;
  color: #5f3b1a;
}

/* Treasury display - defined in icons.css, do not duplicate */
/* .tresury is in icons.css using icons.png sprite */
.tresury-large {
  background: url('/interface4/mainpanels.png') -0px -287px;
  width: 70px;
  height: 30px;
  display: inline-block;
  text-align: center;
  line-height: 30px;
  font-weight: bold;
  color: #5f3b1a;
}

/* Battle table structure (legacy) */
.battletable { width: 940px; height: 440px; }
.battletd1 { width: 124px; }
.battletd2 { width: 610px; height: 350px; }
.battletd3 { width: 180px; }

/* Battle margin classes (original) */
.battlemargin1 { float: left; margin: 0px 0px 5px 10px; }
.battlemargin2 { float: left; margin-left: 10px; }
.battlemargin7 { margin-left: 10px; margin-top: 20px; }
.battlemargin8 { float: left; margin-left: 10px; margin-bottom: 42px; }
.battlemargin9 { float: left; margin: 10px 0px 0px 10px; }
.battlemargin10 { text-align: left; width: 150px; margin: 0px 0px 0px 10px; }
.battlemargin11 { height: 206px; }

/* Battle list (player info) */
ul.battlelist { list-style: none; margin-left: -38px; width: 126px; padding: 0; color: #5f3b1a; }
ul.battlelist li { margin-bottom: 4px; color: #5f3b1a; font-family: arial; font-size: 12px; }

/* Unit display rows */
div.battleselectrow { width: 616px; }
div.battleselectrowstats { height: 12px; width: 616px; font-size: 10px; font-family: arial; float: left; color: #5f3b1a; }

div.selectrowunit { float: left; width: 77px; }
div.selectrowhp { float: left; width: 77px; font-size: 10px; color: #5f3b1a; font-family: arial; }

/* Blood splash effect */
.symbol_blood {
  background: url('/interface4/miscpanels.png') -384px -64px;
  width: 64px;
  height: 64px;
  z-index: 6;
  display: none;
  position: absolute;
  top: 0;
  left: 7px;
  pointer-events: none;
}

/* Ensure unit container is positioned for blood splash overlay */
div.selectrowunit > div {
  position: relative;
}

/* Shield icons (player colors) */
.shield_0 { background: url('/css/interface/transparent.png') no-repeat -230px -89px; width: 25px; height: 34px; float: left; }
.shield_1 { background: url('/css/interface/transparent.png') no-repeat -53px -89px; width: 25px; height: 34px; float: left; }
.shield_2 { background: url('/css/interface/transparent.png') no-repeat -153px -89px; width: 25px; height: 34px; float: left; }
.shield_3 { background: url('/css/interface/transparent.png') no-repeat -77px -89px; width: 25px; height: 34px; float: left; }
.shield_4 { background: url('/css/interface/transparent.png') no-repeat -205px -89px; width: 25px; height: 34px; float: left; }
.shield_5 { background: url('/css/interface/transparent.png') no-repeat -27px -89px; width: 25px; height: 34px; float: left; }
.shield_6 { background: url('/css/interface/transparent.png') no-repeat -2px -89px; width: 25px; height: 34px; float: left; }
.shield_7 { background: url('/css/interface/transparent.png') no-repeat -179px -89px; width: 25px; height: 34px; float: left; }
.shield_8 { background: url('/css/interface/transparent.png') no-repeat -102px -89px; width: 25px; height: 34px; float: left; }

/* Tiny shield icons for battle list */
.shield_tiny0 { background: url('/interface4/mainpanels.png') -159px -80px; float: left; height: 22px; width: 15px; }
.shield_tiny1 { background: url('/interface4/mainpanels.png') -175px -56px; float: left; height: 22px; width: 15px; }
.shield_tiny2 { background: url('/interface4/mainpanels.png') -191px -56px; float: left; height: 22px; width: 15px; }
.shield_tiny3 { background: url('/interface4/mainpanels.png') -192px -80px; float: left; height: 22px; width: 15px; }
.shield_tiny4 { background: url('/interface4/mainpanels.png') -159px -103px; float: left; height: 22px; width: 15px; }
.shield_tiny5 { background: url('/interface4/mainpanels.png') -176px -102px; float: left; height: 22px; width: 15px; }
.shield_tiny6 { background: url('/interface4/mainpanels.png') -193px -103px; float: left; height: 22px; width: 15px; }
.shield_tiny7 { background: url('/interface4/mainpanels.png') -159px -127px; float: left; height: 22px; width: 15px; }
.shield_tiny8 { background: url('/interface4/mainpanels.png') -156px -56px; float: left; height: 22px; width: 15px; }

/* Battle action (info panel) */
.battleaction {
  width: 180px;
  height: 420px;
  overflow-y: scroll;
  margin-top: 0px;
  text-align: left;
  position: absolute;
  border: solid 1px;
  display: none;
  margin-left: -20px;
  background-color: #f2d596;
}

/* Battle list (for viewing past battles) */
.battlelist {
  width: 475px;
  max-height: 460px;
  overflow-y: auto;
  text-align: left;
}

.battlebar1 {
  background: url('/interface4/miscpanels.png') -0px -132px;
  color: #5f3b1a;
  float: left;
  width: 455px;
  padding:1px;
  margin-bottom: 3px;
  cursor: pointer;
}


.battlebar2 {
  background: url('/interface4/miscpanels.png') -0px -170px;
  color: #5f3b1a;
  float: left;
  width: 455px;
  padding: 3px 10px;
  margin-bottom: 3px;
}

/* Toggle button container */
.battlelist_button_container {
  float: left;
  width: 90px;
  margin-left: 5px;
}

/* My battles button */
div.mybattles1 { width: 68px; height: 36px; background: url('/interface4/mainpanels.png') -416px -250px; float: left; margin-bottom: 5px; cursor: pointer; }
div.mybattles2 { width: 68px; height: 36px; background: url('/interface4/mainpanels.png') -484px -250px; float: left; margin-bottom: 5px; cursor: pointer; }

/* Team battles button */
div.teambattles1 { width: 68px; height: 36px; background: url('/interface4/mainpanels.png') -416px -215px; float: left; cursor: pointer; }
div.teambattles2 { width: 68px; height: 36px; background: url('/interface4/mainpanels.png') -484px -215px; float: left; cursor: pointer; }

/* Mini battle marker on minimap */
div.minibattle {
  background: url('/interface4/minimap-icons.png') -75px -0px;
  width: 9px;
  height: 9px;
  position: absolute;
  z-index: 25;
}

/* Battle sword icons */
.battlesword { background: url('/interface4/miscpanels.png') -333px -5px; width: 15px; height: 18px; float: left; margin-left: 3px; }
.defendsword { background: url('/interface4/miscpanels.png') -354px -2px; width: 18px; height: 22px; float: left; }

/* Battle buttons */
.ok3 {
  background: url('/interface4/basepopup.png') -130px -48px;
  width: 151px;
  height: 36px;
  border: 0px;
  background-color: #f1d28f;
  margin-top: 6px;
  margin-left: 0px;
  cursor: pointer;
}
.ok3:hover { background: url('/interface4/basepopup.png') -130px -4px; }
.ok3:focus { outline: none; box-shadow: none; }
.ok4 { background: url('/interface4/basepopup.png') -130px -4px; width: 151px; height: 36px; border: 0px; background-color: #f1d28f; margin-top: 6px; margin-left: 0px; }

.buttontext {
  width: 100%;
  height: 24px;
  font-family: sans-serif;
  font-size: 18px;
  font-style: normal;
  color: #5f3b1a;
  font-weight: bold;
  cursor: default;
  line-height: 28px;
}

/* Battle speed controls */
.battlespeed { width: 35px; height: 14px; float: left; margin: 10px; }
.battlespeeddrag { width: 150px; float: left; margin: 0px 0px 20px 10px; }
.battlespeeddrag input[type="range"] { width: 100%; }

/* Close button style */
.chatwin_close {
  width: 21px;
  height: 22px;
  float: right;
  margin-right: 5px;
  margin-top: 2px;
  background: url('/interface4/basepopup.png') -666px -31px;
  cursor: pointer;
}
.chatwin_close:hover { background: url('/interface4/basepopup.png') -666px -7px; }

/* .info_close — defined in city.css */

/* Info button */
.info1 {
  width: 58px;
  height: 41px;
  background: url(/interface4/miscpanels.png) 183px -70px;
  cursor: pointer;
}

.info1:hover { background: url(/interface4/miscpanels.png) 124px -70px;}

.sidewiki1 {
  background: url('/interface4/mainpanels.png') -282px -73px;
  width: 68px;
  height: 36px;
  cursor: pointer;
}

.sidewiki2 {
  background: url('/interface4/mainpanels.png') -282px -109px;
  width: 68px;
  height: 36px;
  cursor: pointer;
}


/* Round header text */
.roundhead { font-family: arial; color: #5f3b1a; font-weight: bold; font-size: 16px; }

/* Battle modifier icons (clearbaseicon style) */
.clearbaseicon {
  width: 56px;
  height: 26px;
  margin: 2px 4px 2px 2px;
  text-align: right;
  float: left;
  font-size: 14px;
  font-weight: bold;
  line-height: 28px;
  padding: 0px;
  clear: both;
}

/* Modifier icon backgrounds */
.wall { background: url('/icons/icons.png') no-repeat 1px -1269px; }
.siege { background: url('/icons/icons.png') no-repeat 1px -81px; }
.morale { background: url('/icons/icons.png') no-repeat 1px -1215px; }
.fear { background: url('/icons/icons.png') no-repeat 1px -837px; }
.g_ambush { background: url('/icons/icons.png') no-repeat 1px -675px; }
.ward { background: url('/icons/icons.png') no-repeat 1px -1162px; }
.leadership { background: url('/icons/icons.png') no-repeat 1px -1026px; }
.chaos { background: url('/icons/icons.png') no-repeat 1px -648px; }

/* Environment terrain icons */
.env_bridge { width: 150px; height: 150px; background: url('/enviroment/bridge.png'); background-size: 150px 150px; border: solid 1px; }
.env_catacomb { width: 150px; height: 150px; background: url('/enviroment/catacomb.png'); background-size: 150px 150px; border: solid 1px; }
.env_city { width: 150px; height: 150px; background: url('/enviroment/city.png'); background-size: 150px 150px; border: solid 1px; }
.env_desert { width: 150px; height: 150px; background: url('/enviroment/desert.png'); background-size: 150px 150px; border: solid 1px; }
.env_forest { width: 150px; height: 150px; background: url('/enviroment/forest.png'); background-size: 150px 150px; border: solid 1px; }
.env_hill { width: 150px; height: 150px; background: url('/enviroment/hill.png'); background-size: 150px 150px; border: solid 1px; }
.env_mountain { width: 150px; height: 150px; background: url('/enviroment/mountain.png'); background-size: 150px 150px; border: solid 1px; }
.env_ocean { width: 150px; height: 150px; background: url('/enviroment/ocean.png'); background-size: 150px 150px; border: solid 1px; }
.env_open { width: 150px; height: 150px; background: url('/enviroment/open.png'); background-size: 150px 150px; border: solid 1px; }
.env_razed { width: 150px; height: 150px; background: url('/enviroment/razed.png'); background-size: 150px 150px; border: solid 1px; }
.env_river { width: 150px; height: 150px; background: url('/enviroment/river.png'); background-size: 150px 150px; border: solid 1px; }
.env_ruin { width: 150px; height: 150px; background: url('/enviroment/ruin.png'); background-size: 150px 150px; border: solid 1px; }
.env_shore { width: 150px; height: 150px; background: url('/enviroment/shore.png'); background-size: 150px 150px; border: solid 1px; }
.env_snow { width: 150px; height: 150px; background: url('/enviroment/snow.png'); background-size: 150px 150px; border: solid 1px; }
.env_swamp { width: 150px; height: 150px; background: url('/enviroment/swamp.png'); background-size: 150px 150px; border: solid 1px; }
.env_temple { width: 150px; height: 150px; background: url('/enviroment/temple.png'); background-size: 150px 150px; border: solid 1px; }
.env_volcan { width: 150px; height: 150px; background: url('/enviroment/volcan.png'); background-size: 150px 150px; border: solid 1px; }
.env_water { width: 150px; height: 150px; background: url('/enviroment/water.png'); background-size: 150px 150px; border: solid 1px; }

/* Mini icons for battle list */
.micon { width: 28px; height: 26px; float: left; }
.micon.viewradius { background: url('/icons/icons.png') no-repeat 1px -1242px; }
.micon.undeadlore { background: url('/icons/icons.png') no-repeat 1px -1080px; }
.micon.city { background: url('/icons/icons.png') no-repeat 1px -27px; }
.micon.open { background: url('/icons/icons.png') no-repeat 1px -270px; }
.micon.forest { background: url('/icons/icons.png') no-repeat 1px -459px; }
.micon.hill { background: url('/icons/icons.png') no-repeat 1px 1px; }
.micon.desert { background: url('/icons/icons.png') no-repeat 1px -162px; }
.micon.swamp { background: url('/icons/icons.png') no-repeat 1px -810px; }
.micon.snow { background: url('/icons/icons.png') no-repeat 1px -621px; }
.micon.shore { background: url('/icons/icons.png') no-repeat 1px -135px; }
.micon.ocean { background: url('/icons/icons.png') no-repeat 1px -135px; }
.micon.mountain { background: url('/icons/icons.png') no-repeat 1px -135px; }

/* Hover effect for battle list table */
table.hover tr:hover { background-color: rgba(255, 255, 255, 0.1); }

/* Player color indicators */
.player-color-1 { color: #4a90d9; } /* Blue */
.player-color-2 { color: #e74c3c; } /* Red */
.player-color-3 { color: #2ecc71; } /* Green */
.player-color-4 { color: #f39c12; } /* Orange */
.player-color-5 { color: #9b59b6; } /* Purple */
.player-color-6 { color: #1abc9c; } /* Teal */
.player-color-7 { color: #e91e63; } /* Pink */
.player-color-8 { color: #795548; } /* Brown */
.player-color-0 { color: #888888; } /* Neutral */

/* ============================================
   BATTLE POPUP DIV-BASED LAYOUT STYLES
   ============================================ */

/* Battle list layout with minimap */
.battle-list-layout {
  display: flex;
  flex-direction: row;
  padding: 10px 10px 10px 10px;
  height: calc(100% - 50px);
  gap: 5px;
}

/* Minimap container in battle list - fixed 300x300 */
.battle-list-minimap-container {
  position: relative;
  width: 300px;
  height: 300px;
  border: 2px solid #5f3b1a;
  background: #000000;
  overflow: hidden;
  flex-shrink: 0;
}

#battle-minimap-canvas {
  display: block;
  /* Size set dynamically by JS to maintain aspect ratio */
}


/* Battle list items */
.battle-list-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 4px 4px 4px;
  line-height: 26px;
  width: 100%;
}
.battle-list-row:hover { background-color: rgba(239, 234, 178, 0.3); }

.battle-list-row .battlesword {
  margin-right: 4px;
}

.battle-list-row .micon {
  float: none;
  flex-shrink: 0;
}

.battle-list-row .micon:first-of-type {
  margin-left: auto;
}

.battle-player-text {
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
  min-width: 90px;
}

.battle-list-empty {
  color: #5f3b1a;
  font-family: arial;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* Main battle viewer layout (3-column) */
.battle-main-layout {
  display: flex;
  flex-direction: row;

  height: calc(100% - 35px);
  gap: 9px;
}

/* Battle viewer columns */
.battle-col-left {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.battle-col-middle {
  width: 616px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.battle-col-right {
  width: 154px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Defender section at top, attacker at bottom */
.battle-defender-section {
  height: 310px;
}

.battle-attacker-section {
  /* Takes space at bottom */
}

.battle-defender-info {
  height: 340px;
}

.battle-attacker-info {
}

/* Player info in battle viewer */
.battle-player-info {
  margin-bottom: 10px;
}

.battlelist-info {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 126px;
}

.battlelist-info li {
  margin-bottom: 4px;
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
}

.battle-role-label {
  color: #5f3b1a;
  font-weight: bold;
  font-size: 14px;
  margin-right: 4px;
}

.battle-player-name-text {
  color: #5f3b1a;
  font-weight: bold;
}

/* Unit separator between attacker and defender */
.battle-unit-separator {
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, transparent, #5f3b1a, transparent);
  margin: 15px 0;
}

/* Battle info button area */
.battle-info-btn {
  margin-bottom: 10px;
}

/* Battle buttons area */
.battle-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

/* Battle speed controls */
.battle-speed-area {
  margin-top: 10px;
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
}

.battle-speed-label {
  color: #5f3b1a;
  font-weight: bold;
}

.battle-speed-value {
  color: #5f3b1a;
  margin-left: 5px;
}

.battle-speed-area input[type="range"] {
  width: 100%;
  margin-top: 5px;
}

/* Battle probability area */
.battle-prob-area {
  margin-top: 10px;
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
}

.battle-prob-text {
  color: #5f3b1a;
  margin-bottom: 2px;
}

/* Battle environment/terrain display */
.battle-env-area,
.battle-terrain-area {
  margin-top: 10px;
}

.battle-terrain-label {
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
  margin-bottom: 5px;
}

/* Battle round text and info */
.battle-round-header {
  color: #5f3b1a;
  font-family: arial;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  margin-bottom: 10px;
}

.battle-totals-display {
  display: flex;
  justify-content: space-between;
  color: #5f3b1a;
  font-family: arial;
  font-size: 12px;
  margin-top: 5px;
  padding: 0 50px;
}

/* Override default white text in popup - enforce dark brown */
.pop-content,
.pop-content * {
  color: #5f3b1a;
}

/* Fix specific elements that need different colors */
.pop-content .symbol_blood,
.pop-content .shield_0, .pop-content .shield_1, .pop-content .shield_2,
.pop-content .shield_3, .pop-content .shield_4, .pop-content .shield_5,
.pop-content .shield_6, .pop-content .shield_7, .pop-content .shield_8,
.pop-content .shield_tiny0, .pop-content .shield_tiny1, .pop-content .shield_tiny2,
.pop-content .shield_tiny3, .pop-content .shield_tiny4, .pop-content .shield_tiny5,
.pop-content .shield_tiny6, .pop-content .shield_tiny7, .pop-content .shield_tiny8 {
  color: transparent;
}

/* ========================================
   GAME LOBBY SCENE
   ======================================== */

.game-lobby {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--spacing-lg);
  max-width: 1200px;
  min-width:1024px;
  margin: 0 auto;
}

.game-lobby-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--border-gold);
}

.game-lobby-title {
  font-size: 1.8rem;
  color: var(--accent-gold);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-lobby-type {
  background: var(--bg-light);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.game-lobby-content {
  display: grid;
  margin:5px;
  grid-template-columns: auto 1fr auto;
  gap: var(--spacing-lg);
  flex: 1;
  overflow: hidden;
}

.section-title {
  font-size: 1.1rem;
  color: var(--accent-gold-light);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

/* Map Selection */
.game-lobby-map-section {
  display: flex;
  flex-direction: column;
  margin:5px;
}

.map-preview-container {
  width: 260px;
  height: 260px;
  background: #c4a46a;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  overflow: hidden;
}

.map-preview-container:hover {
  border-color: var(--accent-gold);
}

.map-preview-placeholder {
  color: var(--text-muted);
  text-align: center;
}

.map-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.map-info {
  margin-top: var(--spacing-md);
}

.map-info-row {
  display: flex;
  justify-content: start;
  padding: 2px 0;
  font-size: 12px;
}

.map-info-label {
  color: var(--text-muted);
}

.map-info-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Player Slots */
.game-lobby-players-section {
  margin:5px;
  display: flex;
  flex-direction: column;
}

.player-slots {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.player-slot {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: var(--bg-panel);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.player-slot.my-slot {
  border-color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.1);
}

.player-slot-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.player-slot-info {
  flex: 1;
  min-width: 0;
}

.secret-name-section {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-sm);
  border-top: 1px solid rgba(138,118,73,0.3);
}

.secret-name-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.player-slot-secret {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-light);
  color: var(--text-primary);
  box-sizing: border-box;
}

.player-slot-secret::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.player-slot-color-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-slot-name {
  color: var(--accent-gold);
  font-weight: 500;
}

.player-slot-select {
  width: 100%;
  max-width: 120px;
  font-size: 0.85rem;
  padding: 4px 8px;
}

.player-slot-actions {
  flex-shrink: 0;
}

.player-slot-actions .btn-small {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.player-slot-team {
  background: var(--bg-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Joiner slot styles */
.player-slot-status {
  font-size: 0.9rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.player-slot-status.slot-open {
  color: var(--accent-green);
}

.player-slot-status.slot-ai {
  color: var(--accent-blue);
  background: rgba(74, 144, 217, 0.2);
}

.player-slot-status.slot-closed {
  color: var(--text-muted);
  background: rgba(102, 102, 102, 0.2);
}

.player-slot-name.slot-taken {
  color: var(--accent-gold);
}

/* Joiner mode readonly elements */
.game-lobby.joiner-mode .map-preview-container.readonly {
  cursor: default;
}

.game-lobby.joiner-mode .map-preview-container.readonly:hover {
  border-color: var(--border-color);
}

.settings-readonly {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
}

.setting-label {
  color: var(--text-secondary);
}

.setting-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Settings Section */
.game-lobby-settings-section {
  margin:5px;
  display: flex;
  flex-direction: column;
}

.settings-tabs {
  display: flex;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--spacing-sm);
}

.settings-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--spacing-xs) var(--spacing-md);
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.settings-tab:hover {
  color: var(--text-primary);
  background: var(--bg-light);
}

.settings-tab.active {
  color: var(--accent-gold);
  background: var(--bg-light);
}

.settings-content {
  display: none;
}

.settings-content.active {
  display: block;
}

.settings-content .form-group {
  margin-bottom: var(--spacing-md);
}

.settings-content label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-group label {
  display: inline;
  margin-bottom: 0;
  cursor: pointer;
}

.checkbox-group.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkbox-group.disabled label {
  cursor: not-allowed;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--spacing-md) 0;
}

/* Action Buttons */
.game-lobby-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

/* Map Selector Modal */
.map-selector-search {
  margin-bottom: var(--spacing-md);
}

.map-selector-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.map-selector-item {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  background: var(--bg-light);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.map-selector-item:hover {
  background: var(--bg-medium);
}

.map-selector-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-panel);
}

.map-selector-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.map-selector-name {
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

.map-selector-details {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Team header in player slots */
.team-header {
  font-weight: bold;
  color: var(--accent-gold-light);
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-xs);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.team-header:first-child {
  margin-top: 0;
}

.team-alliance-lock {
  font-size: 11px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
}

/* Setup selection styling */
.setup-selection {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

/* ========================================
   MAP SELECTOR MODAL - ENHANCED
   ======================================== */

.map-selector-modal {
  width: 100%;
}

/* Override modal-content max-width when showing map selector */
#modal-content:has(.map-selector-modal) {
  max-width: 1200px;
  width: 95vw;
}

.map-selector-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.map-selector-filters #map-search {
  width: 180px;
}

.map-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

.map-filter-btn {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.map-filter-btn:hover {
  background: var(--bg-medium);
  color: var(--text-primary);
}

.map-filter-btn.active {
  background: var(--accent-gold);
  color: var(--bg-dark);
  border-color: var(--accent-gold);
}

/* 3-column grid layout for map list */
.map-selector-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  min-height: 500px;
  max-height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Map item styling */
.map-selector-item {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--bg-light);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.map-selector-item:hover {
  background: var(--bg-medium);
  border-color: var(--accent-gold);
}

.map-selector-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-panel);
  flex-shrink: 0;
}

.map-selector-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}

.map-selector-name {
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-selector-details {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.map-selector-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-player-filters {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.map-player-filters label {
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.map-player-filters input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* Responsive: single column on smaller screens */
@media (max-width: 700px) {
  .map-selector-modal {
    width: 100%;
  }

  .map-selector-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .map-selector-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Isometric/2D Render Toggle Button */
.btn-toggle-render {
  width: 40px;
  height: 20px;
  background: none;
  border: 1px solid #8a7649;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: var(--text-primary);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  transition: all var(--transition-fast);
}

.btn-toggle-render:hover {
  background-color: rgba(138, 118, 73, 0.3);
}

.btn-toggle-render:active {
  transform: translateY(0);
}

/* ===============================================
   Fight Order Popup
   =============================================== */

/* Fight order overlay - now handled by Popup component (popup.css) */
/* Legacy ID-based styles removed to avoid conflicts with .wb-popup-overlay */

/* Content area styling */
.fightorder-pop-content {
  background-image: url('/interface4/dropdownbg.png');
}

.fightorder-layout {
  padding: 10px;
  min-height: 450px;
  display: flex;
  gap: 10px;
}

/* Left column for tabs and unit stats */
.armylistbox {
  float: left;
  margin-bottom: 5px;
  padding: 2px;
  width: 130px;
  height: 446px;
}

.lefttab {
  cursor: pointer;
  border-top: solid 1px #8a6f32;
  border-left: solid 1px #8a6f32;
  border-bottom: solid 1px #8a6f32;
  border-right: solid 1px #8a6f32;

  margin-bottom: 5px;
  padding: 4px;
  width: 139px;
  float: left;
  font-size: 12px;
  font-weight: bold;
  color: #8a6f32;
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
  text-align: center;
  position:relative
}

.lefttab:hover {
  border-top: solid 1px #FFFFFF;
  border-left: solid 1px #FFFFFF;
  border-bottom: solid 1px #FFFFFF;
  background: rgba(255, 255, 255, 0.1);
}

.lefttabactive {
  cursor: pointer;
  border-top: solid 1px #8a6f32;
  border-left: solid 1px #8a6f32;
  border-bottom: solid 1px #8a6f32;
  border-right: solid 1px #f3d493;
  position: relative;
  z-index: 2;
  margin-bottom: 5px;
  padding: 4px;
  width: 139px;
  float: left;
  font-size: 12px;
  font-weight: bold;

  background: rgba(240, 210, 144, 0.0);
  text-align: center;
  position: relative;
}

/* Right column: scrollable unit list */
.fightorderbox {
  width: 798px;
  height: 450px;
  overflow-y: auto;
  float: left;
  border: solid 1px #8a6f32;
  padding: 2px 0;
}

.fightorderlist {
  width: 124px;
  height: 64px;
  float: left;
  margin-left: 3px;
  margin-bottom: 3px;
  cursor: grab;
  background: url('/interface4/miscpanels.png') -3px -67px;
  padding: 0px;
  border: 2px solid transparent;
  user-select: none;
}

.fightorderlist:active {
  cursor: grabbing;
}

.fightorderlist:hover {
  padding: 1px 0px 0px 1px;
}

/* Drag clone - the element that follows the mouse */
.fightorderlist.drag-clone {
  opacity: 1 !important;
  cursor: grabbing;
}

/* Placeholder - shows where item will be dropped */
.fightorderlist.drag-placeholder {
  background: rgba(240, 210, 144, 0.3) !important;
  border: 2px dashed #f0d290 !important;
}

/* Original item while dragging - hidden */
.fightorderlist.dragging {
  display: none;
}

/* Mini fight order (quick reorder for selected group) */
.fightorderlistmini {
  width: 36px;
  height: 36px;
  margin: 4px;
  border: solid 1px #aa9d85;
  background: #f3ca75;
  float: left;
  cursor: move;
  padding: 2px;
  user-select: none;
  overflow: hidden;
}

.fightorderlistmini:hover {
  border-color: #8a7649;
  background: #f8d88a;
}

.fightorderlistmini.drag-clone {
  opacity: 1 !important;
  cursor: grabbing;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.fightorderlistmini.drag-placeholder {
  background: rgba(240, 210, 144, 0.3) !important;
  border: 2px dashed #f0d290 !important;
}


/* Unit stats preview within armylistbox */
#fightorder-unitstats {

  overflow-y: auto;
}

#fightorder-unitstats .stats-placeholder {
  color: #8a7a6a;
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  font-style: italic;
}

#fightorder-unitstats .unit-detail {
  color: #d4c4a0;
  font-size: 12px;
}

#fightorder-unitstats .unit-detail-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #6f6143;
}

#fightorder-unitstats .unit-detail-name {
  font-weight: bold;
  font-size: 13px;
  text-align: center;
}

#fightorder-unitstats .unit-stats-grid {
  display: flex;
  flex-direction: inherit;
  gap: 5px;
}

#fightorder-unitstats .stat-row {
  display: flex;
  gap: 4px;
  justify-content: left;
  flex-wrap: wrap;
}

/* Footer - standard popup footer with OK/Cancel */
.fightorder-footer {
  clear: both;
}

/* ========================
   Popup Queue System
   ======================== */

/* Darkbox overlay for modal popups */
.popup-darkbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
}

.popup-darkbox.hidden {
  display: none;
}

/* Popup window base styles */
.popup-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
  border: 2px solid var(--border-gold, #c9a84c);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  z-index: 9999;
  min-width: 350px;
  max-width: 600px;
}

.popup-window.hidden {
  display: none;
}

.popup-window-header {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-gold, #c9a84c);
  border-radius: 6px 6px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-window-header span {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent-gold, #c9a84c);
}

.popup-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary, #888);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.popup-close-btn:hover {
  color: var(--text-primary, #fff);
}

.popup-window-body {
  padding: 20px;
  color: var(--text-primary, #ddd);
}

.popup-icon {
  width: 64px;
  height: 64px;
  float: left;
  margin-right: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.popup-text {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.popup-text strong {
  color: var(--accent-gold, #c9a84c);
}

.popup-window-footer {
  padding: 12px 20px 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* City Conquest Popup (uses small Popup component) */
.conquest-info {
  text-align: center;
  margin-bottom: 8px;
  color: #3f320c;
  font-size: 14px;
  font-weight: bold;
}

.conquest-info p {
  margin: 4px 0;
}

.conquest-gold-info {
  color: #5f3b1a;
  font-size: 13px;
}

.conquest-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conquest-option {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background-color: #e8d4a0;
  border: 1px solid #8a7649;
  cursor: pointer;
}

.conquest-option:hover {
  background-color: #fffce7;
}

.conquest-option-text {
  flex: 1;
  color: #3f320c;
  font-size: 13px;
}

.conquest-option-text strong {
  font-size: 14px;
  display: block;
  margin-bottom: 2px;
}

.conquest-option-text p {
  margin: 0;
  font-weight: normal;
  color: #5f3b1a;
  font-size: 12px;
}

/* Hero Level Up Icon */
.hero-icon {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border-gold, #c9a84c);
  border-radius: 4px;
}

/* City Lost Icon */
.city-lost-icon {
  background-color: #c0392b;
  border-radius: 4px;
}

/* City Conquest Popup - uses standard big popup (990x550) */

.city-conquest-popup .conquest-btn {
  cursor: pointer;
}

/* ================================
   CHAT POPUP STYLES
   Matching old version exactly
   ================================ */

/* Chat popup - uses standard big popup (990x550) */

.chat-popup .wb-popup-content {
  padding: 0;
}

.chat-popup .wb-popup-body-inner {
  padding: 0;
  height: 100%;
}

/* Legacy chat popup styles - kept for backwards compatibility */
.chatpopup {
  z-index: 900;
  top: 50%;
  margin-top: -275px;
  left: 50%;
  margin-left: -495px;
  text-align: left;
  position: absolute;
  width: 990px;
  height: 550px;
  padding: 0px;
  display: none;
}

#chat-popup-overlay.chatpopup {
  display: block;
}

/* Chat window content container */
#chatwin {
  width: 100%;
  height: 100%;
}

/* Player list boxes for send/show filters - exact match to old CSS */
.chatwin_plist {
  height: 250px;
  width: 160px;
  float: left;
  border: 1px solid;
  margin: 25px 0px 10px 10px;
  font-family: arial;
  line-height: 25px;
  background: #ffffff;
  padding: 5px;
  font-size: 12px;
  color: #000000;
  overflow-y: auto;
}

.chatwin_plist label {
  display: block;
  cursor: pointer;
}

.chatwin_plist input[type="checkbox"] {
  margin-right: 5px;
  vertical-align: middle;
}

.chatwin_plist input[type="submit"] {
  margin-top: 10px;
  cursor: pointer;
}

/* Chat message display area - exact match to old CSS */
.chatwin_chat {
  height: 430px;
  width: 538px;
  float: left;
  border: 1px solid;
  margin: 25px 10px 10px 10px;
  padding: 5px;
  line-height: 18px;
  background: #ffffff;
  min-height: 80px;
  font-size: 12px;
  font-family: arial;
  color: #000000;
  text-align: left;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Text entry area - exact match to old CSS */
.chatwin_entrydiv {
  margin: 0px 0px 10px 10px;
  width: 352px;
  height: 126px;
  float: left;
  border: 1px solid;
}

.chatwin_entry {
  width: 346px;
  height: 120px;
  background-color: #FFFFFF;
  float: left;
  border: none;
  padding: 3px;
  font-family: arial;
  font-size: 12px;
  resize: none;
}

.chatwin_entry:focus {
  outline: none;
}

/* Chat active indicator on button */
.chatactive {
  background: url('/interface4/icons.png') -130px -1456px !important;
  animation: pulse 1s ease-in-out infinite;
}

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

/* ==============================
   Map Browser Scene
   ============================== */
#scene-map-browser {
  overflow-y: auto;
}

.map-browser-container {
  padding: var(--spacing-md);
}

.map-browser-container > .panel {
  display: flex;
  flex-direction: column;
}

.map-browser-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.map-filter-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.map-filter-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.map-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.map-filter-checkbox input[type="checkbox"] {
  accent-color: var(--accent-gold);
}

.map-browser-count {
  padding: var(--spacing-xs) var(--spacing-md);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.map-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--spacing-md);
  padding: var(--spacing-md);
}

.map-browser-card {
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.map-browser-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.map-browser-thumb {
  width: 100%;
  height: 240px;
  flex-shrink: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.map-browser-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.map-browser-thumb.no-thumb {
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-light) 100%);
}

.map-browser-thumb.no-thumb::after {
  content: 'No Preview';
  color: var(--text-muted);
  font-size: 0.85rem;
}

.map-browser-card-body {
  padding: var(--spacing-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.map-browser-card-name {
  font-weight: bold;
  color: var(--text-primary);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-browser-card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.map-browser-card-creator {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.map-browser-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.map-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
}

.map-tag-ladder {
  background: rgba(201, 162, 39, 0.2);
  color: var(--accent-gold-light);
  border: 1px solid var(--accent-gold);
}

.map-tag-scenario {
  background: rgba(74, 144, 217, 0.2);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

.map-tag-submitted {
  background: rgba(76, 175, 80, 0.2);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.map-browser-card-stats {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.map-browser-card-actions {
  margin-top: auto;
  padding-top: var(--spacing-xs);
}

.map-browser-card-actions .btn {
  width: 100%;
}

/* ===================
   REPLAY VIEWER
   =================== */

.replay-viewer {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
}

.replay-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: url('/interface4/contentback.png');
  border-bottom: 2px solid var(--border-gold);
  min-height: 40px;
}

.replay-back-btn {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
}

.replay-back-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
}

.replay-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent-gold);
  flex: 1;
}

.replay-turn-inline {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-primary);
}

.replay-map-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background: #111;
}

.replay-map-container:active {
  cursor: grabbing;
}

.replay-map-inner {
  position: absolute;
  top: 0;
  left: 0;
}

.replay-controls {
  padding: 6px 16px;
  background: url('/interface4/contentback.png');
  border-top: 2px solid var(--border-gold);
  flex-shrink: 0;
}

.replay-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Sprite buttons from replaybuttons.png */
.replay-sprite-btn {
  cursor: pointer;
  float: left;
}
.btn_play1   { background: url('/interface4/replaybuttons.png') 0px -35px; width: 66px; height: 34px; }
.btn_play2   { background: url('/interface4/replaybuttons.png') -68px -35px; width: 66px; height: 34px; }
.btn_pause1  { background: url('/interface4/replaybuttons.png') 0px -105px; width: 66px; height: 34px; }
.btn_pause2  { background: url('/interface4/replaybuttons.png') -68px -105px; width: 66px; height: 34px; }
.btn_speedup1 { background: url('/interface4/replaybuttons.png') 0px -70px; width: 66px; height: 34px; }
.btn_speedup2 { background: url('/interface4/replaybuttons.png') -68px -70px; width: 66px; height: 34px; }
.btn_break1  { background: url('/interface4/replaybuttons.png') 0px -210px; width: 66px; height: 34px; }
.btn_break2  { background: url('/interface4/replaybuttons.png') -68px -210px; width: 66px; height: 34px; }
.btn_stepforward1 { background: url('/interface4/replaybuttons.png') 0px -140px; width: 66px; height: 34px; }
.btn_stepforward2 { background: url('/interface4/replaybuttons.png') -68px -140px; width: 66px; height: 34px; }
.btn_stepback1 { background: url('/interface4/replaybuttons.png') 0px -175px; width: 66px; height: 34px; }
.btn_stepback2 { background: url('/interface4/replaybuttons.png') -68px -175px; width: 66px; height: 34px; }
.btn_stop1   { background: url('/interface4/replaybuttons.png') 0px 0px; width: 66px; height: 34px; }
.btn_stop2   { background: url('/interface4/replaybuttons.png') -68px 0px; width: 66px; height: 34px; }

/* Text button (Perspective) - game style */
.replay-btn {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 4px 14px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  min-width: 40px;
  text-align: center;
}

.replay-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-dark);
}

.replay-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.replay-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

.replay-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-gold);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.replay-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent-gold);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.replay-speed {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 100px;
  text-align: right;
}

.replay-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.replay-player-stat {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  min-width: 140px;
}

.replay-player-stat strong {
  font-size: 13px;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.replay-fog-overlay {
  background: rgba(0, 0, 0, 0.7);
  z-index: 190;
  pointer-events: none;
}

.replay-player-stat span {
  color: var(--text-secondary);
}

/* Ruin search result toast */
.replay-ruin-toast {
  position: absolute;
  opacity: 0;
  transform: translateY(10px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  background-image: url('/interface4/dropdownbg.png');
  background-color: #f6dca4;
  border-top: solid 2px #f6e1a6;
  border-left: solid 2px #f6e1a6;
  border-right: solid 2px #8a7649;
  border-bottom: solid 2px #8a7649;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  border-radius: 4px;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}

.replay-ruin-toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.replay-ruin-toast-fade {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.replay-ruin-toast-title {
  font-size: 18px;
  font-weight: bold;
  color: #3a1e00;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  text-align: center;
}

.replay-ruin-toast-detail {
  font-size: 14px;
  font-weight: bold;
  color: #5a3e10;
  text-align: center;
}

.replay-ruin-toast-rewards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 2px;
}

.replay-ruin-reward {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: bold;
  color: #3a1e00;
}

.replay-ruin-reward-gold-icon {
  display: inline-block;
  width: 26px;
  height: 26px;
  background: url('/icons/icons.png') no-repeat 1px -243px;
  flex-shrink: 0;
}

.replay-ruin-reward-unit {
  display: inline-block;
  width: 32px;
  height: 32px;
  background-size: auto;
  background-repeat: no-repeat;
  flex-shrink: 0;
  transform: scale(0.5);
  transform-origin: center center;
  margin: -8px;
}

/* ═══════════════════════════════════════════════════════════
   Home Page
   ═══════════════════════════════════════════════════════════ */

.home-page {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  max-width: 1200px;
  margin: 0 auto;
}

.home-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.home-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* Home Games Section */
.home-games-section {
  padding-bottom: var(--spacing-sm);
}

.home-games-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--spacing-sm);
}

/* Game Row - horizontal card layout */
.game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(138, 118, 73, 0.4);
  transition: background var(--transition-fast);
}
.game-row:last-child {
  border-bottom: none;
}

/* Map thumbnail link wrapper */
.game-row-thumb-link {
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}
.game-row-thumb-link::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.15s;
  border-radius: 4px;
}
.game-row-thumb-link:hover::after {
  background: rgba(255, 255, 255, 0.25);
}
.game-row-thumb {
  width: 75px;
  height: 75px;
  border-radius: 4px;
  border: 1px solid #8a7649;
  display: block;
  object-fit: cover;
  background: #c4a46a;
}

/* Clickable shields hover */
.shield-clickable {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}
.shield-clickable:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Play button in game row */
.game-row-play-btn {
  margin-top: 4px;
  font-size: 11px;
  padding: 2px 10px;
}

/* Delete button for finished games */
.game-row-delete-btn {
  margin-top: 4px;
  font-size: 11px;
  padding: 2px 10px;
  color: #ff4444;
  border-color: #ff4444;
  background: transparent;
}
.game-row-delete-btn:hover {
  background: #ff4444;
  color: #fff;
}

/* Clickable info/right areas */
.game-row-play {
  cursor: pointer;
}

/* Replay list rows — entire row is clickable */
.replay-row {
  cursor: pointer;
}
.replay-row:hover {
  background: rgba(138, 118, 73, 0.15);
}
.replay-player-chip {
  display: inline-block;
  margin-right: 6px;
  font-size: 0.85em;
}

/* Game info area */
.game-row-info {
  flex: 1;
  min-width: 0;
}
.game-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.game-row-name {
  font-weight: bold;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-row-map {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Center shields box */
.game-row-shields {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px 8px;
}

.game-row-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Icons for ladder/simultaneous */
.game-row-icons {
  display: flex;
  gap: 4px;
  font-size: 14px;
  flex-shrink: 0;
}

/* Right side: timer */
.game-row-right {
  text-align: right;
  flex-shrink: 0;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.game-row-status {
  margin-bottom: 2px;
}
.game-row-countdown {
  font-weight: bold;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.game-row-countdown.urgent {
  color: var(--accent-red);
}
.game-row-countdown.expired {
  color: var(--accent-red);
  font-weight: bold;
}
.game-row-turn {
  font-size: 11px;
  color: var(--text-muted);
}

/* Shield wrapper: sprite shield + per-player life bar stacked vertically */
.shield-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* Override float:left from sprite classes inside game rows */
.shield-wrap .shield-sprite {
  float: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Per-shield life bar (credit extensions) */
.shield-lifebar {
  width: 25px;
  height: 3px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 2px;
  overflow: hidden;
}
.shield-lifebar-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
}
.shield-lifebar-fill.low {
  background: #e67e22;
}
.shield-lifebar-fill.critical {
  background: var(--accent-red);
}

/* Eliminated shield (greyed out) */
.shield-eliminated {
  opacity: 0.4;
  filter: grayscale(1);
}

/* Override playerMe/playerActive sizes for large shields in game rows */
.shield-wrap .playerMe {
  width: 27px;
  height: 34px;
}
.shield-wrap .playerActive {
  width: 27px;
  height: 34px;
}

/* Shield timeout number overlay */
.shield-timeout {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 4px rgba(154, 42, 26, 0.8);
  line-height: 1;
}

/* Hourglass icon for credit extension usage */
.shield-hourglass {
  position: absolute;
  bottom: 1px;
  right: 0px;
  font-size: 9px;
  line-height: 1;
  color: #f0c040;
  text-shadow: 0 0 2px #000, 0 0 3px #000;
  pointer-events: none;
}

/* Dismiss button for finished games */
.game-row-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 3px;
  flex-shrink: 0;
}
.game-row-dismiss:hover {
  color: var(--accent-red);
  background: rgba(255, 255, 255, 0.1);
}

/* Finished game row */
.game-row.finished {
  opacity: 0.75;
}
.game-item-status.finished-victory {
  background: var(--accent-green);
  color: white;
}
.game-item-status.finished-defeat {
  background: var(--accent-red);
  color: white;
}
.game-item-status.finished-completed {
  background: var(--bg-light);
  color: var(--text-muted);
}

.view-all-link {
  color: #2e5fa1;
  text-decoration: none;
  font-size: 12px;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Activity Wall */
.home-wall-section {
  padding-bottom: 0;
}

.wall-post {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(138, 118, 73, 0.3);
}

.wall-post:last-child {
  border-bottom: none;
}

.wall-post-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.wall-event-icon {
  flex-shrink: 0;
  width: 104px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.wall-event-icon img {
  max-width: 54px;
  max-height: 54px;
  image-rendering: pixelated;
}

/* Medal icons from transparent.png sprite */
.icon_medal {
  background: url('/css/interface/transparent.png') no-repeat -72px -129px;
  width: 48px;
  height: 54px;
}
.icon_medaldead {
  background: url('/css/interface/transparent.png') no-repeat -3px -132px;
  width: 66px;
  height: 52px;
}

/* Elf/Devil sprites scaled for wall */
.wall-event-icon div.elf,
.wall-event-icon div.devil {
  transform: scale(0.75);
  transform-origin: center center;
}

.wall-post-content {
  flex: 1;
  min-width: 0;
}

.wall-post-header {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 2px;
}

.wall-post-header .wall-type-label {
  color: #f6e1a6;
}

.wall-post-header .wall-type-label.wall-label-won {
  color: #139813;
}

.wall-post-header .wall-type-label.wall-label-lost {
  color: #ae2f2f;
}

.wall-post-header .wall-time {
  font-weight: normal;
}

.wall-post-body {
  font-size: 13px;
  line-height: 1.5;
}

.wall-post-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.wall-post-detail a {
  color: #327aaa;
  text-decoration: none;
}

.wall-post-detail a:hover {
  text-decoration: underline;
}

.wall-post-players {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.wall-post-minimap {
  flex-shrink: 0;
  align-self: center;
}

.wall-post-minimap img {
  width: 75px;
  height: auto;
  border-radius: 3px;
  border: 1px solid #8a7649;
  image-rendering: pixelated;
}

.wall-post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 2px;
}

.wall-time {
  font-size: 11px;
  color: var(--text-muted);
}

.wall-gamename {
  color: #2e5fa1;
  font-weight: bold;
}

.wall-post-users {
  font-size: 12px;
  color: var(--text-secondary);
}

.wall-username {
  color: var(--text-primary);
  font-weight: 600;
}

a.wall-username,
a.wall-user-link {
  color: #327aaa;
  text-decoration: none;
  font-weight: 600;
}

a.wall-username:hover,
a.wall-user-link:hover {
  text-decoration: underline;
  color: #7ec8e3;
}

.wall-alliance-tag {
  font-size: 11px;
  font-weight: bold;
  opacity: 0.85;
}

.wall-post-footer {
  display: flex;
  gap: var(--spacing-md);
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.btn-link:hover {
  color: var(--accent-blue);
}

/* Wall Comments */
/* Game Stats Slide-down Panel */
.wall-gamestats {
  margin-top: var(--spacing-sm);
  padding: 8px 0;
  border-top: 1px solid rgba(138, 118, 73, 0.3);
}

.gamestats-panel {
  font-size: 13px;
}

.gamestats-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.gamestats-left {
  flex-shrink: 0;
  width: 200px;
}

.gamestats-map img {
  width: 200px;
  height: auto;
  border: 2px solid #8a7649;
  border-radius: 4px;
  image-rendering: pixelated;
}

.gamestats-info {
  margin-top: 6px;
  font-size: 11px;
  color: #4a3f2a;
  line-height: 1.4;
}

.gamestats-info b {
  color: #2a2010;
}

.gamestats-right {
  flex: 1;
  min-width: 0;
}

/* Player color legend */
.gamestats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: bold;
  color: #2a2010;
}

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

.gamestats-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.3);
}

/* 2-column grid for stat categories */
.gamestats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.gamestats-category {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gamestats-cat-label {
  font-size: 10px;
  font-weight: bold;
  color: #5a4a30;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 1px;
}

.gamestats-bar-row {
  display: flex;
  align-items: center;
}

.gamestats-bar-track {
  flex: 1;
  height: 14px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 2px;
  overflow: hidden;
}

.gamestats-bar-fill {
  height: 100%;
  min-width: 1px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  padding-left: 3px;
  transition: width 0.3s ease;
}

.gamestats-bar-value {
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

.wall-comments {
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  margin-left: 112px;
}

.wall-comment {
  padding: var(--spacing-sm);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.5);
  margin-top:4px;

}

.wall-comment-username {
  font-weight: bold;
  margin-right: var(--spacing-xs);
}

.wall-comment-text {
  color: var(--text-primary);
}

.wall-comment-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: var(--spacing-xs);
}

.wall-view-all-comments {
  display: block;
  font-size: 12px;
  color: #5dade2;
  margin-bottom: 4px;
  cursor: pointer;
}

.wall-view-all-comments:hover {
  text-decoration: underline;
}

.wall-comment-form {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.wall-comment-input {
  flex: 1;
  font-size: 12px;
}

/* Online Users List */
.online-users-list {
  max-height: 250px;
  overflow-y: auto;
  padding: var(--spacing-xs);
}

.online-user-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--spacing-sm);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.online-user-item:hover {
  background: rgba(255, 255, 255, 0.25);
}

.online-friend-star {
  color: var(--accent-gold);
  font-size: 11px;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

.online-friend-star-placeholder {
  width: 12px;
  flex-shrink: 0;
}

.online-flag {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.online-flag-placeholder {
  width: 16px;
  flex-shrink: 0;
}

.online-ally-tag {
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
  min-width: 28px;
}

.online-user-name {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-user-rating {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

/* Home Chat */
.home-chat {
  display: flex;
  flex-direction: column;
}

.home-chat-messages {
  height: 250px;
  overflow-y: auto;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 12px;
}

.home-chat-msg {
  padding: 2px 0;
  line-height: 1.4;
}

.home-chat-msg.own .home-chat-user {
  color: #6b4510;
}

.home-chat-user {
  font-weight: bold;
  margin-right: var(--spacing-xs);
  color: #2e5fa1;
}

.home-chat-text {
  color: var(--text-primary);
  word-break: break-word;
}

.home-chat-input {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm);
  border-top: 1px solid rgba(138, 118, 73, 0.4);
}

.home-chat-input .form-input {
  flex: 1;
  font-size: 12px;
}

/* Responsive: Stack columns on narrow screens */
@media (max-width: 900px) {
  .home-page {
    flex-direction: column;
  }

  .home-sidebar {
    width: 100%;
  }

  .game-row {
    gap: 8px;
    padding: 6px 8px;
  }
  .game-row-thumb {
    width: 50px;
    height: 50px;
  }
  .game-row-shields {
    padding: 2px 4px;
  }
  .game-row-right {
    min-width: 70px;
  }
}

/* ================================
   User Profile Page
   ================================ */

.user-profile-page {
  padding: var(--spacing-lg);
}

.user-profile-main {
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  gap: var(--spacing-md);
}

.user-profile-header {
  padding: 20px;
}

.up-header-content {
  text-align: center;
}

.up-username {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent-gold);
}

.up-alliance {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.up-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.up-membership {
  color: var(--accent-gold);
  font-weight: 600;
}

.up-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
  padding: 12px;
}

.up-stat-block {
  text-align: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.up-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.up-stat-rating {
  font-size: 28px;
  font-weight: bold;
  color: var(--accent-gold);
}

.up-stat-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ================================
   Forum Styles
   ================================ */

.forum-container {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--spacing-md);
}

.forum-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.forum-header h2 {
  font-size: 18px;
  color: var(--text-primary);
}

.forum-back-btn {
  background: none;
  border: none;
  color: var(--accent-gold);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
  padding: 4px 0;
}

.forum-back-btn:hover {
  color: var(--accent-gold-light);
  text-decoration: underline;
}

/* Category rows */
.forum-category {
  display: flex;
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.forum-category:hover {
  background: rgba(138, 108, 47, 0.12);
}

.forum-category-info {
  flex: 1;
}

.forum-category-name {
  font-weight: bold;
  font-size: 14px;
  color: var(--text-primary);
}

.forum-category-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.forum-category-stats {
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 160px;
}

.forum-category-lastpost {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Thread rows */
.forum-thread {
  display: flex;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(138, 118, 73, 0.3);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.forum-thread:hover {
  background: rgba(138, 108, 47, 0.12);
}

.forum-thread.sticky {
  background: rgba(138, 108, 47, 0.08);
}

.forum-thread-info {
  flex: 1;
}

.forum-thread-title {
  font-weight: 600;
  color: var(--text-primary);
}

.forum-thread-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.forum-thread-stats {
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 140px;
}

.forum-sticky-badge {
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: bold;
  margin-right: 4px;
}

.forum-locked-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Post blocks */
.forum-post {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 2px;
}

.forum-post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.forum-post-author {
  font-weight: bold;
  color: var(--accent-gold);
}

.forum-post-date {
  font-size: 12px;
  color: var(--text-muted);
}

.forum-post-content {
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-weight: 400;
  font-size: 13px;
}

.forum-post-content a {
  color: var(--accent-gold);
  text-decoration: underline;
}

.forum-post-content a:hover {
  color: var(--accent-gold-light);
}

.forum-post-content blockquote {
  border-left: 3px solid var(--accent-gold);
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 4px 4px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.forum-post-content blockquote b {
  font-style: normal;
  color: var(--accent-gold);
  font-size: 12px;
}

.forum-post-content pre {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 8px 0;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
}

.forum-post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 4px 0;
}

.forum-post-content ul, .forum-post-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.forum-post-content li {
  margin-bottom: 4px;
}

.forum-post-edited {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
}

.forum-post-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.forum-post-actions button {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
}

.forum-post-actions button:hover {
  background: rgba(138, 108, 47, 0.15);
  color: var(--text-primary);
}

/* Formatting toolbar */
.forum-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 0;
}

.forum-tb-btn {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1.4;
}

.forum-tb-btn:hover {
  background: rgba(138, 108, 47, 0.2);
  color: var(--text-primary);
  border-color: var(--accent-gold);
}

/* Reply / New thread form */
.forum-form {
  padding: 12px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.05);
  margin-top: var(--spacing-md);
}

.forum-form-title {
  font-weight: bold;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
}

.forum-form input[type="text"],
.forum-form textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
  resize: vertical;
}

.forum-form textarea {
  min-height: 100px;
}

.forum-form input[type="text"] {
  margin-bottom: var(--spacing-sm);
}

.forum-form-buttons {
  margin-top: var(--spacing-sm);
  display: flex;
  gap: 8px;
}

/* Pagination */
.forum-pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 12px;
}

.forum-page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forum-page-btn:hover {
  background: var(--bg-medium);
}

.forum-page-btn.active {
  background: var(--accent-gold);
  color: var(--bg-light);
  border-color: var(--accent-gold);
  text-shadow: none;
}

.forum-page-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Edit form inline */
.forum-edit-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
  resize: vertical;
}

.forum-edit-form .forum-form-buttons {
  margin-top: var(--spacing-sm);
}

.forum-empty {
  text-align: center;
  padding: var(--spacing-lg);
  color: var(--text-muted);
}

/* ================================
   Admin Panel Styles
   ================================ */

.admin-container {
  display: flex;
  gap: var(--spacing-md);
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-md);
}

.admin-sidebar {
  width: 200px;
  flex-shrink: 0;
}

.admin-content {
  flex: 1;
  min-width: 0;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-btn {
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 1px 1px 1px #f1e4c8;
}

.admin-nav-btn:hover {
  background: rgba(138, 108, 47, 0.12);
}

.admin-nav-btn.active {
  background: rgba(138, 108, 47, 0.2);
  color: var(--accent-gold);
}

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

.admin-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.admin-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(138, 118, 73, 0.3);
}

.admin-actions {
  display: flex;
  gap: 4px;
}

/* Dashboard grid */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.admin-card {
  padding: 12px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.04);
}

.admin-card-title {
  font-weight: bold;
  font-size: 13px;
  color: var(--accent-gold);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.admin-card-danger {
  border-color: var(--accent-red);
  background: rgba(154, 42, 26, 0.08);
}

.admin-card-danger .admin-card-title {
  color: var(--accent-red);
}

.admin-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}

.admin-progress {
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  margin: 4px 0 6px;
  border-radius: 3px;
  overflow: hidden;
}

.admin-progress-bar {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.3s ease;
}

.admin-progress-bar.danger {
  background: var(--accent-red);
}

.admin-online-list {
  font-size: 12px;
  line-height: 1.6;
}

.admin-online-user {
  color: var(--accent-gold);
}

.admin-status-free {
  color: var(--accent-green);
}

.admin-status-busy {
  color: var(--accent-gold);
  font-weight: bold;
}

.admin-row-danger {
  background: rgba(154, 42, 26, 0.1);
}

/* ═══════════════════════════════════════════════════════
   Country Flags Sprite
   ═══════════════════════════════════════════════════════ */

.flag {
  display: inline-block;
  width: 16px;
  height: 11px;
  background: url(/images/flags.png) no-repeat;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}

.flag.flag-ad {background-position: -16px 0}
.flag.flag-ae {background-position: -32px 0}
.flag.flag-af {background-position: -48px 0}
.flag.flag-ag {background-position: -64px 0}
.flag.flag-ai {background-position: -80px 0}
.flag.flag-al {background-position: -96px 0}
.flag.flag-am {background-position: -112px 0}
.flag.flag-an {background-position: -128px 0}
.flag.flag-ao {background-position: -144px 0}
.flag.flag-ar {background-position: -160px 0}
.flag.flag-as {background-position: -176px 0}
.flag.flag-at {background-position: -192px 0}
.flag.flag-au {background-position: -208px 0}
.flag.flag-aw {background-position: -224px 0}
.flag.flag-az {background-position: -240px 0}
.flag.flag-ba {background-position: 0 -11px}
.flag.flag-bb {background-position: -16px -11px}
.flag.flag-bd {background-position: -32px -11px}
.flag.flag-be {background-position: -48px -11px}
.flag.flag-bf {background-position: -64px -11px}
.flag.flag-bg {background-position: -80px -11px}
.flag.flag-bh {background-position: -96px -11px}
.flag.flag-bi {background-position: -112px -11px}
.flag.flag-bj {background-position: -128px -11px}
.flag.flag-bm {background-position: -144px -11px}
.flag.flag-bn {background-position: -160px -11px}
.flag.flag-bo {background-position: -176px -11px}
.flag.flag-br {background-position: -192px -11px}
.flag.flag-bs {background-position: -208px -11px}
.flag.flag-bt {background-position: -224px -11px}
.flag.flag-bv {background-position: -240px -11px}
.flag.flag-bw {background-position: 0 -22px}
.flag.flag-by {background-position: -16px -22px}
.flag.flag-bz {background-position: -32px -22px}
.flag.flag-ca {background-position: -48px -22px}
.flag.flag-catalonia {background-position: -64px -22px}
.flag.flag-cd {background-position: -80px -22px}
.flag.flag-cf {background-position: -96px -22px}
.flag.flag-cg {background-position: -112px -22px}
.flag.flag-ch {background-position: -128px -22px}
.flag.flag-ci {background-position: -144px -22px}
.flag.flag-ck {background-position: -160px -22px}
.flag.flag-cl {background-position: -176px -22px}
.flag.flag-cm {background-position: -192px -22px}
.flag.flag-cn {background-position: -208px -22px}
.flag.flag-co {background-position: -224px -22px}
.flag.flag-cr {background-position: -240px -22px}
.flag.flag-cu {background-position: 0 -33px}
.flag.flag-cv {background-position: -16px -33px}
.flag.flag-cy {background-position: -32px -33px}
.flag.flag-cz {background-position: -48px -33px}
.flag.flag-de {background-position: -64px -33px}
.flag.flag-dj {background-position: -80px -33px}
.flag.flag-dk {background-position: -96px -33px}
.flag.flag-dm {background-position: -112px -33px}
.flag.flag-do {background-position: -128px -33px}
.flag.flag-dz {background-position: -144px -33px}
.flag.flag-ec {background-position: -160px -33px}
.flag.flag-ee {background-position: -176px -33px}
.flag.flag-eg {background-position: -192px -33px}
.flag.flag-eh {background-position: -208px -33px}
.flag.flag-england {background-position: -224px -33px}
.flag.flag-er {background-position: -240px -33px}
.flag.flag-es {background-position: 0 -44px}
.flag.flag-et {background-position: -16px -44px}
.flag.flag-eu {background-position: -32px -44px}
.flag.flag-fi {background-position: -48px -44px}
.flag.flag-fj {background-position: -64px -44px}
.flag.flag-fk {background-position: -80px -44px}
.flag.flag-fm {background-position: -96px -44px}
.flag.flag-fo {background-position: -112px -44px}
.flag.flag-fr {background-position: -128px -44px}
.flag.flag-ga {background-position: -144px -44px}
.flag.flag-gb {background-position: -160px -44px}
.flag.flag-gd {background-position: -176px -44px}
.flag.flag-ge {background-position: -192px -44px}
.flag.flag-gf {background-position: -208px -44px}
.flag.flag-gh {background-position: -224px -44px}
.flag.flag-gi {background-position: -240px -44px}
.flag.flag-gl {background-position: 0 -55px}
.flag.flag-gm {background-position: -16px -55px}
.flag.flag-gn {background-position: -32px -55px}
.flag.flag-gp {background-position: -48px -55px}
.flag.flag-gq {background-position: -64px -55px}
.flag.flag-gr {background-position: -80px -55px}
.flag.flag-gs {background-position: -96px -55px}
.flag.flag-gt {background-position: -112px -55px}
.flag.flag-gu {background-position: -128px -55px}
.flag.flag-gw {background-position: -144px -55px}
.flag.flag-gy {background-position: -160px -55px}
.flag.flag-hk {background-position: -176px -55px}
.flag.flag-hm {background-position: -192px -55px}
.flag.flag-hn {background-position: -208px -55px}
.flag.flag-hr {background-position: -224px -55px}
.flag.flag-ht {background-position: -240px -55px}
.flag.flag-hu {background-position: 0 -66px}
.flag.flag-id {background-position: -16px -66px}
.flag.flag-ie {background-position: -32px -66px}
.flag.flag-il {background-position: -48px -66px}
.flag.flag-in {background-position: -64px -66px}
.flag.flag-io {background-position: -80px -66px}
.flag.flag-iq {background-position: -96px -66px}
.flag.flag-ir {background-position: -112px -66px}
.flag.flag-is {background-position: -128px -66px}
.flag.flag-it {background-position: -144px -66px}
.flag.flag-jm {background-position: -160px -66px}
.flag.flag-jo {background-position: -176px -66px}
.flag.flag-jp {background-position: -192px -66px}
.flag.flag-ke {background-position: -208px -66px}
.flag.flag-kg {background-position: -224px -66px}
.flag.flag-kh {background-position: -240px -66px}
.flag.flag-ki {background-position: 0 -77px}
.flag.flag-km {background-position: -16px -77px}
.flag.flag-kn {background-position: -32px -77px}
.flag.flag-kp {background-position: -48px -77px}
.flag.flag-kr {background-position: -64px -77px}
.flag.flag-kw {background-position: -80px -77px}
.flag.flag-ky {background-position: -96px -77px}
.flag.flag-kz {background-position: -112px -77px}
.flag.flag-la {background-position: -128px -77px}
.flag.flag-lb {background-position: -144px -77px}
.flag.flag-lc {background-position: -160px -77px}
.flag.flag-li {background-position: -176px -77px}
.flag.flag-lk {background-position: -192px -77px}
.flag.flag-lr {background-position: -208px -77px}
.flag.flag-ls {background-position: -224px -77px}
.flag.flag-lt {background-position: -240px -77px}
.flag.flag-lu {background-position: 0 -88px}
.flag.flag-lv {background-position: -16px -88px}
.flag.flag-ly {background-position: -32px -88px}
.flag.flag-ma {background-position: -48px -88px}
.flag.flag-mc {background-position: -64px -88px}
.flag.flag-md {background-position: -80px -88px}
.flag.flag-me {background-position: -96px -88px}
.flag.flag-mg {background-position: -112px -88px}
.flag.flag-mh {background-position: -128px -88px}
.flag.flag-mk {background-position: -144px -88px}
.flag.flag-ml {background-position: -160px -88px}
.flag.flag-mm {background-position: -176px -88px}
.flag.flag-mn {background-position: -192px -88px}
.flag.flag-mo {background-position: -208px -88px}
.flag.flag-mp {background-position: -224px -88px}
.flag.flag-mq {background-position: -240px -88px}
.flag.flag-mr {background-position: 0 -99px}
.flag.flag-ms {background-position: -16px -99px}
.flag.flag-mt {background-position: -32px -99px}
.flag.flag-mu {background-position: -48px -99px}
.flag.flag-mv {background-position: -64px -99px}
.flag.flag-mw {background-position: -80px -99px}
.flag.flag-mx {background-position: -96px -99px}
.flag.flag-my {background-position: -112px -99px}
.flag.flag-mz {background-position: -128px -99px}
.flag.flag-na {background-position: -144px -99px}
.flag.flag-nc {background-position: -160px -99px}
.flag.flag-ne {background-position: -176px -99px}
.flag.flag-nf {background-position: -192px -99px}
.flag.flag-ng {background-position: -208px -99px}
.flag.flag-ni {background-position: -224px -99px}
.flag.flag-nl {background-position: -240px -99px}
.flag.flag-no {background-position: 0 -110px}
.flag.flag-np {background-position: -16px -110px}
.flag.flag-nr {background-position: -32px -110px}
.flag.flag-nu {background-position: -48px -110px}
.flag.flag-nz {background-position: -64px -110px}
.flag.flag-om {background-position: -80px -110px}
.flag.flag-pa {background-position: -96px -110px}
.flag.flag-pe {background-position: -112px -110px}
.flag.flag-pf {background-position: -128px -110px}
.flag.flag-pg {background-position: -144px -110px}
.flag.flag-ph {background-position: -160px -110px}
.flag.flag-pk {background-position: -176px -110px}
.flag.flag-pl {background-position: -192px -110px}
.flag.flag-pm {background-position: -208px -110px}
.flag.flag-pn {background-position: -224px -110px}
.flag.flag-pr {background-position: -240px -110px}
.flag.flag-ps {background-position: 0 -121px}
.flag.flag-pt {background-position: -16px -121px}
.flag.flag-pw {background-position: -32px -121px}
.flag.flag-py {background-position: -48px -121px}
.flag.flag-qa {background-position: -64px -121px}
.flag.flag-re {background-position: -80px -121px}
.flag.flag-ro {background-position: -96px -121px}
.flag.flag-rs {background-position: -112px -121px}
.flag.flag-ru {background-position: -128px -121px}
.flag.flag-rw {background-position: -144px -121px}
.flag.flag-sa {background-position: -160px -121px}
.flag.flag-sb {background-position: -176px -121px}
.flag.flag-sc {background-position: -192px -121px}
.flag.flag-scotland {background-position: -208px -121px}
.flag.flag-sd {background-position: -224px -121px}
.flag.flag-se {background-position: -240px -121px}
.flag.flag-sg {background-position: 0 -132px}
.flag.flag-sh {background-position: -16px -132px}
.flag.flag-si {background-position: -32px -132px}
.flag.flag-sk {background-position: -48px -132px}
.flag.flag-sl {background-position: -64px -132px}
.flag.flag-sm {background-position: -80px -132px}
.flag.flag-sn {background-position: -96px -132px}
.flag.flag-so {background-position: -112px -132px}
.flag.flag-sr {background-position: -128px -132px}
.flag.flag-ss {background-position: -144px -132px}
.flag.flag-st {background-position: -160px -132px}
.flag.flag-sv {background-position: -176px -132px}
.flag.flag-sy {background-position: -192px -132px}
.flag.flag-sz {background-position: -208px -132px}
.flag.flag-tc {background-position: -224px -132px}
.flag.flag-td {background-position: -240px -132px}
.flag.flag-tf {background-position: 0 -143px}
.flag.flag-tg {background-position: -16px -143px}
.flag.flag-th {background-position: -32px -143px}
.flag.flag-tj {background-position: -48px -143px}
.flag.flag-tk {background-position: -64px -143px}
.flag.flag-tl {background-position: -80px -143px}
.flag.flag-tm {background-position: -96px -143px}
.flag.flag-tn {background-position: -112px -143px}
.flag.flag-to {background-position: -128px -143px}
.flag.flag-tr {background-position: -144px -143px}
.flag.flag-tt {background-position: -160px -143px}
.flag.flag-tv {background-position: -176px -143px}
.flag.flag-tw {background-position: -192px -143px}
.flag.flag-tz {background-position: -208px -143px}
.flag.flag-ua {background-position: -224px -143px}
.flag.flag-ug {background-position: -240px -143px}
.flag.flag-um {background-position: 0 -154px}
.flag.flag-us {background-position: -16px -154px}
.flag.flag-uy {background-position: -32px -154px}
.flag.flag-uz {background-position: -48px -154px}
.flag.flag-va {background-position: -64px -154px}
.flag.flag-vc {background-position: -80px -154px}
.flag.flag-ve {background-position: -96px -154px}
.flag.flag-vg {background-position: -112px -154px}
.flag.flag-vi {background-position: -128px -154px}
.flag.flag-vn {background-position: -144px -154px}
.flag.flag-vu {background-position: -160px -154px}
.flag.flag-wales {background-position: -176px -154px}
.flag.flag-wf {background-position: -192px -154px}
.flag.flag-ws {background-position: -208px -154px}
.flag.flag-ye {background-position: -224px -154px}
.flag.flag-yt {background-position: -240px -154px}
.flag.flag-za {background-position: 0 -165px}
.flag.flag-zm {background-position: -16px -165px}
.flag.flag-zw {background-position: -32px -165px}

/* Chat alliance tag */
.chat-ally-tag {
  font-size: 11px;
  font-weight: bold;
  margin-right: 3px;
}

/* Forum post alliance tag */
.forum-post-ally {
  font-size: 11px;
  font-weight: bold;
  margin-right: 3px;
}

/* Tournament Create Form */
.tournament-create-form { max-width: 700px; margin: 0 auto; }
.tournament-form-section { margin-bottom: var(--spacing-lg); }
.tournament-form-section-title { font-weight: bold; margin-bottom: var(--spacing-sm); border-bottom: 1px solid rgba(0,0,0,0.15); padding-bottom: 4px; }
.tournament-map-slot { display: flex; align-items: center; gap: var(--spacing-sm); margin-bottom: var(--spacing-sm); }
.tournament-map-slot img { width: 50px; height: 50px; image-rendering: pixelated; border-radius: 3px; }
.tournament-map-slot .map-name { flex: 1; }
.form-row { display: flex; gap: var(--spacing-md); }
.form-row .form-group { flex: 1; }
.text-error { color: #c0392b; font-size: 0.9rem; }

/* Tournament Join View */
.tournament-join-layout {
  display: grid;
  grid-template-columns: 320px 1fr 230px;
  gap: var(--spacing-md);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.tournament-join-info h3,
.tournament-join-center h3,
.tournament-join-players h3 {
  margin: 0 0 var(--spacing-sm) 0;
  font-size: 1rem;
}
.tournament-info-table {
  width: 100%;
  font-size: 0.9rem;
  border-collapse: collapse;
}
.tournament-info-table td {
  padding: 3px 8px 3px 0;
  vertical-align: top;
}
.tournament-info-table td:first-child {
  color: var(--text-secondary);
  white-space: nowrap;
  width: 120px;
}
.tournament-join-maps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}
.tournament-join-map {
  display: flex;
  flex-direction: column;
  width: 100px;
}
.tournament-join-map img {
  width: 100px;
  height: 100px;
  image-rendering: pixelated;
  border: 1px solid var(--border-color);
  border-radius: 3px;
}
.tournament-join-map-round {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.tournament-join-map-name {
  font-weight: bold;
  font-size: 0.85rem;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tournament-join-section h3 {
  margin: 0 0 var(--spacing-xs) 0;
  font-size: 0.95rem;
}
.tournament-join-section p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}
.tournament-join-player {
  padding: 2px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 3px;
}
.tournament-join-player a {
  color: var(--text-primary);
  text-decoration: none;
}
.tournament-join-player a:hover {
  text-decoration: underline;
}

.clickable-minimap {
  cursor: pointer;
  transition: opacity 0.15s;
}
.clickable-minimap:hover {
  opacity: 0.8;
}

.team-select-modal {
  min-width: 420px;
  max-width: 500px;
  padding: var(--spacing-lg);
}
/* Apply panel frame styling to modal when team-select-modal is inside */
#modal-content:has(.team-select-modal) {
  background: none;
  background-color: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  overflow: visible;
}
.team-select-modal th {
  padding: 4px 8px 4px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}
.team-select-action .btn-disabled {
  opacity: 0.5;
  cursor: default;
}
#team-alliance-select {
  width: 100%;
}

@media (max-width: 900px) {
  .tournament-join-layout {
    grid-template-columns: 1fr;
  }
}

/* ============================================= */
/* News Popup                                    */
/* ============================================= */

.news-popup-layout {
  display: flex;
  gap: 12px;
  padding: 8px;
}

/* Shared popup minimap container - 300x300 black box, canvas centered at natural size */
.popup-minimap {
  width: 300px;
  height: 300px;
  border: 1px solid #5a3d2b;
  background: #000;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-minimap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

.news-popup-text {
  flex: 1;
  font-size: 13px;
  font-weight: bold;
  color: #3a1e00;
  overflow-y: auto;
  max-height: 300px;
  line-height: 1.5;
}

.news-popup-text .news-line {
  padding: 1px 0;
}

.news-event-line {
  cursor: pointer;
}

.news-event-line:hover {
  color: #8a2a2a;
  text-decoration: underline;
}

/* Temple blessing popup */
div.selectrowmove { float: left; width: 78px; }
div.unitintemple { height: 66px; width: 580px; margin-left: 15px; font-size: 10px; font-family: arial; overflow: hidden; }
div.statsintemple { height: 28px; width: 580px; margin-left: 15px; font-size: 10px; font-family: arial; overflow: hidden; }

/* Quick bless flash popup */
.quickbless-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.quickbless-box {
  background-image: url('/interface4/dropdownbg.png');
  border: 1px solid #5a3a1a;
  padding: 10px 15px;
  min-width: 200px;
  max-width: 700px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.quickbless-box.visible { opacity: 1; }
