/* Global Theme & Reset */
.production-line { padding: 16px; margin: 12px 0; border: 1px solid #334155; border-radius: 8px; background: #0f172a; }
.production-line .form-row { flex-wrap: wrap; gap: 10px; }
.production-line label { flex: 1; min-width: 110px; }
.recipe-columns { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.recipe-resource-row { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.recipe-resource-row select { flex: 1; min-width: 100px; }
.recipe-resource-row input { width: 70px; }
#popup-production { font-size: 12px; color: #eadcb9; line-height: 1.8; margin: 0; }
@media(max-width:900px) { .recipe-columns { grid-template-columns: 1fr; } }
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #0f172a;
  color: #f1f5f9;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* Common Utilities */
.hidden { display: none !important; }
.view-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  padding: 20px;
  overflow-y: auto;
}

/* Island loading splash, shared by initial load and island changes */
html.not-logged-in #view-loading {
  display: none !important;
}
html.not-logged-in #view-auth {
  display: flex !important;
}

#view-loading {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f7edd1;
  background: #101b19;
}

#view-loading .island-loading-art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 18, 17, .28), rgba(8, 18, 17, .93)),
    url("/archipelago_map_bg.png") center / cover no-repeat;
  filter: saturate(.8);
  transform: scale(1.04);
}

.island-loading-card {
  position: relative;
  width: min(520px, calc(100vw - 40px));
  padding: 30px;
  text-align: center;
  border: 1px solid rgba(246, 215, 144, .35);
  border-radius: 18px;
  background: rgba(14, 29, 25, .82);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .48);
  backdrop-filter: blur(7px);
  animation: fadeInSplash 0.2s ease-out;
}

.island-loading-kicker {
  margin: 0 0 7px;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #dfc984;
}

.island-loading-card h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(30px, 7vw, 48px);
  font-weight: 600;
  letter-spacing: .04em;
}

.island-loading-status {
  margin: 14px 0 18px;
  color: #dce8d1;
}

.island-loading-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, .14);
}

.island-loading-bar {
  width: 7%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b99843, #f4dc8a, #a4772d);
  box-shadow: 0 0 16px rgba(247, 216, 126, .7);
  transition: width .28s ease;
}

.island-loading-percent {
  margin: 8px 0 0;
  font-size: 12px;
  color: #bdc9b6;
}

.island-loading-tip {
  min-height: 38px;
  margin: 24px 0 0;
  padding: 12px 15px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: #e9dfc5;
  font-size: 14px;
  line-height: 1.45;
}

.island-loading-tip strong {
  color: #f1d77f;
}

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

@keyframes fadeInSplash {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  color: #fff;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #2563eb; border-color: #1d4ed8; }
.btn-success { background: #16a34a; border-color: #15803d; }
.btn-secondary { background: #475569; border-color: #334155; }
.btn-warning { background: #d97706; border-color: #b45309; }
.btn-danger { background: #dc2626; border-color: #b91c1c; }
.btn-outline { background: transparent; border-color: #64748b; color: #cbd5e1; }
.btn-outline:hover { background: #334155; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 6px;
}
.badge-superadmin { background: #7c3aed; color: #f5f3ff; border: 1px solid #a78bfa; }
.badge-admin { background: #2563eb; color: #eff6ff; }
.badge-user { background: #059669; color: #ecfdf5; }
.badge-pending { background: #d97706; color: #fffbeb; }
.badge-blocked { background: #dc2626; color: #fef2f2; }
.badge-game { background: #334155; color: #94a3b8; }

/* Form Controls */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f8fafc;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-input-wrapper input {
  padding-right: 42px;
}
.btn-toggle-pwd {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  color: #94a3b8;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.1s;
  user-select: none;
}
.btn-toggle-pwd:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Alert Box */
.alert-box {
  margin-top: 15px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.alert-box.alert-error { background: rgba(220, 38, 38, 0.2); border: 1px solid #dc2626; color: #fca5a5; }
.alert-box.alert-success { background: rgba(22, 163, 74, 0.2); border: 1px solid #16a34a; color: #86efac; }
.alert-box.alert-info { background: rgba(37, 99, 235, 0.2); border: 1px solid #2563eb; color: #93c5fd; }

/* 1. AUTH CARD */
.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.auth-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 6px;
}
.auth-header .subtitle {
  font-size: 14px;
  color: #94a3b8;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  background: #0f172a;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.auth-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-tab-btn.active {
  background: #334155;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.first-user-badge {
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid #7c3aed;
  color: #ddd6fe;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 14px;
}
.hint-text {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 14px;
}

/* 2. WELCOME DASHBOARD */
.welcome-card {
  width: 100%;
  max-width: 820px;
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.welcome-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}
.hud-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  object-fit: cover;
}
.hud-avatar-toggle { display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.hud-avatar-toggle:hover .hud-avatar-img, .hud-avatar-toggle:focus-visible .hud-avatar-img { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .28); }
.user-info { display: flex; flex-direction: column; gap: 3px; }
.user-name { font-size: 16px; font-weight: 700; color: #f8fafc; }
.topbar-actions { display: flex; gap: 10px; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
}
.gender-toggle {
  display: flex;
  background: #1e293b;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}
.gender-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.gender-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.username-status { display: block; min-height: 16px; margin-top: 5px; font-size: 12px; color: #94a3b8; }
.username-status.ok { color: #4ade80; }
.username-status.error { color: #f87171; }
#view-auth .auth-card { max-width: 480px; }
#modal-avatar-choice { z-index: 100001; }
.avatar-choice-content { max-width: 520px; text-align: center; }
.avatar-choice-content h3 { font-size: 20px; color: #f8fafc; margin-bottom: 6px; }
.avatar-choice-grid { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 16px 0 18px; }
.avatar-choice-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: 100%; }
.avatar-choice-card { aspect-ratio: 1; padding: 4px; display: grid; place-items: center; border: 2px solid #334155; border-radius: 16px; background: #0f172a; cursor: pointer; transition: transform .15s, border-color .15s; }
.avatar-choice-card:hover { border-color: #38bdf8; transform: translateY(-2px); }
.avatar-choice-card.selected { border-color: #f59e0b; box-shadow: 0 0 16px rgba(245, 158, 11, .5); }
.avatar-choice-card img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.avatar-choice-reroll { min-width: 140px; }
#avatar-choice-alert { margin-top: 12px; }
/* A tall card must stay scrollable from its top: auto margins centre it only when it fits. */
#view-auth .auth-card { margin: auto; }

/* Shipwreck Card */
.welcome-actions-center {
  display: flex;
  justify-content: center;
  width: 100%;
}
.action-card-shipwreck {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid #38bdf8;
  border-radius: 18px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.shipwreck-icon { font-size: 42px; margin-bottom: 12px; }
.action-card-shipwreck h3 { font-size: 20px; color: #38bdf8; margin-bottom: 10px; font-weight: 800; }
.story-text {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.55;
  margin-bottom: 22px;
}
.story-text strong { color: #facc15; }
.btn-glow {
  background: linear-gradient(135deg, #2563eb 0%, #0284c7 100%);
  border: none;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 28px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  animation: pulse-glow 2.5s infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 6px 28px rgba(56, 189, 248, 0.7); }
}

/* 3. ADMIN DASHBOARD (Widescreen + Left Sidebar Navigation) */
.admin-card {
  width: 98vw;
  max-width: 1700px;
  height: 95vh;
  max-height: 96vh;
  margin: auto;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 14px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.admin-title { display: flex; align-items: center; gap: 14px; }
.admin-title h2 { font-size: 22px; font-weight: 800; color: #f8fafc; }

/* Admin Body Layout: Left Sidebar + Right Content */
.admin-body-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 20px;
  overflow: hidden;
}

.admin-sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 12px 8px;
  overflow-y: auto;
}

.admin-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease-in-out;
}
.admin-tab-btn .tab-icon {
  font-size: 17px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.admin-tab-btn .tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-tab-btn:hover {
  background: rgba(51, 65, 85, 0.55);
  color: #f8fafc;
  border-color: #334155;
}
.admin-tab-btn.active {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.admin-tab-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding-right: 8px;
}
.admin-pane { display: none; }
.admin-pane.active { display: block; }
.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.pane-header h3 { font-size: 18px; color: #e2e8f0; }
.hint-tag { font-size: 11px; background: #334155; color: #cbd5e1; padding: 4px 8px; border-radius: 6px; }

/* Definitions Tab Styles */
.definitions-section {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 18px;
}
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-title-row h4 {
  font-size: 16px;
  color: #38bdf8;
  font-weight: 700;
  margin: 0;
}
.order-btn-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-order {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-order:hover {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}
.badge-system {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid #475569;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
}
.badge-custom {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid #059669;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
}
.cat-select-inline {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f1f5f9;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.cat-select-inline:focus {
  outline: none;
  border-color: #38bdf8;
}

/* Admin Form Box */
.admin-form-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}
.admin-form-box h4 {
  font-size: 15px;
  margin-bottom: 14px;
  color: #38bdf8;
}

/* Admin Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.admin-table th {
  background: #0f172a;
  padding: 12px 14px;
  color: #94a3b8;
  font-weight: 600;
  border-bottom: 1px solid #334155;
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #334155;
  color: #f1f5f9;
}
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.table-actions { display: flex; gap: 6px; }

/* Items Grid (Buildings / Islands) */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.item-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
}
.item-card h4 { font-size: 15px; margin-bottom: 6px; color: #f8fafc; }
.item-card .item-meta { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.item-card .item-cost { font-size: 13px; font-weight: 600; color: #fbbf24; }

/* Weather Controls */
.weather-calendar { margin-top: 22px; border-top: 1px solid #334155; padding-top: 14px; min-width: 0; }
.weather-calendar-note { color: #94a3b8; font-size: 12px; line-height: 1.6; }
.weather-calendar-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.weather-calendar-legend span { border-left: 8px solid; padding: 3px 8px; font-size: 12px; }
.weather-calendar-scroll { overflow-x: auto; padding: 5px; }
#weather-calendar-grid { min-width: 925px; }
#weather-calendar-grid .month-label-col { flex-shrink: 0; }
#weather-calendar-grid .month-days-track { overflow: visible; display: grid; grid-template-columns: repeat(31, minmax(22px, 1fr)); }
#weather-calendar-grid .cal-day-cell { cursor: default; }
.weather-controls {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
}
.weather-btn-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.btn-weather {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 14px;
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-weather:hover { border-color: #3b82f6; background: #1e293b; }
.weather-status-box {
  font-size: 14px;
  color: #cbd5e1;
  padding-top: 12px;
  border-top: 1px solid #334155;
}

/* Market Cards */
.market-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.stat-card .stat-val { font-size: 24px; font-weight: 800; color: #38bdf8; margin-bottom: 4px; }
.stat-card .stat-lbl { font-size: 12px; color: #94a3b8; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-content {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 { font-size: 18px; color: #f8fafc; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
}
.modal-footer { margin-top: 20px; }
.app-dialog-content { width:min(460px,92vw); }
.app-dialog-content #app-dialog-message { white-space:pre-line; line-height:1.55; margin:4px 0 14px; }
.app-dialog-content #app-dialog-input-wrap { display:grid; gap:6px; }
.app-dialog-content #app-dialog-input-wrap.hidden { display:none; }
.app-dialog-actions { display:flex; justify-content:flex-end; gap:10px; }
.range-val { font-size: 12px; color: #38bdf8; margin-top: 4px; display: block; }

/* 4. GAME CANVAS & HUD */
#view-game {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: #0d1b2a;
}
#mapCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  /* Always keep a native, visible cursor on the interactive map. */
  cursor: default !important;
}
#mapCanvas:active, #mapCanvas.dragging { cursor: default !important; }

#road-build-notice {
  position: fixed;
  left: 50%;
  top: 108px;
  z-index: 160;
  padding: 10px 16px;
  border: 1px solid rgba(125, 211, 252, .85);
  border-radius: 999px;
  background: rgba(8, 25, 45, .96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .38);
  color: #e0f2fe;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity .16s ease, transform .16s ease;
}

#road-build-notice.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.road-removal-dialog {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 8, 23, .68);
  backdrop-filter: blur(4px);
}

.road-removal-card {
  width: min(390px, 100%);
  padding: 22px;
  border: 1px solid #475569;
  border-radius: 14px;
  background: #0f1d31;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .5);
  color: #e2e8f0;
}

.road-removal-card h3 { margin: 0 0 8px; color: #f8fafc; }
.road-removal-card p { margin: 0; color: #cbd5e1; line-height: 1.45; }
.road-removal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.building-demolition-card { width: min(440px, 100%); }
.demolition-return { display: grid; gap: 8px; margin-top: 16px; padding: 12px; border: 1px solid #334155; border-radius: 9px; background: rgba(15, 23, 42, .72); }
.demolition-return > span { color: #94a3b8; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.demolition-return ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.demolition-return li { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.demolition-return li strong { color: #86efac; }
.road-removal-card .demolition-warning { margin-top: 12px; color: #fbbf24; }
.population-needs { display:grid; gap:7px; margin-top:10px; padding:10px; border:1px solid #334155; border-radius:8px; background:rgba(15,23,42,.6); }
.population-need-row { display:grid; grid-template-columns:minmax(105px,1fr) minmax(80px,1.2fr) 42px; align-items:center; gap:8px; font-size:12px; }
.population-need-row progress { width:100%; accent-color:#22c55e; }
.population-need-row.missing progress { accent-color:#ef4444; }
.population-need-row b { text-align:right; }
.residence-promotion-card { display:grid; gap:9px; margin-top:10px; }
.residence-promotion-card h4 { margin:6px 0 0; }
.residence-promotion-card p { margin:0; color:#cbd5e1; font-size:12px; }
.promotion-conditions { display:grid; gap:4px; margin:0; padding:0; list-style:none; font-size:12px; }
.promotion-conditions .met { color:#86efac; }.promotion-conditions .missing { color:#fca5a5; }
.population-summary-card { width:min(760px,100%); }.population-summary-card table { width:100%; margin-top:14px; border-collapse:collapse; }
.population-summary-card th,.population-summary-card td { padding:8px; border-bottom:1px solid #334155; text-align:left; }
.population-surplus { color:#34d399; font-weight:700; }
.population-deficit { color:#f87171; font-weight:700; }
.build-btn.population-locked { opacity:.58; filter:saturate(.45); }
.build-btn.population-locked .build-btn-name::after { content:' · zablokowany'; color:#fbbf24; font-size:10px; }
.population-lock-tag { color:#fbbf24; border-color:#92400e; }
.population-admin-card { margin-bottom:14px; }
.population-admin-card h4 { margin:0 0 12px; font-size:18px; }
.population-admin-promotion { margin-top:12px; padding-top:12px; border-top:1px solid #334155; }
.population-cost-list { display:grid; gap:8px; margin:10px 0; }
.progression-report-box { margin-top:22px; }
.progression-report-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.progression-report-header h3 { margin:0; }
.progression-summary { display:grid; gap:5px; padding:12px; margin:12px 0; border:1px solid #166534; border-radius:8px; background:rgba(20,83,45,.2); }
.progression-summary.invalid { border-color:#991b1b; background:rgba(127,29,29,.2); }
.progression-summary span,.progression-summary small { color:#cbd5e1; }
.progression-issue { padding:11px 12px; margin-top:8px; border-left:4px solid #d97706; border-radius:6px; background:rgba(120,53,15,.18); }
.progression-issue.error { border-left-color:#dc2626; background:rgba(127,29,29,.2); }
.progression-issue p { margin:5px 0 0; color:#cbd5e1; font-size:12px; }

/* In-game HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid #334155;
  padding: 9px 18px;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
}
.map-avatar-portrait {
  position: absolute;
  top: 47px;
  left: -10px;
  width: clamp(120px, 16vw, 202px);
  aspect-ratio: 1;
  z-index: 90;
  pointer-events: none;
  filter: drop-shadow(5px 8px 8px rgba(0, 0, 0, .38));
}
.map-avatar-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; }
.hud-left { flex: 1; min-width: 0; }
.hud-right { justify-content: flex-end; flex: 1; }
#resourcesBar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hud-island-name { color: #f8fafc; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.resource-pill {
  background: #1e293b;
  border: 1px solid #334155;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
}
.players-online { font-size: 12px; color: #94a3b8; font-weight: 500; white-space: nowrap; }
.hud-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #94a3b8; margin-right: 4px; }
#hudPopulation strong, #resourcesBar strong { color: #f8fafc; }
#hudPopulation small { color: #94a3b8; font-size: 11px; margin-left: 4px; }
#resourcesBar { align-items: center; }
.pinned-resources-hud {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 99;
  display: flex;
  width: min(1180px, calc(100% - 220px));
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}
.pinned-resources-hud.hidden { display: none; }
.pinned-resource-pill {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  max-width: 170px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  padding: 5px 8px;
  border-color: #475569;
  box-shadow: 0 5px 14px rgba(0,0,0,.32);
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
}
.pinned-resource-icon { display: inline-flex; flex: 0 0 auto; }
.pinned-resource-icon img { width: 18px !important; height: 18px !important; object-fit: contain; }
.pinned-resource-name { min-width: 0; overflow: hidden; color: #cbd5e1; text-overflow: ellipsis; }
.pinned-resource-pill strong { flex: 0 0 auto; }
@media (max-width: 1050px) {
  .pinned-resources-hud { width: calc(100% - 36px); }
  .pinned-resource-name { display: none; }
}
#build-cancel-btn { margin-top: 6px; }
.connection-warning { position: absolute; top: 64px; right: 16px; z-index: 130; padding: 7px 11px; border: 1px solid #f87171; border-radius: 8px; background: rgba(69, 10, 10, .92); color: #fecaca; font-size: 12px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.fire-warning { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 131; padding: 10px 16px; border: 1px solid #fbbf24; border-radius: 9px; background: rgba(93, 28, 5, .96); color: #fef3c7; font-size: 13px; font-weight: 800; box-shadow: 0 7px 22px rgba(0,0,0,.45); animation: fire-warning-pulse 1.2s ease-in-out infinite; }
@keyframes fire-warning-pulse { 50% { border-color: #f87171; box-shadow: 0 7px 28px rgba(239,68,68,.55); } }
.social-panel { position:absolute; left:14px; bottom:0; z-index:115; display:flex; flex-direction:column; width:340px; height:340px; min-height:0; box-sizing:border-box; padding:9px 11px; border:1px solid #475569; border-radius:10px 10px 0 0; background:rgba(15,23,42,.96); color:#e2e8f0; box-shadow:0 6px 18px rgba(0,0,0,.38); font-size:12px; }
.social-panel.floating { position:fixed; bottom:auto; z-index:140; border-radius:10px; }
.social-panel.dragging { opacity:.92; user-select:none; }
.social-panel.collapsed { height:auto !important; }
.social-panel.collapsed .social-tabs, .social-panel.collapsed .social-tab-content, .social-panel.collapsed .social-resize-handle, .social-panel.collapsed .chat-mod-menu { display:none !important; }
.social-panel-header { cursor:grab; user-select:none; touch-action:none; flex:0 0 auto; }
.social-panel.dragging .social-panel-header { cursor:grabbing; }
.social-panel-actions { display:flex; gap:4px; }
.social-resize-handle { position:absolute; z-index:3; touch-action:none; }
.social-resize-handle[data-edge="n"] { top:-4px; left:10px; right:10px; height:8px; cursor:ns-resize; }
.social-resize-handle[data-edge="s"] { bottom:-4px; left:10px; right:10px; height:8px; cursor:ns-resize; }
.social-resize-handle[data-edge="e"] { right:-4px; top:10px; bottom:10px; width:8px; cursor:ew-resize; }
.social-resize-handle[data-edge="w"] { left:-4px; top:10px; bottom:10px; width:8px; cursor:ew-resize; }
.social-resize-handle[data-edge="ne"] { top:-5px; right:-5px; width:14px; height:14px; cursor:nesw-resize; }
.social-resize-handle[data-edge="sw"] { bottom:-5px; left:-5px; width:14px; height:14px; cursor:nesw-resize; }
.social-resize-handle[data-edge="nw"] { top:-5px; left:-5px; width:14px; height:14px; cursor:nwse-resize; }
.social-resize-handle[data-edge="se"] { bottom:-5px; right:-5px; width:14px; height:14px; cursor:nwse-resize; }
/* Docked in the corner the window grows up and to the right; floating it resizes from every side. */
.social-panel:not(.floating) .social-resize-handle:is([data-edge="s"],[data-edge="w"],[data-edge="nw"],[data-edge="sw"],[data-edge="se"]) { display:none; }
.chat-unread { display:inline-block; min-width:16px; margin-left:4px; padding:1px 5px; border-radius:9px; background:#dc2626; color:#fff; font-size:10px; text-align:center; vertical-align:middle; }
.chat-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.chat-message { position:relative; }
.chat-author.moderatable { cursor:pointer; text-decoration:underline dotted; }
.chat-delete { position:absolute; right:2px; top:4px; display:none; border:0; background:transparent; color:#f87171; cursor:pointer; font-size:11px; }
.chat-message:hover .chat-delete { display:block; }
.chat-locked { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; flex:1; padding:12px; text-align:center; line-height:1.45; color:#fde68a; }
.chat-locked.compact { flex:0 0 auto; flex-direction:row; justify-content:flex-start; gap:6px; padding:6px 4px; text-align:left; font-size:11px; border-bottom:1px dashed rgba(253,230,138,.35); }
.chat-locked-icon { font-size:28px; }
.chat-locked.compact .chat-locked-icon { font-size:14px; }
.chat-locked-progress { width:80%; height:6px; border-radius:3px; background:rgba(255,255,255,.12); overflow:hidden; }
.chat-locked-progress span { display:block; height:100%; background:#f59e0b; }
.chat-notice { margin-top:6px; padding:5px 7px; border-radius:5px; font-size:11px; background:rgba(14,165,233,.18); }
.chat-notice.error { background:rgba(220,38,38,.25); color:#fecaca; }
.chat-notice.success { background:rgba(22,163,74,.25); color:#bbf7d0; }
.chat-form.disabled { opacity:.5; }
.chat-form .chat-emoji-toggle { padding:5px 7px; font-size:15px; line-height:1; }
.chat-emoji-picker { position:absolute; left:10px; right:10px; bottom:52px; z-index:5; display:grid; grid-template-columns:repeat(auto-fill, minmax(30px, 1fr)); gap:2px; max-height:170px; overflow-y:auto; padding:6px; border:1px solid #475569; border-radius:8px; background:rgba(15,23,42,.98); box-shadow:0 6px 18px rgba(0,0,0,.5); }
.chat-emoji-picker button { border:0; background:transparent; font-size:19px; line-height:1; padding:4px 0; border-radius:5px; cursor:pointer; }
.chat-emoji-picker button:hover { background:rgba(255,255,255,.12); }
.chat-mod-menu { position:absolute; z-index:6; width:220px; display:flex; flex-direction:column; gap:6px; padding:9px; border:1px solid #b45309; border-radius:8px; background:rgba(23,15,8,.98); color:#fde68a; box-shadow:0 8px 20px rgba(0,0,0,.6); }
.chat-mod-menu input { background:#0f172a; border:1px solid #475569; color:#f8fafc; border-radius:5px; padding:5px; font-size:11px; }
.chat-mod-options { display:grid; grid-template-columns:1fr 1fr; gap:4px; }
.chat-mod-menu button { border:1px solid #92400e; background:#451a03; color:#fef3c7; border-radius:5px; padding:5px 4px; font-size:11px; cursor:pointer; }
.chat-mod-menu button.danger { border-color:#b91c1c; background:#450a0a; color:#fecaca; }
.chat-mod-menu button:hover { filter:brightness(1.3); }
.chat-mod-menu .chat-mod-more { background:transparent; border-style:dashed; }
.mod-user-results { display:flex; flex-direction:column; gap:3px; margin-top:4px; max-height:180px; overflow-y:auto; }
.mod-user-result { text-align:left; border:1px solid #334155; background:#0f172a; color:#e2e8f0; border-radius:5px; padding:6px 8px; cursor:pointer; }
.mod-user-result:hover { border-color:#38bdf8; }
.mod-chat-log { display:flex; flex-direction:column; gap:4px; max-height:360px; overflow-y:auto; }
.mod-chat-row { display:flex; align-items:center; gap:8px; padding:5px 6px; border-bottom:1px solid #1e293b; }
.mod-chat-row > span:nth-child(2) { flex:1; overflow-wrap:anywhere; }
.mod-chat-meta { color:#94a3b8; font-size:11px; white-space:nowrap; }
#chat-set-words { width:100%; box-sizing:border-box; font-family:monospace; background:#0f172a; color:#f8fafc; border:1px solid #475569; border-radius:6px; padding:8px; }
.social-panel-header { display:flex; justify-content:space-between; align-items:center; height:28px; }
.social-panel-header button { border:1px solid #475569; background:#1e293b; color:#e2e8f0; border-radius:6px; padding:4px 8px; cursor:pointer; font-size:11px; }
.social-tabs { display:flex; gap:5px; border-bottom:1px solid #334155; margin:5px -11px 8px; padding:0 11px; }
.social-tab { border:0; background:transparent; color:#94a3b8; padding:7px 9px; cursor:pointer; font-weight:700; }
.social-tab.active { color:#f8fafc; border-bottom:2px solid #38bdf8; }
.social-tabs { flex:0 0 auto; }
.social-tab-content { display:none; flex:1; min-height:0; }.social-tab-content.active { display:flex; flex-direction:column; }
.social-messages { overflow-y:auto; flex:1; min-height:0; padding-right:3px; }
.chat-message { padding:5px 2px; border-bottom:1px solid rgba(51,65,85,.55); line-height:1.3; }.chat-message .chat-time { color:#64748b; margin-right:5px; }.chat-message .chat-author { color:#7dd3fc; font-weight:800; margin-right:4px; }.chat-message.admin .chat-author { color:#fbbf24; }
.chat-form { display:flex; gap:6px; margin-top:8px; }.chat-form input { flex:1; min-width:0; background:#0f172a; border:1px solid #475569; color:#f8fafc; border-radius:6px; padding:7px; }.chat-form button { background:#0369a1; color:white; border:0; border-radius:6px; padding:7px 9px; cursor:pointer; }
.fire-log-summary { color:#cbd5e1; padding-bottom:5px; border-bottom:1px solid #334155; }
.fire-log-entry { padding-top:4px; line-height:1.25; color:#cbd5e1; }
.fire-log-entry.alarm { color:#fca5a5; }.fire-log-entry.damage { color:#fdba74; }.fire-log-entry.success { color:#86efac; }
.fire-log-entry.loss { color:#fcd34d; }
.fire-log-entries { max-height:none; }
@media (max-width: 980px) {
  #hud { gap: 8px; padding: 7px 10px; }
  .hud-island-name { max-width: 130px; }
  #hudCalendar, #hudWeather, .players-online { display: none; }
  .map-avatar-portrait { top: 44px; left: -24px; width: clamp(96px, 24vw, 144px); }
}
#hudDevelopment { cursor: default; font: inherit; }
#hudWeekdayVal.weekend { color: #fbbf24; font-weight: 800; }

/* Bottom construction dock */
#build-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}
#build-panel.collapsed #build-panel-body { transform: translateY(calc(100% - 46px)); }
#build-panel-body {
  pointer-events: auto;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.game-settings-section h4 { margin: 0 0 12px; color: #f8fafc; font-size: 15px; }
.game-settings-toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 13px; background: #0f172a; border: 1px solid #334155; border-radius: 9px; }
.game-settings-toggle input { width: 18px; height: 18px; margin-top: 2px; accent-color: #38bdf8; cursor: pointer; }
.game-settings-toggle strong, .game-settings-toggle small { display: block; }
.game-settings-toggle strong { color: #e2e8f0; font-size: 13px; }
.game-settings-toggle small { margin-top: 4px; color: #94a3b8; font-size: 12px; line-height: 1.4; }
.game-settings-toggle select { flex-shrink: 0; background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 6px; padding: 3px 4px; font-size: 12px; cursor: pointer; }
#build-panel-body {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid #334155;
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 8px 14px 10px;
  width: min(1180px, calc(100vw - 24px));
  max-height: 220px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -12px 32px rgba(0,0,0,0.5);
  box-sizing: border-box;
}

.build-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.build-panel-header .build-search-box { margin-bottom: 0; flex: 1; max-width: 320px; margin-left: auto; }
#build-panel-toggle {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #cbd5e1;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
#build-panel-toggle:hover { background: #334155; color: #fff; }
.build-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: #f1f5f9;
  letter-spacing: 0.5px;
}
.build-count-badge {
  font-size: 11px;
  font-weight: 700;
  background: #334155;
  color: #93c5fd;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Build Search Box */
.build-search-box {
  position: relative;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}
#build-search-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 7px 28px 7px 10px;
  color: #f8fafc;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#build-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.build-search-clear {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}
.build-search-clear:hover {
  color: #f87171;
}

/* Dock: tabs + horizontal cards */
.build-accordion-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  padding-right: 2px;
  max-height: 158px;
}
.build-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.build-accordion-container::-webkit-scrollbar {
  width: 5px;
}
.build-accordion-container::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 3px;
}
.build-accordion-container::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
.build-accordion-container::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

.build-category-group {
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 9px;
  overflow: hidden;
  background: rgba(30, 41, 59, 0.3);
  transition: border-color 0.2s;
}
.build-category-group:hover {
  border-color: #475569;
}

.build-category-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid #334155;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  user-select: none;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.build-category-header:hover {
  background: rgba(51, 65, 85, 0.7);
  color: #f8fafc;
}
.build-category-header.active {
  background: rgba(37, 99, 235, 0.35);
  border-color: #60a5fa;
  color: #dbeafe;
}
.build-category-title-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.build-category-title-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.build-category-pill {
  font-size: 10px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.6);
  padding: 1px 5px;
  border-radius: 8px;
  color: #94a3b8;
}
.build-category-chevron {
  font-size: 11px;
  transition: transform 0.2s ease;
  display: inline-block;
  color: #64748b;
}
.build-category-header.active .build-category-chevron {
  transform: rotate(90deg);
  color: #93c5fd;
}

.build-category-items {
  padding: 2px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #475569 rgba(30, 41, 59, 0.5);
}
.build-category-items::-webkit-scrollbar {
  height: 6px;
}
.build-category-items::-webkit-scrollbar-track {
  background: rgba(30, 41, 59, 0.5);
  border-radius: 3px;
}
.build-category-items::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}
.build-category-items::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
.build-category-items.collapsed {
  display: none;
}

/* Building Buttons / Cards */
.build-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 148px;
  max-width: 168px;
  box-sizing: border-box;
  font-family: inherit;
}
.build-btn:hover {
  background: #334155;
  border-color: #3b82f6;
  transform: translateY(-1px);
}
.build-btn.active {
  background: #2563eb;
  border-color: #60a5fa;
  color: #fff;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}
.build-btn-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}
.build-btn-preview {
  width: 96px;
  height: 64px;
  flex-shrink: 0;
  image-rendering: auto;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 6px;
}
.build-btn-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.build-btn-right {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}
.build-info-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  flex-shrink: 0;
}
.build-info-tag.workforce-tag {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(14, 165, 233, 0.15);
}
.build-info-tag.deposit-tag {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.15);
}
.build-info-tag.shift-tag {
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.35);
  background: rgba(147, 51, 234, 0.15);
}
.btip-meta-pill.shift-pill {
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.4);
  background: rgba(168, 85, 247, 0.15);
}
.build-cost-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fbbf24;
  white-space: nowrap;
  flex-shrink: 0;
}
.build-cost-tag.cant-afford {
  color: #f87171;
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.35);
}

.build-empty-state {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 18px 8px;
  font-style: italic;
}

#build-cancel-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: #dc2626;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
#build-cancel-btn:hover {
  filter: brightness(1.15);
}

.world-tools {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 101;
}
.world-tools button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.world-tools button:hover { background: #1e293b; }
@media (max-width: 700px) {
  .building-tooltip { display: none !important; }
  .world-tools { top: auto; bottom: 230px; transform: none; }
  #hudCalendar, #hudWeather { display: none; }
}

.btip-meta-pill.workforce-pill {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(14, 165, 233, 0.15);
}
.btip-meta-pill.deposit-pill {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.15);
}
#build-panel-toggle:hover {
  background: #1e293b;
  color: #fff;
}

/* Compact map launchers and friends dock */
.world-bottom-actions {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 121;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}
.world-bottom-actions button,
#friends-panel-close,
.friends-toolbar button,
.friend-card button,
#visit-return-home {
  border: 1px solid #475569;
  border-radius: 9px;
  background: rgba(15, 23, 42, .96);
  color: #e2e8f0;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .35);
}
.world-bottom-actions button:hover,
.world-bottom-actions button.active,
#friends-panel-close:hover,
.friends-toolbar button:hover,
.friends-toolbar button.active { background: #334155; border-color: #60a5fa; color: #fff; }
#build-panel { bottom: 58px; }
#build-panel.collapsed { display: none; }
#build-panel.collapsed #build-panel-body { transform: none; }
#build-panel-toggle { margin-left: 0; }

#friends-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 58px;
  z-index: 120;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
#friends-panel.collapsed { display: none; }
#inventory-panel { position:absolute; left:0; right:0; bottom:58px; z-index:120; display:flex; justify-content:center; pointer-events:none; }
#inventory-panel.collapsed { display:none; }
#inventory-panel-body { width:min(920px,calc(100vw - 24px)); max-height:620px; box-sizing:border-box; padding:12px 14px 0; pointer-events:auto; color:#e2e8f0; background:rgba(15,23,42,.96); border:1px solid #a16207; border-radius:14px; box-shadow:0 -12px 32px rgba(0,0,0,.55); }
.inventory-panel-header { display:flex; align-items:center; gap:10px; padding-bottom:10px; border-bottom:1px solid #334155; }
.inventory-panel-header input { width:100%; box-sizing:border-box; padding:8px 11px; border:1px solid #334155; border-radius:8px; outline:none; background:#0f172a; color:#f8fafc; }
.inventory-empty-toggle { display:flex; align-items:center; gap:5px; white-space:nowrap; color:#cbd5e1; font-size:12px; }
#inventory-panel-close { border:1px solid #475569; border-radius:8px; background:#1e293b; color:#e2e8f0; padding:8px 10px; cursor:pointer; }
.inventory-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(78px,1fr)); grid-auto-rows:78px; align-content:start; gap:8px; height:422px; padding:12px 8px 12px 2px; overflow-y:scroll; scrollbar-color:#b45309 #17120d; scrollbar-width:thin; }
.inventory-grid::-webkit-scrollbar { width:10px; }.inventory-grid::-webkit-scrollbar-track { background:#17120d; border-radius:8px; }.inventory-grid::-webkit-scrollbar-thumb { background:#b45309; border:2px solid #17120d; border-radius:8px; }
.inventory-item { min-height:78px; display:grid; place-items:center; align-content:center; gap:4px; border:1px solid #7c4a13; border-radius:8px; background:linear-gradient(145deg,#352314,#17120d); color:#fef3c7; text-align:center; }
.inventory-item.zero { opacity:.48; filter:grayscale(.65); }.inventory-item-icon { font-size:27px; }.inventory-item-amount { font-size:15px; font-weight:800; }.inventory-item-name { max-width:72px; overflow:hidden; color:#d6d3d1; font-size:10px; text-overflow:ellipsis; white-space:nowrap; }
.inventory-empty-state { grid-column:1/-1; padding:34px; color:#94a3b8; text-align:center; }
.inventory-tabs { display:flex; justify-content:space-around; margin:0 -14px; border-top:1px solid #7c4a13; }.inventory-tabs button { flex:1; border:0; border-right:1px solid #7c4a13; padding:10px; background:#17120d; color:#cbd5e1; cursor:pointer; font-family:inherit; font-weight:700; }.inventory-tabs button.active { background:#4a2b12; color:#fde68a; }
#friends-panel-body {
  width: min(900px, calc(100vw - 24px));
  max-height: 330px;
  box-sizing: border-box;
  padding: 10px 14px 14px;
  overflow: hidden;
  pointer-events: auto;
  color: #e2e8f0;
  background: rgba(15, 23, 42, .94);
  border: 1px solid #334155;
  border-radius: 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, .5);
}
.friends-panel-header { display: flex; align-items: center; gap: 12px; }
.friends-panel-header .build-panel-title { gap: 8px; }
.friends-search-box { flex: 1; margin-left: auto; max-width: 360px; }
#friends-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  border: 1px solid #334155;
  border-radius: 8px;
  outline: none;
  background: #0f172a;
  color: #f8fafc;
}
#friends-search-input:focus { border-color: #60a5fa; box-shadow: 0 0 0 2px rgba(59, 130, 246, .2); }
.friends-toolbar { display: flex; gap: 7px; margin: 10px 0 8px; }
.friends-toolbar button { padding: 7px 11px; box-shadow: none; }
.friends-status { min-height: 18px; margin-bottom: 7px; color: #94a3b8; font-size: 12px; }
.friends-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; }
.friend-card {
  flex: 0 0 170px;
  min-height: 175px;
  padding: 11px;
  box-sizing: border-box;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #1e293b;
  text-align: center;
}
.friend-card.is-friend { border-color: rgba(96, 165, 250, .65); }
.friend-avatar {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  border: 2px solid #475569;
  border-radius: 50%;
  object-fit: cover;
  background: #0f172a;
}
.friend-name { display: block; overflow: hidden; color: #f8fafc; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.friend-island-state { display: block; min-height: 17px; margin: 4px 0 8px; color: #94a3b8; font-size: 11px; }
.friend-actions { display: flex; justify-content: center; gap: 6px; }
.friend-card button { padding: 6px 8px; box-shadow: none; font-size: 11px; }
.friend-card .visit-friend { border-color: #2563eb; background: #1d4ed8; }
.friend-card .remove-friend { color: #fca5a5; }
.friend-card button:disabled { opacity: .45; cursor: not-allowed; }

.visit-mode-banner {
  position: absolute;
  top: 64px;
  left: 50%;
  z-index: 125;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  padding: 8px 10px 8px 15px;
  border: 1px solid #60a5fa;
  border-radius: 10px;
  background: rgba(15, 23, 42, .96);
  color: #dbeafe;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .4);
  font-size: 12px;
  font-weight: 700;
}
.visit-mode-banner.hidden { display: none; }
#visit-island-select { max-width: 220px; padding: 5px 8px; border: 1px solid #60a5fa; border-radius: 6px; background: #0f172a; color: #dbeafe; font-size: 12px; }
#visit-island-select.hidden { display: none; }
#visit-return-home { padding: 6px 9px; border-color: #60a5fa; background: #1d4ed8; box-shadow: none; }
body.visiting-island #build-launcher,
body.visiting-island #build-panel,
body.visiting-island #resourcesBar { display: none !important; }

@media (max-width: 680px) {
  .friends-panel-header { flex-wrap: wrap; }
  .friends-search-box { order: 3; flex-basis: 100%; max-width: none; }
  .friend-card { flex-basis: 150px; }
  .visit-mode-banner { top: 58px; width: calc(100vw - 24px); box-sizing: border-box; }
}

/* Dedicated Building Hover Tooltip */
.building-tooltip {
  position: fixed;
  z-index: 1050;
  pointer-events: none;
  width: 300px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid #475569;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  animation: fadeInTip 0.12s ease-out;
  font-size: 14px;
}
@keyframes fadeInTip {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.btip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.btip-icon {
  font-size: 24px;
}
.btip-title-group h4 {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
}
.btip-category-badge {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
}
.btip-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.btip-meta-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}
.btip-meta-pill.cost-pill {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}
.btip-desc {
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.4;
  margin: 0;
}

/* Tooltip & Popups */
#tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid #475569;
  color: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
/* Building window: the game's carved wood look (like the chat and quest
   windows), docked at the bottom so the map stays visible; content in tabs. */
#building-popup {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 32px));
  max-height: min(52vh, 480px);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  text-align: left;
  color: var(--cream, #f3e6c8);
  border: 1px solid var(--brass-600, #8a6334);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(58, 39, 22, .98), rgba(24, 15, 9, .98) 80%);
  box-shadow: inset 0 1px #b8955a, inset 0 0 0 2px rgba(20, 10, 4, .55), 0 14px 36px rgba(0, 0, 0, .6);
  overflow: hidden;
}
#building-popup.hidden { display: none; }
.bw-head {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 12px;
  border-bottom: 1px solid var(--brass-600, #8a6334);
  background: linear-gradient(#79552d, #46301c);
  box-shadow: inset 0 1px var(--brass-400, #c9a45f), 0 3px 6px rgba(0, 0, 0, .3);
}
#popup-preview { width: 56px; height: 56px; border-radius: 8px; background: rgba(20, 12, 6, .45); border: 1px solid rgba(184, 149, 90, .5); }
#popup-icon { display: none; }
.bw-title { min-width: 0; }
#popup-name { font-size: 18px; font-weight: 700; margin: 0; color: var(--cream, #f3e6c8); text-shadow: 0 2px 2px #1b1007; letter-spacing: .02em; }
#popup-desc { font-size: 13px; color: #e2cfa6; margin: 2px 0 0; line-height: 1.35; }
#popup-close {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--brass-300, #d5b56e); border-radius: 50%;
  background: var(--wood-600, #4a331d); color: var(--cream, #f3e6c8); cursor: pointer; font-size: 14px;
}
#popup-close:hover { background: #6b321d; color: #fff; }
#popup-demolish {
  padding: 6px 12px; border: 1px solid #b4553a; border-radius: 6px;
  background: linear-gradient(#7a2e1c, #4e1a10); color: #ffe4d6; font-size: 13px; cursor: pointer;
  box-shadow: inset 0 1px rgba(255, 180, 150, .35);
}
#popup-demolish:hover:not(:disabled) { background: linear-gradient(#933a24, #5e2014); color: #fff; }
#popup-demolish:disabled { opacity: .45; cursor: not-allowed; }
.bw-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid rgba(141, 104, 47, .55); overflow-x: auto; overflow-y: hidden; flex-shrink: 0; }
/* The header and the tabs keep their height; only the content scrolls. */
.bw-head { flex-shrink: 0; }
.bw-tab {
  flex: 0 0 auto;
  padding: 6px 14px; border: 1px solid var(--brass-700, #6e4f2a); border-bottom: 0; border-radius: 7px 7px 0 0;
  background: linear-gradient(#3b2716, #2a1b0f); color: #d9c49a; font-size: 13px; font-weight: 600; cursor: pointer;
}
.bw-tab:hover { color: #fff; border-color: var(--brass-600, #8a6334); }
.bw-tab.active { background: linear-gradient(#8a6334, #5a3d20); color: #fff; border-color: var(--brass-300, #d5b56e); box-shadow: inset 0 1px #e2c78b; }
.bw-tab.hidden { display: none; }
.bw-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 14px 12px; scrollbar-color: var(--brass-600, #8a6334) transparent; scrollbar-width: thin; }
.bw-pane { display: none; }
.bw-pane.active { display: block; }
#popup-work-hours { font-size: 13px; color: #e2cfa6; margin: 2px 0 8px; }
#popup-lumberjack-overtime { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:6px 0; padding:8px 10px; border:1px solid rgba(141,104,47,.6); border-radius:7px; background:rgba(20,12,6,.35); }
#popup-lumberjack-overtime small { display:block; margin-top:2px; color:#cdb88f; font-size:11px; line-height:1.3; }
#popup-owner { font-size: 12px; color: #b9a47b; margin: 8px 0 0; }
#popup-buffers { display: grid; gap: 10px; }
.buffer-group { border: 1px solid rgba(141, 104, 47, .7); border-radius: 8px; padding: 9px 10px; background: rgba(20, 12, 6, .38); }
.buffer-group-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 8px; }
.buffer-group-head strong { color: #fff4d6; font-size: 14px; }
.buffer-group-head span { color: #cdb88f; font-size: 11px; text-align: right; }
.buffer-columns { display: flex; align-items: flex-end; gap: 10px; min-height: 154px; overflow-x: auto; padding: 3px 2px 2px; }
.buffer-column { flex: 0 0 66px; display: grid; justify-items: center; gap: 4px; color: #eadcb9; text-align: center; }
.buffer-meter { position: relative; width: 36px; height: 104px; overflow: hidden; border: 1px solid #9d7744; border-radius: 6px 6px 4px 4px; background: linear-gradient(90deg, rgba(10,7,4,.75), rgba(52,35,19,.75)); box-shadow: inset 0 0 8px rgba(0,0,0,.65); }
.buffer-meter-fill { position: absolute; left: 3px; right: 3px; bottom: 3px; min-height: 0; border-radius: 3px 3px 2px 2px; background: linear-gradient(#63d7ff, #247ca4); box-shadow: inset 0 1px rgba(255,255,255,.45), 0 0 7px rgba(56,189,248,.25); transition: height .25s ease; }
.buffer-meter.unknown .buffer-meter-fill { background: repeating-linear-gradient(135deg, #a9874e 0 7px, #765a31 7px 14px); }
.buffer-column-icon { height: 25px; display: grid; place-items: center; font-size: 20px; }
.buffer-column-icon img { width: 24px; height: 24px; object-fit: contain; }
.buffer-column b { color: #fff4d6; font-size: 12px; }
.buffer-column small { width: 66px; color: #cdb88f; font-size: 10px; line-height: 1.15; overflow-wrap: anywhere; }
.buffer-empty { color: #b9a47b; font-size: 12px; padding: 12px 2px; }
/* Content cards inside the window: wood instead of slate. */
#building-popup .production-overview { color: #eadcb9; }
#building-popup .production-overview strong { color: #fff4d6; }
#building-popup .production-line,
#building-popup .auxiliary-row { border-color: rgba(141, 104, 47, .7); background: rgba(20, 12, 6, .38); color: #eadcb9; }
#building-popup .production-line-title { color: #fff4d6; }
#building-popup .production-line-meta,
#building-popup .production-line small,
#building-popup .production-empty,
#building-popup .auxiliary-row small { color: #cdb88f; }
#building-popup #building-upgrades-section > div { border-top: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }
@media (max-width: 620px) {
  #building-popup { bottom: 8px; width: calc(100vw - 16px); max-height: 62vh; }
  .bw-head { grid-template-columns: 44px 1fr auto; }
  #popup-preview { width: 44px; height: 44px; }
  #popup-demolish { grid-column: 1 / -1; grid-row: 2; }
  .bw-tab { padding: 6px 9px; font-size: 12px; }
  .buffer-column { flex-basis: 58px; }
}

#popup-production { margin: 0; }
.production-overview { display:flex; gap:14px; flex-wrap:wrap; align-items:center; color:#cbd5e1; font-size:14px; }
.production-overview strong { color:#f8fafc; font-size:15px; }
.production-overview b { color:#4ade80; }
.production-lines { display:grid; grid-template-columns:repeat(auto-fit, minmax(250px, 1fr)); gap:9px; margin-top:10px; }
.production-line { border:1px solid #334155; background:rgba(30,41,59,.72); border-radius:8px; padding:10px; font-size:13px; color:#cbd5e1; }
.production-line-title { display:flex; justify-content:space-between; gap:8px; color:#f8fafc; font-size:14px; }
.production-efficiency { color:#4ade80; font-weight:700; }
.production-line-meta { color:#94a3b8; margin:4px 0; }
.production-line-flow { display:grid; gap:2px; color:#cbd5e1; margin-bottom:5px; }
.production-line progress { width:100%; height:10px; accent-color:#38bdf8; display:block; }
.production-line small, .production-empty { color:#94a3b8; display:block; margin-top:4px; }
#popup-auxiliary { margin: 0; }
.auxiliary-title { color:#f8fafc; font-weight:700; font-size:13px; margin-bottom:7px; }
.auxiliary-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:7px 9px; border:1px solid #334155; border-radius:7px; background:rgba(30,41,59,.72); margin-top:5px; }
.auxiliary-row small { display:block; color:#94a3b8; margin-top:2px; }


/* HUD Menu Dropdown */
.menu-dropdown-wrapper {
  position: relative;
  display: inline-block;
}
.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid #334155;
  border-radius: 10px;
  min-width: 200px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  padding: 6px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.menu-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.menu-dropdown-item:hover {
  background: #1e293b;
  color: #38bdf8;
}
.menu-dropdown-item.text-danger:hover {
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
}

/* Modal Archipelago (Full-Width Fantasy Ocean Chart with 15 Islands) */
.modal-archipelago-content {
  max-width: 1750px;
  width: 98vw;
  height: 94vh;
  max-height: 96vh;
  background: rgba(10, 20, 35, 0.98);
  border: 1px solid #0284c7;
  box-shadow: 0 25px 60px rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
}

/* Modal Economy Panel */
.modal-economy-content {
  padding: 0;
  max-width: none;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  background: rgba(10, 20, 35, 0.98);
  border: 1px solid #0284c7;
  box-shadow: 0 25px 60px rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
}

.modal-economy-content .modal-body { max-height: none !important; flex: 1; min-height: 0; }
.economy-toolbar { display: flex; flex-wrap: wrap; gap: 14px; margin: 18px 0 12px; }
.economy-toolbar label { display: flex; flex: 1; min-width: 170px; flex-direction: column; gap: 6px; color: #94a3b8; font-size: 12px; }
.economy-toolbar label:first-child { flex: 2; }
.economy-toolbar input, .economy-toolbar select { width: 100%; padding: 10px; background: #0f172a; border: 1px solid #334155; border-radius: 6px; color: #e2e8f0; }
.economy-toolbar :focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; }
.economy-note { color: #94a3b8; font-size: 12px; line-height: 1.6; }
.economy-grid-scroll { overflow: auto; max-height: 55vh; border: 1px solid #1e3a5f; border-radius: 8px; }
.economy-grid-scroll table { min-width: 1050px; }
.economy-grid-scroll th { position: sticky; top: 0; background: #122238; z-index: 1; }
.economy-table small { display: block; color: #94a3b8; font-size: 11px; margin-top: 5px; }
.economy-resource-icon { margin-right: 9px; font-size: 22px; }
.economy-numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.economy-table progress { display: block; width: 100%; height: 5px; margin-top: 7px; accent-color: #38bdf8; }
.economy-table details { max-width: 270px; font-size: 12px; line-height: 1.6; }
.economy-table summary { cursor: pointer; color: #7dd3fc; }
.economy-sparkline { width: 110px; height: 32px; }
.economy-sparkline polyline { stroke: #38bdf8; stroke-width: 2; fill: none; }
.economy-pagination, .economy-refresh { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: #94a3b8; font-size: 12px; flex-wrap: wrap; }
.economy-pagination span, .economy-refresh span { flex: 1; }
.economy-pagination button:disabled { opacity: .4; cursor: default; }
#economy-panel-warehouses { overflow-x: auto; }

.economy-resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 2px 2px 12px;
}
.economy-resource-card {
  position: relative;
  overflow: hidden;
  border: 1px solid #29486c;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(20, 38, 61, .98), rgba(10, 23, 40, .98));
  color: #e2e8f0;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.economy-resource-card:hover { transform: translateY(-2px); border-color: #3b82f6; box-shadow: 0 11px 28px rgba(0, 0, 0, .38); }
.economy-resource-card.expanded { grid-column: span 2; border-color: #38bdf8; }
.economy-resource-card.pinned { border-color: #eab308; box-shadow: 0 8px 24px rgba(234, 179, 8, .13); }
.economy-resource-main { padding: 16px; }
.economy-resource-heading { display: flex; align-items: center; gap: 12px; }
.economy-resource-card-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 1px solid rgba(125, 211, 252, .25);
  border-radius: 13px;
  background: rgba(15, 23, 42, .75);
  font-size: 34px;
}
.economy-resource-card-icon img { width: 44px !important; height: 44px !important; }
.economy-resource-title { min-width: 0; flex: 1; }
.economy-resource-title strong { display: block; overflow: hidden; color: #f8fafc; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.economy-resource-title small { display: block; margin-top: 4px; color: #94a3b8; font-size: 11px; }
.economy-resource-island { max-width: 110px; overflow: hidden; padding: 3px 7px; border-radius: 999px; background: rgba(14, 165, 233, .13); color: #7dd3fc; text-overflow: ellipsis; white-space: nowrap; }
.economy-resource-amount-block { margin: 16px 0 12px; }
.economy-resource-amount-label { color: #94a3b8; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.economy-resource-amount { display: flex; align-items: baseline; gap: 7px; margin-top: 2px; }
.economy-resource-amount strong { color: #fff; font-size: clamp(32px, 3vw, 44px); font-variant-numeric: tabular-nums; line-height: 1; }
.economy-resource-amount span { color: #94a3b8; font-size: 13px; }
.economy-storage-track { height: 8px; overflow: hidden; margin-top: 10px; border-radius: 999px; background: #07111f; }
.economy-storage-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0284c7, #38bdf8); }
.economy-storage-caption { display: flex; justify-content: space-between; margin-top: 5px; color: #64748b; font-size: 10px; }
.economy-resource-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.economy-resource-metric { padding: 8px; border: 1px solid rgba(51, 65, 85, .8); border-radius: 9px; background: rgba(15, 23, 42, .55); text-align: center; }
.economy-resource-metric strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.economy-resource-metric span { display: block; margin-top: 2px; color: #94a3b8; font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }
.economy-resource-forecast { margin: 10px 0 0; color: #cbd5e1; font-size: 11px; }
.economy-resource-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 13px; }
.economy-resource-actions button { font-size: 11px; }
.economy-pin-toggle { display:inline-flex; align-items:center; gap:6px; margin-left:auto; color:#cbd5e1; font-size:11px; font-weight:700; cursor:pointer; }
.economy-pin-toggle input { width:16px; height:16px; margin:0; accent-color:#eab308; cursor:pointer; }
.economy-pin-toggle:has(input:disabled) { opacity:.45; cursor:not-allowed; }
.economy-resource-details { padding: 15px 16px 17px; border-top: 1px solid #29486c; background: rgba(3, 12, 24, .55); }
.economy-resource-description { margin: 0 0 13px; color: #cbd5e1; font-size: 12px; line-height: 1.55; }
.economy-resource-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 13px; }
.economy-resource-detail-stats div { padding: 8px; border-radius: 8px; background: rgba(15, 23, 42, .72); }
.economy-resource-detail-stats span { display: block; color: #64748b; font-size: 9px; text-transform: uppercase; }
.economy-resource-detail-stats strong { display: block; margin-top: 2px; color: #e2e8f0; font-size: 14px; }
.economy-resource-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.economy-source-group { padding: 10px; border: 1px solid #263d59; border-radius: 9px; background: rgba(15, 23, 42, .55); }
.economy-source-group h5 { display: flex; justify-content: space-between; margin: 0 0 8px; font-size: 12px; }
.economy-source-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(148, 163, 184, .09); font-size: 11px; }
.economy-source-empty { color: #64748b; font-size: 11px; }
.economy-admin-card-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #29486c; }

/* Large asset cards used by the administrator's flora and decoration panels. */
#trees-list > table,
#decorations-list > table,
#buildings-list > table { display: block; }
#trees-list thead,
#decorations-list thead,
#buildings-list thead { display: none; }
#trees-list tbody,
#decorations-list tbody,
#buildings-list tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
  padding: 2px 2px 12px;
}
#trees-list tbody tr,
#decorations-list tbody tr,
#buildings-list tbody tr { display: block; min-width: 0; }
#trees-list tbody td,
#decorations-list tbody td,
#buildings-list tbody td { display: block; padding: 0; border: 0; }
.admin-asset-card {
  display: flex;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid #29486c;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(20, 38, 61, .98), rgba(10, 23, 40, .98));
  color: #e2e8f0;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.admin-asset-card:hover { transform: translateY(-2px); border-color: #3b82f6; box-shadow: 0 11px 28px rgba(0, 0, 0, .38); }
.admin-asset-card-media {
  display: grid;
  place-items: center;
  flex: 0 0 145px;
  min-height: 260px;
  padding: 12px;
  background: rgba(15, 23, 42, .7);
  border-right: 1px solid #29486c;
}
.admin-asset-preview { display: grid; place-items: center; width: 100%; height: 100%; }
.admin-asset-preview-main { width: 120px; height: 150px; object-fit: contain; image-rendering: pixelated; }
.admin-asset-preview-stages { display: flex; align-items: end; justify-content: center; gap: 5px; height: 38px; margin-top: -8px; }
.admin-asset-preview-stages img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.admin-asset-preview-stages span { font-size: 20px; opacity: .7; }
.decoration-asset-preview { min-width: 120px; }
.decoration-asset-preview img { width: 125px; height: 175px; object-fit: contain; image-rendering: pixelated; }
.admin-asset-card-content { display: flex; flex: 1; min-width: 0; flex-direction: column; padding: 16px; }
.admin-asset-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.admin-asset-card-heading h4 { margin: 0; color: #f8fafc; font-size: 17px; }
.admin-asset-id { display: block; margin-top: 4px; color: #64748b; font-size: 11px; }
.admin-asset-card-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 15px 0 10px; color: #cbd5e1; font-size: 11px; line-height: 1.5; }
.admin-asset-card-biomes { display: flex; flex-wrap: wrap; gap: 4px; color: #94a3b8; font-size: 12px; line-height: 1.6; }
.admin-asset-card-file { overflow: hidden; margin-top: 10px; color: #94a3b8; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.admin-asset-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 14px; }
.admin-building-card-media { flex-basis: 155px; }
.admin-building-preview { display: grid; place-items: center; width: 135px; height: 175px; border: 1px solid rgba(125, 211, 252, .2); border-radius: 12px; background: rgba(15, 23, 42, .7); }
.admin-building-preview img { width: 125px; height: 165px; object-fit: contain; image-rendering: pixelated; }
.admin-building-preview-icon { font-size: 64px; line-height: 1; }
.admin-building-cost { margin-top: 10px; color: #cbd5e1; font-size: 12px; }
.admin-asset-label { display: block; margin-bottom: 4px; color: #64748b; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }

@media (max-width: 640px) {
  #trees-list tbody, #decorations-list tbody { grid-template-columns: 1fr; }
  .admin-asset-card { min-height: 230px; }
  .admin-asset-card-media { flex-basis: 120px; min-height: 230px; }
  .admin-building-card-media { flex-basis: 125px; }
  .admin-building-preview { width: 105px; height: 145px; }
  .admin-building-preview img { width: 95px; height: 135px; }
  .admin-asset-preview-main { width: 100px; height: 130px; }
}

@media (max-width: 760px) {
  .economy-resource-grid { grid-template-columns: 1fr; }
  .economy-resource-card.expanded { grid-column: span 1; }
  .economy-resource-sources { grid-template-columns: 1fr; }
}

.economy-tab-btn {
  padding: 6px 14px !important;
  font-size: 12px !important;
  border-radius: 6px 6px 0 0 !important;
  border-bottom: 2px solid transparent !important;
  transition: all 0.2s ease;
}
.economy-tab-btn.active {
  background: rgba(56, 189, 248, 0.15) !important;
  border-bottom-color: #38bdf8 !important;
  color: #38bdf8 !important;
}

.economy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.economy-table th {
  text-align: left;
  padding: 8px 10px;
  color: #94a3b8;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #1e3a5f;
}
.economy-table td {
  padding: 8px 10px;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(30, 58, 95, 0.5);
  vertical-align: middle;
}
.economy-table tr:hover td {
  background: rgba(56, 189, 248, 0.06);
}
.economy-table .icon-cell {
  font-size: 20px;
  text-align: center;
}

.economy-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 80px;
}
.economy-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
}
.economy-stat-lbl {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rate-positive { color: #22c55e; }
.rate-negative { color: #ef4444; }
.rate-zero { color: #64748b; }

.btn-focus-building {
  padding: 3px 8px;
  font-size: 11px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-focus-building:hover {
  background: rgba(56, 189, 248, 0.3);
  border-color: #38bdf8;
}
.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 14px;
}
.modal-title-with-icon h3 {
  margin: 0;
  font-size: 19px;
  color: #38bdf8;
}
.modal-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

/* Nautical Ocean Chart Container — background from uploaded image */
.archipelago-ocean-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 520px;
  background: #0b1a30;
  border-radius: 8px;
  border: 1px solid #1e3a5f;
  overflow: hidden;
  user-select: none;
}

.archipelago-svg-routes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Island & Sector Nodes on Virtual Ocean */
.archipelago-ocean-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
}

.island-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s;
  z-index: 5;
}
.island-node:hover {
  transform: translate(-50%, -50%) scale(1.12);
  z-index: 25;
}

/* 1. Discovered Island — frameless miniature */
.island-canvas-wrap {
  position: relative;
  width: 86px;
  height: 86px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: all 0.25s ease;
}

.island-mini-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.island-node:hover .island-canvas-wrap {
  border: none;
  box-shadow: none;
}

.island-node.is-primary .island-canvas-wrap {
  width: 104px;
  height: 104px;
  border: none;
  box-shadow: none;
}
.island-node.is-primary:hover .island-canvas-wrap {
  border: none;
  box-shadow: none;
}

.island-node.is-fog {
  pointer-events: none;
  cursor: default;
  z-index: 6;
}

.archipelago-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
  z-index: 1;
}
.island-cloud {
  display: block;
  width: 150px;
  height: 100px;
  object-fit: contain;
  user-select: none;
  filter: drop-shadow(0 5px 8px rgba(2, 12, 28, 0.2));
}

.island-node-label {
  margin-top: 6px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.island-node-label:hover {
  background: #1e293b;
  border-color: #38bdf8;
  color: #38bdf8;
  transform: scale(1.04);
}
.island-node.is-primary .island-node-label {
  border-color: #f59e0b;
  color: #fef08a;
  font-size: 12px;
}
.island-node.is-primary .island-node-label:hover {
  border-color: #fbbf24;
  color: #fff;
}

.island-edit-icon {
  font-size: 10px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.island-node-label:hover .island-edit-icon {
  opacity: 1;
}

.island-node-sub {
  font-size: 9px;
  color: #94a3b8;
  margin-top: 2px;
  background: rgba(0,0,0,0.6);
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

/* Grid & Sector View fallback */
.archipelago-grid-container {
  padding: 10px;
  display: flex;
  flex: 1;
  min-height: 0;
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  background: radial-gradient(circle at center, #12375a, #071525 72%);
  justify-content: flex-start;
}
.archipelago-grid {
  display: grid;
  grid-template-columns: repeat(5, 92px);
  grid-template-rows: repeat(5, 92px);
  gap: 8px;
  width: max-content;
  margin: auto;
}

/* Archipelago ownership list: islands are added as large sequential cards,
   rather than being implied by empty sectors on a grid. */
.archipelago-grid { display:flex; flex-direction:column; gap:12px; width:min(980px,100%); margin:0 auto; padding:4px 6px 18px; }
.archipelago-island-card { display:grid; grid-template-columns:142px minmax(0,1fr); gap:16px; align-items:center; padding:13px; border:1px solid #8b6739; border-radius:8px; background:linear-gradient(145deg,rgba(67,45,26,.97),rgba(30,19,12,.98)); box-shadow:inset 0 0 0 2px rgba(20,10,4,.55),0 5px 12px rgba(0,0,0,.28); }
.archipelago-island-card.primary { border-color:#d5ad58; background:linear-gradient(145deg,rgba(85,58,29,.98),rgba(35,22,12,.99)); }
.archipelago-island-preview { width:132px; height:132px; border:2px solid #b8914e; border-radius:7px; background:#17374b; image-rendering:pixelated; box-shadow:inset 0 0 0 2px #24160d,0 3px 8px rgba(0,0,0,.45); }
.archipelago-island-details { min-width:0; }.archipelago-island-title { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }.archipelago-island-title h4 { margin:0; color:#fff0c7; font-size:19px; text-shadow:0 1px #211308; }.archipelago-island-title span { padding:3px 8px; border:1px solid #c7a15d; border-radius:999px; color:#fff0c7; background:rgba(116,76,33,.5); font-size:11px; }
.archipelago-rename { margin-left:auto; padding:4px 7px; border:1px solid #ae884b; border-radius:5px; background:rgba(47,29,17,.75); color:#f1d49b; font-size:11px; cursor:pointer; }.archipelago-rename:hover { background:#68401f; color:#fff3d0; }
.archipelago-fertility { min-height:25px; margin:9px 0; color:#e7c98f; line-height:1.55; }.archipelago-fertility small { color:#b7955e; }
.archipelago-island-stats { display:flex; gap:10px; flex-wrap:wrap; }.archipelago-island-stats span { padding:6px 9px; border:1px solid rgba(190,148,80,.5); border-radius:5px; color:#ead9b5; background:rgba(27,16,9,.55); }.archipelago-island-stats .positive { color:#a7e5ad; }.archipelago-island-stats .negative { color:#f3a4a4; }
.archipelago-island-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:13px; }.archipelago-island-actions .btn-danger:disabled { opacity:.55; cursor:not-allowed; }
.archipelago-empty { padding:30px; color:#d8bd8a; text-align:center; }
@media(max-width:650px){.archipelago-island-card{grid-template-columns:86px minmax(0,1fr);gap:10px;padding:10px}.archipelago-island-preview{width:82px;height:82px}.archipelago-island-title h4{font-size:16px}.archipelago-island-actions{justify-content:stretch}.archipelago-island-actions button{flex:1;padding:7px 5px;font-size:11px}}
.archipelago-sector-card {
  width: 92px;
  height: 92px;
  background: #0f172a;
  border: 1px dashed #334155;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
  padding: 6px;
  text-align: center;
}
.sector-coord {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  font-family: monospace;
}
.sector-icon {
  font-size: 26px;
  margin-bottom: 4px;
}
.sector-name {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  line-height: 1.2;
}
.sector-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 8px;
  margin-top: 4px;
  font-weight: 600;
}
.sector-primary {
  border: 2px solid #f59e0b !important;
  background: linear-gradient(145deg, #1e293b 0%, rgba(245, 158, 11, 0.15) 100%) !important;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.35);
  cursor: pointer;
}
.sector-primary:hover {
  transform: scale(1.04);
  border-color: #fbbf24 !important;
}
.sector-primary .sector-name {
  color: #fef08a;
}
.sector-primary .sector-badge {
  background: #f59e0b;
  color: #000;
}
.sector-fog {
  opacity: 0.65;
}
.sector-fog:hover {
  opacity: 0.9;
  border-color: #64748b;
}
.sector-fog .sector-name {
  color: #64748b;
}
.archipelago-info-footer {
  margin-top: 14px;
  border-top: 1px solid #334155;
  padding-top: 12px;
}
.archipelago-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 12px;
  color: #94a3b8;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-primary { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.dot-fog { background: #475569; }
.dot-primary { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.dot-fog { background: #475569; }

/* =====================================================================
   CALENDAR & SEASONS STYLES
   ===================================================================== */
.calendar-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 20px;
}

.calendar-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
}

.calendar-status-item .status-label {
  color: #94a3b8;
}
.archipelago-sector-card.sector-discovered { cursor: pointer; border-style: solid; border-color: #2563eb; background: rgba(15, 35, 60, .95); }
.archipelago-sector-card.sector-discovered:hover { transform: scale(1.06); z-index: 2; border-color: #38bdf8; }
.archipelago-sector-card .archipelago-fertility-trigger { display: none; }
.sector-ships { position: absolute; top: 4px; right: 5px; padding: 2px 5px; border-radius: 999px; background: #075985; color: #bae6fd; font-size: 9px; font-weight: 800; }

.archipelago-shipping-view { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 12px; overflow: auto; }
.shipping-toolbar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.shipping-rule-note { padding: 9px 11px; border-left: 3px solid #0ea5e9; border-radius: 4px; background: rgba(14, 165, 233, .08); color: #bae6fd; font-size: 11px; line-height: 1.45; }
.shipping-toolbar label, .shipping-editor-main label { display: flex; min-width: 220px; flex-direction: column; gap: 5px; color: #94a3b8; font-size: 11px; }
.shipping-toolbar select, .shipping-editor input, .shipping-editor select, .shipping-operation select, .shipping-operation input, .shipping-stop select {
  min-height: 34px; padding: 6px 8px; border: 1px solid #334155; border-radius: 6px; background: #0f172a; color: #e2e8f0;
}
.shipping-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.shipping-card { padding: 14px; border: 1px solid #29486c; border-radius: 10px; background: rgba(15, 29, 48, .9); color: #e2e8f0; }
.shipping-card h4 { margin: 0 0 12px; color: #7dd3fc; }
.shipping-empty { padding: 18px; border: 1px dashed #475569; border-radius: 8px; color: #94a3b8; text-align: center; }
.shipping-table-wrap { overflow-x: auto; }
.shipping-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.shipping-table th, .shipping-table td { padding: 8px; border-bottom: 1px solid #29405b; text-align: left; }
.shipping-table th { color: #94a3b8; }
.shipping-ship-row { display: grid; grid-template-columns: minmax(170px, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid #29405b; }
.shipping-ship-row small { display: block; margin-top: 3px; color: #94a3b8; line-height: 1.35; }
.shipping-state { padding: 3px 7px; border-radius: 999px; background: #334155; color: #cbd5e1; font-size: 9px; font-weight: 800; }
.shipping-state.active { background: rgba(34, 197, 94, .2); color: #86efac; }
.shipping-editor { margin-bottom: 8px; }
.shipping-editor-main { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.shipping-editor-main .shipping-check { min-width: auto; flex-direction: row; align-items: center; padding-bottom: 8px; }
.shipping-stops { display: flex; flex-direction: column; gap: 9px; margin: 13px 0; }
.shipping-stop { padding: 10px; border: 1px solid #334155; border-radius: 8px; background: rgba(2, 12, 27, .45); }
.shipping-stop-head { display: grid; grid-template-columns: 110px minmax(220px, 1fr) auto; gap: 9px; align-items: center; margin-bottom: 8px; }
.shipping-stop small { display: block; margin: 7px 0; color: #64748b; }
.shipping-operation { display: grid; grid-template-columns: 110px minmax(180px, 1fr) 100px auto; gap: 7px; margin: 7px 0; }
.shipping-editor-actions { display: flex; gap: 8px; align-items: center; }
.shipping-editor-actions span { flex: 1; }
.shipping-market-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.shipping-market-head h4 { margin:0; }
.shipping-market-head small { color:#94a3b8; }
.shipping-market-port { display:flex; gap:8px; align-items:center; margin:12px 0; color:#94a3b8; }
.market-offer-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(270px,1fr)); gap:10px; margin:10px 0 16px; }
.market-offer-card { padding:12px; border:1px solid #334155; border-radius:9px; background:#0f172a; }
.market-offer-card strong { color:#f8fafc; }
.market-offer-meta { color:#94a3b8; font-size:11px; margin:6px 0; }
.market-alternatives { display:flex; flex-direction:column; gap:6px; }
.market-alternative { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.market-contract-progress { height:7px; width:100%; }
@media (max-width: 900px) {
  .shipping-layout { grid-template-columns: 1fr; }
  .shipping-stop-head, .shipping-operation { grid-template-columns: 1fr; }
  .shipping-ship-row { grid-template-columns: 1fr auto; }
}

#cal-game-time {
  background: #1e293b;
  border: 1px solid #475569;
  color: #f8fafc;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.cal-day-night-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: #f8fafc;
  white-space: nowrap;
}

#cal-fixed-day-night { accent-color: #eab308; }

.override-select {
  background: #1e293b;
  border: 1px solid #475569;
  color: #f8fafc;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.calendar-tools-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.season-palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  margin-bottom: 14px;
}

.season-brush-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 8px;
  color: #f1f5f9;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.season-brush-btn:hover {
  transform: translateY(-2px);
  border-color: #64748b;
}

.season-brush-btn.active {
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
  background: #1e293b;
}

.season-color-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.season-editor-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
}

.season-editor-box h5 {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #38bdf8;
}

.calendar-grid-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 18px;
}

.calendar-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #334155;
  padding-bottom: 12px;
}

.calendar-grid-header h4 {
  margin: 0;
  font-size: 14px;
  color: #f8fafc;
}

.grid-actions {
  display: flex;
  gap: 10px;
}

.calendar-months-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}

.calendar-month-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 8px;
}

.month-label-col {
  width: 100px;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.month-quick-btn {
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.month-quick-btn:hover {
  background: #334155;
  color: #fff;
  border-color: #64748b;
}

.month-days-track {
  display: flex;
  flex: 1;
  gap: 3px;
  overflow-x: auto;
}

.cal-day-cell {
  flex: 1;
  min-width: 22px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cal-day-cell:hover {
  transform: scale(1.18);
  z-index: 2;
  filter: brightness(1.25);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

.cal-day-cell.is-today {
  border: 2px solid #ffffff !important;
  box-shadow: 0 0 8px #ffffff, inset 0 0 4px #000;
  font-weight: 900;
  color: #000;
}

/* Season colors defaults */
.season-spring { background-color: #10b981; }
.season-summer { background-color: #eab308; }
.season-autumn { background-color: #f97316; }
.season-winter { background-color: #38bdf8; }

.hud-season-tag {
  font-weight: 600;
  color: #f59e0b;
}

/* =====================================================================
   Building Definition Editor Styles
   ===================================================================== */

.building-form-section {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.building-form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #334155;
}

/* Dynamic resource list rows */
.dynamic-resource-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 12px;
}

.resource-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 7px;
  padding: 6px 10px;
}

.resource-list-row select {
  flex: 1;
  background: #1e293b;
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
}

.resource-list-row input[type="number"] {
  width: 80px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
}

.resource-list-row .btn-remove-row {
  background: transparent;
  border: none;
  color: #f87171;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s;
}

.resource-list-row .btn-remove-row:hover {
  background: #450a0a;
}

/* Aux building row (type select + count) */
.aux-building-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 7px;
  padding: 6px 10px;
}

.aux-building-row select {
  flex: 1;
  background: #1e293b;
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
}

.aux-building-row input[type="number"] {
  width: 70px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
}

/* Biome checkboxes */
.biome-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
}

.biome-checkboxes label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  color: #cbd5e1;
  white-space: nowrap;
}

.biome-checkboxes input[type="checkbox"] {
  accent-color: #38bdf8;
  width: 14px;
  height: 14px;
}

.decoration-biome-option {
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
}

.decoration-biomes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  background: #1e293b;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 6px;
}

.decoration-biome-option > label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.decoration-biome-option .biome-settings {
  padding-top: 8px;
}

/* Buildings list table badges */
.badge-productive {
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #059669;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.badge-storage {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #3b82f6;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.badge-auxiliary {
  background: #2e1065;
  color: #c4b5fd;
  border: 1px solid #7c3aed;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

/* =====================================================================
   Terrain & Flora (Trees) Styles
   ===================================================================== */

.sprite-preview-box {
  min-width: 42px;
  width: 42px;
  height: 42px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
}

.sprite-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.building-appearance-editor { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(148, 163, 184, .2); }
#bld-appearance-levels { display: grid; gap: 10px; margin: 10px 0; }
.building-appearance-level-card { padding: 10px; border: 1px solid #334155; border-radius: 9px; background: rgba(15, 23, 42, .55); }
.building-appearance-level-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.building-appearance-level-head label { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.building-appearance-level { width: 72px !important; }
.building-appearance-files { display: grid; gap: 7px; }
.building-appearance-file { display: grid; grid-template-columns: 44px minmax(140px, 1fr) auto auto; align-items: center; gap: 7px; }
.building-appearance-preview { display: grid; place-items: center; width: 42px; height: 42px; overflow: hidden; border: 1px solid #334155; border-radius: 6px; color: #94a3b8; font-size: 9px; }
.building-appearance-preview img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.building-night-light-editor { margin-top: 16px; padding: 14px; border: 1px solid #475569; border-radius: 9px; background: rgba(15, 23, 42, .55); }
.building-night-light-editor .form-row { flex-wrap: wrap; align-items: end; }
.building-night-light-editor .form-row label { min-width: 150px; flex: 1; }
#bld-night-light-preview, #bld-smoke-preview { display: block; width: min(100%, 400px); height: auto; margin: 12px 0; border: 1px solid #475569; border-radius: 8px; cursor: crosshair; touch-action: none; }
.building-night-light-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 700px) {
  .building-appearance-level-head { align-items: flex-start; flex-direction: column; }
  .building-appearance-file { grid-template-columns: 42px minmax(100px, 1fr); }
  .building-appearance-file button { grid-column: auto; }
}

.decoration-footprint-preview {
  --cell: 24px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-template-rows: repeat(5, var(--cell));
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * 5);
  overflow: hidden;
  border: 1px solid #475569;
  border-radius: 5px;
  background: #1e293b;
}

.decoration-footprint-cell { border-right: 1px solid rgba(148,163,184,.28); border-bottom: 1px solid rgba(148,163,184,.28); }
.decoration-footprint-cell.center { background: rgba(56,189,248,.22); outline: 1px solid #38bdf8; z-index: 1; }
.decoration-footprint-preview img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); object-fit: contain; image-rendering: pixelated; z-index: 2; pointer-events: none; }

.tree-biome-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 1px 2px;
  white-space: nowrap;
}

.biome-card-item {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.biome-card-item:hover, .biome-card-item.active-filter {
  border-color: #38bdf8;
  background: #172554;
  transform: translateY(-1px);
}

.biome-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.biome-card-img {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
  image-rendering: pixelated;
}

.biome-card-name {
  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
}

.biome-card-count {
  font-size: 10px;
  color: #94a3b8;
}

.badge-choppable {
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #059669;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.badge-protected {
  background: #78350f;
  color: #fde68a;
  border: 1px solid #d97706;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.badge-cluster {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #3b82f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.badge-single {
  background: #312e81;
  color: #c7d2fe;
  border: 1px solid #6366f1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.sprite-quick-picker {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.sprite-quick-picker button,
.btn-chip {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sprite-quick-picker button:hover,
.btn-chip:hover {
  background: #334155;
  color: #f1f5f9;
  border-color: #64748b;
}

.geologist-level-card { margin-top: 10px; padding: 12px; border: 1px solid #334155; border-radius: 9px; background: rgba(15, 23, 42, .55); }
.geologist-level-title { margin-bottom: 9px; color: #7dd3fc; font-size: 14px; font-weight: 800; }
.academy-modal-content { width: min(1160px, 96vw); max-width: 1160px; min-height: min(720px, 88vh); }
.academy-modal-content .modal-body { min-height: 600px; }
.academy-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; min-height: 560px; }
.academy-menu { padding: 8px; border: 1px solid #334155; border-radius: 10px; background: rgba(7, 17, 31, .78); }
.academy-menu-item, .academy-menu-placeholder { width: 100%; min-height: 78px; padding: 11px; border: 1px solid #334155; border-radius: 8px; color: #cbd5e1; text-align: left; }
.academy-menu-item { display: grid; grid-template-columns: 30px 1fr; background: #13233a; cursor: pointer; }
.academy-menu-item.active { border-color: #38bdf8; box-shadow: inset 3px 0 #38bdf8; }
.academy-menu-item span { grid-row: 1 / 3; font-size: 23px; }.academy-menu-item small { color: #94a3b8; }
.academy-menu-placeholder { display: grid; place-items: center; margin-top: 9px; background: transparent; color: #64748b; text-align: center; }
.academy-workspace { min-width: 0; }
.academy-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 13px; min-height: 76px; }
.academy-stat { padding: 12px; border: 1px solid #334155; border-radius: 10px; background: linear-gradient(145deg, #13233a, #0b1729); }
.academy-stat strong { display: block; color: #f8fafc; font-size: 24px; }
.academy-stat span { color: #94a3b8; font-size: 11px; }
.academy-toolbar { display: flex; align-items: center; gap: 9px; padding: 11px 0 15px; border-bottom: 1px solid #334155; }
.academy-toolbar .field-hint { margin-left: auto; }
.academy-workspace h4 { margin: 15px 0 9px; }
.academy-geologists { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 12px; min-height: 210px; max-height: 350px; padding-right: 5px; overflow-y: auto; align-content: start; }
.academy-results { display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 9px; max-height: 180px; overflow-y: auto; }
.academy-geologist-card, .academy-result-card { padding: 12px; border: 1px solid #334155; border-radius: 10px; background: rgba(15, 23, 42, .78); }
.academy-geologist-card.searching .academy-avatar { filter: grayscale(1); opacity: .48; }
.academy-geologist-card.has-result { border-color: #22c55e; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(34,197,94,.2); }
.academy-geologist-card.has-result:hover { background: rgba(20, 65, 50, .72); }
.academy-result-badge { color:#86efac; font-weight:800; }
.academy-expedition-config { display:grid; gap:7px; margin-top:10px; }
.academy-expedition-cost { min-height:20px; color:#facc15; font-size:12px; }
.academy-geologist-identity { display:flex; align-items:center; gap:10px; }.academy-avatar { display:grid; place-items:center; width:48px; height:48px; border-radius:50%; background:#243b55; font-size:27px; }
.academy-card-skeleton { min-height: 170px; opacity: .45; background: linear-gradient(100deg, #111f34 30%, #1d3550 50%, #111f34 70%); background-size: 200% 100%; animation: academy-loading 1.2s infinite; }
@keyframes academy-loading { to { background-position: -200% 0; } }
.academy-geologist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.academy-geologist-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 9px 0; color: #cbd5e1; font-size: 11px; }
.academy-geologist-metrics span { padding: 6px; border-radius: 6px; background: rgba(30, 41, 59, .8); }
.academy-geologist-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.academy-progress { height: 6px; overflow: hidden; margin-top: 8px; border-radius: 999px; background: #07111f; }
.academy-progress div { height: 100%; background: linear-gradient(90deg, #0ea5e9, #22d3ee); }
.academy-result-card.success { border-color: rgba(34, 197, 94, .55); }
.academy-result-card.failure { border-color: rgba(239, 68, 68, .45); }
.expedition-notifications { position: absolute; left: 14px; bottom: 72px; z-index: 140; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.expedition-notification { padding: 11px 13px; border: 1px solid #38bdf8; border-radius: 9px; background: rgba(8, 20, 37, .96); color: #e2e8f0; box-shadow: 0 9px 25px rgba(0, 0, 0, .42); animation: expedition-in .25s ease-out; }
.expedition-notification.success { border-color: #22c55e; }
.expedition-notification.failure { border-color: #ef4444; }
@keyframes expedition-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.archipelago-resource-summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 3px; max-width: 150px; color: #dbeafe; font-size: 10px; }
.archipelago-resource-chip { padding: 2px 5px; border: 1px solid rgba(125, 211, 252, .28); border-radius: 999px; background: rgba(3, 18, 35, .82); }
.archipelago-fertility-trigger { position: relative; z-index: 4; display: inline-block; margin-top: 4px; color: #d9f99d; font-size: 11px; cursor: help; }
.archipelago-fertility-trigger > span { display: inline-block; padding: 3px 7px; border: 1px solid rgba(190, 242, 100, .45); border-radius: 999px; background: rgba(20, 50, 25, .88); }
.archipelago-fertility-tooltip { position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 7px); width: max-content; max-width: 250px; padding: 9px 11px; border: 1px solid #84cc16; border-radius: 8px; background: rgba(8, 24, 14, .98); color: #ecfccb; box-shadow: 0 8px 22px rgba(0, 0, 0, .5); font-size: 12px; line-height: 1.6; text-align: left; opacity: 0; pointer-events: none; transform: translate(-50%, 4px); transition: opacity .16s, transform .16s; }
.archipelago-fertility-tooltip strong { display: block; margin-bottom: 3px; color: #d9f99d; }
.archipelago-fertility-tooltip b { float: right; margin-left: 18px; color: #fff; }
.archipelago-fertility-trigger:hover .archipelago-fertility-tooltip, .archipelago-fertility-trigger:focus-within .archipelago-fertility-tooltip { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) { .academy-modal-content .modal-body { min-height: 0; } .academy-layout { grid-template-columns: 1fr; }.academy-menu { display:flex; gap:8px; }.academy-menu-placeholder { display:none; }.academy-summary { grid-template-columns: repeat(3, 1fr); }.academy-geologists,.academy-results { grid-template-columns: 1fr; }.academy-toolbar { align-items: stretch; flex-direction: column; } .academy-toolbar .field-hint { margin-left: 0; } }

.quest-modal-content { position:relative; isolation:isolate; box-sizing:border-box; width:min(1100px,96vw); max-width:1100px; min-height:min(730px,92vh); padding:58px 58px 48px; border:0; border-radius:5px; background:linear-gradient(145deg,#302316,#160f0a 72%); box-shadow:0 28px 70px rgba(0,0,0,.78); }
.quest-modal-content::before { content:""; position:absolute; z-index:0; inset:-10px; pointer-events:none; background:url("assets/ui/tentoria-window-frame-v1.png") center/100% 100% no-repeat; filter:drop-shadow(0 16px 20px rgba(0,0,0,.55)); }
.quest-modal-content > * { position:relative; z-index:1; }
.quest-modal-content .modal-header { margin:-23px 7px 25px; padding:8px 48px 10px; border:1px solid #8d682f; border-radius:5px 5px 14px 14px; background:linear-gradient(#79552d,#46301c); box-shadow:inset 0 1px #c5a568,0 4px 8px rgba(0,0,0,.35); }
.quest-modal-content .modal-header h3 { color:#fff3cd; text-shadow:0 2px 2px #1b1007; letter-spacing:.03em; }
.quest-modal-content .modal-close { position:relative; z-index:5; flex:0 0 auto; display:grid; place-items:center; width:30px; height:30px; border:1px solid #d5b56e; border-radius:50%; background:#3a2516; color:#fff3cd; box-shadow:0 2px 5px rgba(0,0,0,.55); }
.quest-modal-content .modal-close:hover { background:#6b321d; color:#fff; }

/* The in-world HUD, chat and notices use the same wood-and-parchment language
   as the quest window, but remain deliberately compact over the map. */
#hud { gap:12px; padding:10px 20px 13px; border:0; border-radius:0 0 7px 7px; background:linear-gradient(180deg,rgba(53,36,21,.97),rgba(24,15,9,.93)); box-shadow:0 8px 20px rgba(0,0,0,.54), inset 0 -1px rgba(231,193,119,.38); }
#hud::after { content:""; position:absolute; z-index:-1; inset:0; pointer-events:none; opacity:.34; background:url("assets/ui/tentoria-window-frame-v1.png") center/100% 165% no-repeat; }
#hud .hud-island-name { padding:5px 12px; border:1px solid #9b7339; border-radius:5px; background:linear-gradient(#75512c,#3a2516); color:#fff0c7; text-shadow:0 1px #1c1008; box-shadow:inset 0 1px rgba(255,235,179,.3); }
#hud .resource-pill { border:1px solid #9b7339; border-radius:6px; background:linear-gradient(145deg,rgba(94,64,34,.97),rgba(47,29,17,.97)); color:#ffe8b6; box-shadow:inset 0 1px rgba(255,229,162,.22),0 2px 3px rgba(0,0,0,.28); text-shadow:0 1px #231408; }
#hud .resource-pill strong, #hud .resource-pill small { color:#fff7dd; }
#hud .hud-stat-label, #hud .players-online { color:#d5b56e; }
#hud .hud-island-name { max-width:420px; min-width:170px; }
#hud #btn-hud-menu, #hud #hud-admin-btn { border-color:#c39a55; background:linear-gradient(#806039,#442817); color:#fff0c7; box-shadow:inset 0 1px rgba(255,235,179,.3); }
#hud #btn-hud-menu:hover { background:linear-gradient(#9b713d,#58341b); }

.social-panel { padding:25px 22px 21px; border:0; border-radius:5px; background:linear-gradient(145deg,#302316,#160f0a 72%); color:#f4dfb2; box-shadow:0 16px 32px rgba(0,0,0,.64); }
.social-panel::before { content:""; position:absolute; z-index:-1; inset:-9px; pointer-events:none; background:url("assets/ui/tentoria-window-frame-v1.png") center/100% 100% no-repeat; filter:drop-shadow(0 7px 8px rgba(0,0,0,.45)); }
.social-panel.floating { border-radius:5px; }
.social-panel.collapsed { padding-bottom:12px; }
.chat-emoji-picker { border-color:#96713e; background:rgba(31,18,10,.98); }
.social-panel-header { height:31px; margin:-8px 0 10px; padding:4px 8px; border:1px solid #9b7339; border-radius:5px 5px 10px 10px; background:linear-gradient(#77532d,#442b18); color:#fff0c7; text-shadow:0 1px #1c1008; box-shadow:inset 0 1px rgba(255,235,179,.28); }
.social-panel-header button { border-color:#c39a55; border-radius:5px; background:#392516; color:#fff0c7; }
.social-panel-header button:hover { background:#6b321d; }
.social-tabs { gap:7px; margin:5px -4px 9px; padding:0 4px; border-bottom-color:#8b6739; }
.social-tab { padding:7px 11px; color:#caa86c; text-shadow:0 1px #1c1008; }
.social-tab.active { color:#fff2ca; border-bottom-color:#d6a951; background:rgba(114,74,33,.35); }
.social-messages { padding:2px 4px 2px 0; }
.chat-message { padding:7px 5px; border-bottom-color:rgba(187,140,74,.26); color:#f0dfbe; }
.chat-message .chat-time { color:#b59562; }.chat-message .chat-author { color:#f4c96f; }.chat-message.admin .chat-author { color:#f7df84; }
.chat-form { gap:7px; margin-top:10px; }.chat-form input { border-color:#96713e; border-radius:5px; background:rgba(31,18,10,.88); color:#fff0cd; box-shadow:inset 0 1px 4px rgba(0,0,0,.55); }.chat-form input::placeholder { color:#b89d76; }.chat-form button { border:1px solid #c39a55; border-radius:5px; background:linear-gradient(#8c6130,#543017); color:#fff2ca; text-shadow:0 1px #251307; }
.fire-log-summary { color:#f0dfbe; border-bottom-color:#8b6739; }.fire-log-entry { color:#ead6ae; }
@media (max-width:980px) { #hud { padding:8px 10px 11px; } .social-panel { padding:22px 18px 18px; } }
.quest-layout { display:grid; grid-template-columns:320px minmax(0,1fr); gap:18px; min-height:560px; }
.quest-sidebar { padding:10px; border:1px solid #8b6739; border-radius:7px; background:linear-gradient(145deg,rgba(69,46,27,.96),rgba(31,20,13,.98)); box-shadow:inset 0 0 0 2px rgba(20,10,4,.6),inset 0 0 18px rgba(0,0,0,.45); }
.quest-filters { display:flex; gap:5px; margin-bottom:10px; }
.quest-filters button { flex:1; padding:7px 5px; border:1px solid #334155; border-radius:7px; background:#13233a; color:#94a3b8; cursor:pointer; font-size:11px; }
.quest-filters button.active { color:#fff; border-color:#38bdf8; background:#174264; }
.quest-list { display:grid; gap:8px; max-height:500px; overflow:auto; }
.quest-list-item { display:grid; grid-template-columns:42px 1fr; gap:9px; width:100%; padding:11px; border:1px solid #334155; border-radius:9px; background:#111f34; color:#e2e8f0; text-align:left; cursor:pointer; }
.quest-list-item.active { border-color:#38bdf8; box-shadow:inset 3px 0 #38bdf8; }
.quest-list-item.state-ready { border-color:#eab308; }.quest-list-item.state-claimed { opacity:.68; }
.quest-list-icon { display:grid; place-items:center; font-size:25px; }.quest-list-item strong,.quest-list-item small { display:block; }.quest-list-item small { margin:3px 0 8px;color:#94a3b8;font-size:10px; }
.quest-list-item i,.quest-objective i { display:block;height:6px;overflow:hidden;border-radius:99px;background:#07111f; }.quest-list-item i b,.quest-objective i b { display:block;height:100%;background:linear-gradient(90deg,#0ea5e9,#22d3ee); }
.quest-details { padding:18px; border:1px solid #9a7643; border-radius:7px; background:linear-gradient(145deg,#ead8ae,#cbb17c); color:#392918; box-shadow:inset 0 0 0 2px rgba(255,244,204,.45),inset 0 0 28px rgba(91,55,18,.16); }.quest-empty { display:grid;place-items:center;align-content:center;height:100%;color:#765c38;text-align:center}.quest-empty>span{font-size:60px;opacity:.5}
.quest-details .quest-description,.quest-details .field-hint { color:#59452d; }.quest-details section h4,.quest-details .quest-detail-head h2 { color:#362312; }.quest-details .quest-detail-head { border-color:#9d7c4d; }.quest-details .quest-objective { border-color:#aa8957; background:rgba(255,248,220,.42); color:#3f2d19; }.quest-details .quest-objective i { background:#8f744e; }.quest-details .quest-objective i b { background:linear-gradient(90deg,#8a531e,#d3983d); }
.quest-detail-head { display:grid; grid-template-columns:64px 1fr auto; gap:14px; align-items:center; padding-bottom:16px; border-bottom:1px solid #334155; }.quest-detail-head>span{display:grid;place-items:center;width:64px;height:64px;border-radius:14px;background:#182a44;font-size:36px}.quest-detail-head h2{margin:2px 0;color:#f8fafc}.quest-detail-head small{color:#7dd3fc}.quest-detail-head em{padding:5px 9px;border-radius:99px;background:#1e293b;color:#cbd5e1;font-size:11px;font-style:normal}.quest-detail-head em.state-ready{color:#fde047;border:1px solid #a16207}
.quest-description { min-height:50px;color:#cbd5e1;line-height:1.55 }.quest-details section{margin-top:20px}.quest-details section h4{margin:0 0 9px;color:#f8fafc}
.quest-objective { margin-bottom:9px;padding:11px;border:1px solid #334155;border-radius:8px;background:rgba(15,23,42,.72) }.quest-objective>div{display:flex;justify-content:space-between;gap:12px;margin-bottom:8px}.quest-objective.complete{border-color:rgba(34,197,94,.55)}.quest-objective.complete span{color:#86efac}
.quest-rewards { display:flex;flex-wrap:wrap;gap:8px}.quest-reward{padding:9px 12px;border:1px solid #a16207;border-radius:8px;background:rgba(113,63,18,.25);color:#fde68a}.quest-actions{display:flex;justify-content:flex-end;margin-top:28px}.quest-completed{padding:9px 13px;color:#86efac;border:1px solid #15803d;border-radius:8px;background:rgba(20,83,45,.3)}
.event-timing { margin:13px 0 4px; padding:9px 12px; border:1px solid #7c3aed; border-radius:8px; background:rgba(76,29,149,.2); color:#ddd6fe; font-size:12px; }
.world-bottom-actions button.quest-attention { border-color:#facc15; color:#fef08a; box-shadow:0 0 0 2px rgba(250,204,21,.16),0 0 16px rgba(250,204,21,.18); }
.quest-ready-count { display:inline-grid; place-items:center; min-width:19px; height:19px; margin-left:3px; padding:0 5px; border-radius:99px; background:#dc2626; color:#fff; font-size:11px; font-weight:800; }
.quest-toast { position:fixed; z-index:100000; right:18px; bottom:84px; padding:12px 16px; border:1px solid #eab308; border-radius:10px; background:rgba(30,24,8,.97); color:#fef08a; box-shadow:0 12px 32px rgba(0,0,0,.45); animation:expedition-in .25s ease-out; }
@media(max-width:760px){.quest-modal-content{min-height:0;padding:46px 32px 38px}.quest-modal-content::before{inset:-4px}.quest-modal-content .modal-header{margin:-20px 0 18px;padding:7px 12px}.quest-layout{grid-template-columns:1fr}.quest-list{max-height:230px}.quest-detail-head{grid-template-columns:52px 1fr}.quest-detail-head>em{grid-column:2}.quest-detail-head>span{width:52px;height:52px}}
.quest-admin-section { margin-top:15px; padding:13px; border:1px solid #334155; border-radius:9px; background:rgba(7,17,31,.38); }
.quest-admin-section h5 { margin:0 0 10px; color:#e2e8f0; font-size:14px; }
.quest-admin-section-head { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.quest-admin-row { display:grid; grid-template-columns:1.05fr 1.2fr .55fr 1.5fr auto; gap:8px; align-items:end; margin-top:8px; padding:9px; border:1px solid #26374e; border-radius:8px; background:#101d30; }
.quest-admin-row.quest-reward-editor { grid-template-columns:1.5fr .8fr auto; max-width:620px; }
.quest-admin-row label { margin:0; min-width:0; }
.quest-admin-row input,.quest-admin-row select { width:100%; }
.quest-prerequisite-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:7px; }
.quest-prerequisite-list label { display:grid; grid-template-columns:auto 1fr auto; gap:7px; align-items:center; margin:0; padding:8px; border:1px solid #334155; border-radius:7px; background:#101d30; cursor:pointer; }
.quest-prerequisite-list code { color:#64748b; font-size:10px; }
@media(max-width:900px){.quest-admin-row{grid-template-columns:1fr 1fr}.quest-admin-row>button{justify-self:end}.quest-admin-row.quest-reward-editor{grid-template-columns:1fr 1fr auto}}

/* ---- Discovery expeditions (Archipelago) ---- */
.archipelago-expeditions-view { flex-direction: column; gap: 12px; overflow: auto; min-height: 0; flex: 1; }
.expedition-summary { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 14px; border: 1px solid #29486c; border-radius: 10px; background: rgba(15, 29, 48, .9); color: #cbd5e1; font-size: 13px; }
.expedition-summary b { color: #f8fafc; }
.expedition-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 11px; margin-top: 8px; border: 1px solid #1e3a5f; border-radius: 8px; background: #0f172a; }
.expedition-row small { display: block; color: #94a3b8; margin-top: 2px; }
.expedition-row-state { text-align: right; font-size: 12px; color: #94a3b8; white-space: nowrap; }
.expedition-row-state b { display: block; color: #38bdf8; font-size: 14px; }
.expedition-row.completed .expedition-row-state span { color: #4ade80; }
.expedition-row.failed .expedition-row-state span { color: #f87171; }
.expedition-profile-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-top: 8px; }
.expedition-profile { padding: 12px; border: 1px solid #334155; border-radius: 10px; background: #0f172a; display: flex; flex-direction: column; gap: 6px; }
.expedition-profile.available { border-color: #22c55e; }
.expedition-profile.claimed { opacity: .72; }
.expedition-profile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.expedition-profile-head h5 { margin: 0; font-size: 15px; color: #f8fafc; }
.expedition-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #334155; color: #cbd5e1; white-space: nowrap; }
.expedition-badge.ok { background: #14532d; color: #bbf7d0; }
.expedition-badge.progress { background: #0c4a6e; color: #bae6fd; }
.expedition-badge.done { background: #3f3f46; color: #e4e4e7; }
.expedition-profile-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: #94a3b8; }
.expedition-line { margin: 0; font-size: 12px; color: #cbd5e1; }
.expedition-conditions { list-style: none; margin: 2px 0; padding: 0; font-size: 12px; color: #fca5a5; display: grid; gap: 3px; }
.expedition-conditions li.met { color: #86efac; }
.expedition-conditions b { color: #f8fafc; margin-left: 4px; }
.expedition-launch { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.expedition-launch select { flex: 1; min-width: 0; }
@media (max-width: 650px) { .expedition-profile-list { grid-template-columns: 1fr; } .expedition-row { flex-direction: column; align-items: flex-start; } .expedition-row-state { text-align: left; } }
.expedition-note { margin: 4px 0 0; font-size: 12px; color: #fbbf24; }

/* ---- Expedition finds (inspect, settle or reject) ---- */
.visit-mode-actions { display: flex; gap: 8px; }
.visit-mode-actions:empty { display: none; }
.visit-mode-actions button { padding: 6px 10px; border-radius: 6px; border: 1px solid #60a5fa; background: #1e293b; color: #f8fafc; font-weight: 700; cursor: pointer; }
.visit-mode-actions .visit-action-primary { background: #15803d; border-color: #22c55e; }
.visit-mode-actions .visit-action-danger { background: #7f1d1d; border-color: #f87171; }
#visit-mode-label { max-width: 520px; }
.expedition-row-main { min-width: 0; flex: 1; }
.expedition-row.found { border-color: #22c55e; background: rgba(20, 83, 45, .25); }
.expedition-row.found .expedition-row-state span { color: #86efac; }
.expedition-row.settled .expedition-row-state span { color: #4ade80; }
.expedition-row.rejected .expedition-row-state span, .expedition-row.expired .expedition-row-state span { color: #fca5a5; }
.expedition-found { margin-top: 8px; font-size: 12px; color: #cbd5e1; }
.expedition-found p { margin: 2px 0; }
.expedition-found-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
@media (max-width: 680px) { .visit-mode-banner { flex-wrap: wrap; } #visit-mode-label { max-width: none; flex-basis: 100%; } }

/* ==========================================================================
   Wood-and-parchment theme for the HUD menu and the Tasks window
   (replaces the leftover navy/sky-blue prototype colours).
   Palette: dark wood #1f140c–#46301c, brass #8d682f/#c5a568/#d5b56e,
   cream text #fff3cd, parchment #ead8ae/#cbb17c, ink #392918, amber #d3983d.
   ========================================================================== */
.menu-dropdown {
  top: calc(100% + 10px);
  min-width: 232px;
  padding: 8px;
  gap: 3px;
  border: 1px solid #8d682f;
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(74, 51, 29, .98), rgba(33, 21, 12, .98) 78%);
  backdrop-filter: none;
  box-shadow: inset 0 1px #c5a568, inset 0 0 0 2px rgba(20, 10, 4, .55), 0 14px 30px rgba(0, 0, 0, .6);
}
.menu-dropdown::before {
  content: ""; position: absolute; top: -7px; left: 26px; width: 12px; height: 12px;
  border-left: 1px solid #8d682f; border-top: 1px solid #8d682f;
  background: #4a331d; transform: rotate(45deg);
}
.menu-dropdown-item {
  position: relative;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #f3e3bd;
  font-weight: 600;
  text-shadow: 0 1px 1px #1b1007;
}
.menu-dropdown-item + .menu-dropdown-item::after {
  content: ""; position: absolute; left: 10px; right: 10px; top: -2px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(197, 165, 104, .35), transparent);
}
.menu-dropdown-item:hover,
.menu-dropdown-item:focus-visible {
  outline: none;
  border-color: #b98d45;
  background: linear-gradient(#79552d, #563a20);
  color: #fff3cd;
  box-shadow: inset 0 1px #c5a568;
}
.menu-dropdown-item.text-danger { color: #f0b39c; }
.menu-dropdown-item.text-danger:hover,
.menu-dropdown-item.text-danger:focus-visible {
  border-color: #b4553a;
  background: linear-gradient(#7a2e1c, #4e1a10);
  color: #ffe4d6;
}

/* ---- Tasks window ---- */
.quest-modal-content { background: transparent; box-shadow: none; }
.quest-modal-content .modal-header .field-hint { color: #e9d3a0; }
.quest-filters button {
  border: 1px solid #6f5230;
  border-radius: 5px;
  background: linear-gradient(#4a331d, #2c1c10);
  color: #d9c08b;
  font-weight: 600;
}
.quest-filters button:hover { color: #fff3cd; border-color: #a47c40; }
.quest-filters button.active {
  border-color: #d5b56e;
  background: linear-gradient(#8a6334, #5a3d20);
  color: #fff3cd;
  box-shadow: inset 0 1px #e2c78b;
}
.quest-list { padding-right: 3px; scrollbar-color: #8d682f #1f140c; scrollbar-width: thin; }
.quest-list::-webkit-scrollbar { width: 8px; }
.quest-list::-webkit-scrollbar-track { background: #1f140c; border-radius: 8px; }
.quest-list::-webkit-scrollbar-thumb { background: #8d682f; border-radius: 8px; }
.quest-list-item {
  border: 1px solid #5f4527;
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(58, 39, 22, .95), rgba(34, 22, 13, .95));
  color: #f3e3bd;
  transition: border-color .15s, background .15s;
}
.quest-list-item:hover { border-color: #a47c40; background: linear-gradient(145deg, #4a331d, #2c1c10); }
.quest-list-item.active {
  border-color: #d5b56e;
  background: linear-gradient(145deg, #6a4a27, #3b2716);
  box-shadow: inset 3px 0 #d3983d, 0 0 0 1px rgba(213, 181, 110, .25);
}
.quest-list-item.state-ready { border-color: #e0b44a; box-shadow: 0 0 10px rgba(224, 180, 74, .25); }
.quest-list-item strong { color: #fff3cd; }
.quest-list-item small { color: #bfa57a; }
.quest-list-item i { background: #150d07; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.quest-list-item i b, .quest-objective i b { background: linear-gradient(90deg, #8a531e, #d3983d); }
.quest-detail-head > span {
  border: 1px solid #9a7643;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 35%, #fff4d4, #d6bd86);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .5), 0 2px 5px rgba(60, 35, 10, .3);
}
.quest-details .quest-detail-head small { color: #8a5a22; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.quest-detail-head em { border: 1px solid #9a7643; background: #5a3d20; color: #fff3cd; }
.quest-detail-head em.state-ready { border-color: #b7791f; background: #7c4f12; color: #fff3cd; }
.quest-detail-head em.state-claimed { border-color: #3f7d3a; background: #2f5a2a; color: #e7f8d6; }
.quest-details section h4 { color: #5a3a17; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid rgba(154, 118, 67, .45); padding-bottom: 4px; }
.quest-details .quest-description { color: #4b3820; }
.quest-details .quest-objective.complete { border-color: #5f8f4a; background: rgba(214, 236, 190, .45); }
.quest-details .quest-objective.complete span { color: #2f6a24; }
.quest-reward { border: 1px solid #9a7643; background: rgba(255, 248, 220, .55); color: #3f2d19; }
.quest-reward b { color: #7c4a12; }
.quest-completed { border-color: #5f8f4a; background: rgba(214, 236, 190, .5); color: #2f6a24; }
.quest-actions .btn, .quest-actions button {
  border: 1px solid #d5b56e;
  background: linear-gradient(#8a6334, #5a3d20);
  color: #fff3cd;
  box-shadow: inset 0 1px #e2c78b, 0 2px 4px rgba(60, 35, 10, .35);
}
.quest-actions .btn:hover, .quest-actions button:hover { background: linear-gradient(#9c733d, #6a4826); }
.quest-actions .btn:disabled, .quest-actions button:disabled { opacity: .55; cursor: not-allowed; }
.quest-empty h3 { color: #5a3a17; }

/* ==========================================================================
   Wood-and-parchment theme, part 2: bottom launchers, Build dock, Warehouse
   and the Archipelago window (Handel / Porty i statki / Wyspy / Wyprawy).
   ========================================================================== */
:root {
  --wood-900: #160f0a; --wood-800: #211509; --wood-700: #2c1c10; --wood-600: #3b2716;
  --wood-500: #4a331d; --wood-400: #6a4a27; --brass-700: #6f5230; --brass-600: #8d682f;
  --brass-500: #a47c40; --brass-400: #c5a568; --brass-300: #d5b56e; --cream: #fff3cd;
  --cream-dim: #d9c08b; --muted: #bfa57a; --parch-100: #f1e3bf; --parch-200: #ead8ae;
  --parch-400: #cbb17c; --ink: #392918; --ink-soft: #59452d; --amber: #d3983d;
}

/* ---- Bottom launchers ---- */
.world-bottom-actions { gap: 8px; }
.world-bottom-actions button {
  border: 1px solid var(--brass-600);
  border-radius: 6px;
  background: linear-gradient(#5a3d20, #2c1c10);
  color: var(--cream);
  text-shadow: 0 1px 1px #1b1007;
  box-shadow: inset 0 1px #b8955a, inset 0 0 0 1px rgba(20, 10, 4, .45), 0 5px 14px rgba(0, 0, 0, .45);
}
.world-bottom-actions button:hover {
  border-color: var(--brass-300);
  background: linear-gradient(#79552d, #46301c);
  color: #fff;
}
.world-bottom-actions button.active,
.world-bottom-actions button[aria-expanded="true"] {
  border-color: #e2c78b;
  background: linear-gradient(#8a6334, #5a3d20);
  color: #fff;
  box-shadow: inset 0 1px #e2c78b, 0 0 0 2px rgba(213, 181, 110, .25), 0 0 14px rgba(211, 152, 61, .35);
}

/* ---- Shared panel skin (Build dock, Warehouse) ---- */
#build-panel-body,
#inventory-panel-body {
  border: 1px solid var(--brass-600);
  background: linear-gradient(160deg, rgba(58, 39, 22, .98), rgba(24, 15, 9, .98) 80%);
  backdrop-filter: none;
  color: var(--cream);
  box-shadow: inset 0 1px #b8955a, inset 0 0 0 2px rgba(20, 10, 4, .55), 0 -12px 32px rgba(0, 0, 0, .55);
}
#build-panel-body { border-bottom: 1px solid var(--brass-600); border-radius: 8px; }
#inventory-panel-body { border-radius: 8px; overflow: hidden; }
.build-panel-title { color: var(--cream); text-shadow: 0 1px 1px #1b1007; }
.build-count-badge { background: var(--wood-500); border: 1px solid var(--brass-600); color: #f3d48f; }
#build-search-input,
.inventory-panel-header input {
  border: 1px solid var(--brass-700);
  background: rgba(22, 15, 10, .85);
  color: var(--cream);
}
#build-search-input::placeholder, .inventory-panel-header input::placeholder { color: #9c8460; }
#build-search-input:focus, .inventory-panel-header input:focus {
  border-color: var(--brass-300);
  box-shadow: 0 0 0 2px rgba(213, 181, 110, .2);
}
.build-search-clear { color: var(--cream-dim); }
#build-panel-toggle,
#inventory-panel-close {
  border: 1px solid var(--brass-600);
  border-radius: 5px;
  background: linear-gradient(#4a331d, #2c1c10);
  color: var(--cream);
  box-shadow: inset 0 1px #9c7a45;
}
#build-panel-toggle:hover, #inventory-panel-close:hover { background: linear-gradient(#6b321d, #43190f); border-color: #c98a5b; color: #fff; }
.inventory-panel-header { border-bottom-color: rgba(141, 104, 47, .6); }
.inventory-empty-toggle { color: var(--cream-dim); }
.inventory-empty-toggle input { accent-color: var(--amber); }

/* Build categories */
.build-category-group { border-color: var(--brass-700); background: rgba(22, 15, 10, .35); }
.build-category-header {
  border: 1px solid var(--brass-700);
  border-radius: 5px;
  background: linear-gradient(#4a331d, #2c1c10);
  color: var(--cream-dim);
}
.build-category-header:hover { border-color: var(--brass-500); background: linear-gradient(#5a3d20, #3b2716); color: var(--cream); }
.build-category-header.active {
  border-color: var(--brass-300);
  background: linear-gradient(#8a6334, #5a3d20);
  color: #fff;
  box-shadow: inset 0 1px #e2c78b;
}
.build-category-pill { background: rgba(22, 15, 10, .7); color: #f3d48f; }
.build-category-chevron, .build-category-header.active .build-category-chevron { color: #f3d48f; }
.build-accordion-container::-webkit-scrollbar-track, .build-category-items::-webkit-scrollbar-track { background: var(--wood-900); }
.build-accordion-container::-webkit-scrollbar-thumb, .build-category-items::-webkit-scrollbar-thumb { background: var(--brass-600); }
.build-category-items { scrollbar-color: var(--brass-600) var(--wood-900); }

/* Building cards */
.build-btn {
  border: 1px solid var(--brass-700);
  border-radius: 7px;
  background: linear-gradient(160deg, #3b2716, #211509);
  color: var(--cream);
  box-shadow: inset 0 1px rgba(197, 165, 104, .35);
}
.build-btn:hover { border-color: var(--brass-400); background: linear-gradient(160deg, #4a331d, #2c1c10); }
.build-btn.active {
  border-color: #f0cf85;
  background: linear-gradient(160deg, #7a5530, #4a331d);
  color: #fff;
  box-shadow: inset 0 1px #e2c78b, 0 0 12px rgba(211, 152, 61, .45);
}
.build-btn-preview {
  border: 1px solid rgba(141, 104, 47, .55);
  border-radius: 5px;
  background: radial-gradient(circle at 50% 40%, rgba(241, 227, 191, .22), rgba(22, 15, 10, .55));
}
.build-info-tag { border-color: rgba(197, 165, 104, .35); background: rgba(22, 15, 10, .65); color: var(--cream-dim); }
.build-info-tag.workforce-tag { color: #f3d48f; border-color: rgba(213, 181, 110, .45); background: rgba(138, 99, 52, .3); }
.build-info-tag.deposit-tag { color: #b9dd8f; border-color: rgba(137, 179, 94, .45); background: rgba(70, 104, 42, .3); }
.build-info-tag.shift-tag { color: #e8c9a0; border-color: rgba(201, 138, 91, .45); background: rgba(107, 50, 29, .3); }
.build-empty-state { color: var(--muted); }
#build-cancel-btn { border-color: #b4553a; background: linear-gradient(#7a2e1c, #4e1a10); color: #ffe4d6; }

/* Warehouse grid and tabs */
.inventory-item { border-color: var(--brass-700); background: linear-gradient(160deg, #3b2716, #1b120b); box-shadow: inset 0 1px rgba(197, 165, 104, .3); }
.inventory-item:not(.zero) { border-color: var(--brass-500); background: linear-gradient(160deg, #5a3d20, #2c1c10); }
.inventory-item-amount { color: var(--cream); }
.inventory-item-name { color: var(--cream-dim); }
.inventory-empty-state { color: var(--muted); }
.inventory-tabs { border-top-color: var(--brass-600); }
.inventory-tabs button { border-right-color: var(--brass-700); background: var(--wood-800); color: var(--cream-dim); }
.inventory-tabs button:hover { color: var(--cream); background: var(--wood-600); }
.inventory-tabs button.active { background: linear-gradient(#8a6334, #5a3d20); color: #fff; box-shadow: inset 0 1px #e2c78b; }

/* ---- Archipelago window (Wyspy · Porty i statki · Wyprawy) ---- */
#modal-archipelago .modal-archipelago-content {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: min(1400px, 96vw);
  height: min(900px, 92vh);
  padding: 62px 80px 58px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
}
#modal-archipelago .modal-archipelago-content::before {
  content: ""; position: absolute; z-index: 0; inset: -10px; pointer-events: none;
  background: url("assets/ui/tentoria-window-frame-v1.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .55));
}
#modal-archipelago .modal-archipelago-content > * { position: relative; z-index: 1; }
#modal-archipelago .modal-header {
  margin: -27px -14px 14px;
  border: 1px solid var(--brass-600) !important;
  border-radius: 5px 5px 14px 14px;
  background: linear-gradient(#79552d, #46301c);
  box-shadow: inset 0 1px var(--brass-400), 0 4px 8px rgba(0, 0, 0, .35);
}
#modal-archipelago .modal-header h3 { color: var(--cream) !important; text-shadow: 0 2px 2px #1b1007; }
#modal-archipelago .modal-subtitle { color: #e9d3a0 !important; }
#modal-archipelago .modal-close {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--brass-300); border-radius: 50%;
  background: var(--wood-600); color: var(--cream);
}
#modal-archipelago .modal-close:hover { background: #6b321d; color: #fff; }
#modal-archipelago .modal-header [style*="background:#0f172a"] {
  background: rgba(22, 15, 10, .75) !important;
  border-color: var(--brass-700) !important;
}
#modal-archipelago .modal-header input { color: var(--cream) !important; }
#modal-archipelago .modal-body { color: var(--cream); }

/* Buttons and form fields inside the window */
#modal-archipelago .btn {
  border: 1px solid var(--brass-600);
  border-radius: 5px;
  background: linear-gradient(#4a331d, #2c1c10);
  color: var(--cream);
  box-shadow: inset 0 1px #9c7a45;
  text-shadow: 0 1px 1px #1b1007;
}
#modal-archipelago .btn:hover:not(:disabled) { border-color: var(--brass-300); background: linear-gradient(#5a3d20, #3b2716); color: #fff; }
#modal-archipelago .btn-primary {
  border-color: var(--brass-300);
  background: linear-gradient(#8a6334, #5a3d20);
  box-shadow: inset 0 1px #e2c78b, 0 2px 4px rgba(0, 0, 0, .35);
}
#modal-archipelago .btn-primary:hover:not(:disabled) { background: linear-gradient(#9c733d, #6a4826); }
#modal-archipelago .btn-danger { border-color: #b4553a; background: linear-gradient(#7a2e1c, #4e1a10); color: #ffe4d6; }
#modal-archipelago .btn-danger:hover:not(:disabled) { background: linear-gradient(#8e3622, #5c2014); }
#modal-archipelago .btn:disabled { opacity: .5; cursor: not-allowed; }
#modal-archipelago select,
#modal-archipelago input[type="number"],
#modal-archipelago input[type="text"] {
  border: 1px solid var(--brass-700);
  border-radius: 5px;
  background: rgba(22, 15, 10, .85);
  color: var(--cream);
}
#modal-archipelago select:focus, #modal-archipelago input:focus { outline: none; border-color: var(--brass-300); }

/* Cards, notes and empty states */
.shipping-card,
.expedition-summary {
  border: 1px solid var(--brass-600);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(69, 46, 27, .96), rgba(31, 20, 13, .98));
  color: var(--cream);
  box-shadow: inset 0 0 0 2px rgba(20, 10, 4, .6), inset 0 0 18px rgba(0, 0, 0, .45);
}
.shipping-card h4 { color: #f3d48f; text-shadow: 0 1px 1px #1b1007; }
.shipping-market-head small, .shipping-market-port,
.shipping-toolbar label, .shipping-editor-main label,
.shipping-table th, .shipping-ship-row small, .shipping-stop small { color: var(--muted); }
.expedition-summary b { color: #f3d48f; }
.shipping-rule-note {
  border: 1px solid #9a7643;
  border-left: 4px solid var(--amber);
  background: linear-gradient(145deg, var(--parch-200), var(--parch-400));
  color: var(--ink);
}
.shipping-empty { border: 1px dashed var(--brass-700); background: rgba(22, 15, 10, .35); color: var(--muted); }
.shipping-table th, .shipping-table td, .shipping-ship-row { border-bottom-color: rgba(141, 104, 47, .45); }
.shipping-state { background: var(--wood-500); color: var(--cream-dim); }
.shipping-state.active { background: rgba(70, 104, 42, .45); color: #cfe9ad; }
.shipping-stop { border-color: var(--brass-700); background: rgba(22, 15, 10, .45); }

/* Offers read like parchment notices */
.market-offer-card,
.expedition-profile {
  border: 1px solid #9a7643;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--parch-100), var(--parch-400));
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .45), 0 3px 8px rgba(0, 0, 0, .3);
}
.market-offer-card strong, .expedition-profile-head h5 { color: #362312; }
.market-offer-card b { color: #6a3a0e; }
.market-offer-meta, .expedition-profile-meta { color: var(--ink-soft); }
.expedition-line { color: var(--ink); }
.expedition-conditions { color: #8e2f1b; }
.expedition-conditions li.met { color: #2f6a24; }
.expedition-conditions b { color: #362312; }
.expedition-note { color: #8a4b0f; font-weight: 600; }
.expedition-profile.available { border-color: #5f8f4a; box-shadow: inset 0 0 0 2px rgba(214, 236, 190, .5), 0 3px 8px rgba(0, 0, 0, .3); }
.expedition-badge { border: 1px solid #9a7643; background: #5a3d20; color: var(--cream); }
.expedition-badge.ok { border-color: #3f7d3a; background: #2f5a2a; color: #e7f8d6; }
.expedition-badge.progress { border-color: #b7791f; background: #7c4f12; color: var(--cream); }
.expedition-badge.done { background: #6b5a45; color: #efe3cc; }
.expedition-row { border-color: var(--brass-700); background: rgba(22, 15, 10, .5); }
.expedition-row small, .expedition-row-state { color: var(--muted); }
.expedition-row-state b { color: #f3d48f; }
.expedition-row.found { border-color: #7fae5f; background: rgba(47, 90, 42, .3); }
.expedition-found { color: var(--cream-dim); }
.archipelago-info-footer { border-top-color: rgba(141, 104, 47, .6) !important; }
.archipelago-info-footer, .archipelago-info-footer span, #archipelago-snapshot-info { color: var(--muted) !important; }
#modal-archipelago .archipelago-shipping-view,
#modal-archipelago .archipelago-grid-container,
#modal-archipelago .archipelago-expeditions-view { scrollbar-color: var(--brass-600) var(--wood-900); scrollbar-width: thin; }
#modal-archipelago .modal-body { padding: 0 4px !important; }
#modal-archipelago .archipelago-grid-container {
  border: 1px solid var(--brass-600);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(69, 46, 27, .9), rgba(22, 15, 10, .95));
  box-shadow: inset 0 0 0 2px rgba(20, 10, 4, .6), inset 0 0 22px rgba(0, 0, 0, .5);
}
#modal-archipelago .archipelago-info-footer { display: none; } /* would sit on the carved frame */
@media (max-width: 760px) {
  #modal-archipelago .modal-archipelago-content { padding: 46px 30px 34px; height: 94vh; }
  #modal-archipelago .modal-archipelago-content::before { inset: -4px; }
  #modal-archipelago .modal-header { margin: -20px 0 12px; flex-wrap: wrap; }
}
/* Opaque wood behind the content, inside the carved frame. */
#modal-archipelago .modal-archipelago-content::after {
  content: ""; position: absolute; z-index: -1; inset: 30px 34px 28px; pointer-events: none;
  border-radius: 10px;
  background: linear-gradient(145deg, #302316, #160f0a 72%);
}
.quest-modal-content::after {
  content: ""; position: absolute; z-index: -1; inset: 34px 36px 30px; pointer-events: none;
  border-radius: 10px;
  background: linear-gradient(145deg, #302316, #160f0a 72%);
}
#modal-archipelago .modal-subtitle { max-width: 420px; }
#modal-archipelago .shipping-toolbar { padding: 6px 14px 0; }

/* ==========================================================================
   Wood-and-parchment theme, part 3: Friends dock, map tools, visit banner
   and a reusable carved window (.wood-window) used by Game settings.
   ========================================================================== */
/* ---- Friends dock ---- */
#friends-panel-body {
  border: 1px solid var(--brass-600);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(58, 39, 22, .98), rgba(24, 15, 9, .98) 80%);
  backdrop-filter: none;
  color: var(--cream);
  box-shadow: inset 0 1px #b8955a, inset 0 0 0 2px rgba(20, 10, 4, .55), 0 -12px 32px rgba(0, 0, 0, .55);
}
#friends-search-input { border: 1px solid var(--brass-700); background: rgba(22, 15, 10, .85); color: var(--cream); }
#friends-search-input::placeholder { color: #9c8460; }
#friends-search-input:focus { border-color: var(--brass-300); box-shadow: 0 0 0 2px rgba(213, 181, 110, .2); }
#friends-panel-close,
.friends-toolbar button,
.friend-card button,
#visit-return-home {
  border: 1px solid var(--brass-600);
  border-radius: 5px;
  background: linear-gradient(#4a331d, #2c1c10);
  color: var(--cream);
  box-shadow: inset 0 1px #9c7a45;
}
#friends-panel-close:hover,
.friends-toolbar button:hover,
.friend-card button:hover:not(:disabled),
#visit-return-home:hover { border-color: var(--brass-300); background: linear-gradient(#5a3d20, #3b2716); color: #fff; }
.friends-toolbar button.active { border-color: var(--brass-300); background: linear-gradient(#8a6334, #5a3d20); color: #fff; box-shadow: inset 0 1px #e2c78b; }
.friends-status { color: var(--muted); }
.friends-cards { scrollbar-color: var(--brass-600) var(--wood-900); scrollbar-width: thin; }
.friend-card {
  border: 1px solid #9a7643;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--parch-100), var(--parch-400));
  box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .45), 0 3px 8px rgba(0, 0, 0, .3);
}
.friend-card.is-friend { border-color: var(--amber); box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .5), 0 0 10px rgba(211, 152, 61, .3); }
.friend-card[role="button"]:hover { transform: translateY(-1px); }
.friend-avatar { border: 2px solid var(--brass-600); background: var(--wood-600); box-shadow: 0 2px 5px rgba(60, 35, 10, .35); }
.friend-name { color: #362312; }
.friend-island-state { color: var(--ink-soft); }
.friend-card .visit-friend { border-color: #3f7d3a; background: linear-gradient(#3d6e33, #254720); color: #eaf8dc; }
.friend-card .remove-friend { border-color: #b4553a; background: linear-gradient(#7a2e1c, #4e1a10); color: #ffe4d6; }

/* ---- Map tools (zoom / home) ---- */
.world-tools button {
  border: 1px solid var(--brass-600);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #6a4a27, #2c1c10 75%);
  color: var(--cream);
  text-shadow: 0 1px 1px #1b1007;
  box-shadow: inset 0 1px #b8955a, 0 3px 8px rgba(0, 0, 0, .45);
}
.world-tools button:hover { border-color: var(--brass-300); background: radial-gradient(circle at 50% 35%, #8a6334, #3b2716 75%); color: #fff; }

/* ---- Visit banner ---- */
.visit-mode-banner {
  border: 1px solid var(--brass-600);
  border-radius: 7px;
  background: linear-gradient(#5a3d20, #2c1c10);
  color: var(--cream);
  box-shadow: inset 0 1px #b8955a, 0 6px 22px rgba(0, 0, 0, .45);
}
#visit-island-select { border-color: var(--brass-600); background: rgba(22, 15, 10, .85); color: var(--cream); }

/* ---- Reusable carved window ---- */
.modal-content.wood-window {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: min(560px, 94vw);
  padding: 50px 46px 54px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
  color: var(--cream);
}
.modal-content.wood-window::before {
  content: ""; position: absolute; z-index: 0; inset: -10px; pointer-events: none;
  background: url("assets/ui/tentoria-window-frame-v1.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .55));
}
.modal-content.wood-window::after {
  content: ""; position: absolute; z-index: -1; inset: 24px 24px 20px; pointer-events: none;
  border-radius: 8px;
  background: linear-gradient(145deg, #302316, #160f0a 72%);
}
.modal-content.wood-window > * { position: relative; z-index: 1; }
.modal-content.wood-window .modal-header {
  margin: -20px -4px 18px;
  padding: 8px 14px 9px 18px;
  border: 1px solid var(--brass-600);
  border-radius: 5px 5px 12px 12px;
  background: linear-gradient(#79552d, #46301c);
  box-shadow: inset 0 1px var(--brass-400), 0 4px 8px rgba(0, 0, 0, .35);
}
.modal-content.wood-window .modal-header h3 { color: var(--cream); text-shadow: 0 2px 2px #1b1007; letter-spacing: .03em; }
.modal-content.wood-window .modal-close {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--brass-300); border-radius: 50%;
  background: var(--wood-600); color: var(--cream);
}
.modal-content.wood-window .modal-close:hover { background: #6b321d; color: #fff; }
.wood-window .game-settings-section h4 {
  color: #f3d48f; font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  padding-bottom: 5px; border-bottom: 1px solid rgba(141, 104, 47, .55);
}
.wood-window .game-settings-toggle {
  border: 1px solid #9a7643;
  border-radius: 6px;
  background: linear-gradient(145deg, var(--parch-100), var(--parch-400));
  box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .45);
  transition: box-shadow .15s, border-color .15s;
}
.wood-window .game-settings-toggle:hover { border-color: var(--amber); box-shadow: inset 0 0 0 2px rgba(255, 244, 204, .5), 0 0 8px rgba(211, 152, 61, .35); }
.wood-window .game-settings-toggle input { accent-color: #8a531e; }
.wood-window .game-settings-toggle strong { color: #362312; }
.wood-window .game-settings-toggle small { color: var(--ink-soft); }
/* Keep the map tools clear of the framed island chart below them. */
@media (min-width: 701px) {
  .world-tools { top: auto; bottom: 446px; transform: none; }
}
.island-fertility-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.island-fertility-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #334155; border-radius: 999px; background: #0f172a; color: #cbd5e1; cursor: pointer; font-size: 12px; }
.island-fertility-chip.on { border-color: #22c55e; background: rgba(34, 197, 94, .15); color: #dcfce7; }
.island-fertility-chip input { margin: 0; }
.build-btn.fertility-locked { opacity: .6; filter: saturate(.4); }
.build-info-tag.fertility-lock-tag { color: #fca5a5; border-color: rgba(248, 113, 113, .45); background: rgba(127, 29, 29, .35); }

/* ---- Księga produkcji (dependency window) ---- */
.modal-content.wood-window.production-book-window { max-width: none; width: min(1400px, 97vw); height: min(900px, 93vh); display: flex; flex-direction: column; padding: 54px 52px 48px 62px; }
.pb-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr; gap: 18px; }
.pb-sidebar { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.pb-sidebar input { padding: 7px 10px; border: 1px solid var(--brass-600); border-radius: 6px; background: rgba(22, 15, 10, .85); color: var(--cream); }
.pb-tabs { display: flex; gap: 4px; }
.pb-tab { flex: 1; padding: 5px 4px; font-size: 12px; border: 1px solid var(--brass-600); border-radius: 5px; background: linear-gradient(#5a3d20, #2c1c10); color: var(--cream); cursor: pointer; }
.pb-tab.active, .pb-tab:hover { background: linear-gradient(#8a6334, #57391c); border-color: var(--amber); }
.pb-list { flex: 1; overflow-y: auto; padding-right: 4px; }
.pb-group h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); border-bottom: 1px solid rgba(184, 149, 90, .35); padding-bottom: 2px; }
.pb-item { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; margin: 1px 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--cream); text-align: left; cursor: pointer; font-size: 13px; }
.pb-item span { flex: 1; }
.pb-item em { color: #facc15; font-style: normal; }
.pb-item:hover { background: rgba(211, 152, 61, .15); }
.pb-item.active { background: rgba(211, 152, 61, .3); border-color: var(--amber); }
.pb-none { color: #a08f76; font-size: 12px; margin: 2px 6px; }
.pb-detail { min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; border-radius: 8px; padding: 10px; background: linear-gradient(#efe0bd, #dcc597); color: var(--ink, #2b1d10); box-shadow: inset 0 0 0 1px #b8955a, inset 0 0 18px rgba(92, 60, 25, .35); }
.pb-empty { margin: auto; text-align: center; color: #5c4428; font-size: 15px; }
.pb-empty h3 { margin: 6px 0; }
.pb-head { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 8px; border-bottom: 1px solid rgba(92, 60, 25, .35); }
.pb-head-icon { font-size: 40px; line-height: 1; }
.pb-head-icon img { width: 44px; height: 44px; }
.pb-head-main h3 { margin: 0; color: #3b2612; }
.pb-head-main > small { color: #6f5334; }
.pb-row { margin-top: 5px; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pb-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; border: 1px solid #b8955a; background: #f7ecd2; color: #3b2612; font-size: 12px; }
.pb-chip.req { background: #f5dfa0; border-color: #a86f1e; font-weight: 600; }
.pb-chip.link { cursor: pointer; }
.pb-chip.link:hover { background: #fff3d4; border-color: #8a531e; }
.pb-tree-scroll { flex: 1; min-height: 0; overflow: auto; padding: 6px 4px 10px; }
.pb-tree { display: inline-block; min-width: 100%; }
.pb-branch { display: flex; align-items: center; }
.pb-inputs { display: flex; flex-direction: column; gap: 8px; padding-right: 26px; position: relative; }
.pb-edge { display: flex; align-items: center; flex-direction: row-reverse; position: relative; }
.pb-edge-label { position: relative; min-width: 96px; margin-left: 6px; padding: 2px 16px 2px 4px; font-size: 11px; color: #5c4428; white-space: nowrap; border-bottom: 2px solid #8a6334; }
.pb-edge-label::after { content: ""; position: absolute; right: -2px; bottom: -6px; border: 5px solid transparent; border-left: 8px solid #8a6334; }
.pb-edge { flex-direction: row; }
.pb-edge-label { order: 2; }
.pb-edge > .pb-branch { order: 1; }
.pb-local { display: block; font-size: 10px; color: #8a531e; }
.pb-node { flex: none; }
.pb-leaf { padding: 5px 9px; border: 1px dashed #8a6334; border-radius: 6px; background: rgba(255, 248, 230, .6); font-size: 12.5px; white-space: nowrap; }
.pb-leaf small { display: block; font-size: 10px; color: #7a6040; }
.pb-card { width: 214px; padding: 7px 9px; border: 1px solid #8a6334; border-radius: 7px; background: linear-gradient(#fff8e6, #f1e2bf); box-shadow: 0 2px 5px rgba(60, 38, 15, .3); font-size: 12px; color: #2b1d10; }
.pb-card.pb-missing { border: 2px solid #b3261e; box-shadow: 0 0 0 2px rgba(179, 38, 30, .18), 0 2px 5px rgba(60, 38, 15, .3); }
.pb-card-head { display: flex; align-items: center; gap: 6px; }
.pb-card-head > div { flex: 1; line-height: 1.15; }
.pb-card-head small { display: block; color: #7a6040; font-size: 10.5px; }
.pb-card-icon { font-size: 20px; }
.pb-ratio { padding: 1px 7px; border-radius: 9px; background: #5a3d20; color: #fff3d4; font-weight: 700; font-size: 12px; }
.pb-card-output { margin: 4px 0 2px; }
.pb-card-meta { display: flex; flex-wrap: wrap; gap: 3px 8px; color: #5c4428; font-size: 11px; }
.pb-line-name { margin-top: 3px; font-style: italic; color: #6f5334; font-size: 11px; }
.pb-where { margin-top: 4px; font-size: 11px; }
.pb-where.ok { color: #2f6b1f; }
.pb-where.no { color: #b3261e; font-weight: 600; }
.pb-byproducts { margin-top: 3px; font-size: 11px; color: #6f5334; }
.pb-alt { margin-top: 5px; padding: 2px 8px; border: 1px solid #8a6334; border-radius: 5px; background: #f7ecd2; color: #3b2612; font-size: 11px; cursor: pointer; }
.pb-alt:hover { background: #fff3d4; }
.pb-alt-row { display: flex; gap: 5px; align-items: center; }
.pb-alt.ghost { padding: 2px 6px; }
.pb-parent { border-style: dashed; background: rgba(255, 248, 230, .75); }
.pb-parent small { display: block; font-size: 10px; color: #7a6040; }
path.pb-link.module { stroke-dasharray: 6 5; }
.pb-note { margin: 8px 0 0; padding: 8px 11px; border: 1px solid #b08a52; border-radius: 7px; background: rgba(255, 248, 225, .85); color: #3b2612; font-size: 13px; line-height: 1.45; }
.pb-legend { margin: 0; font-size: 11px; color: #6f5334; }
.build-btn.fertility-locked { filter: grayscale(.6); }
@media (max-width: 760px) {
  .modal-content.wood-window.production-book-window { padding: 40px 18px 30px; }
  .pb-layout { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
}

/* ---- Coins on the top bar ---- */
#hudGold { cursor: pointer; font: inherit; }
#hudGold small { font-size: 11px; margin-left: 2px; }
#hudGold .hud-gold-positive { color: #86efac; }
#hudGold .hud-gold-negative { color: #fca5a5; font-weight: 700; }
#hudGold.hud-gold-alert { border-color: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, .25); }
.pb-chip.boost { background: #fff1b8; border-color: #c9a227; }
.pb-chip.service { background: #e6f0d8; border-color: #7c9a52; }
.pb-boosters { margin-top: 3px; font-size: 11px; color: #7a5a00; }

/* ---- Build menu: preview of locked buildings & unlock notices ---- */
.build-next-divider { flex: 0 0 88px; align-self: stretch; display: flex; align-items: center; justify-content: center; text-align: center; margin: 0 2px; padding: 4px 6px; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--amber, #d3983d); border-left: 1px dashed rgba(184, 149, 90, .6); }
.build-show-more { flex: 0 0 118px; align-self: stretch; padding: 6px 10px; border: 1px dashed var(--brass-600, #8a6334); border-radius: 6px; background: rgba(22, 15, 10, .55); color: var(--cream, #f3e3c3); cursor: pointer; font-size: 12px; }
.build-show-more:hover { border-color: var(--amber, #d3983d); background: rgba(90, 61, 32, .6); }
.build-btn.population-locked { opacity: .62; }
.unlock-notices { position: fixed; right: 18px; top: 76px; z-index: 900; display: flex; flex-direction: column; gap: 8px; width: min(330px, calc(100vw - 32px)); }
.unlock-notice { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--brass-600, #8a6334); border-radius: 8px; background: linear-gradient(#5a3d20, #2c1c10); color: var(--cream, #f3e3c3); box-shadow: inset 0 1px #b8955a, 0 8px 22px rgba(0, 0, 0, .45); animation: unlock-in .35s ease-out; }
.unlock-notice small { color: #d9c7a4; line-height: 1.3; }
.unlock-notice-actions { display: flex; gap: 6px; margin-top: 4px; }
.unlock-notice-actions button { padding: 3px 9px; border: 1px solid var(--brass-600, #8a6334); border-radius: 5px; background: rgba(22, 15, 10, .6); color: var(--cream, #f3e3c3); cursor: pointer; font-size: 12px; }
.unlock-notice-actions button:hover { border-color: var(--amber, #d3983d); }
.unlock-notice-actions button[data-act="close"] { margin-left: auto; }
.production-boosters { color: #fde68a; }
@keyframes unlock-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Akademia Specjalistów (wood & parchment) ---- */
.modal-content.wood-window.academy-window { max-width: none; width: min(1240px, 96vw); height: min(860px, 92vh); display: flex; flex-direction: column; padding: 50px 44px 46px; }
.acad-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px 1fr; gap: 14px; }
.acad-nav { display: flex; flex-direction: column; gap: 8px; }
.acad-nav-item { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 9px 10px; border: 1px solid var(--brass-600, #8a6334); border-radius: 8px; background: linear-gradient(#4a321b, #24170c); color: var(--cream, #f3e3c3); text-align: left; cursor: pointer; }
.acad-nav-item span { grid-row: span 2; font-size: 24px; text-align: center; }
.acad-nav-item small { color: #cdb993; font-size: 11px; line-height: 1.25; }
.acad-nav-item.active { background: linear-gradient(#8a6334, #57391c); border-color: var(--amber, #d3983d); box-shadow: 0 0 10px rgba(211, 152, 61, .35); }
.acad-nav-item:not(.soon):not(.active):hover { border-color: var(--amber, #d3983d); }
.acad-nav-item.soon { opacity: .55; cursor: default; border-style: dashed; }
.acad-main { min-height: 0; overflow-y: auto; padding: 12px 14px; border-radius: 8px; background: linear-gradient(#efe0bd, #dcc597); color: #2b1d10; box-shadow: inset 0 0 0 1px #b8955a, inset 0 0 18px rgba(92, 60, 25, .35); }
.acad-main h4 { margin: 12px 0 6px; color: #5a3d20; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid rgba(92, 60, 25, .3); padding-bottom: 3px; }
.acad-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.acad-stat { padding: 8px 10px; border: 1px solid #b8955a; border-radius: 8px; background: #f7ecd2; text-align: center; }
.acad-stat strong { display: block; font-size: 20px; color: #3b2612; }
.acad-stat span { font-size: 11px; color: #6f5334; text-transform: uppercase; letter-spacing: .04em; }
.acad-status { margin: 8px 0 0; font-size: 12px; color: #6f5334; min-height: 16px; }
.acad-geologists { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.acad-geo { display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid #8a6334; border-radius: 9px; background: linear-gradient(#fff8e6, #f1e2bf); box-shadow: 0 2px 6px rgba(60, 38, 15, .25); }
.acad-geo header { display: flex; align-items: center; gap: 9px; }
.acad-avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; border: 2px solid #b8955a; background: radial-gradient(#fff3d4, #e0c690); font-size: 22px; }
.acad-stars span { color: #c9b791; font-size: 13px; }
.acad-stars span.on { color: #d49b1f; text-shadow: 0 0 2px rgba(120, 70, 0, .4); }
.acad-geo-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: #5c4428; }
.acad-geo.searching { border-color: #4f7a3a; }
.acad-geo.has-result { border-color: #d49b1f; box-shadow: 0 0 0 2px rgba(212, 155, 31, .35), 0 2px 6px rgba(60, 38, 15, .25); animation: acad-glow 1.6s ease-in-out infinite alternate; }
@keyframes acad-glow { to { box-shadow: 0 0 0 4px rgba(212, 155, 31, .5), 0 2px 10px rgba(212, 155, 31, .45); } }
.acad-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.acad-chip { position: relative; display: grid; place-items: center; width: 36px; height: 34px; border: 1px solid #b8955a; border-radius: 7px; background: #f7ecd2; cursor: pointer; font-size: 17px; }
.acad-chip em { position: absolute; right: -5px; top: -6px; min-width: 15px; padding: 0 3px; border-radius: 8px; background: #5a3d20; color: #fff3d4; font-size: 10px; font-style: normal; line-height: 15px; }
.acad-chip.active { border-color: #8a531e; background: #ffe7a8; box-shadow: 0 0 0 2px rgba(138, 83, 30, .35); }
.acad-chip:disabled { opacity: .35; cursor: not-allowed; }
.acad-cost { font-size: 12px; color: #4a3520; line-height: 1.4; }
.acad-btn { padding: 5px 10px; border: 1px solid #8a6334; border-radius: 6px; background: #f7ecd2; color: #3b2612; cursor: pointer; font-size: 12px; text-align: left; }
.acad-btn small { display: block; color: #6f5334; font-size: 10.5px; }
.acad-btn:hover { background: #fff3d4; }
.acad-btn.primary { background: linear-gradient(#8a6334, #57391c); color: #fff3d4; border-color: #57391c; text-align: center; font-weight: 600; }
.acad-btn.primary:hover { background: linear-gradient(#9d7340, #664322); }
.acad-btn.small { padding: 2px 7px; font-size: 11px; }
.acad-report { padding: 8px; border: 1px solid #d49b1f; border-radius: 7px; background: #fff1b8; color: #3b2612; font-weight: 600; cursor: pointer; }
.acad-report.fail { background: #f3e2d6; border-color: #a86f4e; }
.acad-searching { font-size: 12.5px; }
.acad-progress { height: 8px; border-radius: 5px; background: rgba(92, 60, 25, .2); overflow: hidden; }
.acad-progress i { display: block; height: 100%; background: linear-gradient(90deg, #6a9a45, #a7c65d); }
.acad-muted { color: #7a6040; font-size: 12px; }
.acad-hire { align-items: center; justify-content: center; text-align: center; border-style: dashed; background: rgba(255, 248, 230, .55); }
.acad-bottom { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.acad-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.acad-table th { text-align: left; font-size: 11px; color: #6f5334; border-bottom: 1px solid rgba(92, 60, 25, .3); padding: 3px 4px; }
.acad-table td { padding: 3px 4px; border-bottom: 1px dotted rgba(92, 60, 25, .2); }
.acad-deposit-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.acad-deposit { display: grid; grid-template-columns: 150px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; font-size: 12px; }
.acad-deposit small { grid-column: 1 / 3; color: #6f5334; }
.acad-deposit button { grid-row: 1 / 3; grid-column: 3; }
.acad-deposit.low .acad-progress i { background: linear-gradient(90deg, #b3261e, #e0763a); }
.acad-results { display: flex; flex-direction: column; gap: 4px; }
.acad-log { padding: 4px 7px; border-radius: 5px; background: rgba(255, 248, 230, .7); font-size: 12px; border-left: 3px solid #b8955a; }
.acad-log.ok { border-left-color: #4f7a3a; }
.acad-log.fail { border-left-color: #a86f4e; }
.acad-log.depleted { border-left-color: #b3261e; }
.expedition-notification.warning { border-color: #e0763a; }
@media (max-width: 860px) { .acad-layout, .acad-bottom { grid-template-columns: 1fr; } .acad-nav { flex-direction: row; overflow-x: auto; } .acad-summary { grid-template-columns: repeat(2, 1fr); } }

/* ---- Faction coin shop ---- */
.faction-shop-gold { font-weight: 700; color: #facc15; white-space: nowrap; }
.faction-shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.faction-shop-item { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--brass-600, #8a6334); border-radius: 8px; background: rgba(22, 15, 10, .55); }
.faction-shop-item small { color: #d9c7a4; font-size: 11px; }
.faction-shop-item.sold-out { opacity: .5; }
.faction-shop-name { display: flex; align-items: center; gap: 6px; }
.faction-shop-buy { display: flex; gap: 6px; margin-top: 3px; }
.faction-shop-buy input { width: 64px; padding: 3px 5px; border: 1px solid var(--brass-600, #8a6334); border-radius: 5px; background: rgba(0, 0, 0, .3); color: var(--cream, #f3e3c3); }
.faction-shop-buy button { flex: 1; white-space: nowrap; }

/* ---- Księga: flow diagram ---- */
#production-book-detail .pb-tree-scroll { position: relative; overflow: hidden; padding: 0; cursor: grab; border-radius: 6px; background:
  radial-gradient(circle, rgba(92, 60, 25, .16) 1px, transparent 1.4px) 0 0 / 18px 18px; }
#production-book-detail .pb-tree-scroll.dragging { cursor: grabbing; }
.pb-canvas { position: absolute; inset: 0; }
.pb-graph { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pb-gnode { position: absolute; width: 222px; }
.pb-gnode .pb-card { width: 100%; box-sizing: border-box; }
.pb-gnode.root .pb-card { border: 2px solid #a86f1e; box-shadow: 0 0 0 3px rgba(212, 155, 31, .3), 0 3px 8px rgba(60, 38, 15, .35); }
.pb-gnode .pb-leaf { white-space: normal; background: #fff8e6; border-style: dashed; }
.pb-gnode .pb-leaf small { display: block; }
.pb-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.pb-link { fill: none; stroke: #8a6334; stroke-width: 2.2; opacity: .85; }
.pb-link.local { stroke-dasharray: 6 4; }
.pb-link-label { font-size: 10.5px; fill: #4a3520; paint-order: stroke; stroke: #efe0bd; stroke-width: 3px; stroke-linejoin: round; }
.pb-zoom { position: absolute; right: 8px; top: 8px; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid #b8955a; border-radius: 7px; background: rgba(247, 236, 210, .92); }
.pb-zoom button { width: 26px; height: 24px; border: 1px solid #8a6334; border-radius: 5px; background: #fff8e6; color: #3b2612; cursor: pointer; font-size: 14px; line-height: 1; }
.pb-zoom span { min-width: 40px; text-align: center; font-size: 11px; color: #5c4428; }
.pb-gnode { cursor: move; touch-action: none; user-select: none; }
.pb-gnode.moving { z-index: 5; }
.pb-gnode.moving .pb-card, .pb-gnode.moving .pb-leaf { box-shadow: 0 10px 22px rgba(60, 38, 15, .45); transform: scale(1.02); }
.pb-link.hot { stroke: #c2410c; stroke-width: 3.2; opacity: 1; }

/* Large carved windows: the frame PNG scales with the window, so its border
   thickness is a fixed share of the size (left/right ≈7%, top ≈15%, bottom
   ≈13% of the image). Padding follows the same proportions so content never
   slides under the wood. */
.modal-content.wood-window.production-book-window,
.modal-content.wood-window.academy-window {
  --fw: min(1400px, 97vw); --fh: min(900px, 93vh);
  width: var(--fw); height: var(--fh);
  padding: calc((var(--fh) + 20px) * .149 - 64px) calc((var(--fw) + 20px) * .0703 + 4px) calc((var(--fh) + 20px) * .133 - 4px) calc((var(--fw) + 20px) * .0703 + 4px);
}
.modal-content.wood-window.academy-window { --fw: min(1260px, 96vw); --fh: min(880px, 93vh); }
.modal-content.wood-window.production-book-window .modal-header,
.modal-content.wood-window.academy-window .modal-header { margin-left: calc((var(--fw) + 20px) * -.0703 + 40px); margin-right: calc((var(--fw) + 20px) * -.0703 + 40px); }
.season-groups-box { flex-basis: 100%; margin-top: 8px; }
.season-groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.season-groups-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.season-groups-grid input { width: 100%; }

/* Cookie consent & account deletion (after login) */
#modal-storage-choice, #modal-delete-account { z-index: 100001; }
.storage-choice-content, .delete-account-content { max-width: 520px; }
.storage-choice-content h3, .delete-account-content h3 { font-size: 20px; color: #f8fafc; margin-bottom: 8px; }
.storage-category { margin-top: 10px; padding: 10px 12px; border: 1px solid #334155; border-radius: 10px; background: rgba(15, 23, 42, .6); }
.storage-category strong { color: #f8fafc; font-size: 14px; }
.storage-category p { margin: 5px 0 0; color: #94a3b8; font-size: 12px; line-height: 1.45; }
.storage-badge { margin-left: 6px; padding: 2px 7px; border-radius: 9px; background: rgba(22, 163, 74, .25); color: #86efac; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.storage-badge.optional { background: rgba(37, 99, 235, .25); color: #93c5fd; }
.storage-actions, .delete-account-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.storage-footnote { margin: 12px 0 0; font-size: 12px; }
.game-settings-account { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.game-settings-account small, .settings-storage-state { font-size: 12px; opacity: .8; }
.delete-account-warning { color: #fecaca; line-height: 1.5; }
.delete-account-list { margin: 8px 0 12px 20px; color: #cbd5e1; font-size: 13px; line-height: 1.6; }
.delete-account-check { display: flex; gap: 8px; align-items: center; color: #f8fafc; font-size: 13px; cursor: pointer; }
.delete-account-content .form-group { margin-top: 10px; }
.btn-danger-outline { color: #fca5a5; border-color: rgba(220, 38, 38, .6); }
.btn-danger-outline:hover { background: rgba(220, 38, 38, .15); }
.game-settings-account.danger { margin-bottom: 4px; }
#modal-game-settings .modal-content.wood-window { max-height: 94vh; display: flex; flex-direction: column; }
#modal-game-settings .modal-body { overflow-y: auto; min-height: 0; padding: 0 6px 18px 0; }
#modal-game-settings .modal-content.wood-window { padding-bottom: 64px; }

/* ---- Build menu: room for full building names ---- */
/* Cards used to be clipped at the bottom (fixed 158 px area) and names were
   cut to one line; names now wrap to two lines and the panel grows to fit. */
#build-panel-body { max-height: 300px; }
.build-accordion-container { max-height: 238px; }
.build-category-items { padding-bottom: 6px; align-items: stretch; }
.build-btn { min-width: 156px; max-width: 176px; }
.build-btn-name {
  max-width: 162px;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  min-height: 2.4em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.build-btn.population-locked .build-btn-name::after { content: ''; }
.build-btn.population-locked .build-btn-left::after { content: '🔒 zablokowany'; font-size: 10px; color: #fbbf24; }

/* Admin: test generation of an island profile */
.island-preview-results { margin-top: 14px; display: grid; gap: 14px; }
.island-preview-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.island-preview-chip { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.island-preview-chip strong { color: #f8fafc; }
.island-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.island-preview-block h4 { margin: 0 0 6px; font-size: 14px; }
.island-preview-block .admin-table td, .island-preview-block .admin-table th { padding: 5px 8px; font-size: 13px; }
.island-preview-warn { color: #fbbf24; }
.island-preview-bad { color: #f87171; }
.island-preview-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); min-width: 60px; overflow: hidden; }
.island-preview-bar > span { display: block; height: 100%; background: #34d399; }

/* Admin: performance test island */
.perf-island-box { background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; }
.perf-island-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 130px; }
.perf-island-box input, .perf-island-box select { width: 130px; }

.fire-log-empty { color: #94a3b8; font-size: 12px; padding: 8px 4px; opacity: .8; }
.archipelago-season { margin: 2px 0 4px; font-size: 12px; color: #fcd34d; }
.population-need-substitutes { display: block; font-size: 11px; opacity: .75; }

/* Winter forecast */
.winter-forecast-pill { cursor: pointer; font: inherit; }
.winter-forecast-pill.warning { background: rgba(185, 28, 28, .45); border-color: #f87171; }
.winter-forecast-card { width: min(760px, 94vw); max-width: none; max-height: 85vh; overflow: auto; }
.winter-forecast-card table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.winter-forecast-card td, .winter-forecast-card th { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: top; }
.winter-forecast-card tr.ok td:last-child { color: #4ade80; }
.winter-forecast-card tr.warn td:last-child { color: #fbbf24; }
.winter-forecast-card tr.bad td:last-child { color: #f87171; }
.winter-forecast-card small { opacity: .75; }
#hudCalendar { cursor: pointer; }
.weather-forecast-card { width: min(640px, 94vw); max-width: none; max-height: 85vh; overflow: auto; }
.weather-forecast-card table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.weather-forecast-card td { padding: 6px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
.weather-forecast-card small { opacity: .75; }
.weather-forecast-card .wf-temp { white-space: nowrap; font-variant-numeric: tabular-nums; }
.wf-today { font-size: 15px; margin: 4px 0 10px; }
.wf-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.wf-day { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; padding: 8px; text-align: center; font-size: 13px; }
.wf-day-name { text-transform: capitalize; font-weight: 600; margin-bottom: 4px; }
.wf-day-icon { font-size: 26px; line-height: 1.2; }
.wf-fuel { font-size: 12px; color: #fdba74; margin-top: 2px; }

/* Production rules */
.production-rule { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.production-rule-row { display: flex; gap: 6px; align-items: center; margin: 6px 0 4px; flex-wrap: wrap; }
.production-rule-row .rule-value { width: 90px; }
.production-rule .rule-status { display: block; opacity: .85; line-height: 1.35; }
.faction-season-note { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.25); font-size: 13px; line-height: 1.4; }
.island-fertility-chip select { margin-left: 4px; font-size: 12px; }
.island-fertility-chip.random { border-style: dashed; }
.epidemic-pill { cursor: pointer; font: inherit; }
.epidemic-pill.warning { background: rgba(126, 34, 206, .45); border-color: #c084fc; }
.acad-avatar-img { position: relative; overflow: visible; background: none; border: 2px solid #b8955a; padding: 0; }
.acad-avatar-img img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.acad-avatar-badge { position: absolute; right: -6px; bottom: -4px; font-style: normal; font-size: 14px; background: #fff3d4; border: 1px solid #b8955a; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.acad-spec-hire .acad-avatar-img, .acad-spec header .acad-avatar-img { width: 52px; height: 52px; }
.acad-spec-bonuses { flex-direction: column; gap: 2px; }
.acad-next { color: #2f6b2a; font-weight: 600; }
.acad-xp { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: #5c4428; }
.acad-btn[disabled] { opacity: .55; cursor: not-allowed; }
.acad-synergies { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.acad-synergy { padding: 7px 9px; border: 1px dashed #8a6334; border-radius: 8px; background: #fbf1da; font-size: 12.5px; }
.acad-synergy.active { border-style: solid; border-color: #3f7a2f; background: #eef7df; }
.acad-synergy.locked { opacity: .7; }
.admin-spec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-spec-head img { width: 48px; height: 48px; border-radius: 50%; }
.admin-spec-head h4 { margin: 0; flex: 1; }
.admin-spec-card textarea.spec-description { width: 100%; box-sizing: border-box; min-height: 56px; }
.admin-spec-levels input { width: 80px; }
.admin-spec-costs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.admin-spec-costs > .form-row { grid-column: 1 / -1; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.admin-spec-synergy { display: grid !important; grid-template-columns: 180px 1fr 120px; align-items: end; gap: 6px 12px; border-top: 1px solid rgba(255,255,255,.08); padding: 8px 0; }
.admin-spec-synergy .form-group { margin: 0; }
.admin-spec-synergy .hint-text { grid-column: 1 / -1; margin: 0; }
@media (max-width: 700px) { .admin-spec-synergy, .admin-spec-costs > .form-row { grid-template-columns: 1fr; } }
.popup-nature { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.popup-nature.hidden { display: none; }
.popup-nature-note { font-size: 12px; padding: 5px 8px; border-radius: 6px; background: rgba(59, 130, 246, .12); border-left: 3px solid #60a5fa; }
.popup-nature-note.ok { background: rgba(34, 197, 94, .12); border-left-color: #22c55e; }
.popup-nature-note.bad { background: rgba(239, 68, 68, .12); border-left-color: #ef4444; }
.expedition-directions-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.expedition-direction-admin h4 { margin: 0 0 6px; }
.expedition-direction-admin label { display: block; }
.expedition-direction h5 small { font-weight: 400; opacity: .75; margin-left: 4px; }
.population-need-row.locked { opacity: .65; }
.population-need-row .population-need-locked { grid-column: 2 / -1; color: #94a3b8; font-size: 11px; }
#building-popup .population-needs,
#building-popup .production-rule { border-color: rgba(141, 104, 47, .7); background: rgba(20, 12, 6, .38); }
#building-popup .residence-promotion-card p { color: #cdb88f; }
#building-popup select, #building-popup input[type="number"] { border: 1px solid var(--brass-700, #6e4f2a); border-radius: 5px; background: rgba(22, 15, 10, .85); color: #f3e6c8; }
#building-popup .btn:not(.btn-primary):not(.btn-warning):not(.btn-danger),
#building-popup .production-rule button { border: 1px solid var(--brass-600, #8a6334); background: linear-gradient(#4a331d, #2c1c10); color: #f3e6c8; }
.sprite-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
#sprite-report table { margin-top: 8px; font-size: 12px; }
.sprite-checks .checkbox-label { display: inline-flex; flex-direction: row; align-items: center; gap: 5px; margin: 0; }
#sprite-optimizer > .checkbox-label { display: flex; align-items: center; gap: 6px; }
/* A new quest: the Zadania button gently flashes until the player opens it. */
@keyframes quest-new-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0), inset 0 1px #b8955a; border-color: var(--brass-600, #8a6334); }
  50% { box-shadow: 0 0 14px 4px rgba(250, 204, 21, .55), inset 0 1px #f8e3a0; border-color: #facc15; color: #fff7cc; }
}
.world-bottom-actions button.quest-new, #quests-launcher.quest-new, .quest-list-item.quest-new { animation: quest-new-pulse 1.8s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .world-bottom-actions button.quest-new, #quests-launcher.quest-new, .quest-list-item.quest-new { animation: none; border-color: #facc15; box-shadow: 0 0 10px 2px rgba(250, 204, 21, .45); }
}

/* Admin: loading-screen background of a season */
.season-loading-bg { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.season-loading-preview {
  width: 192px; height: 108px; flex: 0 0 auto; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .45); display: flex; align-items: center; justify-content: center;
  background: #0f1d1b url("/archipelago_map_bg.png") center / cover no-repeat;
}
.season-loading-preview span { font-size: 11px; color: #e2e8f0; background: rgba(8, 18, 17, .65); padding: 2px 8px; border-radius: 10px; }
.season-loading-preview.has-image span { display: none; }
.season-loading-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; flex: 1 1 200px; }
.season-loading-actions .field-hint { margin: 0; }

/* Admin calendar: one player's date */
.player-date-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.player-date-row label { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
#player-date-islands { margin-top: 8px; line-height: 1.6; }

/* Admin: violations */
.violations-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.violations-summary .vio-stat { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 8px 12px; min-width: 120px; }
.violations-summary .vio-stat strong { display: block; font-size: 20px; color: #f8fafc; }
.violations-summary .vio-stat span { font-size: 12px; color: #94a3b8; }
.violations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.violations-grid fieldset { border: 1px solid #334155; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.violations-grid legend { padding: 0 6px; font-weight: 600; }
.violations-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.violations-grid legend label, .violations-grid .inline-check { flex-direction: row; align-items: center; gap: 8px; }
.violations-grid .field-hint { margin: 0; }
.violations-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.violations-filters label { display: flex; flex-direction: column; gap: 4px; }
.violations-table td { vertical-align: top; font-size: 13px; }
.violations-table td.vio-detail { word-break: break-word; max-width: 420px; }
.violations-grid input[type="number"], .violations-grid input[type="text"],
.violations-filters input, .violations-filters select {
  width: 100%; padding: 8px 12px; background: #0f172a; border: 1px solid #334155;
  border-radius: 8px; color: #f8fafc; font-size: 14px; outline: none;
}
.violations-grid input:focus, .violations-filters input:focus, .violations-filters select:focus { border-color: #3b82f6; }
.violations-grid .field-hint, #tab-content-violations .field-hint { font-size: 12px; color: #94a3b8; line-height: 1.4; }
.violations-grid input[type="checkbox"] { width: auto; }
.violations-table tr.monitor-suspicious td { background: rgba(239, 68, 68, 0.12); }
.violations-table td.monitor-up { color: #4ade80; }
.violations-table td.monitor-down { color: #f87171; }
.violations-table tr.monitor-first td { border-top: 2px solid #334155; }

/* Admin: Ekonomia */
.econ-subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.econ-subtab { background: #1e293b; color: #cbd5e1; border: 1px solid #334155; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.econ-subtab.active { background: #2563eb; border-color: #3b82f6; color: #fff; }
.econ-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #b91c1c; color: #fff; font-size: 11px; }
.econ-count:empty { display: none; }
.econ-panel { display: none; }
.econ-panel.active { display: block; }
.econ-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.econ-toolbar label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #94a3b8; }
.econ-toolbar label.inline-check { flex-direction: row; align-items: center; gap: 6px; color: #cbd5e1; }
.econ-toolbar input[type=search] { min-width: 220px; }
.econ-table-wrap { overflow-x: auto; max-height: 70vh; overflow-y: auto; }
.econ-table td, .econ-table th { padding: 7px 9px; vertical-align: top; font-size: 12.5px; }
.econ-table thead th { position: sticky; top: 0; z-index: 1; }
.econ-table tr.econ-clickable { cursor: pointer; }
.econ-muted { color: #64748b; }
.econ-chip { display: inline-block; background: #0f172a; border: 1px solid #334155; border-radius: 6px; padding: 1px 6px; margin: 1px 2px 1px 0; white-space: nowrap; }
.econ-chip.warn { border-color: #b45309; color: #fcd34d; }
.econ-totals { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.econ-totals .vio-stat { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 8px 12px; min-width: 130px; }
.econ-totals .vio-stat strong { display: block; font-size: 18px; color: #f8fafc; }
.econ-totals .vio-stat span { font-size: 12px; color: #94a3b8; }
.econ-class-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.econ-class-card h4 { margin: 0 0 6px; }
.econ-whatif-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 10px; }
.econ-whatif-grid fieldset { border: 1px solid #334155; border-radius: 8px; padding: 10px; }
.econ-whatif-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #94a3b8; margin-bottom: 6px; }
.econ-wi-row { display: flex; gap: 6px; margin-bottom: 6px; }
.econ-wi-row select { flex: 1; min-width: 0; }
.econ-wi-row input { width: 70px; }
.econ-issue { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; background: #1e293b; border-left: 4px solid #d97706; }
.econ-issue.error { border-left-color: #dc2626; }
.econ-issue.info { border-left-color: #3b82f6; }
.econ-assumptions { color: #94a3b8; font-size: 12px; margin-top: 14px; }
.econ-timeline { max-height: 420px; overflow-y: auto; font-size: 13px; }
.econ-timeline div { padding: 3px 0; border-bottom: 1px solid #1e293b; }
.econ-timeline .day { display: inline-block; min-width: 88px; color: #94a3b8; }
.econ-sim-live { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; background: #0f172a; border: 1px solid #334155; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 8px; }
.econ-sim-bar { flex-basis: 100%; height: 4px; background: #1e293b; border-radius: 2px; overflow: hidden; }
.econ-sim-bar i { display: block; height: 100%; background: #38bdf8; transition: width .4s; }
.econ-sim-tools { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #cbd5e1; margin-bottom: 6px; }
.econ-sim-tools label { display: flex; gap: 6px; align-items: center; }
.econ-sim-flow { max-height: 62vh; overflow-y: auto; font-size: 13px; border: 1px solid #334155; border-radius: 8px; padding: 6px 8px; margin-bottom: 14px; background: #0b1220; }
.econ-sim-flow.hide-quiet .sim-tick.quiet { display: none; }
.econ-sim-flow .sim-h { flex: 0 0 64px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.econ-sim-flow .sim-tick, .econ-sim-flow .sim-event { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid #172033; }
.econ-sim-flow .sim-lines { flex: 1; min-width: 0; line-height: 1.45; }
.econ-sim-flow .sim-made { color: #cbd5e1; }
.econ-sim-flow .sim-prog { color: #7dd3fc; }
.econ-sim-flow .sim-warn { color: #fca5a5; }
.econ-sim-flow .sim-ok { color: #86efac; }
.econ-sim-flow .sim-full { color: #fcd34d; }
.econ-sim-flow .sim-waste { color: #fdba74; }
.econ-sim-flow .sim-break { background: #111a2e; }
.econ-sim-flow .sim-break-title { color: #a5b4fc; }
.econ-sim-flow .sim-event { color: #e2e8f0; font-weight: 600; }
.econ-sim-flow .sim-event.sim-side { font-weight: 400; color: #c4b5fd; }
.econ-sim-flow .sim-stall, .econ-sim-flow .sim-stop { color: #fca5a5; }
.econ-sim-flow .sim-goal { color: #86efac; }
.sim-quest { border: 1px solid #334155; border-radius: 8px; margin: 6px 0; background: #111827; }
.sim-quest > summary { cursor: pointer; padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; }
.sim-quest.done > summary .sim-q-title::after { content: " ✅"; }
.sim-quest .sim-q-meta { color: #94a3b8; font-size: 12px; }
.sim-quest .sim-q-goals { padding: 0 10px 4px; }
.sim-quest .sim-quest-body { padding: 0 10px 6px; }


/* =====================================================================
   Panel Zarządzania Światem — one consistent look for every form.
   Scoped to #view-admin, so it also covers the editors built by scripts.
   ===================================================================== */
#view-admin {
  --adm-field-bg: #0b1324;
  --adm-field-border: #334155;
  --adm-field-hover: #475569;
  --adm-focus: #3b82f6;
  --adm-text: #e2e8f0;
  --adm-muted: #94a3b8;
  --adm-accent: #38bdf8;
}

/* Text fields, number fields, dropdowns and text areas */
#view-admin input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]),
#view-admin select,
#view-admin textarea {
  background: var(--adm-field-bg);
  border: 1px solid var(--adm-field-border);
  border-radius: 8px;
  color: var(--adm-text);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  padding: 7px 10px;
  min-height: 34px;
  max-width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#view-admin textarea { min-height: 64px; resize: vertical; width: 100%; }
#view-admin input:not([type=checkbox]):not([type=radio]):hover,
#view-admin select:hover, #view-admin textarea:hover { border-color: var(--adm-field-hover); }
#view-admin input:not([type=checkbox]):not([type=radio]):focus,
#view-admin select:focus, #view-admin textarea:focus {
  border-color: var(--adm-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .22);
}
#view-admin input::placeholder, #view-admin textarea::placeholder { color: #64748b; }
#view-admin input:disabled, #view-admin select:disabled, #view-admin textarea:disabled { opacity: .55; cursor: not-allowed; }

/* Dropdowns: dark list with a chevron (the open list was white on white) */
#view-admin select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color-scheme: dark;
}
#view-admin select option, #view-admin select optgroup { background: #0f172a; color: var(--adm-text); }
#view-admin select[multiple] { background-image: none; padding-right: 10px; min-height: 90px; }

/* Checkboxes become switches */
#view-admin input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 34px !important;
  min-width: 34px;
  height: 20px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #475569;
  background: #1f2a3d;
  cursor: pointer;
  vertical-align: middle;
  transition: background .18s, border-color .18s;
}
#view-admin input[type=checkbox]::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  transition: transform .18s, background .18s;
}
#view-admin input[type=checkbox]:checked { background: #2563eb; border-color: #3b82f6; }
#view-admin input[type=checkbox]:checked::before { transform: translateX(14px); background: #fff; }
#view-admin input[type=checkbox]:focus-visible { box-shadow: 0 0 0 3px rgba(59, 130, 246, .3); outline: none; }
#view-admin input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }
#view-admin input[type=radio] { accent-color: #3b82f6; }

/* A switch and its text sit together on the left */
#view-admin label:has(> input[type=checkbox]),
#view-admin .checkbox-label,
#view-admin .inline-check {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--adm-text);
  font-size: 13px;
  line-height: 1.35;
  margin: 4px 0;
}
#view-admin label:has(> input[type=checkbox]) > span { flex: 1 1 auto; }
#view-admin .checkbox-group, #view-admin .form-group.checkbox-group { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; }

/* Labels, hints and running text inside forms */
#view-admin .form-group label:not(:has(> input[type=checkbox])) { color: var(--adm-muted); font-size: 12px; font-weight: 600; margin-bottom: 5px; }
#view-admin .form-group input:not([type=checkbox]):not([type=radio]),
#view-admin .form-group select { width: 100%; }
#view-admin .field-hint, #view-admin .hint-text { color: var(--adm-muted); font-size: 12px; line-height: 1.45; }
#view-admin .admin-form-box > p, #view-admin .admin-pane form > p { color: var(--adm-muted); font-size: 13px; line-height: 1.5; margin: 0 0 12px; }
#view-admin .form-row { gap: 12px 16px; align-items: end; }
#view-admin .form-group { margin-bottom: 12px; }

/* Label-wrapped fields ("Pojemność domu <input>") stack neatly */
#view-admin .population-admin-card .form-row,
#view-admin .form-row:has(> label > input:not([type=checkbox])) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px 16px;
}
#view-admin .form-row > label:has(> input:not([type=checkbox]), > select) {
  display: flex; flex-direction: column; gap: 5px;
  color: var(--adm-muted); font-size: 12px; font-weight: 600;
}
#view-admin .form-row > label > input:not([type=checkbox]), #view-admin .form-row > label > select { width: 100%; }

/* Section titles and collapsible groups */
#view-admin .admin-form-box h4,
#view-admin .form-section-title {
  color: var(--adm-accent);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, .16);
}
#view-admin .admin-form-box > h4:first-child,
#view-admin .admin-form-box > .admin-collapse-head:first-child { margin-top: 0; }
#view-admin .admin-collapse-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
#view-admin .admin-collapse-head::after {
  content: "▾";
  margin-left: auto;
  color: var(--adm-muted);
  font-size: 12px;
  transition: transform .18s;
}
#view-admin .admin-collapse-head.collapsed::after { transform: rotate(-90deg); }
#view-admin .admin-collapse-head:hover { color: #7dd3fc; }
#view-admin .admin-collapse-body { display: block; }
#view-admin .admin-collapse-body.collapsed { display: none; }

/* Needs of a population class: one tidy row per need, wrapping on narrow screens */
#view-admin .population-need-config.resource-list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #2b3a52;
  border-radius: 10px;
  background: rgba(15, 23, 42, .55);
}
#view-admin .population-need-config > select { flex: 1 1 190px; min-width: 170px; }
#view-admin .population-need-config > label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--adm-muted); line-height: 1.2;
  flex: 0 1 96px; min-width: 84px; margin: 0;
}
#view-admin .population-need-config > label:has(> input[type=checkbox]) {
  flex-direction: row; align-items: center; flex: 0 0 auto; min-width: 0; font-size: 12px; color: var(--adm-text); padding-bottom: 7px;
}
#view-admin .population-need-config > label:has(> .need-seasons) { flex: 0 1 130px; }
#view-admin .population-need-config > label:has(> .need-substitutes) { flex: 1 1 170px; }
#view-admin .population-need-config > label > input:not([type=checkbox]),
#view-admin .population-need-config > label > select { width: 100%; }
#view-admin .population-need-config .btn-remove-row { align-self: center; margin-left: auto; }
#view-admin .population-admin-needs > strong, #view-admin .population-admin-card strong {
  display: block; color: var(--adm-text); font-size: 13px; margin: 14px 0 4px;
}
#view-admin input[type=range] { accent-color: #3b82f6; }

/* Tree editor: chance of the species in every biome. */
.tree-biomes-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 6px;
  background: #1e293b;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #334155;
}
.tree-biome-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 40px;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.6;
}
.tree-biome-row.active { opacity: 1; background: rgba(56, 189, 248, 0.08); }
.tree-biome-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; margin: 0; }
.tree-biome-row .tree-biome-density { width: 100%; }
.tree-biome-density-label { font-size: 12px; text-align: right; color: #cbd5e1; font-variant-numeric: tabular-nums; }
.unlock-notice.night-notice { background: linear-gradient(#26324f, #121a2e); border-color: #52648f; box-shadow: inset 0 1px #7d90bd, 0 8px 22px rgba(0, 0, 0, .45); transition: opacity .7s ease, transform .7s ease; }
.unlock-notice.night-notice small { color: #cfd8ee; }
.unlock-notice.night-notice .unlock-notice-actions button { border-color: #52648f; }
.unlock-notice.night-notice .unlock-notice-actions button[data-act="ok"] { margin-left: auto; min-width: 54px; }
.unlock-notice.fading { opacity: 0; transform: translateX(24px); }
/* A finished quest whose reward waits: green tick in its title. */
.quest-ready-check { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 7px; border-radius: 50%; background: #16a34a; color: #fff; font-size: 11px; font-style: normal; font-weight: 800; line-height: 1; vertical-align: 2px; box-shadow: 0 0 0 2px rgba(22, 163, 74, .35), 0 0 8px rgba(34, 197, 94, .55); animation: quest-ready-pulse 1.8s ease-in-out infinite; }
.quest-detail-head h2 .quest-ready-check { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: #16a34a; color: #fff; font-size: 13px; vertical-align: 4px; }
@keyframes quest-ready-pulse { 50% { box-shadow: 0 0 0 4px rgba(22, 163, 74, .18), 0 0 12px rgba(34, 197, 94, .8); } }
/* Messages raised while a window is open must show above it. */
.road-removal-dialog { z-index: 10050; }
#modal-app-dialog { z-index: 10060; }
.unlock-notices { z-index: 10040; }
.quest-actions button.quest-busy { opacity: .85; cursor: progress; }
/* Sound settings: a switch and its volume slider. */
.game-settings-audio-row { display: grid; gap: 6px; margin-top: 10px; }
.game-settings-volume { display: flex; align-items: center; gap: 8px; padding: 0 13px; color: #94a3b8; font-size: 13px; }
.game-settings-volume input[type=range] { flex: 1; accent-color: #38bdf8; }
.game-settings-hint { display: block; margin-top: 8px; color: #94a3b8; font-size: 11.5px; }
/* Panel admina → Muzyka */
#view-admin .admin-audio-tracks { display: grid; gap: 10px; }
#view-admin .admin-audio-group { padding: 8px 10px; border: 1px solid #334155; border-radius: 8px; background: rgba(15, 23, 42, .5); }
#view-admin .admin-audio-group code { color: #94a3b8; font-size: 11px; }
#view-admin .admin-audio-track { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
#view-admin .admin-audio-track span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-admin .admin-audio-track audio { height: 30px; width: min(320px, 55%); }
#view-admin .admin-audio-slider { display: grid; grid-template-columns: 200px 1fr 48px; align-items: center; gap: 10px; margin-top: 8px; }
#view-admin .admin-audio-slider b { text-align: right; }
#view-admin .admin-audio-rules { display: grid; gap: 8px; margin: 10px 0; }
#view-admin .admin-audio-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #334155; border-radius: 8px; background: rgba(15, 23, 42, .5); }
#view-admin .admin-audio-rule select { min-width: 150px; }
#view-admin .admin-audio-rule-volume { display: flex; align-items: center; gap: 6px; }
#view-admin .admin-audio-rule-volume input { width: 110px; }
/* Population window: the treasury's expenses, item by item. */
.population-expenses-title { margin: 14px 0 6px; }
.population-expenses { width: 100%; border-collapse: collapse; }
.population-expenses td { padding: 4px 6px; border-bottom: 1px solid rgba(148, 163, 184, .18); vertical-align: top; }
.population-expenses td:last-child { text-align: right; white-space: nowrap; }
.population-expense { color: #f87171; }
.population-expense-total td { border-bottom: 0; }
.population-expense-details summary { cursor: pointer; }
.population-expense-details ul { margin: 6px 0 2px; padding-left: 16px; font-size: 12px; }
.population-expense-details li { display: flex; justify-content: space-between; gap: 10px; }
.population-expense-details li b { color: #fca5a5; font-weight: 500; }
.biome-compose-btn { margin-top: 6px; width: 100%; }
.biome-composer-card { width: min(1280px, 96vw); max-width: none; max-height: 92vh; overflow: auto; }
.biome-composer-head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; }
.biome-composer-head .inline-check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.biome-composer-body { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.3fr); gap: 16px; }
@media (max-width: 900px) { .biome-composer-body { grid-template-columns: 1fr; } }
.biome-compose-row { display: grid; grid-template-columns: 36px minmax(90px, 1fr) minmax(90px, 1.3fr) 44px 86px 30px; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 13px; }
.biome-compose-row img { width: 34px; height: 34px; object-fit: contain; }
.biome-compose-row .effective { opacity: .75; font-size: 11px; }
.biome-compose-sum { font-size: 12px; opacity: .85; margin: 6px 0 4px; }
.biome-compose-add { display: flex; gap: 6px; margin-bottom: 12px; }
.biome-compose-add select { flex: 1; min-width: 0; }
.biome-composer-preview canvas { width: 100%; height: auto; border: 1px solid #334155; border-radius: 8px; background: #0b1b33; }
.biome-composer-preview .field-hint { margin-top: 6px; line-height: 1.5; }
#building-popup .aux-cost { display: block; margin-top: 3px; color: #cdb88f; }
#building-popup .aux-cost-item { white-space: nowrap; }
#building-popup .aux-cost-item.missing { color: #f87171; font-weight: 600; }
#building-popup .aux-cost-warn { color: #f87171; }
.admin-free-build { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px; border: 1px dashed #b45309; border-radius: 6px; color: #fcd34d; cursor: pointer; white-space: nowrap; }
.admin-free-build.active { background: rgba(180, 83, 9, .35); border-style: solid; }
.admin-free-build.hidden { display: none; }
/* Budget window: loan button on the left, "Zamknij" on the right. */
.loan-actions [data-close] { margin-left: auto; }
.loan-info { margin: 12px 0 0; padding: 9px 11px; border-radius: 8px; background: rgba(15, 23, 42, .55); border: 1px solid #334155; }
/* Game settings: a wide window, each setting in two columns —
   the switch and its name on the left, the description on the right. */
#modal-game-settings .modal-content.game-settings-wide { max-width: min(1000px, 96vw); width: 100%; }
#modal-game-settings .modal-header { gap: 10px; }
#modal-game-settings .game-settings-reset { margin-left: auto; font-size: 12px; padding: 5px 10px; }
#modal-game-settings .game-settings-toggle {
  display: grid; grid-template-columns: 22px minmax(150px, 230px) 1fr; column-gap: 14px; align-items: start;
}
#modal-game-settings .game-settings-toggle > span { display: contents; }
#modal-game-settings .game-settings-toggle strong { grid-column: 2; padding-top: 1px; }
#modal-game-settings .game-settings-toggle small { grid-column: 3; margin-top: 0; font-size: 12.5px; line-height: 1.45; }
#modal-game-settings .game-settings-toggle select { grid-column: 1 / span 1; min-width: 0 !important; width: 74px; }
#modal-game-settings .game-settings-toggle:has(select) { grid-template-columns: 74px minmax(98px, 178px) 1fr; }
#modal-game-settings .game-settings-audio-row { grid-template-columns: 1fr; }
@media (max-width: 700px) {
  #modal-game-settings .game-settings-toggle { grid-template-columns: 22px 1fr; }
  #modal-game-settings .game-settings-toggle:has(select) { grid-template-columns: 74px 1fr; }
  #modal-game-settings .game-settings-toggle small { grid-column: 2; margin-top: 4px; }
}
/* The carved frame is a picture stretched to the window: at this width its
   sides and corners are thicker, so the content keeps a proportional margin
   and fades out where it scrolls under the top and bottom of the frame. */
#modal-game-settings .modal-content.wood-window.game-settings-wide {
  padding: 58px clamp(52px, 8.4%, 92px) 74px;
}
#modal-game-settings .modal-content.wood-window.game-settings-wide::after { inset: 30px clamp(30px, 4.6%, 52px) 28px; }
#modal-game-settings .game-settings-wide .modal-body {
  padding: 14px 10px 22px 4px;
  -webkit-mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 20px), transparent);
          mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 20px), transparent);
}
#modal-game-settings .game-settings-wide .game-settings-section h4 { font-size: 15px; }
#modal-game-settings .game-settings-wide .game-settings-toggle { padding: 14px 16px; }
#modal-game-settings .game-settings-wide .game-settings-toggle strong { font-size: 15px; }
#modal-game-settings .game-settings-wide .game-settings-toggle small { font-size: 14px; line-height: 1.5; }
#modal-game-settings .game-settings-wide .game-settings-toggle select { font-size: 13px; padding: 4px 5px; }
#modal-game-settings .game-settings-wide .game-settings-hint,
#modal-game-settings .game-settings-wide .game-settings-account small { font-size: 13px; }
/* The frame's bottom beam also grows with the window's height. */
#modal-game-settings .modal-content.wood-window.game-settings-wide { padding-bottom: clamp(84px, 11.5vh, 124px); }
#modal-game-settings .game-settings-wide .modal-body {
  -webkit-mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 28px), transparent);
}

/* Admin sidebar: link to the start page editor (a separate page). */
.admin-site-link {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px;
  border-radius: 8px; border: 1px dashed rgba(227, 176, 75, .45);
  color: #e3b04b; text-decoration: none; font-weight: 600;
}
.admin-site-link:hover { background: rgba(227, 176, 75, .1); }
