* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

html.mobile-touch-ui {
  font-size: 20px;
}

:root {
  --ui-base-width: 1920;
  --ui-base-height: 1080;
  --ui-scale: 1;
  --ui-viewport-width: 1920px;
  --ui-viewport-height: 1080px;
  --ui-offset-x: 0px;
  --ui-offset-y: 0px;
  --game-offset-x: 0px;
  --game-offset-y: 0px;
  --map-brightness: 1.12;
  --map-saturation: 1.08;
  --menu-map-brightness: 0.85;
  --menu-map-saturation: 0.78;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --font-base: 20px;
  --inventory-slot-size: 116px;
  --inventory-slot-height: 90px;
  --inventory-slot-gap: 6px;
  --trade-panel-width: 320px;
  --trade-panel-gap: 0px;
  --trade-panel-gutter: calc(var(--trade-panel-width) + var(--trade-panel-gap));
  --modal-shell-width: min(1100px, 92vw);
  --modal-shell-height: 82vh;
  --flow-card-height: 72px;
  --parchment-ink: #eef8f4;
  --parchment-ink-muted: rgba(206, 225, 221, 0.76);
  --parchment-ink-soft: rgba(174, 196, 193, 0.62);
  --parchment-border: rgba(92, 221, 195, 0.25);
  --parchment-border-strong: rgba(236, 184, 92, 0.46);
  --parchment-shadow: 0 16px 34px rgba(1, 6, 10, 0.46), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  --parchment-surface: rgba(13, 26, 31, 0.9);
  --parchment-surface-strong: rgba(20, 39, 43, 0.94);
  --parchment-surface-muted: rgba(28, 52, 55, 0.78);
  --parchment-header: rgba(36, 57, 54, 0.96);
  --parchment-wash: rgba(15, 31, 36, 0.94);
  --city-text-color: var(--parchment-ink);
  --city-surface-bg: var(--parchment-surface);
  --city-surface-border: var(--parchment-border);
  --city-surface-shadow: var(--parchment-shadow);
  --menu-glow: var(--parchment-shadow);
  --menu-surface: var(--parchment-surface);
  --menu-border: var(--parchment-border);
  --menu-text: var(--parchment-ink);
  --accent: #e7b85d;
  --accent-strong: #f3c56f;
  --emphasis-green: #44d68a;
  --emphasis-red: #ff6b5f;
}

@media (max-width: 700px) {
  html {
    font-size: 17px;
  }
}

body {
  overflow: hidden;
  background: radial-gradient(circle at 15% 20%, rgba(110, 78, 40, 0.2), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(67, 44, 24, 0.25), transparent 35%),
    #2a1d12;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: var(--font-base);
  line-height: 1.3;
  color: var(--parchment-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

body,
body * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.emphasis-positive,
.emphasis-positive * {
  color: var(--emphasis-green) !important;
}

.emphasis-negative,
.emphasis-negative * {
  color: var(--emphasis-red) !important;
}

.danger,
.danger * {
  color: var(--emphasis-red) !important;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--ui-base-width) * 1px);
  height: calc(var(--ui-base-height) * 1px);
  transform: translate3d(var(--game-offset-x), var(--game-offset-y), 0) scale(var(--ui-scale));
  transform-origin: top left;
  overflow: hidden;
  pointer-events: auto;
  filter: saturate(var(--map-saturation)) brightness(var(--map-brightness));
  transition: opacity 320ms ease, filter 320ms ease;
}

#game-container.hidden-before-start {
  opacity: 0;
  pointer-events: none;
}

body.app-city-select #game-container,
body.app-menu #game-container {
  width: 100vw;
  height: 100vh;
  transform: none;
}

body.boat-mode #game-container {
  width: 100vw;
  height: 100vh;
  transform: none;
  opacity: 1;
  pointer-events: auto;
  filter: saturate(1.12) brightness(1.04);
}

#parchment-map {
  position: fixed;
  inset: 0;
  background-color: #2a1d12;
  background-image: url('../images/parchment_map.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

body.app-city-select #parchment-map,
body.app-menu #parchment-map {
  opacity: 0;
  pointer-events: none;
}

.parchment-stars {
  position: absolute;
  inset: 0;
}

.parchment-star {
  position: absolute;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%) scaleX(1) scaleY(2);
  background: transparent url('../textures/new/city_map.png') center/contain no-repeat;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: transform 160ms ease, opacity 220ms ease;
}

.parchment-star.near {
  opacity: 1;
  transition-delay: 0s;
}

.parchment-star.active {
  opacity: 1;
  transform: translate(-50%, -50%) scaleX(1.1) scaleY(2.2);
  transition-delay: 0s;
}

#game-container.menu-map {
  filter: saturate(var(--menu-map-saturation)) brightness(var(--menu-map-brightness));
  transition: opacity 320ms ease, filter 320ms ease;
}

#game-container.city-map {
  filter: saturate(var(--map-saturation)) brightness(var(--map-brightness));
  transition: opacity 320ms ease, filter 320ms ease;
}

body.player-ship-sunk #game-container {
  filter: grayscale(1) saturate(0.08) brightness(0.58) contrast(1.06);
}

body.player-ship-sunk #hud-bar,
body.player-ship-sunk #broadside-hud,
body.player-ship-sunk #quest-log-panel,
body.player-ship-sunk #city-hover-label,
body.player-ship-sunk #docking-progress {
  display: none !important;
}

#game-container.loading {
  opacity: 0;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #game-container.loading,
body.boat-mode:not(.app-loading) #game-container.hidden-before-start {
  opacity: 1;
  pointer-events: auto;
}

#game-container.hidden {
  display: none;
}

#ui-layer,
.menu-overlay,
.loading-overlay {
  color: var(--parchment-ink);
}

canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.three-map-canvas {
  touch-action: none;
  cursor: grab;
}

.three-map-canvas:active {
  cursor: grabbing;
}

.three-map-canvas.is-hovering-pickable {
  cursor: pointer;
}

/* Guard rails for text overflow across the HUD */
:is(
    #economy-hud span,
    #fleet-display,
    #city-info-name,
    .city-info-allegiance,
    .foreign-label,
    .foreign-amount,
    .foreign-rate,
    .tier-chip,
    .foreign-line,
    .vehicle-action-btn,
    #vehicle-status-title,
    #vehicle-status-assignment,
    #vehicle-status-closest,
    #vehicle-status-allegiance,
    #vehicle-status-wealth,
    .company-panel-name,
    .company-panel-summary,
    .company-panel-title,
    .company-city-name,
    .company-city-meta,
    .company-ship-value,
    .diplomacy-company-name,
    .diplomacy-company-meta,
    .diplomacy-city-name,
    .diplomacy-city-meta
  ) {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Clamp multi-line body copy to avoid runaway wrapping */
:is(
    .foreign-subtitle,
    .foreign-trade-status,
    .wizard-field label,
    .wizard-error,
    #vehicle-status-assignment,
    #vehicle-status-cargo,
    #vehicle-auto-status
  ) {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#ui-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--ui-viewport-width);
  height: var(--ui-viewport-height);
  transform: translate3d(0, 0, 0) scale(var(--ui-scale));
  transform-origin: top left;
  pointer-events: none;
  z-index: 20;
}

.hidden {
  display: none !important;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 18px 32px;
  overflow-y: auto;
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms ease;
  z-index: 30;
}

.menu-overlay.active {
  pointer-events: auto;
  opacity: 1;
}

.menu-gradient {
  position: absolute;
  inset: 0;
  background: transparent;
}

.menu-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.45fr);
  gap: 28px;
  width: min(1280px, 96vw);
  margin: 0 auto;
  z-index: 1;
  color: var(--menu-text);
}

.menu-shell.compact {
  grid-template-columns: minmax(0, 1fr);
  width: min(720px, 92vw);
}

.menu-left {
  padding: 32px 28px;
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  border-radius: 28px;
  box-shadow: var(--menu-glow);
  backdrop-filter: blur(6px);
}

.menu-logo {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.menu-tagline {
  margin-top: 8px;
  color: var(--parchment-ink-muted);
}

.menu-actions {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}

.menu-action {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  border-radius: 16px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  color: var(--parchment-ink);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.menu-action.primary {
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  font-weight: 700;
  border: 1px solid var(--parchment-border-strong);
  box-shadow: var(--parchment-shadow);
}

.menu-action.secondary {
  background: var(--parchment-surface-muted);
}

.menu-action.ghost {
  border-style: dashed;
}

.menu-action.danger {
  border-color: rgba(122, 44, 28, 0.45);
  color: #7a2c1c;
}

.menu-action:hover {
  transform: translateY(-2px);
  border-color: var(--parchment-border-strong);
}

.menu-right {
  display: grid;
  grid-template-rows: 1fr;
  max-height: calc(100vh - 96px);
}

.menu-card {
  background: var(--parchment-surface-strong);
  border: 1px solid var(--parchment-border);
  border-radius: 24px;
  padding: 22px 22px 26px;
  box-shadow: var(--menu-glow);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  max-height: 100%;
}

.menu-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.menu-card h1 {
  font-size: clamp(28px, 3vw, 36px);
}

.subtitle {
  color: var(--parchment-ink-muted);
  font-size: 15px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  color: var(--parchment-ink-soft);
  margin-bottom: 4px;
}

.ghost-icon {
  border: 1px solid var(--parchment-border);
  color: var(--parchment-ink);
  background: var(--parchment-surface-muted);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  cursor: pointer;
}

.start-button {
  margin-top: 8px;
  width: 100%;
  padding: 16px;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 800;
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  border: 1px solid var(--parchment-border-strong);
  cursor: pointer;
  box-shadow: var(--parchment-shadow);
  transition: transform 120ms ease;
}

.start-button.secondary {
  background: var(--parchment-surface-muted);
  color: var(--parchment-ink);
  box-shadow: none;
  border: 1px dashed var(--parchment-border);
}

.start-button:hover {
  transform: translateY(-1px);
}

.start-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--parchment-border);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 14, 16, 0.98) 0%, rgba(11, 30, 32, 0.98) 48%, rgba(4, 9, 11, 0.98) 100%),
    linear-gradient(90deg, rgba(92, 221, 195, 0.08), rgba(231, 184, 93, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.app-loading .loading-overlay,
.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-loader {
  position: relative;
  display: grid;
  width: min(420px, 72vw);
  padding: 0;
  z-index: 1;
}

.loading-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(92, 221, 195, 0.26);
  background: rgba(2, 8, 9, 0.72);
  box-shadow:
    0 0 20px rgba(92, 221, 195, 0.16),
    inset 0 1px 2px rgba(0, 0, 0, 0.55);
}

.loading-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, rgba(92, 221, 195, 0), rgba(92, 221, 195, 0.95), rgba(231, 184, 93, 0.95));
  box-shadow: 0 0 18px rgba(92, 221, 195, 0.55);
  animation: loading-bar-sweep 820ms ease-in-out infinite;
}

@keyframes loading-bar-sweep {
  0% {
    transform: translateX(-115%);
  }
  100% {
    transform: translateX(285%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-bar {
    animation-duration: 1500ms;
  }
}

.city-map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 28px 18px 36px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms ease;
  z-index: 32;
}

.app-menu .city-map-overlay,
.app-loading .city-map-overlay,
.app-playing .city-map-overlay {
  display: none;
}

.city-map-overlay.active {
  opacity: 1;
}

.city-map-panel {
  background: rgba(248, 239, 221, 0.9);
  border: 1px solid var(--parchment-border);
  border-radius: 20px;
  padding: 14px 16px 16px;
  width: min(360px, 86vw);
  box-shadow: 0 24px 60px rgba(34, 24, 12, 0.25);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.city-map-header h1 {
  margin: 6px 0 6px;
}

.city-map-header .subtitle {
  margin: 0 0 18px;
}

.city-map-selection {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--parchment-border);
  margin-bottom: 12px;
}

.city-map-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.city-map-actions .start-button {
  margin-top: 0;
}

.city-map-selection-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.city-map-selection-row .label {
  color: var(--parchment-ink-muted);
}

.city-map-selection-row .value {
  font-weight: 600;
  color: var(--parchment-ink);
}

@media (max-width: 420px) {
  .city-map-actions {
    grid-template-columns: 1fr;
  }
}

.city-hover-label {
  position: absolute;
  min-width: 120px;
  padding: 2px 6px;
  border-radius: 10px;
  background: transparent;
  color: #000;
  font-family: 'Macondo Swash Caps', 'Cinzel', serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  transform: translate(-50%, -120%);
  pointer-events: none;
  -webkit-text-stroke: 1.5px #f2e0b9;
  text-shadow:
    -1px -1px 0 #f2e0b9,
    1px -1px 0 #f2e0b9,
    -1px 1px 0 #f2e0b9,
    1px 1px 0 #f2e0b9,
    0 0 8px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 120ms ease;
}

.city-hover-label.visible {
  opacity: 1;
}

.loading-spinner {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 24px auto 6px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid rgba(122, 90, 52, 0.25);
  border-top-color: #b06a1f;
  animation: spin 1.1s linear infinite;
}

.spinner-core {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 205, 156, 0.65), rgba(199, 146, 84, 0.4));
}

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

.floating-menu {
  position: absolute;
  top: 120px;
  left: 20px;
  width: 240px;
  background: var(--parchment-surface-strong);
  border: 1px solid var(--parchment-border);
  border-radius: 14px;
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  pointer-events: auto;
  z-index: 12;
}

.floating-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--parchment-border);
}

.floating-menu-body {
  display: grid;
  gap: 8px;
  padding: 10px 12px 14px;
}

.floating-menu-button {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  color: var(--parchment-ink);
  cursor: pointer;
  text-align: left;
}

.floating-menu-button.danger {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecdd3;
}

.floating-menu-button:hover {
  border-color: rgba(125, 211, 252, 0.7);
}

.day-night-control {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 270;
  pointer-events: auto;
}

body:not(.boat-mode) .day-night-control {
  top: 112px;
}

.app-menu .day-night-control,
.app-city-select .day-night-control,
.app-loading .day-night-control {
  opacity: 0;
  pointer-events: none;
}

.day-night-toggle {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 2px solid var(--parchment-border-strong);
  background: var(--parchment-surface);
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease;
}

.day-night-toggle:hover,
.day-night-toggle[aria-pressed='false'] {
  border-color: rgba(176, 106, 31, 0.9);
  background: var(--parchment-surface-strong);
  transform: translateY(-1px);
}

.day-night-toggle span {
  line-height: 1;
}

.audio-settings {
  position: absolute;
  top: 84px;
  left: 16px;
  z-index: 260;
  display: grid;
  justify-items: start;
  gap: 8px;
  pointer-events: auto;
}

body:not(.boat-mode) .audio-settings {
  top: 180px;
}

.app-menu .audio-settings,
.app-city-select .audio-settings,
.app-loading .audio-settings {
  opacity: 0;
  pointer-events: none;
}

.audio-settings-toggle {
  width: 56px;
  height: 56px;
  border: 2px solid var(--parchment-border-strong);
  background: var(--parchment-surface);
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease;
}

.audio-settings-toggle:hover,
.audio-settings-toggle[aria-expanded='true'] {
  border-color: rgba(176, 106, 31, 0.9);
  background: var(--parchment-surface-strong);
  transform: translateY(-1px);
}

.audio-settings-menu {
  width: min(292px, calc(100vw - 32px));
  background: var(--parchment-surface);
  border: 2px solid var(--parchment-border-strong);
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
}

.audio-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 8px 10px 8px 14px;
  border-bottom: 2px solid var(--parchment-border);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}

.audio-settings-close {
  width: 32px;
  height: 32px;
  border: 2px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.audio-settings-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.music-track-manager {
  display: grid;
  gap: 10px;
}

.music-track-select-control {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 0 !important;
}

.music-track-select {
  min-width: 0;
  width: 100%;
  height: 32px;
  border: 1px solid rgba(83, 52, 24, 0.32);
  border-radius: 4px;
  background: rgba(255, 244, 211, 0.72);
  color: #302416;
  font: 700 0.78rem 'Courier New', monospace;
}

.music-transport-controls {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  justify-content: center;
  gap: 8px;
}

.music-transport-button {
  width: 40px;
  height: 34px;
  border: 1px solid rgba(83, 52, 24, 0.38);
  border-radius: 4px;
  background: rgba(255, 244, 211, 0.82);
  color: #302416;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.music-transport-button:hover,
.music-transport-button:focus-visible {
  background: rgba(255, 232, 166, 0.95);
  outline: none;
}

.music-transport-button--primary {
  border-color: rgba(118, 74, 24, 0.55);
  background: rgba(241, 201, 112, 0.9);
}

.audio-volume-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.audio-volume-control output {
  min-width: 42px;
  text-align: right;
  color: var(--parchment-ink-muted);
  font-variant-numeric: tabular-nums;
}

.audio-volume-slider {
  --volume-value: 0%;
  grid-column: 1 / -1;
  width: 100%;
  height: 28px;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  cursor: pointer;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}

.audio-volume-slider::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid var(--parchment-border);
  background: linear-gradient(
    to right,
    var(--accent-strong) 0%,
    var(--accent-strong) var(--volume-value),
    rgba(108, 76, 38, 0.22) var(--volume-value),
    rgba(108, 76, 38, 0.22) 100%
  );
  transition: background 120ms ease;
}

.audio-volume-slider::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 2px solid var(--parchment-border-strong);
  background: var(--parchment-surface-strong);
  box-shadow: 0 2px 6px rgba(76, 52, 24, 0.28);
  -webkit-appearance: none;
  appearance: none;
}

.audio-volume-slider::-moz-range-track {
  height: 8px;
  border: 1px solid var(--parchment-border);
  background: rgba(108, 76, 38, 0.22);
}

.audio-volume-slider::-moz-range-progress {
  height: 8px;
  background: var(--accent-strong);
}

.audio-volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--parchment-border-strong);
  background: var(--parchment-surface-strong);
}

.gear-button {
  width: 72px;
  height: 72px;
  font-size: 32px;
  background: linear-gradient(145deg, #1d4ed8, #0ea5e9);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 14px 32px rgba(14, 165, 233, 0.35);
}

.menu-overlay,
.loading-overlay {
  visibility: hidden;
}

.menu-overlay.active,
.app-loading .loading-overlay,
.loading-overlay.active {
  visibility: visible;
}

@media (max-width: 1200px) {
  .menu-shell {
    grid-template-columns: 1fr;
    width: min(1100px, 98vw);
  }
  .menu-right {
    max-height: none;
  }
}

.app-playing .menu-overlay {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-menu #game-container {
  pointer-events: none;
}

.app-city-select #game-container {
  pointer-events: auto;
}

.app-loading #game-container {
  opacity: 0;
  pointer-events: none;
}

.app-menu #notification-panel,
.app-city-select #notification-panel,
.app-loading #notification-panel,
.app-menu #economy-hud,
.app-menu #experience-hud,
.app-menu #ship-health-hud,
.app-city-select #economy-hud,
.app-city-select #experience-hud,
.app-city-select #ship-health-hud,
.app-loading #economy-hud,
.app-loading #experience-hud,
.app-loading #ship-health-hud,
.app-menu #trade-ui-stack,
.app-city-select #trade-ui-stack,
.app-loading #trade-ui-stack,
.app-menu #company-panel,
.app-city-select #company-panel,
.app-loading #company-panel,
.app-menu #diplomacy-panel,
.app-city-select #diplomacy-panel,
.app-loading #diplomacy-panel,
.app-menu #map-editor-panel,
.app-city-select #map-editor-panel,
.app-loading #map-editor-panel,
.app-menu #model-editor-panel,
.app-city-select #model-editor-panel,
.app-loading #model-editor-panel,
.app-menu #boat-model-editor-panel,
.app-city-select #boat-model-editor-panel,
.app-loading #boat-model-editor-panel,
.app-menu #city-info-panel,
.app-city-select #city-info-panel,
.app-loading #city-info-panel {
  opacity: 0;
  pointer-events: none;
}

body.boat-mode .menu-overlay,
body.boat-mode:not(.app-loading) .loading-overlay,
body.boat-mode .city-map-overlay,
body.boat-mode #parchment-map,
body.boat-mode #notification-panel,
body.boat-mode #economy-hud,
body.boat-mode #model-editor-panel,
body.boat-mode #city-banner {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

#ui-layer #fleet-tuning-panel,
#ui-layer #combat-tuning-panel,
#ui-layer #debug-teleport-panel,
#ui-layer #wave-tuning-panel,
#ui-layer #hud-bar-tuning-panel,
#ui-layer #map-editor-panel,
#ui-layer #model-editor-panel,
#ui-layer #boat-model-editor-panel,
#ui-layer #vehicle-status-debug {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.app-loading #ui-layer {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.map-editor-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 296px;
  max-height: 430px;
  padding: 10px;
  background: var(--parchment-surface);
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  pointer-events: auto;
  z-index: 230;
  display: grid;
  gap: 8px;
  overflow: hidden;
  transition:
    width 160ms ease,
    max-height 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.map-editor-panel.is-active {
  border-color: rgba(27, 122, 51, 0.8);
}

.map-editor-panel:not(.is-active) {
  width: 64px;
  max-height: 64px;
  gap: 0;
}

.map-editor-panel:not(.is-active) .map-editor-header {
  grid-template-columns: 44px;
}

.map-editor-panel:not(.is-active) .map-editor-heading,
.map-editor-panel:not(.is-active) .map-editor-terrains,
.map-editor-panel:not(.is-active) .map-editor-status {
  display: none;
}

.map-editor-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.map-editor-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: var(--parchment-surface-strong);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(76, 52, 24, 0.18);
}

.map-editor-toggle[aria-pressed='true'] {
  background: #a9c98d;
  border-color: rgba(27, 122, 51, 0.75);
}

.map-editor-heading {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.map-editor-kicker {
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.7;
}

.map-editor-selected {
  font-size: 19px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-editor-terrains {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 298px;
  overflow-y: auto;
  padding-right: 2px;
}

.map-editor-terrain {
  min-width: 0;
  height: 38px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--parchment-border);
  border-radius: 7px;
  background: var(--parchment-surface-muted);
  cursor: pointer;
  text-align: left;
}

.map-editor-terrain.is-selected {
  border-color: rgba(176, 106, 31, 0.9);
  background: #d9b97f;
  box-shadow: inset 0 0 0 1px rgba(176, 106, 31, 0.28);
}

.map-editor-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(46, 31, 16, 0.45);
}

.map-editor-terrain-label {
  min-width: 0;
  font-size: 13px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-editor-status {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.72;
}

.model-editor-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 372px;
  max-height: min(820px, calc(100% - 36px));
  padding: 10px;
  background: var(--parchment-surface);
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  pointer-events: auto;
  z-index: 232;
  display: grid;
  gap: 9px;
  overflow: hidden;
  transition:
    width 160ms ease,
    max-height 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.model-editor-panel.is-active {
  border-color: rgba(63, 91, 132, 0.82);
}

.model-editor-panel:not(.is-active) {
  width: 64px;
  max-height: 64px;
  gap: 0;
}

.model-editor-panel:not(.is-active) .model-editor-header {
  grid-template-columns: 44px;
}

.model-editor-panel:not(.is-active) .model-editor-heading,
.model-editor-panel:not(.is-active) .model-editor-preview,
.model-editor-panel:not(.is-active) .model-editor-color-row,
.model-editor-panel:not(.is-active) .model-editor-parts,
.model-editor-panel:not(.is-active) .model-editor-sliders,
.model-editor-panel:not(.is-active) .model-editor-actions,
.model-editor-panel:not(.is-active) .model-editor-status {
  display: none;
}

.model-editor-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.model-editor-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: var(--parchment-surface-strong);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(76, 52, 24, 0.18);
}

.model-editor-toggle[aria-pressed='true'] {
  background: #9fb6c7;
  border-color: rgba(63, 91, 132, 0.85);
}

.model-editor-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.model-editor-kicker {
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.7;
}

.model-editor-resource {
  min-width: 0;
  width: 100%;
  height: 31px;
  padding: 0 8px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  font-size: 15px;
  line-height: 1;
}

.model-editor-preview {
  height: 188px;
  min-height: 188px;
  border: 1px solid var(--parchment-border);
  background:
    linear-gradient(180deg, rgba(38, 58, 72, 0.88), rgba(19, 32, 44, 0.96)),
    #13202c;
  overflow: hidden;
}

.model-editor-preview canvas {
  width: 100% !important;
  height: 100% !important;
}

.model-editor-color-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.model-editor-color-label,
.model-editor-color-value {
  font-size: 13px;
  line-height: 1;
}

.model-editor-color-input {
  width: 48px;
  height: 32px;
  padding: 2px;
  background: var(--parchment-surface-muted);
  cursor: pointer;
}

.model-editor-color-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.75;
}

.model-editor-parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.model-editor-part {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-editor-part[aria-pressed='true'] {
  border-color: rgba(63, 91, 132, 0.9);
  background: #b9c3b8;
  box-shadow: inset 0 0 0 1px rgba(63, 91, 132, 0.28);
}

.model-editor-sliders {
  display: grid;
  gap: 7px;
}

.model-editor-slider {
  min-width: 0;
  height: 26px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  line-height: 1;
}

.model-editor-slider input {
  min-width: 0;
  width: 100%;
}

.model-editor-slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.76;
}

.model-editor-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.model-editor-action {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-editor-status {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.72;
}

@media (max-width: 820px) {
  .model-editor-panel.is-active {
    right: 10px;
    bottom: 10px;
    width: min(372px, calc(100% - 20px));
    max-height: calc(100% - 20px);
  }

  .model-editor-preview {
    height: 160px;
    min-height: 160px;
  }
}

body:not(.boat-mode) #boat-model-editor-panel {
  display: none !important;
}

.boat-model-editor-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(920px, calc(100% - 36px));
  max-height: min(820px, calc(100% - 36px));
  padding: 10px;
  background: var(--parchment-surface);
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  pointer-events: auto;
  z-index: 276;
  display: grid;
  gap: 9px;
  overflow: hidden;
  transition:
    width 160ms ease,
    max-height 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.boat-model-editor-panel.is-active {
  border-color: rgba(176, 106, 31, 0.86);
}

.boat-model-editor-panel:not(.is-active) {
  width: 64px;
  max-height: 64px;
  gap: 0;
}

.boat-model-editor-panel:not(.is-active) .boat-model-editor-header {
  grid-template-columns: 44px;
}

.boat-model-editor-panel:not(.is-active) .boat-model-editor-heading,
.boat-model-editor-panel:not(.is-active) .boat-model-editor-body {
  display: none;
}

.boat-model-editor-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.boat-model-editor-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: var(--parchment-surface-strong);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(76, 52, 24, 0.18);
}

.boat-model-editor-toggle[aria-pressed='true'] {
  background: #d2b06d;
  border-color: rgba(176, 106, 31, 0.85);
}

.boat-model-editor-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.boat-model-editor-kicker {
  font-size: 13px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.7;
}

.boat-model-editor-title {
  min-width: 0;
  font-size: 19px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(330px, 0.9fr);
  gap: 10px;
  overflow: hidden;
}

.boat-model-editor-display,
.boat-model-editor-controls {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 8px;
}

.boat-model-editor-controls {
  align-content: start;
  overflow-y: auto;
  padding-right: 2px;
}

.boat-model-editor-preview-bar,
.boat-model-editor-section-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  opacity: 0.78;
}

.boat-model-editor-section-heading span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-count {
  min-width: 28px;
  padding: 3px 6px;
  border: 1px solid rgba(103, 76, 39, 0.28);
  border-radius: 6px;
  background: rgba(255, 251, 235, 0.44);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.boat-model-editor-preview {
  position: relative;
  height: 322px;
  min-height: 322px;
  overflow: hidden;
  border: 1px solid rgba(103, 76, 39, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(117, 162, 172, 0.28), rgba(239, 210, 146, 0.14)),
    rgba(88, 74, 48, 0.12);
  cursor: grab;
  touch-action: none;
}

.boat-model-editor-preview.is-dragging {
  cursor: grabbing;
}

.boat-model-editor-preview canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.boat-model-editor-component-panel {
  min-height: 0;
  display: grid;
  gap: 7px;
}

.boat-model-editor-components {
  min-height: 164px;
  max-height: 230px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 5px;
  padding-right: 2px;
}

.boat-model-editor-component {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 6px;
  align-items: stretch;
}

.boat-model-editor-component-select,
.boat-model-editor-component-delete {
  min-width: 0;
  border: 1px solid var(--parchment-border);
  border-radius: 7px;
  background: var(--parchment-surface-muted);
  cursor: pointer;
}

.boat-model-editor-component-select {
  display: grid;
  gap: 4px;
  justify-items: start;
  align-content: center;
  padding: 6px 8px;
  text-align: left;
}

.boat-model-editor-component-name,
.boat-model-editor-component-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-component-name {
  font-size: 12px;
  line-height: 1;
  color: var(--parchment-ink);
}

.boat-model-editor-component-meta {
  font-size: 10px;
  line-height: 1;
  opacity: 0.62;
}

.boat-model-editor-component-delete {
  padding: 0 7px;
  font-size: 11px;
  line-height: 1;
}

.boat-model-editor-component.is-selected .boat-model-editor-component-select {
  border-color: rgba(176, 106, 31, 0.88);
  background: rgba(210, 176, 109, 0.3);
}

.boat-model-editor-component.is-deleted {
  opacity: 0.58;
}

.boat-model-editor-component.is-deleted .boat-model-editor-component-name {
  text-decoration: line-through;
}

.boat-model-editor-empty {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px dashed rgba(103, 76, 39, 0.34);
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.7;
}

.boat-model-editor-component-inspector {
  min-height: 0;
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.boat-model-editor-component-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.boat-model-editor-colors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.boat-model-editor-color {
  min-width: 0;
  height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  padding: 0 7px 0 9px;
  border: 1px solid var(--parchment-border);
  border-radius: 7px;
  background: var(--parchment-surface-muted);
}

.boat-model-editor-color span {
  min-width: 0;
  font-size: 12px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-color input {
  width: 44px;
  height: 26px;
  padding: 1px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.boat-model-editor-sliders {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.boat-model-editor-sliders.component {
  max-height: 244px;
}

.boat-model-editor-slider {
  min-width: 0;
  height: 28px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  line-height: 1;
}

.boat-model-editor-slider span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-slider input {
  min-width: 0;
  width: 100%;
}

.boat-model-editor-slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.76;
}

.boat-model-editor-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.boat-model-editor-action {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--parchment-border);
  border-radius: 7px;
  background: var(--parchment-surface-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boat-model-editor-action.compact {
  width: 76px;
  height: 28px;
}

.boat-model-editor-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.boat-model-editor-status {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.72;
}

@media (max-width: 980px) {
  .boat-model-editor-panel.is-active {
    right: 10px;
    bottom: 10px;
    width: min(640px, calc(100% - 20px));
    max-height: calc(100% - 20px);
  }

  .boat-model-editor-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .boat-model-editor-preview {
    height: 260px;
    min-height: 260px;
  }

  .boat-model-editor-components {
    max-height: 180px;
  }

  .boat-model-editor-sliders {
    max-height: 220px;
  }
}

@media (max-width: 620px) {
  .boat-model-editor-panel.is-active {
    width: min(390px, calc(100% - 20px));
  }

  .boat-model-editor-preview {
    height: 220px;
    min-height: 220px;
  }

  .boat-model-editor-components {
    max-height: 156px;
  }

  .boat-model-editor-component {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .boat-model-editor-slider {
    grid-template-columns: 76px minmax(0, 1fr) 42px;
  }
}

.foreign-header,
.foreign-progress-labels,
#economy-hud {
  min-width: 0;
}

.labor-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  align-items: start;
}

.labor-header {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.labor-section-wide {
  grid-column: 1 / -1;
}

.labor-production-columns {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.labor-production-columns.single {
  grid-template-columns: 1fr;
}

.labor-stat,
.labor-section,
.labor-row,
.labor-recipe-btn {
  border: 1px solid rgba(92, 61, 30, 0.28);
  background: var(--parchment-surface-muted);
  border-radius: 8px;
}

.labor-stat {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 10px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.labor-stat-label,
.labor-empty,
.labor-warning {
  color: var(--parchment-ink-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.labor-stat strong {
  color: var(--parchment-ink);
  font-size: 0.92rem;
  white-space: nowrap;
}

.labor-warning {
  color: #a34121;
  grid-column: 1 / -1;
  font-size: 0.75rem;
}

.labor-stat.population-risk {
  border-color: rgba(163, 65, 33, 0.46);
  background: rgba(163, 65, 33, 0.08);
}

.population-loss-warning {
  border: 1px solid rgba(163, 65, 33, 0.32);
  background: rgba(163, 65, 33, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  white-space: normal;
}

.labor-section {
  padding: 8px;
}

.labor-section-title {
  margin-bottom: 6px;
  color: var(--parchment-ink-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.labor-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.labor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
}

.labor-row-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.labor-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 0.95rem;
}

.labor-row-title {
  color: var(--parchment-ink);
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.labor-row-metrics {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 132px;
  white-space: nowrap;
}

.labor-stock {
  color: var(--parchment-ink-muted) !important;
  font-size: 0.78rem;
}

.labor-rate {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 52px;
  text-align: right;
}

.labor-rate[title] {
  cursor: help;
}

.labor-rate.rate-zero {
  color: var(--parchment-ink-muted);
  font-weight: 400;
}

.labor-job-progress {
  font-size: 0.78rem;
  color: var(--parchment-ink-muted);
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
}

.labor-stepper {
  display: inline-grid;
  grid-template-columns: 22px 28px 22px;
  align-items: center;
  justify-items: center;
}

.labor-step,
.labor-cancel-btn,
.labor-recipe-btn {
  color: var(--parchment-ink);
  cursor: pointer;
}

.labor-step {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(92, 61, 30, 0.35);
  border-radius: 5px;
  background: var(--parchment-surface-strong);
  font-weight: 800;
  font-size: 0.85rem;
}

.labor-count {
  color: var(--parchment-ink);
  font-weight: 700;
  font-size: 0.85rem;
}

.labor-step:disabled,
.labor-cancel-btn:disabled,
.labor-recipe-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.labor-recipes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.labor-build-actions {
  align-items: stretch;
  flex-direction: column;
  flex-wrap: nowrap;
}

.labor-recipe-btn,
.labor-cancel-btn {
  min-height: 26px;
  border: 1px solid rgba(92, 61, 30, 0.32);
  background: var(--parchment-surface-strong);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 0.82rem;
}

.labor-cancel-btn {
  width: 22px;
  min-height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0.7;
}

.labor-cancel-btn:not(:disabled):hover {
  opacity: 1;
  color: #f97316;
}

.labor-recipe-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.labor-build-btn {
  width: 100%;
  justify-content: space-between;
  min-width: 0;
  text-align: left;
}

.labor-build-btn span:nth-child(2) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.labor-build-cost {
  color: var(--parchment-ink-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.labor-build-empty {
  margin-bottom: 6px;
  padding: 6px;
  color: var(--parchment-ink-muted);
  font-size: 0.78rem;
  border: 1px dashed rgba(92, 61, 30, 0.24);
  background: var(--parchment-surface-muted);
}

.labor-empty {
  padding: 6px;
  font-size: 0.78rem;
}

.labor-board-compact {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 5px;
  padding: 4px;
  font-size: 0.82rem;
}

.labor-board-compact .labor-header {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.labor-board-compact .labor-stat {
  min-height: 24px;
  padding: 3px 6px;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.labor-board-compact .labor-stat-label {
  font-size: 0.92rem;
  line-height: 1;
}

.labor-board-compact .labor-stat strong {
  font-size: 0.82rem;
  line-height: 1;
}

.labor-board-compact .labor-warning {
  padding: 4px 6px;
  font-size: 0.72rem;
}

.labor-board-compact .labor-section {
  padding: 5px;
  border-radius: 6px;
}

.labor-board-compact .labor-section-title {
  margin-bottom: 3px;
  font-size: 0.95rem;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}

.labor-board-compact .labor-list {
  gap: 2px;
}

.labor-board-compact .labor-row {
  grid-template-columns: 28px minmax(92px, auto) auto;
  min-height: 27px;
  gap: 5px;
  padding: 3px 5px;
  border-radius: 5px;
}

.labor-board-compact .labor-job-row {
  grid-template-columns: 28px 38px auto 22px;
}

.labor-board-compact .labor-row-main {
  justify-content: center;
  gap: 0;
}

.labor-board-compact .labor-icon {
  width: 22px;
  height: 22px;
  font-size: 1rem;
}

.labor-board-compact .labor-row-title {
  display: none;
}

.labor-board-compact .labor-row-metrics {
  min-width: 92px;
  gap: 5px;
}

.labor-board-compact .labor-stock {
  min-width: 26px;
  text-align: right;
}

.labor-board-compact .labor-rate {
  min-width: 44px;
  font-size: 0.74rem;
}

.labor-board-compact .labor-job-progress {
  min-width: 34px;
  font-size: 0.74rem;
}

.labor-board-compact .labor-stepper {
  grid-template-columns: 20px 24px 20px;
}

.labor-board-compact .labor-step {
  width: 20px;
  height: 20px;
  font-size: 0.78rem;
}

.labor-board-compact .labor-count {
  font-size: 0.78rem;
}

.labor-board-compact .labor-recipes {
  gap: 2px;
  margin-bottom: 3px;
}

.labor-board-compact .labor-recipe-btn,
.labor-board-compact .labor-cancel-btn {
  min-height: 24px;
  padding: 2px 6px;
  border-radius: 5px;
}

.labor-board-compact .labor-build-actions {
  gap: 2px;
}

.labor-board-compact .labor-build-btn {
  min-height: 24px;
}

.labor-board-compact .labor-recipe-btn span:nth-child(2):not(.labor-build-cost),
.labor-board-compact .labor-build-empty,
.labor-board-compact .labor-empty {
  display: none;
}

.labor-board-compact .labor-build-cost {
  margin-left: auto;
  font-size: 0.72rem;
}

@media (max-width: 760px) {
  .labor-board {
    grid-template-columns: 1fr;
  }

  .labor-section-wide {
    grid-column: 1;
  }

  .labor-production-columns {
    grid-column: 1;
    grid-template-columns: 1fr;
  }

  .labor-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .labor-board-compact {
    grid-template-columns: 1fr;
  }

  .labor-board-compact .labor-header {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .labor-board-compact .labor-row {
    grid-template-columns: 28px minmax(92px, auto) auto;
  }
}

.resource-icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: -0.1em;
  flex: 0 0 auto;
}

.resource-label-text {
  display: inline-block;
}

.resource-select {
  background-repeat: no-repeat;
  background-position: 8px center;
  background-size: 1.1em;
  padding-left: 32px;
}

.ui-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12, 18, 35, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 24px 28px;
  width: min(420px, 90vw);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  color: #f5f8ff;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.ui-panel.hidden {
  display: none;
}

/* ── City Info Panel ── */

.city-info {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  /* fit between the left/right trade panels with a comfortable gap */
  width: min(900px, calc(100% - 2 * var(--trade-panel-gutter) - 16px));
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--city-surface-bg);
  border: 1px solid var(--city-surface-border);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--city-surface-shadow);
  backdrop-filter: blur(8px);
  z-index: 25;
  pointer-events: auto;
  color: var(--city-text-color);
  font-size: 1.05rem;
  line-height: 1.4;
}

.city-info.hidden {
  display: none;
}

/* Sticky header: name + allegiance + alerts + close */
.city-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--city-surface-border);
  flex-shrink: 0;
  background: var(--parchment-header);
  border-radius: 14px 14px 0 0;
  min-width: 0;
}

.city-panel-identity {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.city-panel-name {
  font-size: 1.05rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.city-panel-allegiance-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(176, 106, 31, 0.18);
  border: 1px solid rgba(176, 106, 31, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
}

.city-panel-alerts {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  overflow: hidden;
}

.city-panel-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.city-panel-alert-chip.alert-danger {
  background: rgba(163, 65, 33, 0.15);
  border: 1px solid rgba(163, 65, 33, 0.45);
  color: #a34121 !important;
}

.city-panel-alert-chip.alert-warn {
  background: rgba(161, 117, 18, 0.15);
  border: 1px solid rgba(161, 117, 18, 0.45);
  color: #795c0a !important;
}

.city-panel-close-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background 0.12s ease;
  color: var(--parchment-ink-muted) !important;
}

.city-panel-close-btn:hover {
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink) !important;
}

/* Scrollable body */
.city-info-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Content inside shell */
.city-info-content {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  font-size: 0.96rem;
  line-height: 1.4;
  color: var(--city-text-color);
}

/* No-op: compact-labor class kept for JS compatibility, sizing controlled by panel */
.city-info-content--compact-labor {
  font-size: 0.94rem;
  line-height: 1.2;
}

/* Give the labor board a bit more room in the compact panel */
.city-info .labor-board-compact {
  padding: 6px;
}

.city-info-arrow {
  display: none;
}

/* Banner: slim map-anchor label above the panel (city name + message only) */
.city-banner {
  position: fixed;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

.city-banner-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--city-surface-bg);
  border: 1px solid var(--city-surface-border);
  box-shadow: var(--city-surface-shadow);
  pointer-events: auto;
  color: var(--city-text-color);
}

.city-banner.hidden {
  display: none;
}

.city-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Slim banner name (city identity in panel header is the primary display) */
#city-info-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-block;
  max-width: min(320px, 36vw);
}

.city-info-message {
  display: none;
  font-size: 0.95rem;
  color: #7a2c1c;
  line-height: 1.25;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.city-info-message.visible {
  display: block;
  opacity: 1;
}

.city-info-allegiance {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(176, 106, 31, 0.18);
  color: #6a3812;
  border: 1px solid rgba(176, 106, 31, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
}

.city-foreign .muted {
  opacity: 0.7;
}

.city-foreign {
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.1), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.city-foreign.hidden {
  display: none;
}

.foreign-label {
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
  margin: 0;
}

.foreign-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.foreign-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.foreign-primary {
  min-width: 160px;
}

.foreign-amount {
  font-size: 2rem;
  font-weight: 800;
  color: #f8fafc;
}

.foreign-rate {
  font-size: 1.05rem;
  opacity: 0.85;
}

.rate-positive {
  color: var(--emphasis-green) !important;
}

.rate-negative {
  color: var(--emphasis-red) !important;
}

.foreign-tier-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}

.tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.foreign-role-chip-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foreign-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  width: fit-content;
}

.foreign-role-chip.rival {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(234, 179, 8, 0.18));
  border-color: rgba(239, 68, 68, 0.35);
  color: #ffe4e6;
}

.foreign-production {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.foreign-production-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}

.foreign-production-pill.empty {
  opacity: 0.7;
  font-style: italic;
}

.foreign-trade-status {
  min-width: 180px;
}

.foreign-line {
  margin: 2px 0;
  font-size: 1.05rem;
  opacity: 0.9;
}

.foreign-subtitle {
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.75;
  margin: 4px 0 0;
}

.foreign-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foreign-progress-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.foreign-progress-bar {
  flex: 1;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.foreign-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
  transition: width 0.25s ease;
}

.foreign-progress-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  opacity: 0.8;
}

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

.foreign-actions.foreign-buy-sell {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.foreign-actions.foreign-buy-sell .foreign-buy {
  flex: 1 1 240px;
  min-width: 240px;
}

.foreign-buy {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foreign-buy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.foreign-input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 7px 10px;
  color: #f8fafc;
  width: 110px;
}

.foreign-input[type='number'] {
  -moz-appearance: textfield;
}

.foreign-input::-webkit-outer-spin-button,
.foreign-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.foreign-help {
  font-size: 0.85rem;
  opacity: 0.75;
  margin: 0;
}

.foreign-button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.foreign-button.primary {
  background: linear-gradient(135deg, #2563eb, #22c55e);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}

.foreign-button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.foreign-button.tertiary {
  background: rgba(255, 255, 255, 0.05);
  color: #e5e7eb;
  border: 1px dashed rgba(255, 255, 255, 0.2);
}
.foreign-button.danger {
  background: linear-gradient(135deg, #991b1b, #ef4444);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.25);
}

.foreign-annex-button {
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  white-space: nowrap;
}

.locked-message {
  color: #fbbf24;
  font-weight: 700;
}

.foreign-button:hover {
  transform: translateY(-1px);
}

.foreign-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.foreign-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.foreign-action-row .foreign-button {
  flex: 1 1 180px;
  min-width: 160px;
  padding: 8px 10px;
}

.foreign-button.locked {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border: 1px dashed rgba(255, 255, 255, 0.2);
}

.banquet-tab h3 {
  margin: 8px 0 6px;
}

.banquet-meal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.banquet-meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.banquet-meal-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.banquet-meal-detail {
  font-size: 0.85rem;
  opacity: 0.8;
  text-align: right;
}

.banquet-tag {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(253, 224, 71, 0.15);
  border: 1px solid rgba(253, 224, 71, 0.4);
  color: #fcd34d;
  font-size: 0.75rem;
  font-weight: 700;
}

.resource-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 14px;
}

.resource-meta {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
}

.resource-meta .emoji {
  font-size: 1.1rem;
  text-align: center;
}

.resource-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.resource-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: normal;
}

.resource-source {
  font-size: 0.75rem;
  opacity: 0.7;
  white-space: pre-line;
  display: block;
  margin-top: 1px;
}

.resource-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: right;
}

.resource-details .expand-button,
.resource-details .inventory-toggle,
.resource-details .trade-cancel-button {
  align-self: flex-end;
}

.resource-stored {
  font-size: 0.82rem;
  opacity: 0.7;
  white-space: nowrap;
  text-align: right;
}

.ship-health-hud {
  position: absolute;
  top: max(18px, calc(env(safe-area-inset-top) + 18px));
  left: 50%;
  width: min(760px, calc(var(--ui-base-width) * 1px - 720px));
  min-width: 420px;
  padding: 12px 16px 14px;
  color: #f8fafc;
  background:
    linear-gradient(180deg, rgba(19, 32, 46, 0.94), rgba(7, 14, 24, 0.92)),
    rgba(7, 14, 24, 0.92);
  border: 2px solid rgba(248, 250, 252, 0.28);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 285;
}

.ship-health-meter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.ship-condition-meter {
  min-width: 0;
}

.ship-health-hud-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.ship-health-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ship-health-value {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
  font-weight: 800;
  color: rgba(248, 250, 252, 0.92);
  font-variant-numeric: tabular-nums;
}

.ship-health-track,
.ship-morale-track {
  position: relative;
  height: 24px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.86);
  border: 1px solid rgba(248, 250, 252, 0.22);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.ship-health-fill,
.ship-morale-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.ship-health-fill {
  background: linear-gradient(90deg, #16a34a, #84cc16);
}

.ship-morale-fill {
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.ship-health-hud.low .ship-health-fill {
  background: linear-gradient(90deg, #f59e0b, #facc15);
}

.ship-health-hud.critical .ship-health-fill {
  background: linear-gradient(90deg, #dc2626, #f97316);
}

.ship-health-hud.morale-low .ship-morale-fill {
  background: linear-gradient(90deg, #f59e0b, #fde047);
}

.ship-health-hud.morale-critical .ship-morale-fill,
.ship-health-hud.mutiny .ship-morale-fill {
  background: linear-gradient(90deg, #b91c1c, #fb7185);
}

.ship-health-hud.mutiny {
  border-color: rgba(248, 113, 113, 0.55);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.32),
    0 0 24px rgba(220, 38, 38, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.ship-health-hud.morale-warning {
  border-color: rgba(248, 113, 113, 0.7);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.34),
    0 0 28px rgba(220, 38, 38, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.crew-morale-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  margin-top: 14px;
  padding: 12px 18px;
  border: 2px solid rgba(254, 202, 202, 0.72);
  background:
    linear-gradient(180deg, rgba(153, 27, 27, 0.96), rgba(69, 10, 10, 0.95)),
    rgba(69, 10, 10, 0.95);
  box-shadow:
    0 14px 28px rgba(127, 29, 29, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: #fff7ed;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .ship-health-hud {
    width: min(92vw, 520px);
    min-width: 0;
  }

  .ship-health-meter-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .crew-morale-warning {
    min-height: 48px;
    padding: 10px 12px;
    font-size: 1.05rem;
  }
}

#economy-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  transform: scale(1.65);
  transform-origin: top right;
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--parchment-surface-strong);
  border: 1px solid var(--parchment-border);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--parchment-ink);
  pointer-events: auto;
  box-shadow: var(--parchment-shadow);
}

#economy-hud span {
  pointer-events: none;
}

body.app-playing.boat-mode #economy-hud {
  display: inline-flex !important;
  top: max(16px, calc(env(safe-area-inset-top) + 16px));
  right: max(16px, calc(env(safe-area-inset-right) + 16px));
  left: auto;
  gap: 0;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  transform: none;
  transform-origin: top right;
  border-radius: 8px;
  opacity: 1;
  pointer-events: none;
  z-index: 260;
}

body.app-playing.boat-mode #fleet-display {
  display: none;
}

#fleet-display {
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--parchment-ink-muted);
}

#economy-hud .rate-positive {
  color: #4ade80;
}

#economy-hud .rate-negative {
  color: #f87171;
}

#economy-hud .rate-neutral {
  color: var(--parchment-ink-muted);
}

.trade-ui-stack {
  position: absolute;
  top: 96px;
  right: 16px;
  width: min(430px, calc(var(--ui-base-width) * 1px - 32px));
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 270;
}

.company-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  pointer-events: auto;
}

.diplomacy-panel {
  flex: 0 0 auto;
  display: flex;
  pointer-events: auto;
}

.company-panel-toggle {
  width: 100%;
  max-width: 330px;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  box-shadow: var(--parchment-shadow);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.diplomacy-panel-toggle {
  width: 64px;
  min-height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  box-shadow: var(--parchment-shadow);
  cursor: pointer;
  font-family: inherit;
  font-size: 30px;
  line-height: 1;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.company-panel-toggle:hover,
.company-panel-toggle.active,
.diplomacy-panel-toggle:hover,
.diplomacy-panel-toggle.active {
  border-color: rgba(176, 106, 31, 0.78);
}

.company-panel-toggle:hover,
.diplomacy-panel-toggle:hover {
  transform: translateY(-1px);
}

.company-panel-icon {
  flex: 0 0 auto;
  font-size: 28px;
  line-height: 1;
}

.company-panel-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.company-panel-name {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.12;
}

.company-panel-summary {
  font-size: 0.72rem;
  color: var(--parchment-ink-muted);
  line-height: 1.18;
}

.company-panel-menu,
.diplomacy-panel-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(430px, 100%);
  max-height: min(680px, calc(var(--ui-base-height) * 1px - 132px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  border: 2px solid var(--parchment-border-strong);
  border-radius: 8px;
  background: var(--parchment-surface);
  color: var(--parchment-ink);
  box-shadow: var(--parchment-shadow);
}

.company-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--parchment-border);
}

.company-panel-kicker,
.company-panel-section-title,
.company-panel-stat span,
.company-ship-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parchment-ink-muted);
}

.company-panel-title {
  max-width: 290px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.16;
}

.company-panel-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--parchment-border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.24);
  color: var(--parchment-ink);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.company-panel-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.company-panel-stat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
}

.company-panel-stat strong {
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.15;
}

.company-panel-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.company-panel-section-title {
  font-weight: 800;
}

.company-panel-city-list {
  min-height: 0;
  max-height: 245px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: auto;
  padding-right: 2px;
}

.company-city-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: var(--parchment-surface-muted);
}

.company-city-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.company-city-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.company-city-name {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.15;
}

.company-city-meta {
  font-size: 0.75rem;
  color: var(--parchment-ink-muted);
  line-height: 1.15;
}

.company-panel-empty,
.company-panel-ship {
  padding: 10px;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--parchment-ink-muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.company-panel-empty.hidden {
  display: none;
}

.company-panel-ship {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.company-ship-title {
  color: var(--parchment-ink);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.15;
}

.company-ship-line {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.company-ship-label {
  letter-spacing: 0.05em;
}

.company-ship-value {
  min-width: 0;
  color: var(--parchment-ink);
  font-size: 0.8rem;
  text-align: right;
}

.diplomacy-company-list {
  min-height: 0;
  max-height: 418px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.diplomacy-company-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  background: var(--parchment-surface-muted);
}

.diplomacy-company-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.diplomacy-company-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 38px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.diplomacy-company-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diplomacy-company-name {
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.15;
}

.diplomacy-company-meta {
  font-size: 0.75rem;
  color: var(--parchment-ink-muted);
  line-height: 1.15;
}

.diplomacy-city-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.diplomacy-city-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(108, 76, 38, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
}

.diplomacy-city-name {
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.diplomacy-city-meta {
  min-width: 0;
  color: var(--parchment-ink-muted);
  font-size: 0.7rem;
  text-align: right;
}

body.app-playing.boat-mode #trade-ui-stack {
  top: max(76px, calc(env(safe-area-inset-top) + 76px));
  right: max(16px, calc(env(safe-area-inset-right) + 16px));
  width: min(360px, calc(var(--ui-base-width) * 1px - 32px));
  z-index: 261;
}

body.app-playing.boat-mode .company-panel-toggle,
body.app-playing.boat-mode .diplomacy-panel-toggle {
  min-height: 54px;
  border-radius: 8px;
  padding: 8px 12px;
}

body.app-playing.boat-mode .diplomacy-panel-toggle {
  width: 54px;
  padding: 8px;
  font-size: 26px;
}

body.app-playing.boat-mode .company-panel-menu,
body.app-playing.boat-mode .diplomacy-panel-menu {
  width: min(360px, 100%);
  max-height: min(560px, calc(var(--ui-base-height) * 1px - 140px));
}

.notification-panel {
  position: static;
  flex: 1 1 auto;
  width: auto;
  max-width: 450px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  z-index: 210;
}

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

.gold-console {
  width: 100%;
}

.reward-log {
  align-items: stretch;
}

.notification-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--parchment-surface-strong);
  border: 2px solid var(--parchment-border-strong);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--parchment-ink);
  box-shadow: var(--parchment-shadow);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  text-align: left;
}

.gold-console-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--parchment-surface-strong);
  border: 2px solid var(--parchment-border-strong);
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--parchment-ink);
  box-shadow: var(--parchment-shadow);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  text-align: left;
}

.gold-console-icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}

.gold-console-message {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gold-console-entry.positive {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.5);
}

.gold-console-entry.negative {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}

.gold-console-entry.danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.65);
}

.gold-console-entry.xp {
  color: #7dd3fc;
  border-color: rgba(125, 211, 252, 0.5);
}

.gold-console-entry.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}

.permanent-entry {
  cursor: pointer;
  border-left: 6px solid #b06a1f;
  background: var(--parchment-surface-strong);
}

.permanent-entry.warn {
  border-left-color: #fbbf24;
}

.permanent-entry.danger {
  border-left-color: #7a2c1c;
  background: linear-gradient(135deg, rgba(244, 214, 188, 0.8), rgba(215, 170, 130, 0.85));
}

.notification-icon {
  flex: 0 0 auto;
  font-size: 1.2rem;
  line-height: 1.1;
  opacity: 0.98;
}

.notification-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.notification-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.notification-detail {
  font-size: 0.95rem;
  opacity: 0.85;
}

.vehicle-status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 28px));
  pointer-events: auto;
  z-index: 220;
}

body.app-playing.boat-mode #vehicle-status-bar {
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 262;
}

body.app-playing.boat-mode .vehicle-status-shell {
  border-radius: 8px;
}

.vehicle-status.hidden {
  display: none;
}

.vehicle-status-shell {
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--parchment-surface-strong);
  border: 1px solid var(--parchment-border);
  color: var(--parchment-ink);
  font-family: inherit;
  box-shadow: var(--parchment-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vehicle-status-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vehicle-status-header.hidden {
  display: none;
}

.vehicle-status-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 1.2rem;
}

.vehicle-status-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.vehicle-status-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.vehicle-status-assignment {
  font-size: 0.82rem;
  color: var(--parchment-ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-status-tier {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(30, 64, 175, 0.1);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #93c5fd;
}

.vehicle-status-tier.hidden {
  display: none;
}

.vehicle-status-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}

.vehicle-status-details.hidden {
  display: none;
}

.vehicle-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
}

.vehicle-status-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  color: var(--parchment-ink-muted);
}

.vehicle-status-value {
  font-weight: 600;
  color: var(--parchment-ink);
  text-align: right;
  min-width: 0;
}

.vehicle-status-cargo-icon {
  margin-left: 6px;
  font-size: 1rem;
}

.vehicle-status-cargo-icon.hidden {
  display: none;
}

.vehicle-status-debug {
  border-top: 1px solid rgba(30, 41, 59, 0.18);
  padding-top: 10px;
}

.vehicle-status-debug.hidden {
  display: none;
}

.vehicle-status-debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--parchment-ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.vehicle-status-debug-refresh {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.08);
  color: var(--parchment-ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.vehicle-status-debug-refresh:hover {
  background: rgba(15, 23, 42, 0.14);
}

.vehicle-status-debug-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 16px;
  font-size: 0.78rem;
}

.vehicle-status-debug-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.vehicle-status-debug-row.is-wide {
  grid-column: 1 / -1;
}

.vehicle-status-debug-key {
  flex: 0 0 auto;
  color: var(--parchment-ink-muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.vehicle-status-debug-value {
  min-width: 0;
  color: var(--parchment-ink);
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
}

.vehicle-status-debug-row.is-wide .vehicle-status-debug-value {
  text-align: left;
}

.vehicle-status-debug-pre {
  grid-column: 1 / -1;
  margin: 0;
  max-height: 120px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid rgba(30, 41, 59, 0.16);
  background: rgba(15, 23, 42, 0.08);
  color: var(--parchment-ink);
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.vehicle-status-fleet {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.12);
  border: 1px solid rgba(94, 234, 212, 0.3);
}

.vehicle-status-fleet.hidden {
  display: none;
}

.vehicle-status-fleet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vehicle-status-fleet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.12);
  min-width: 140px;
}

.vehicle-status-fleet-icon {
  font-size: 1.05rem;
}

.vehicle-status-fleet-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.vehicle-status-fleet-name {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-status-fleet-assignment {
  font-size: 0.7rem;
  color: var(--parchment-ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.vehicle-status-actions.hidden {
  display: none;
}

.vehicle-action-btn {
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #dbeafe;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.vehicle-action-btn:hover {
  background: rgba(96, 165, 250, 0.22);
  border-color: rgba(96, 165, 250, 0.65);
}

.vehicle-action-btn:active {
  background: rgba(37, 99, 235, 0.3);
}

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

.vehicle-auto-status {
  margin-top: 6px;
  color: #bbf7d0;
  font-weight: 600;
}

@media (max-width: 720px) {
  .vehicle-status-shell {
    padding: 10px 12px;
  }

  .vehicle-status-details {
    grid-template-columns: 1fr;
  }

  .vehicle-status-debug-body {
    grid-template-columns: 1fr;
  }

  .vehicle-status-actions {
    justify-content: flex-start;
  }
}

.inventory-toggle {
  display: inline-flex;
  gap: 6px;
}

.resource-group {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin: 4px 0 0;
  padding: 0 2px;
}

.inventory-toggle button {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #f5f8ff;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.expand-button {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1.5px solid rgba(74, 222, 128, 0.7);
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
  line-height: 1;
  min-width: 24px;
  text-align: center;
}

.expand-button:hover:not(.disabled) {
  background: rgba(74, 222, 128, 0.25);
  border-color: rgba(74, 222, 128, 0.9);
}

.expand-button.disabled {
  pointer-events: none;
  opacity: 0.3;
  border-color: rgba(139, 139, 139, 0.3);
  color: rgba(139, 139, 139, 0.5);
  background: rgba(139, 139, 139, 0.08);
}

.inventory-toggle button.active {
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  border-color: transparent;
}

.inventory-toggle button:not(.active):hover {
  background: var(--parchment-surface-muted);
}

.trade-button {
  margin-top: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  color: var(--parchment-ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.trade-button:hover {
  background: var(--parchment-surface-strong);
  border-color: var(--parchment-border-strong);
}

.trade-button:active {
  background: var(--parchment-surface-strong);
}

.trade-panel {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trade-section.hidden {
  display: none;
}

.trade-section.pulse {
  animation: trade-section-pulse 0.75s ease;
}

@keyframes trade-section-pulse {
  0% {
    box-shadow: 0 0 0 rgba(139, 229, 197, 0);
  }
  50% {
    box-shadow: 0 0 12px rgba(139, 229, 197, 0.35);
  }
  100% {
    box-shadow: 0 0 0 rgba(139, 229, 197, 0);
  }
}

.trade-range {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
}

.trade-empty {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.75;
}

.trade-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-panel {
  margin-top: 12px;
}

.trade-city-row {
  background: var(--parchment-surface-muted);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--parchment-border);
}

.trade-city-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.trade-city-entry .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.trade-city-entry .info .name {
  font-size: 0.9rem;
  font-weight: 600;
}

.trade-city-entry .info .meta {
  font-size: 0.75rem;
  opacity: 0.65;
}

.trade-city-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--parchment-ink);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.trade-city-button .trade-city-name {
  flex: 1 1 auto;
  min-width: 0;
}

.trade-city-button .trade-city-goods {
  flex: 0 0 auto;
  font-size: 1.1rem;
  opacity: 0.85;
}

.trade-city-button .trade-city-distance {
  font-size: 0.75rem;
  opacity: 0.55;
}

.trade-city-button.selected {
  color: var(--accent);
}

.trade-resource-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trade-resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--parchment-surface-muted);
  border-radius: 6px;
  padding: 6px 10px;
}

.trade-resource-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.trade-resource-meta .emoji {
  font-size: 1.1rem;
}

.trade-resource-meta .name {
  font-size: 0.85rem;
  font-weight: 600;
}

.trade-resource-meta .price {
  font-size: 0.78rem;
  opacity: 0.7;
}

.trade-buy-button {
  flex: 0 0 auto;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(176, 106, 31, 0.45);
  background: rgba(176, 106, 31, 0.18);
  color: #7a4a1b;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.trade-buy-button:hover:not(.active):not(:disabled) {
  background: rgba(176, 106, 31, 0.28);
  border-color: rgba(176, 106, 31, 0.7);
}

.trade-cancel-button {
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid rgba(122, 44, 28, 0.45);
  background: rgba(122, 44, 28, 0.15);
  color: #7a2c1c;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.trade-cancel-button:hover:not(:disabled) {
  background: rgba(122, 44, 28, 0.25);
  border-color: rgba(122, 44, 28, 0.6);
  color: #7a2c1c;
}

.trade-cancel-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.trade-buy-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.trade-buy-button.active {
  border-color: transparent;
  background: rgba(122, 44, 28, 0.85);
  color: #fff7ed;
}

.trade-buy-button.active:hover:not(:disabled) {
  background: rgba(122, 44, 28, 0.95);
}

.trade-export-button {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(176, 106, 31, 0.45);
  background: rgba(176, 106, 31, 0.18);
  color: #7a4a1b;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.trade-export-button:hover:not(:disabled) {
  background: rgba(176, 106, 31, 0.28);
  border-color: rgba(176, 106, 31, 0.7);
  color: #7a4a1b;
}

.trade-export-button:disabled {
  opacity: 0.55;
  cursor: default;
}
.inventory-toggle button.disabled {
  pointer-events: none;
  opacity: 0.35;
  border-color: rgba(255, 255, 255, 0.2);
}

#price-tooltip {
  position: absolute;
  max-width: 220px;
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--parchment-border);
  pointer-events: none;
  box-shadow: var(--parchment-shadow);
  transform: translate(-50%, 0);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.08s ease;
  white-space: pre-line;
  user-select: none;
}

#price-tooltip.is-html {
  white-space: normal;
}

#price-tooltip,
#price-tooltip * {
  pointer-events: none;
}

#price-tooltip .tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
}

#price-tooltip .tooltip-section {
  margin-top: 6px;
}

#price-tooltip .tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

#price-tooltip .tooltip-row .resource-icon {
  width: 1em;
  height: 1em;
}

#price-tooltip .labor-goods-tooltip-row {
  justify-content: space-between;
  min-width: 150px;
  gap: 8px;
}

#price-tooltip .labor-goods-tooltip-icon {
  flex: 0 0 auto;
}

#price-tooltip .labor-goods-tooltip-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#price-tooltip .labor-goods-tooltip-total {
  flex: 0 0 auto;
  color: #16a34a;
  font-weight: 800;
}

#price-tooltip.visible {
  opacity: 1;
}

.fleet-status {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #bfdbfe;
  white-space: nowrap;
}

.fleet-status.hidden {
  display: none;
}

.fleet-status.hidden {
  display: none;
}

.trade-route-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 0.75rem;
  color: #9ca3c1;
}

.harbor-section.hidden {
  display: none;
}

.harbor-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.harbor-controls.hidden {
  display: none;
}

.harbor-toggle-button {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #dbeafe;
  cursor: pointer;
  transition: background 0.15s ease;
}

.harbor-toggle-button:hover {
  background: rgba(59, 130, 246, 0.3);
}

.timber-button {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.55);
  color: #bbf7d0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.timber-button:disabled,
.refinery-button:disabled,
.harbor-toggle-button:disabled,
#city-buy-caravan-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.timber-button:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.3);
}

.refinery-button {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.15);
  border: 1px solid rgba(191, 219, 254, 0.5);
  color: #dbeafe;
  cursor: pointer;
  transition: background 0.15s ease;
}

.refinery-button:hover:not(:disabled) {
  background: rgba(125, 211, 252, 0.3);
}

#city-buy-caravan-button.secondary {
  background: rgba(226, 232, 240, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e2e8f0;
}

/* Harbor Panel */
.harbor-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 400px;
  pointer-events: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.harbor-panel.hidden {
  display: none;
}

.harbor-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.harbor-panel-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
}

.panel-close-button {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.panel-close-button:hover {
  color: #f1f5f9;
}

.harbor-panel-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.harbor-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.harbor-status p {
  color: #cbd5e1;
  font-size: 14px;
  margin: 0;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(51, 65, 85, 0.8);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.3s ease;
  width: 0%;
}

.harbor-ships-count {
  font-weight: 600;
  color: #f1f5f9;
}

.harbor-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.harbor-toggle-btn {
  padding: 12px 20px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 8px;
  color: #60a5fa;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.harbor-toggle-btn:hover {
  background: rgba(59, 130, 246, 0.3);
}

.harbor-toggle-btn.active {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.harbor-toggle-btn.active:hover {
  background: rgba(34, 197, 94, 0.3);
}

.harbor-info-text {
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  margin: 0;
}

/* Economic Flow Map - Docked Strip */
.economic-flow-map {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  padding: 0;
}

.flow-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

/* Flow Edges (Left and Right) */
.flow-edge {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--city-surface-border);
  background: var(--city-surface-bg);
  box-shadow: var(--city-surface-shadow);
  overflow: hidden;
  min-height: 0;
  backdrop-filter: blur(10px);
  color: var(--city-text-color);
}

.trade-panel-shell {
  position: fixed;
  top: 220px;
  width: var(--trade-panel-width);
  max-height: calc(100vh - 420px);
  z-index: 160;
  pointer-events: auto;
  overflow: hidden;
}

.trade-panel-shell.hidden {
  display: none;
}

.flow-edge-left {
  border-color: rgba(139, 229, 197, 0.32);
  left: 18px;
}

.flow-edge-right {
  border-color: rgba(96, 165, 250, 0.32);
  right: 18px;
}

#trade-export-panel {
  left: auto;
  right: 18px;
}

#trade-import-panel {
  left: 18px;
  right: auto;
}

/* Flow Sections */
.flow-section {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border-radius: 10px;
  padding: 8px 8px 10px;
  border: 1px solid var(--city-surface-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--city-text-color);
  font-size: 1rem;
}

.flow-connector-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.flow-connection {
  fill: none;
  stroke-width: 2;
  opacity: 0.9;
}

.flow-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.flow-section-header h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.68;
  margin: 0;
  font-weight: 800;
}

.flow-add-button {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1.5px solid rgba(139, 229, 197, 0.65);
  background: rgba(139, 229, 197, 0.16);
  color: #d9fff0;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.flow-add-button:hover {
  background: rgba(139, 229, 197, 0.26);
  border-color: rgba(139, 229, 197, 0.9);
  transform: translateY(-1px);
}

.flow-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
  min-height: 0;
  flex: 0 1 auto;
  color: var(--city-text-color);
}

.flow-items-list.has-items {
  max-height: calc((var(--flow-card-height) + 6px) * 3);
}

.flow-items-list::-webkit-scrollbar {
  width: 6px;
}

.flow-items-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.flow-items-list::-webkit-scrollbar-thumb {
  background: rgba(139, 229, 197, 0.3);
  border-radius: 3px;
}

.flow-items-list::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 229, 197, 0.5);
}

.flow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}

.flow-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(139, 229, 197, 0.25);
  transform: translateY(-1px);
}

.flow-item.waste-highlight {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
}

.flow-item.waste-highlight .flow-item-name,
.flow-item.waste-highlight .flow-item-stats,
.flow-item.waste-highlight .flow-item-emoji {
  color: #ff9f9f;
}

.flow-item-action {
  flex: 0 0 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-expand-btn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid rgba(139, 229, 197, 0.5);
  background: rgba(139, 229, 197, 0.12);
  color: #8be5c5;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.flow-expand-btn:hover:not(.disabled):not(:disabled) {
  transform: translateY(-1px);
  background: rgba(139, 229, 197, 0.2);
  border-color: rgba(139, 229, 197, 0.8);
}

.flow-expand-btn.disabled,
.flow-expand-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.flow-items-list.flow-drop-active {
  outline: 1px dashed rgba(74, 222, 128, 0.7);
  outline-offset: 4px;
}

.flow-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.flow-item-emoji {
  font-size: 1rem;
  flex: 0 0 auto;
  line-height: 1;
}

.flow-item-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(245, 248, 255, 0.9);
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-route-item {
  margin-left: 20px;
  font-size: 12px;
  color: var(--city-text-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  gap: 6px;
  flex-wrap: wrap;
  min-height: var(--flow-card-height);
}

.flow-route-item.route-paused {
  border-color: #f6a03b;
  background: rgba(246, 160, 59, 0.12);
  color: #f6d7a4;
}

.route-info {
  display: block;
  line-height: 1.3;
  white-space: normal;
}

.route-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.route-status-icon {
  color: #f6a03b;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.route-resume-btn,
.route-cancel-btn {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f8ff;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
}

.route-resume-btn {
  color: #f6a03b;
  background: rgba(246, 160, 59, 0.18);
}

.route-resume-btn:hover {
  background: rgba(246, 160, 59, 0.28);
}

.route-cancel-btn {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.14);
}

.route-cancel-btn:hover {
  background: rgba(255, 107, 107, 0.22);
}

.route-action-btn {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f8ff;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
}

.route-action-btn.disabled,
.route-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.route-escort-btn {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.22);
}

.export-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.export-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.export-option-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.export-option-meta {
  font-size: 0.8rem;
  opacity: 0.72;
}

.export-option-details {
  font-size: 0.82rem;
  opacity: 0.85;
  white-space: normal;
  line-height: 1.3;
}

.export-option-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.export-option-controls button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(139, 229, 197, 0.6);
  background: rgba(139, 229, 197, 0.15);
  color: #caffea;
  cursor: pointer;
}

.flow-item-stats {
  font-size: 0.78rem;
  color: rgba(245, 248, 255, 0.7);
  flex: 0 0 auto;
  white-space: nowrap;
}

.flow-empty {
  font-size: 0.75rem;
  opacity: 0.5;
  font-style: italic;
  padding: 8px 4px;
  text-align: center;
}

/* Center Processing Grid */
.flow-center {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.processing-grid-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  font-weight: 800;
  margin-bottom: 0;
}

.grid-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 0;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.processing-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flow-build-button {
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #bbf7d0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.flow-build-button:hover {
  background: rgba(74, 222, 128, 0.25);
  border-color: rgba(74, 222, 128, 0.45);
}

/* Facility Slots - Minimal & Sleek */
.facility-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
  position: relative;
  min-height: var(--inventory-slot-height);
  width: 100%;
  min-width: 0;
  height: 100%;
  flex: 1 1 auto;
}

.facility-slot:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.facility-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(248, 113, 113, 0.6);
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.facility-delete:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: rgba(248, 113, 113, 0.8);
}

.facility-delete:disabled {
  opacity: 0.5;
  cursor: default;
}

.facility-slot:not(.facility-active) .facility-delete {
  display: none;
}

.facility-active {
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.05);
}

.facility-active:hover {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.4);
}

.facility-inactive {
  opacity: 0.6;
  border-color: rgba(255, 255, 255, 0.08);
}

.facility-locked {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.2);
  opacity: 0.6;
  text-align: center;
}

.facility-emoji {
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.9;
}

.facility-name {
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  color: rgba(245, 248, 255, 0.75);
  letter-spacing: 0.02em;
}

.facility-status {
  display: none;
}

.facility-available {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.02);
}

.facility-available:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.06);
}

.facility-hint {
  display: none;
}

.facility-refinery {
  border-color: rgba(59, 130, 246, 0.65);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.18), rgba(11, 16, 36, 0.45));
}

.facility-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* Dynamic Grid for Active Buildings */
.grid-container.dynamic-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  grid-auto-rows: minmax(var(--inventory-slot-height), auto);
  gap: var(--inventory-slot-gap);
  padding: 6px 4px;
  align-content: start;
  justify-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
}

.inventory-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 2px 2px;
  flex: 0 0 auto;
  min-height: 0;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 10px;
  width: 100%;
}

.inventory-section-title {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 800;
}

.inventory-group-title {
  display: none;
}

.inventory-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.inventory-group {
  display: none;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.inventory-group.visible {
  display: flex;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: minmax(var(--inventory-slot-height), auto);
  grid-auto-flow: row dense;
  gap: var(--inventory-slot-gap);
  padding: 6px 4px;
  width: 100%;
  max-height: calc((var(--inventory-slot-height) + var(--inventory-slot-gap)) * 4 + 6px);
  overflow-y: auto;
  overflow-x: auto;
  align-content: start;
  justify-content: start;
  min-height: 0;
}

.inventory-grid .inventory-card {
  width: 100%;
  height: 100%;
  min-width: 0;
}

.inventory-empty {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.82rem;
  opacity: 0.6;
  padding: 10px 4px;
  font-style: italic;
  grid-column: 1 / -1;
}

.inventory-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 6px;
  padding: 6px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  min-width: 0;
  max-width: none;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.inventory-emoji {
  font-size: 1.05rem;
}

.inventory-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.inventory-label-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.inventory-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.inventory-expand-btn {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(139, 229, 197, 0.5);
  background: rgba(139, 229, 197, 0.14);
  color: #d7fff0;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1;
  font-size: 0.85rem;
}

.inventory-expand-btn:hover:not(:disabled) {
  background: rgba(139, 229, 197, 0.25);
  border-color: rgba(139, 229, 197, 0.8);
}

.inventory-expand-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.inventory-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: rgba(245, 248, 255, 0.9);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-amount {
  font-size: 0.92rem;
  font-weight: 750;
}

.inventory-type {
  display: none;
}

/* Strengthened type colors for readability */
.inventory-type.raw {
  background: rgba(74, 222, 128, 0.28);
  border-color: rgba(74, 222, 128, 0.8);
  color: #d9f99d;
}

.inventory-type.refined {
  background: rgba(59, 130, 246, 0.28);
  border-color: rgba(59, 130, 246, 0.8);
  color: #c7d2fe;
}

.inventory-type.strategic {
  background: rgba(248, 113, 113, 0.32);
  border-color: rgba(248, 113, 113, 0.85);
  color: #fecdd3;
}

.inventory-tags,
.inventory-refine {
  display: none !important;
}

.inventory-card:active {
  cursor: grabbing;
}

.inventory-card.raw {
  border-color: rgba(74, 222, 128, 0.65);
  background: linear-gradient(145deg, rgba(74, 222, 128, 0.18), rgba(10, 19, 24, 0.4));
}

.inventory-card.refined {
  border-color: rgba(59, 130, 246, 0.65);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.2), rgba(11, 16, 36, 0.45));
}

.inventory-card.strategic {
  border-color: rgba(248, 113, 113, 0.75);
  background: linear-gradient(145deg, rgba(248, 113, 113, 0.24), rgba(28, 12, 12, 0.4));
}

.grid-empty-message {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
  padding: 14px 12px;
  font-style: italic;
}

.build-menu {
  margin-top: 14px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(12, 18, 28, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  max-height: 320px;
  overflow: hidden;
}

.build-menu.hidden {
  display: none;
}

.build-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.build-menu-title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.build-menu-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.build-menu-hint {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.build-menu-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 190px; /* roughly two rows visible */
  overflow-y: auto;
  padding-right: 6px;
}

.build-menu-option {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    'meta cost action'
    'extras extras extras';
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.build-menu-option-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-area: meta;
}

.build-menu-option-emoji {
  font-size: 1rem;
}

.build-menu-option-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.build-menu-option-cost {
  font-size: 0.85rem;
  opacity: 0.72;
  text-align: right;
  grid-area: cost;
}

.build-menu-option-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  grid-area: action;
}

.build-menu-option-action button {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(139, 229, 197, 0.5);
  background: rgba(139, 229, 197, 0.16);
  color: #c9ffe7;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  min-width: 0;
  line-height: 1.2;
}

.build-menu-option-action button:hover:not(:disabled) {
  background: rgba(139, 229, 197, 0.26);
  border-color: rgba(139, 229, 197, 0.8);
}

.build-menu-option-action button:disabled {
  opacity: 0.4;
  cursor: default;
}

.build-menu-option-extras {
  grid-area: extras;
}

.build-menu-option-reason {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
}

.goods-tab {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
}

.goods-workbench {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.2fr);
  gap: 12px;
  margin-top: 12px;
  min-height: 0;
  align-items: flex-start;
}

.goods-recipe-column,
.goods-craft-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goods-slot-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.goods-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.goods-slot-header h4 {
  margin: 0;
  font-size: 1rem;
}

.goods-slot-list {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
}

.goods-slot-card {
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: 0 0 260px;
  max-width: 260px;
}

.goods-slot-card.locked {
  opacity: 0.75;
  background: var(--parchment-surface-strong);
  border-style: dashed;
}

.goods-slot-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding-right: 72px;
}

.goods-slot-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
}

.goods-slot-label {
  font-weight: 700;
}

.goods-slot-eta {
  font-size: 0.85rem;
  opacity: 0.8;
}

.goods-slot-status-row,
.goods-slot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.goods-slot-progress {
  position: relative;
  background: var(--parchment-surface-strong);
  border: 1px solid var(--parchment-border);
  border-radius: 8px;
  overflow: hidden;
  height: 10px;
  margin-top: 4px;
}

.goods-slot-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 8px;
  transition: width 0.2s linear;
  background: linear-gradient(90deg, rgba(27, 122, 51, 0.5), rgba(27, 122, 51, 0.25));
}

.goods-slot-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.goods-queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  font-weight: 700;
  flex-wrap: wrap;
}

.goods-queue-chip.muted {
  opacity: 0.7;
}

.slot-cancel-btn {
  border: none;
  background: rgba(158, 27, 27, 0.12);
  color: var(--emphasis-red) !important;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

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

.goods-recipe-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  border-radius: 12px;
  padding: 10px 12px;
}

.goods-recipe-title {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  font-weight: 800;
  opacity: 0.9;
}

.goods-recipe-bar label {
  font-size: 0.9rem;
  letter-spacing: 0.025em;
  opacity: 0.85;
}

.goods-recipe-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.goods-recipe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-strong);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.goods-recipe-btn:hover {
  border-color: rgba(27, 122, 51, 0.55);
  background: rgba(27, 122, 51, 0.08);
}

.goods-recipe-btn.active {
  border-color: rgba(27, 122, 51, 0.7);
  background: linear-gradient(135deg, rgba(27, 122, 51, 0.16), rgba(27, 122, 51, 0.06));
  transform: translateY(-1px);
}

.goods-recipe-btn:disabled {
  cursor: not-allowed;
}

.goods-recipe-btn.locked {
  border-style: dashed;
  opacity: 0.7;
  cursor: not-allowed;
}

.goods-recipe-emoji {
  font-size: 1rem;
}

.goods-recipe-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.goods-recipe-availability {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-strong);
}

.goods-recipe-availability.ready {
  background: rgba(27, 122, 51, 0.12);
  border-color: rgba(27, 122, 51, 0.5);
  color: var(--emphasis-green) !important;
}

.goods-recipe-availability.partial {
  background: rgba(27, 122, 51, 0.08);
  border-color: rgba(27, 122, 51, 0.35);
  color: var(--emphasis-green) !important;
}

.goods-recipe-availability.low {
  background: rgba(158, 27, 27, 0.12);
  border-color: rgba(158, 27, 27, 0.45);
  color: var(--emphasis-red) !important;
}

.goods-recipe-availability.locked {
  background: rgba(158, 27, 27, 0.08);
  border-style: dashed;
  color: var(--emphasis-red) !important;
}

@media (max-width: 1100px) {
  .goods-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .goods-recipe-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.goods-slot-select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
}

.goods-slot-select {
  padding: 6px 8px;
  font-size: 0.9rem;
}

.goods-slot-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.goods-slot-row {
  display: grid;
  grid-template-columns: 110px 1fr 120px;
  align-items: center;
  gap: 8px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  border-radius: 10px;
  padding: 8px 10px;
}

.goods-slot-type {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.goods-slot-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px var(--parchment-border-strong);
}

.goods-slot-amount {
  justify-self: end;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.86rem;
}

.goods-action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.goods-preview {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--parchment-wash);
  border: 1px solid var(--parchment-border);
}

.goods-preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.goods-preview-emoji {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--parchment-surface-strong);
  font-size: 1.4rem;
  box-shadow: inset 0 0 0 1px rgba(122, 90, 52, 0.18);
}

.goods-preview-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.goods-preview-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.goods-preview-meta {
  font-size: 0.9rem;
  opacity: 0.82;
}

.goods-detail {
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.goods-status-text {
  font-size: 0.9rem;
  opacity: 0.82;
}

.goods-craft-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: var(--parchment-surface-strong);
  border: 1px solid rgba(27, 122, 51, 0.6);
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.goods-craft-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.goods-craft-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.goods-loop-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(27, 122, 51, 0.4);
  background: rgba(27, 122, 51, 0.08);
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.goods-loop-btn.active {
  border-color: rgba(27, 122, 51, 0.7);
  background: linear-gradient(120deg, rgba(27, 122, 51, 0.16), rgba(27, 122, 51, 0.08));
}

.goods-loop-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(88, 60, 28, 0.18);
}

@media (max-width: 720px) {
  .build-menu-option {
    grid-template-columns: 1fr;
  }

  .build-menu-option-cost {
    text-align: left;
  }

  .build-menu-option-action {
    justify-content: flex-start;
  }
}

/* ── City Tabs ── */

.city-tabs-container {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.city-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--parchment-border);
  background: var(--parchment-surface-muted);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.city-tabs::-webkit-scrollbar {
  display: none;
}

.city-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
  border-radius: 0;
  color: var(--parchment-ink-muted) !important;
}

.city-tab:hover {
  background: rgba(176, 106, 31, 0.08);
  color: var(--parchment-ink) !important;
}

.city-tab.active {
  border-bottom-color: var(--accent);
  background: var(--city-surface-bg);
  color: var(--parchment-ink) !important;
}

.city-tab:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.74rem;
  white-space: nowrap;
}

.city-tab-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 10px 12px;
}

#resources-tab-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Tab Panels */
.city-tab-content .tab-panel-container {
  overflow-y: visible;
  padding-right: 4px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: auto;
}

.goods-tab,
.drydock-tab {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.tab-panel h3 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
}

.tab-empty {
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.6;
  font-style: italic;
  padding: 24px 12px;
  background: var(--parchment-surface-muted);
  border: 1px dashed var(--parchment-border);
  border-radius: 12px;
}

/* Food Tab */
.food-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.food-group {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.food-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.food-group-header span {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.7;
}

.food-rows {
  display: flex;
  flex-direction: column;
}

.food-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.food-row:first-child {
  border-top: none;
}

.food-row .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.food-row .meta .emoji {
  font-size: 1.3rem;
}

.food-row .meta .name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.food-row .stats {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  text-align: right;
  min-width: 120px;
}

.food-row .stats span + span {
  margin-top: 2px;
  opacity: 0.7;
}

.food-row .food-manage-button {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(139, 229, 197, 0.3);
  background: rgba(139, 229, 197, 0.08);
  color: #c9ffed;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.food-row .food-manage-button:hover {
  background: rgba(139, 229, 197, 0.18);
  border-color: rgba(139, 229, 197, 0.5);
}

.food-empty {
  padding: 10px 0;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* Trade Route Wizard */
.trade-wizard {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 20, 0.82);
  backdrop-filter: blur(6px);
  z-index: 400;
}

.trade-wizard.hidden {
  display: none;
}

.trade-wizard-dialog {
  width: min(640px, 92vw);
  max-height: min(90vh, 760px);
  background: var(--parchment-surface);
  border: 2px solid var(--parchment-border-strong);
  border-radius: 0;
  padding: 20px 24px;
  box-shadow: var(--parchment-shadow);
  color: var(--parchment-ink);
  overflow: hidden;
}

.trade-wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--parchment-border);
}

.trade-wizard-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

.trade-wizard-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--parchment-surface-muted);
  border: 2px solid var(--parchment-border);
  border-radius: 0;
  padding: 12px;
}

.wizard-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-field label {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
  color: var(--parchment-ink-muted);
}

.wizard-field select,
.wizard-field input {
  background: var(--parchment-surface);
  border: 2px solid var(--parchment-border);
  border-radius: 0;
  padding: 8px 10px;
  color: inherit;
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.wizard-field select:disabled,
.wizard-field input:disabled {
  opacity: 0.5;
}

.wizard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.wizard-type-toggle {
  display: inline-flex;
  background: var(--parchment-surface-muted);
  border: 2px solid var(--parchment-border);
  border-radius: 0;
  padding: 5px;
  gap: 4px;
}

.wizard-type-button {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--parchment-ink-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 12px;
  cursor: pointer;
}

.wizard-type-button.active {
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
  box-shadow: inset 0 0 0 2px var(--parchment-border-strong);
}

.wizard-capacity p {
  margin: 0;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 0;
  background: var(--parchment-surface-muted);
  border: 2px solid var(--parchment-border);
}

.wizard-error {
  min-height: 18px;
  font-size: 0.85rem;
  color: var(--emphasis-red);
  padding: 4px 0;
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.wizard-actions button {
  border: 2px solid var(--parchment-border-strong);
  border-radius: 0;
  padding: 8px 20px;
  font-weight: 600;
  cursor: pointer;
}

.wizard-actions .secondary {
  background: var(--parchment-surface-muted);
  color: var(--parchment-ink);
}

.wizard-actions button:not(.secondary) {
  background: var(--parchment-surface-strong);
  color: var(--parchment-ink);
}

#ui-layer *,
.menu-overlay *,
.loading-overlay *,
.trade-wizard * {
  border-radius: 0 !important;
}

.menu-left,
.menu-card,
.floating-menu,
.ui-panel,
.trade-panel,
.trade-panel-shell,
.export-panel,
.build-menu,
.harbor-panel,
.tab-panel,
.trade-wizard-dialog {
  position: relative;
  border-width: 2px;
  border-style: solid;
  border-color: var(--parchment-border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 0 0 4px rgba(108, 76, 38, 0.15);
}

.trade-panel-shell {
  position: fixed;
}

#ui-layer button,
#ui-layer input,
#ui-layer select,
#ui-layer textarea,
.menu-overlay button,
.menu-overlay input,
.menu-overlay select,
.menu-overlay textarea,
.trade-wizard button,
.trade-wizard input,
.trade-wizard select,
.trade-wizard textarea {
  border-width: 2px;
  border-style: solid;
  border-color: var(--parchment-border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* Build Tab */
.build-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.build-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
}

.build-option:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.build-option.disabled {
  opacity: 0.5;
}

.build-option-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
}

.build-option-emoji {
  font-size: 1.4rem;
  flex: 0 0 auto;
}

.build-option-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.build-option-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f5f8ff;
}

.build-option-extra {
  font-size: 0.75rem;
  opacity: 0.7;
}

.build-option-button {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(139, 229, 197, 0.55);
  background: rgba(139, 229, 197, 0.12);
  color: #b9ffe3;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.build-option-button:hover:not(:disabled) {
  background: rgba(139, 229, 197, 0.25);
  border-color: rgba(139, 229, 197, 0.8);
}

.build-option-button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Drydock Tab */
.drydock-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drydock-construction-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(17, 138, 178, 0.12), rgba(34, 197, 94, 0.08));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drydock-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drydock-action-btn {
  min-width: 180px;
}

.drydock-empty-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  color: rgba(245, 248, 255, 0.9);
  font-weight: 600;
}

.drydock-slot-section {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drydock-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.drydock-slot-buy,
.goods-slot-buy {
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #0b1727;
  font-weight: 800;
  border: none;
  cursor: pointer;
}

.drydock-slot-buy:disabled,
.goods-slot-buy:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
}

.drydock-slot-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.drydock-slot-card {
  position: relative;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.08), rgba(14, 165, 233, 0.08));
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
}

.drydock-slot-card.locked {
  background: rgba(255, 255, 255, 0.03);
  border-style: dashed;
  opacity: 0.8;
}

.drydock-slot-title {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.drydock-slot-status {
  font-size: 0.9rem;
  color: rgba(245, 248, 255, 0.86);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.drydock-slot-progress {
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.drydock-slot-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
}

.drydock-slot-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drydock-queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
  font-weight: 700;
  flex-wrap: wrap;
}

.drydock-queue-chip.muted {
  opacity: 0.7;
}

.drydock-loop-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #f5f8ff;
  cursor: pointer;
  font-weight: 700;
}

.drydock-loop-btn.active {
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(34, 197, 94, 0.14);
  color: #d8ffe6;
}

.nav-store-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-store-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.nav-store-emoji {
  font-size: 1.1rem;
}

.nav-store-label {
  font-weight: 700;
}

.nav-store-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.drydock-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.drydock-status-banner {
  background: linear-gradient(135deg, rgba(17, 138, 178, 0.25), rgba(131, 56, 236, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
  border-radius: 12px;
  margin: 12px 0;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drydock-status-title {
  font-size: 1rem;
  font-weight: 700;
}

.drydock-status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drydock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 229, 197, 0.55);
  background: rgba(139, 229, 197, 0.12);
  font-size: 0.82rem;
  font-weight: 700;
  color: #e7fff6;
}

.drydock-chip.muted {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.drydock-status-detail {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(245, 248, 255, 0.82);
}

.drydock-summary-wrapper {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drydock-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drydock-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
}

.drydock-summary-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.drydock-tier-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drydock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(139, 229, 197, 0.2);
  border: 1px solid rgba(139, 229, 197, 0.6);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.drydock-badge.muted {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.drydock-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  width: fit-content;
}

.drydock-build-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.drydock-card {
  background: linear-gradient(180deg, rgba(17, 138, 178, 0.12), rgba(131, 56, 236, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.drydock-card-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.drydock-help {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(245, 248, 255, 0.82);
}

.shipyard-select-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.drydock-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  color: #f5f8ff;
  font-size: 0.85rem;
}

.persistent-select,
.drydock-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(12, 17, 27, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f5f8ff;
}

.shipyard-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.shipyard-stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.9rem;
}

.shipyard-reqs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drydock-req-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.drydock-req-chip .chip-label {
  flex: 1;
  font-weight: 700;
}

.drydock-req-chip .chip-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.chip-label {
  font-weight: 700;
}

.drydock-req-chip.chip-optional {
  border-style: dashed;
  opacity: 0.85;
}

.drydock-req-chip.chip-missing {
  border-color: rgba(239, 71, 111, 0.6);
  background: rgba(239, 71, 111, 0.1);
}

.chip-emoji {
  font-size: 1rem;
}

.shipyard-missing {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
}

.shipyard-missing.has-missing {
  border-color: rgba(239, 71, 111, 0.6);
}

.shipyard-actions {
  display: flex;
  justify-content: flex-start;
}

.ship-upgrade-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.ship-upgrade-stat {
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.ship-upgrade-stat-label {
  color: rgba(245, 248, 255, 0.68);
  font-size: 0.76rem;
  font-weight: 700;
}

.ship-upgrade-stat-value {
  color: #f5f8ff;
  font-size: 0.95rem;
  font-weight: 800;
}

.ship-upgrade-track-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ship-upgrade-row {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ship-upgrade-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ship-upgrade-title {
  color: #f5f8ff;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ship-upgrade-detail {
  color: rgba(245, 248, 255, 0.68);
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ship-upgrade-action {
  min-width: 72px;
  text-align: center;
}

.ship-upgrade-status {
  margin-top: auto;
}

.shipyard-build-btn {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #0b1727;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.1;
  min-height: 32px;
  border: none;
  cursor: pointer;
}

.shipyard-build-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
}

.navcraft-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip-missing {
  border-color: rgba(239, 71, 111, 0.6);
  background: rgba(239, 71, 111, 0.15);
}

@media (max-width: 1280px) {
  :root {
    --trade-panel-width: clamp(240px, 26vw, 300px);
    --trade-panel-gap: 14px;
    --trade-panel-gutter: calc(var(--trade-panel-width) + var(--trade-panel-gap));
  }
}

@media (max-width: 1040px) {
  :root {
    --trade-panel-width: 100%;
    --trade-panel-gap: 0px;
    --trade-panel-gutter: 0px;
  }

  .economic-flow-map {
    padding: 0;
  }

  .trade-panel-shell {
    position: static;
    width: 100%;
    max-height: none;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
  }

  .flow-row {
    gap: 10px;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .economic-flow-map {
    gap: 6px;
    padding: 0;
  }

  .flow-row {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 8px;
  }

  .flow-edge {
    width: 100%;
    flex: 0 0 auto;
    padding: 10px;
  }

  .flow-edge-left,
  .flow-edge-right {
    border: none;
    padding: 0;
  }

  .trade-panel-shell {
    position: static;
    width: 100%;
    max-height: none;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
  }

  .flow-center {
    padding: 0;
  }

  .city-tabs {
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .city-tab {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .build-option {
    flex-direction: column;
    align-items: flex-start;
  }

  .build-option-button {
    width: 100%;
  }
}

.mobile-joystick {
  --joystick-size: 158px;
  --joystick-knob-size: 66px;
  --joystick-knob-x: 0px;
  --joystick-knob-y: 0px;
  position: fixed;
  left: max(18px, calc(env(safe-area-inset-left) + 18px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  width: var(--joystick-size);
  height: var(--joystick-size);
  display: none;
  z-index: 260;
  pointer-events: auto;
  touch-action: none;
  opacity: 0.82;
  -webkit-tap-highlight-color: transparent;
}

.mobile-joystick.is-active {
  opacity: 1;
}

.mobile-joystick-pad,
.mobile-joystick-knob {
  position: absolute;
  border-radius: 50%;
}

.mobile-joystick-pad {
  inset: 0;
  border: 2px solid rgba(244, 224, 184, 0.72);
  background:
    radial-gradient(circle at 50% 50%, rgba(246, 230, 196, 0.34) 0 21%, transparent 22%),
    radial-gradient(circle at 50% 50%, rgba(69, 48, 30, 0.2) 0 49%, rgba(18, 30, 38, 0.38) 50% 100%),
    rgba(31, 47, 54, 0.46);
  box-shadow:
    0 18px 38px rgba(5, 12, 18, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    inset 0 12px 24px rgba(255, 237, 199, 0.16),
    inset 0 -18px 28px rgba(8, 20, 28, 0.26);
  backdrop-filter: blur(8px);
}

.mobile-joystick-pad::before,
.mobile-joystick-pad::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 2px;
  background: rgba(244, 224, 184, 0.34);
  transform: translate(-50%, -50%);
}

.mobile-joystick-pad::after {
  width: 2px;
  height: 62%;
}

.mobile-joystick-knob {
  left: 50%;
  top: 50%;
  width: var(--joystick-knob-size);
  height: var(--joystick-knob-size);
  border: 2px solid rgba(255, 239, 205, 0.9);
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 246, 220, 0.92), rgba(222, 174, 100, 0.88) 46%, rgba(117, 70, 32, 0.92) 100%);
  box-shadow:
    0 10px 22px rgba(6, 15, 21, 0.34),
    inset 0 2px 6px rgba(255, 255, 255, 0.38),
    inset 0 -8px 12px rgba(80, 38, 16, 0.28);
  transform: translate(calc(-50% + var(--joystick-knob-x)), calc(-50% + var(--joystick-knob-y)));
  transition: transform 110ms ease-out;
}

.mobile-joystick.is-active .mobile-joystick-knob {
  transition: none;
}

@media (hover: none) and (pointer: coarse), (max-width: 860px) {
  body.app-playing.boat-mode .mobile-joystick {
    display: block;
  }
}

@media (max-width: 520px) {
  .mobile-joystick {
    --joystick-size: 150px;
    --joystick-knob-size: 62px;
    left: max(14px, calc(env(safe-area-inset-left) + 14px));
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 14px));
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .mobile-joystick {
    --joystick-size: 132px;
    --joystick-knob-size: 54px;
    left: max(12px, calc(env(safe-area-inset-left) + 12px));
    bottom: max(10px, calc(env(safe-area-inset-bottom) + 10px));
  }
}

body.mobile-touch-ui .mobile-joystick {
  --joystick-size: 190px;
  --joystick-knob-size: 78px;
  left: max(20px, calc(env(safe-area-inset-left) + 20px));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
}

@media (max-height: 520px) and (orientation: landscape) {
  body.mobile-touch-ui .mobile-joystick {
    --joystick-size: 168px;
    --joystick-knob-size: 68px;
    left: max(16px, calc(env(safe-area-inset-left) + 16px));
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 14px));
  }
}

body.app-menu .mobile-joystick,
body.app-loading .mobile-joystick,
body.app-city-select .mobile-joystick,
body.mobile-landscape-required .mobile-joystick {
  display: none !important;
}

.mobile-landscape-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  color: #f6ead0;
  text-align: center;
  background:
    linear-gradient(rgba(13, 29, 37, 0.9), rgba(16, 35, 42, 0.94)),
    url("../images/ui/nautical-chart-surface.jpg") center / cover;
  pointer-events: auto;
  touch-action: none;
}

.mobile-landscape-overlay:not(.hidden) {
  display: flex;
}

.mobile-landscape-overlay h2 {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.65rem, 6vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.36);
}

.mobile-landscape-overlay p {
  margin: 0;
  max-width: 20rem;
  color: rgba(246, 234, 208, 0.86);
  font-size: 1rem;
  line-height: 1.4;
}

.mobile-landscape-device {
  position: relative;
  width: 82px;
  height: 132px;
  border: 4px solid rgba(246, 234, 208, 0.92);
  border-radius: 16px;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  animation: mobileLandscapeRotate 1.8s ease-in-out infinite;
}

.mobile-landscape-device span {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(246, 234, 208, 0.86);
  transform: translateX(-50%);
}

@keyframes mobileLandscapeRotate {
  0%,
  20% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-landscape-device {
    animation: none;
    transform: rotate(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-joystick-knob {
    transition: none;
  }
}

#ui-layer .docking-progress {
  position: absolute;
  left: 50%;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 34px));
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: min(480px, calc(100vw - 36px));
  max-width: min(590px, calc(100vw - 36px));
  padding: 14px 22px 14px 16px;
  background: var(--parchment-surface);
  border: 2px solid var(--parchment-border-strong);
  box-shadow:
    var(--parchment-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    inset 0 0 0 4px rgba(108, 76, 38, 0.15);
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 48;
}

#ui-layer .docking-progress-ring {
  --dock-progress: 0%;
  position: relative;
  flex: 0 0 68px;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, var(--parchment-surface) 0 55%, transparent 57%),
    conic-gradient(
      var(--emphasis-green) var(--dock-progress),
      rgba(108, 76, 38, 0.24) 0
    );
  border: 1px solid var(--parchment-border-strong);
  border-radius: 50% !important;
}

#ui-layer .docking-progress-core {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
  border-radius: 50% !important;
  font-size: 22px;
  line-height: 1;
}

#ui-layer .docking-progress-label {
  min-width: 0;
  font-size: 23px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(860px, calc(100vw - 40px));
  min-width: 0;
  max-width: calc(100vw - 40px);
  padding: 0;
  background: var(--parchment-surface);
  border: 2px solid var(--parchment-border-strong);
  box-shadow:
    var(--parchment-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    inset 0 0 0 4px rgba(108, 76, 38, 0.15);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 52;
}

#ui-layer .docked-harbor-panel .harbor-panel-header {
  min-height: 76px;
  padding: 16px 20px;
  margin: 0;
  background: var(--parchment-header);
  border-bottom: 2px solid var(--parchment-border-strong);
}

#ui-layer .docked-harbor-panel .harbor-panel-header h2 {
  min-width: 0;
  font-size: 28px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-panel .panel-close-button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 1px solid var(--parchment-border-strong);
  background: var(--parchment-surface-muted);
  font-size: 28px;
}

#ui-layer .docked-harbor-panel .harbor-panel-content {
  gap: 20px;
  padding: 20px 32px 28px;
}

#ui-layer .docked-harbor-panel .harbor-status {
  gap: 12px;
}

#ui-layer .docked-harbor-panel .harbor-status p {
  font-size: 18px;
  line-height: 1.35;
}

#ui-layer .docked-harbor-berth {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 14px 16px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
}

#ui-layer .docked-harbor-label {
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#ui-layer .docked-harbor-value {
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#ui-layer .docked-harbor-market {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

#ui-layer .docked-harbor-quests {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

#ui-layer .docked-harbor-market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#ui-layer .docked-harbor-market-status {
  min-width: 0;
  color: var(--parchment-ink-muted);
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-market-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 2px;
}

#ui-layer .docked-harbor-market-list:empty {
  display: none;
}

#ui-layer .harbor-quest-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

#ui-layer .harbor-quest-list:empty {
  display: none;
}

#ui-layer .docked-harbor-upgrades {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

#ui-layer .docked-harbor-upgrade-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

#ui-layer .docked-harbor-upgrade-list:empty {
  display: none;
}

#ui-layer .docked-harbor-upgrade-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
}

#ui-layer .docked-harbor-market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
}

#ui-layer .harbor-quest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 11px 12px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border);
}

#ui-layer .docked-harbor-market-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

#ui-layer .docked-harbor-market-icon {
  flex: 0 0 auto;
  font-size: 24px;
}

#ui-layer .docked-harbor-market-copy {
  min-width: 0;
}

#ui-layer .docked-harbor-market-name {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-market-detail {
  margin-top: 2px;
  color: var(--parchment-ink-muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ui-layer .docked-harbor-market-buy {
  min-height: 40px;
  min-width: 96px;
  padding: 8px 12px;
  background: var(--parchment-header);
  border: 1px solid var(--parchment-border-strong);
  color: var(--parchment-ink);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

#ui-layer .docked-harbor-market-buy:disabled {
  opacity: 0.48;
  cursor: default;
}

#ui-layer .docked-harbor-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  padding: 12px 10px;
  background: var(--parchment-surface-muted);
  border: 1px solid var(--parchment-border-strong);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

#ui-layer .docked-harbor-action-icon {
  width: 26px;
  height: 26px;
  font-size: 24px;
}

#ui-layer .docked-harbor-action-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

#ui-layer .docked-harbor-action:disabled {
  opacity: 0.58;
  cursor: default;
}

#ui-layer .docked-harbor-manual-status {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--parchment-ink-muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#ui-layer .fleet-tuning-panel {
  position: absolute;
  left: 18px;
  bottom: 86px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 48;
}

body:not(.app-playing) #ui-layer .fleet-tuning-panel {
  display: none;
}

#ui-layer .fleet-tuning-toggle {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(72, 50, 25, 0.72);
  background: rgba(247, 232, 192, 0.92);
  color: #2f2113;
  box-shadow: 0 8px 18px rgba(31, 22, 13, 0.22);
  font-size: 22px;
  font-weight: 800;
}

#ui-layer .fleet-tuning-controls {
  width: min(370px, calc(100vw - 92px));
  padding: 14px;
  background: rgba(247, 232, 192, 0.96);
  border: 1px solid rgba(72, 50, 25, 0.72);
  box-shadow: 0 12px 28px rgba(31, 22, 13, 0.24);
}

#ui-layer .fleet-tuning-controls.hidden {
  display: none;
}

#ui-layer .fleet-tuning-slider {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: #2f2113;
  font-size: 14px;
  font-weight: 800;
}

#ui-layer .fleet-tuning-slider + .fleet-tuning-slider {
  margin-top: 8px;
}

#ui-layer .fleet-tuning-slider input {
  width: 100%;
  accent-color: #2c7a7b;
}

#ui-layer .fleet-tuning-slider output {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ui-layer .combat-tuning-panel {
  position: absolute;
  left: 18px;
  bottom: 138px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 49;
}

body:not(.app-playing) #ui-layer .combat-tuning-panel {
  display: none;
}

#ui-layer .combat-tuning-toggle {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(72, 50, 25, 0.72);
  background: rgba(247, 232, 192, 0.92);
  color: #2f2113;
  box-shadow: 0 8px 18px rgba(31, 22, 13, 0.22);
  font-size: 21px;
  font-weight: 800;
}

#ui-layer .combat-tuning-controls {
  width: min(490px, calc(100vw - 92px));
  max-height: min(620px, calc(100vh - 210px));
  overflow: auto;
  padding: 14px;
  background: rgba(247, 232, 192, 0.97);
  border: 1px solid rgba(72, 50, 25, 0.72);
  box-shadow: 0 12px 28px rgba(31, 22, 13, 0.24);
}

#ui-layer .combat-tuning-controls.hidden {
  display: none;
}

#ui-layer .combat-tuning-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-right: 14px;
  color: #2f2113;
  font-size: 14px;
  font-weight: 900;
}

#ui-layer .combat-tuning-check input {
  width: 19px;
  height: 19px;
  accent-color: #2c7a7b;
}

#ui-layer .combat-tuning-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(72, 50, 25, 0.2);
}

#ui-layer .combat-tuning-group-title {
  margin-bottom: 8px;
  color: #5a3a1f;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#ui-layer .combat-tuning-slider {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 68px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: #2f2113;
  font-size: 14px;
  font-weight: 800;
}

#ui-layer .combat-tuning-slider + .combat-tuning-slider {
  margin-top: 8px;
}

#ui-layer .combat-tuning-slider input {
  width: 100%;
  accent-color: #9a3412;
}

#ui-layer .combat-tuning-slider output {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ui-layer .combat-tuning-status {
  margin-top: 10px;
  color: #5a3a1f;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

#ui-layer .debug-teleport-panel {
  position: absolute;
  left: 18px;
  bottom: 24px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 49;
}

body:not(.app-playing) #ui-layer .debug-teleport-panel {
  display: none;
}

#ui-layer .debug-teleport-toggle {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(72, 50, 25, 0.72);
  background: rgba(247, 232, 192, 0.92);
  color: #2f2113;
  box-shadow: 0 8px 18px rgba(31, 22, 13, 0.22);
  font-size: 21px;
  font-weight: 900;
}

#ui-layer .debug-teleport-controls {
  width: min(300px, calc(100vw - 92px));
  padding: 12px;
  background: rgba(247, 232, 192, 0.97);
  border: 1px solid rgba(72, 50, 25, 0.72);
  box-shadow: 0 12px 28px rgba(31, 22, 13, 0.24);
}

#ui-layer .debug-teleport-controls.hidden {
  display: none;
}

#ui-layer .debug-teleport-field {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #2f2113;
  font-size: 14px;
  font-weight: 900;
}

#ui-layer .debug-teleport-field select {
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(72, 50, 25, 0.38);
  border-radius: 6px;
  background: #fff8e7;
  color: #2f2113;
  font: inherit;
}

#ui-layer .debug-teleport-city-button {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  border: 1px solid rgba(72, 50, 25, 0.48);
  border-radius: 6px;
  background: #8b4513;
  color: #fff8e7;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

#ui-layer .debug-teleport-city-button:disabled {
  cursor: default;
  opacity: 0.48;
}

#ui-layer .debug-teleport-status {
  margin-top: 8px;
  color: #5a3a1f;
  font-size: 12px;
  font-weight: 800;
}

#ui-layer .wave-tuning-panel {
  position: absolute;
  left: 18px;
  bottom: 190px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 50;
}

body:not(.app-playing) #ui-layer .wave-tuning-panel {
  display: none;
}

#ui-layer .wave-tuning-toggle {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(72, 50, 25, 0.72);
  background: rgba(247, 232, 192, 0.92);
  color: #123044;
  box-shadow: 0 8px 18px rgba(31, 22, 13, 0.22);
  font-size: 24px;
  font-weight: 900;
}

#ui-layer .wave-tuning-controls {
  width: min(490px, calc(100vw - 92px));
  max-height: min(620px, calc(100vh - 260px));
  overflow: auto;
  padding: 14px;
  background: rgba(247, 232, 192, 0.97);
  border: 1px solid rgba(72, 50, 25, 0.72);
  box-shadow: 0 12px 28px rgba(31, 22, 13, 0.24);
}

#ui-layer .wave-tuning-controls.hidden {
  display: none;
}

#ui-layer .wave-tuning-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(72, 50, 25, 0.2);
}

#ui-layer .wave-tuning-group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

#ui-layer .wave-tuning-group-title {
  margin-bottom: 8px;
  color: #275369;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#ui-layer .wave-tuning-slider {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 68px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: #2f2113;
  font-size: 14px;
  font-weight: 800;
}

#ui-layer .wave-tuning-slider + .wave-tuning-slider {
  margin-top: 8px;
}

#ui-layer .wave-tuning-slider input {
  width: 100%;
  accent-color: #0e7490;
}

#ui-layer .wave-tuning-slider output {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ui-layer .wave-tuning-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

#ui-layer .wave-tuning-reset {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(72, 50, 25, 0.45);
  background: rgba(255, 244, 211, 0.82);
  color: #2f2113;
  font-size: 12px;
  font-weight: 900;
}

#ui-layer .wave-tuning-status {
  color: #5a3a1f;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

#ui-layer .hud-bar-tuning-panel {
  position: absolute;
  left: 18px;
  bottom: 242px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 51;
}

body:not(.app-playing) #ui-layer .hud-bar-tuning-panel {
  display: none;
}

#ui-layer .hud-bar-tuning-toggle {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(72, 50, 25, 0.72);
  background: rgba(247, 232, 192, 0.92);
  color: #2f2113;
  box-shadow: 0 8px 18px rgba(31, 22, 13, 0.22);
  font-size: 22px;
  font-weight: 900;
}

#ui-layer .hud-bar-tuning-controls {
  width: min(430px, calc(100vw - 92px));
  padding: 14px;
  background: rgba(247, 232, 192, 0.97);
  border: 1px solid rgba(72, 50, 25, 0.72);
  box-shadow: 0 12px 28px rgba(31, 22, 13, 0.24);
}

#ui-layer .hud-bar-tuning-controls.hidden {
  display: none;
}

#ui-layer .hud-bar-tuning-slider {
  display: grid;
  grid-template-columns: 102px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: #2f2113;
  font-size: 13px;
  font-weight: 900;
}

#ui-layer .hud-bar-tuning-slider + .hud-bar-tuning-slider {
  margin-top: 7px;
}

#ui-layer .hud-bar-tuning-slider input {
  width: 100%;
  accent-color: #2c7a7b;
}

#ui-layer .hud-bar-tuning-slider output {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#ui-layer .hud-bar-tuning-readout {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid rgba(72, 50, 25, 0.2);
  background: rgba(64, 38, 16, 0.08);
  color: #3a2614;
  font: 800 12px 'Courier New', monospace;
  overflow-wrap: anywhere;
}

#ui-layer .hud-bar-tuning-reset {
  margin-top: 9px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(72, 50, 25, 0.45);
  background: rgba(255, 244, 211, 0.82);
  color: #2f2113;
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 640px) {
  #ui-layer .debug-teleport-panel {
    left: 12px;
    right: 12px;
    bottom: 20px;
  }

  #ui-layer .debug-teleport-controls {
    width: min(300px, calc(100vw - 72px));
  }

  #ui-layer .fleet-tuning-panel {
    left: 12px;
    right: 12px;
    bottom: 74px;
  }

  #ui-layer .fleet-tuning-controls {
    width: min(340px, calc(100vw - 72px));
  }

  #ui-layer .fleet-tuning-slider {
    grid-template-columns: 76px minmax(0, 1fr) 52px;
    gap: 8px;
  }

  #ui-layer .combat-tuning-panel {
    left: 12px;
    right: 12px;
    bottom: 126px;
  }

  #ui-layer .combat-tuning-controls {
    width: min(390px, calc(100vw - 72px));
    max-height: min(520px, calc(100vh - 180px));
  }

  #ui-layer .combat-tuning-slider {
    grid-template-columns: 128px minmax(0, 1fr) 58px;
    gap: 8px;
  }

  #ui-layer .hud-bar-tuning-panel {
    left: 12px;
    right: 12px;
    bottom: 230px;
  }

  #ui-layer .wave-tuning-panel {
    left: 12px;
    right: 12px;
    bottom: 178px;
  }

  #ui-layer .wave-tuning-controls {
    width: min(390px, calc(100vw - 72px));
    max-height: min(520px, calc(100vh - 220px));
  }

  #ui-layer .wave-tuning-slider {
    grid-template-columns: 104px minmax(0, 1fr) 58px;
    gap: 8px;
  }

  #ui-layer .hud-bar-tuning-controls {
    width: min(360px, calc(100vw - 72px));
  }

  #ui-layer .hud-bar-tuning-slider {
    grid-template-columns: 88px minmax(0, 1fr) 62px;
    gap: 8px;
  }

  .quest-compass {
    grid-template-columns: 26px minmax(0, 1fr);
    min-width: 0;
    max-width: calc(100vw - 120px);
    padding: 0 9px;
  }

  .quest-compass-distance {
    display: none;
  }

  .quest-log-panel {
    right: 6px;
    width: calc(100vw - 12px);
  }

  #ui-layer .docking-progress {
    left: 50%;
    right: auto;
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
    min-width: min(390px, calc(100vw - 28px));
    padding: 12px 14px;
    gap: 10px;
  }

  #ui-layer .docked-harbor-upgrade-list {
    grid-template-columns: 1fr;
  }

  #ui-layer .docking-progress-ring {
    flex-basis: 58px;
    width: 58px;
    height: 58px;
  }

  #ui-layer .docking-progress-core {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  #ui-layer .docking-progress-label {
    font-size: 19px;
  }

  #ui-layer .docked-harbor-actions {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   HUD REBUILD — Dark Glass System
   Age of Sail · Low Poly · Sleek Navigation Strip
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --hud-glass:        rgba(8, 19, 21, 0.82);
  --hud-glass-strong: rgba(5, 11, 13, 0.94);
  --hud-rim:          rgba(92, 221, 195, 0.30);
  --hud-rim-active:   rgba(231, 184, 93, 0.62);
  --hud-rim-subtle:   rgba(92, 221, 195, 0.16);
  --hud-gold:         #e7b85d;
  --hud-gold-dim:     #9e7a35;
  --hud-text:         #eef8f4;
  --hud-text-muted:   rgba(190, 213, 207, 0.72);
  --hud-green:        #44d68a;
  --hud-amber:        #f3b54a;
  --hud-red:          #ff6b5f;
  --hud-blur:         blur(12px) saturate(1.35);
  --hud-r:            2px;
  --hud-edge-size:    62px;
  --hud-gold-size:    188px;
  --hud-shadow:       0 10px 28px rgba(0, 0, 0, 0.44),
                      0 1px 0 rgba(255, 255, 255, 0.05) inset;
  --hud-ease:         200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── TOP BAR WRAPPER ─── */
#hud-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  min-height: var(--hud-edge-size);
  padding: 0;
  gap: 0;
  background:
    linear-gradient(90deg, rgba(5, 11, 13, 0.96), rgba(9, 24, 25, 0.86) 42%, rgba(5, 11, 13, 0.96));
  border-bottom: 1px solid var(--hud-rim);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.hud-cluster {
  display: flex;
  align-items: stretch;
  gap: 0;
  pointer-events: all;
  flex-shrink: 0;
}

.hud-cluster--center {
  position: absolute;
  top: 0;
  left: 50%;
  flex: 0 0 auto;
  justify-content: center;
  align-items: stretch;
  gap: 0;
  max-width: max(280px, calc(var(--ui-viewport-width) - 340px));
  transform: translateX(-50%);
  z-index: 2;
}

.hud-cluster--right {
  position: absolute;
  top: 0;
  right: 0;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 3;
}

/* ─── ICON BUTTONS ─── */
.hud-icon-btn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--hud-edge-size);
  height: var(--hud-edge-size);
  border-radius: var(--hud-r);
  border: 0;
  border-right: 1px solid var(--hud-rim-subtle);
  border-bottom: 1px solid transparent;
  background: var(--hud-glass);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
  color: var(--hud-text);
  font-size: 1.08rem;
  cursor: pointer;
  transition: border-color var(--hud-ease), color var(--hud-ease),
              background var(--hud-ease), transform var(--hud-ease);
  user-select: none;
}

.hud-icon-btn:hover {
  border-color: var(--hud-rim-active);
  color: var(--hud-gold);
  background: var(--hud-glass-strong);
}

.hud-icon-btn:active {
  transform: scale(0.93);
}

.hud-icon-btn[aria-pressed='false'] {
  color: var(--hud-text-muted);
  border-color: var(--hud-rim-subtle);
}

.broadside-hud {
  position: absolute;
  top: calc(var(--ui-viewport-height) * 0.8333);
  left: 50%;
  z-index: 295;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.broadside-hud .broadside-reload {
  width: 86px;
  height: 86px;
  border: 1px solid var(--hud-rim-active);
  border-radius: 50%;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.46),
    0 0 20px rgba(231, 184, 93, 0.2),
    0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.broadside-reload {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  --broadside-reload-progress: 1;
}

.broadside-reload-ring {
  position: absolute;
  inset: 12px;
  z-index: 0;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--hud-gold) calc(var(--broadside-reload-progress) * 360deg),
      rgba(92, 221, 195, 0.13) 0
    );
  box-shadow:
    0 0 12px rgba(231, 184, 93, 0.24),
    0 0 0 1px rgba(238, 248, 244, 0.08) inset;
  mask: radial-gradient(circle, transparent 48%, #000 50%);
  -webkit-mask: radial-gradient(circle, transparent 48%, #000 50%);
  opacity: 0.95;
  pointer-events: none;
}

.broadside-reload-icon,
.broadside-reload-timer {
  position: relative;
  z-index: 1;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.broadside-reload-icon {
  font-size: 1.45rem;
  transform: translateY(-1px);
}

.broadside-reload-timer {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--hud-text);
  font-size: 1.12rem;
}

.broadside-reload.is-ready {
  color: var(--hud-gold);
  border-color: var(--hud-rim-active);
}

.broadside-reload.is-reloading {
  color: var(--hud-text-muted);
  cursor: wait;
}

.broadside-reload.is-reloading .broadside-reload-icon {
  opacity: 0.2;
}

.broadside-reload.is-reloading .broadside-reload-timer {
  display: grid;
}

.broadside-reload:disabled {
  opacity: 1;
}

body:not(.boat-mode) #broadside-reload,
body:not(.boat-mode) #broadside-hud,
.app-menu #broadside-reload,
.app-menu #broadside-hud,
.app-city-select #broadside-reload,
.app-city-select #broadside-hud,
.app-loading #broadside-reload,
.app-loading #broadside-hud {
  display: none;
}

@media (max-width: 640px) {
  .broadside-hud .broadside-reload {
    width: 76px;
    height: 76px;
  }

  .broadside-reload-ring {
    inset: 10px;
  }
}

/* ─── DAY/NIGHT CONTROL — reset old absolute positioning ─── */
#hud-bar #day-night-control {
  position: static !important;
  top: auto !important;
  right: auto !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* ─── AUDIO SETTINGS — reset and re-anchor ─── */
#hud-bar #audio-settings {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  z-index: 310;
}

.hud-icon-btn.audio-settings-toggle {
  font-size: 1.1rem;
  letter-spacing: 0;
}

#hud-bar .audio-settings-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 400;
  min-width: 250px;
  padding: 16px;
  border-radius: var(--hud-r);
  border: 1px solid var(--hud-rim);
  background: var(--hud-glass-strong);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
}

#hud-bar .audio-settings-menu.hidden {
  display: none !important;
}

#hud-bar .audio-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-text);
}

#hud-bar .audio-settings-close {
  all: unset;
  cursor: pointer;
  color: var(--hud-text-muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color var(--hud-ease);
}

#hud-bar .audio-settings-close:hover {
  color: var(--hud-text);
}

#hud-bar .audio-volume-control {
  display: grid;
  grid-template-columns: 44px 1fr 48px;
  align-items: center;
  gap: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hud-text-muted);
  margin-bottom: 10px;
}

#hud-bar .audio-volume-control:last-child {
  margin-bottom: 0;
}

#hud-bar output {
  text-align: right;
  color: var(--hud-text);
  font-size: 0.78rem;
  font-family: 'Cinzel', serif;
}

#hud-bar .audio-volume-slider {
  accent-color: var(--hud-gold);
  width: 100%;
  cursor: pointer;
}

.hud-icon-btn.quest-log-toggle {
  font-size: 1rem;
  letter-spacing: 0;
}

.hud-icon-btn.quest-log-toggle--active {
  color: var(--hud-gold);
  border-color: var(--hud-rim-active);
}

.quest-compass {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 36px minmax(0, 280px) auto;
  align-items: center;
  gap: 9px;
  min-width: 360px;
  max-width: 540px;
  height: var(--hud-edge-size);
  padding: 0 16px;
  border-left: 1px solid var(--hud-rim-subtle);
  border-right: 1px solid var(--hud-rim-subtle);
  background: rgba(10, 24, 25, 0.9);
  color: var(--hud-text);
  pointer-events: none;
}

.quest-compass.hidden {
  display: none !important;
}

.quest-compass-arrow {
  position: relative;
  display: block;
  width: 30px;
  height: 30px;
  transform-origin: 50% 50%;
  transition: transform 120ms linear;
}

.quest-compass-arrow::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 2px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 23px solid var(--hud-gold);
  filter: drop-shadow(0 0 8px rgba(231, 184, 93, 0.34));
  transform: translateX(-50%);
}

.quest-compass-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--hud-text);
}

.quest-compass-distance {
  color: var(--hud-text-muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.quest-log-panel {
  position: absolute;
  top: calc(var(--hud-edge-size) + 8px);
  right: 8px;
  z-index: 340;
  width: min(460px, calc(100vw - 18px));
  max-height: min(520px, calc(100vh - var(--hud-edge-size) - 28px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hud-rim);
  border-radius: var(--hud-r);
  background: var(--hud-glass-strong);
  color: var(--hud-text);
  box-shadow: var(--hud-shadow);
  pointer-events: auto;
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
}

.quest-log-panel.hidden {
  display: none !important;
}

.quest-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  color: var(--hud-text);
  font-size: 0.9rem;
  font-weight: 900;
}

.quest-log-close {
  all: unset;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hud-rim-subtle);
  border-radius: var(--hud-r);
  color: var(--hud-text-muted);
  cursor: pointer;
}

.quest-log-close:hover {
  color: var(--hud-text);
  border-color: var(--hud-rim-active);
}

.quest-log-empty {
  color: var(--hud-text-muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.quest-log-empty.hidden {
  display: none !important;
}

.quest-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
}

.quest-log-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 11px 12px;
  border: 1px solid var(--hud-rim-subtle);
  border-radius: var(--hud-r);
  background: rgba(27, 48, 50, 0.72);
}

.quest-log-row--current {
  border-color: var(--hud-rim-active);
}

.quest-log-copy,
.harbor-quest-copy {
  min-width: 0;
}

.quest-log-title,
.harbor-quest-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 900;
}

.quest-log-detail,
.harbor-quest-detail {
  margin-top: 3px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--hud-text-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.quest-log-select,
.harbor-quest-action {
  min-width: 92px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--hud-rim-subtle);
  border-radius: var(--hud-r);
  background: rgba(231, 184, 93, 0.12);
  color: var(--hud-text);
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.quest-log-select:disabled,
.harbor-quest-action:disabled {
  opacity: 0.56;
  cursor: default;
}

.hud-icon-btn.tutorial-toggle {
  position: relative;
  font-family: 'Cinzel', serif;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0;
}

.hud-icon-btn.tutorial-toggle--active {
  color: var(--hud-gold);
  border-color: var(--hud-rim-active);
}

body.tutorial-open {
  overflow: hidden;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 6200;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(3, 9, 11, 0.76), rgba(3, 9, 11, 0.92)),
    radial-gradient(circle at 50% 10%, rgba(92, 221, 195, 0.13), transparent 42%);
  color: var(--hud-text);
  pointer-events: all;
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

.tutorial-overlay.hidden {
  display: none !important;
}

.tutorial-shell {
  width: min(1180px, calc(var(--ui-viewport-width) - 36px));
  max-height: min(900px, calc(var(--ui-viewport-height) - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid rgba(231, 184, 93, 0.42);
  border-radius: 6px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(10, 27, 29, 0.98), rgba(4, 13, 16, 0.99)),
    rgba(4, 13, 16, 0.99);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.62),
    inset 0 0 0 1px rgba(255, 241, 183, 0.06);
}

.tutorial-header,
.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-color: rgba(231, 184, 93, 0.2);
  background: rgba(2, 8, 10, 0.42);
}

.tutorial-header {
  border-bottom: 1px solid rgba(231, 184, 93, 0.2);
}

.tutorial-footer {
  justify-content: flex-end;
  border-top: 1px solid rgba(231, 184, 93, 0.2);
}

.tutorial-heading {
  min-width: 0;
}

.tutorial-kicker,
.tutorial-section h3 {
  font-family: 'Cinzel', serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.tutorial-kicker {
  display: block;
  color: var(--hud-gold);
  font-size: 0.76rem;
  font-weight: 900;
}

.tutorial-heading h2 {
  margin: 2px 0 4px;
  color: var(--hud-text);
  font-family: 'Cinzel', serif;
  font-size: clamp(2.15rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.tutorial-heading p {
  margin: 0;
  color: var(--hud-text-muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.tutorial-close,
.tutorial-action {
  border: 1px solid rgba(231, 184, 93, 0.38);
  border-radius: 6px;
  background: rgba(231, 184, 93, 0.1);
  color: var(--hud-text);
  cursor: pointer;
}

.tutorial-close {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  line-height: 1;
}

.tutorial-action {
  min-width: 138px;
  min-height: 46px;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tutorial-close:hover,
.tutorial-close:focus-visible,
.tutorial-action:hover,
.tutorial-action:focus-visible {
  border-color: var(--hud-rim-active);
  color: var(--hud-gold);
}

.tutorial-body {
  min-height: 0;
  display: block;
  overflow: auto;
}

.tutorial-guide {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px 22px 24px;
}

.tutorial-section {
  min-width: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(231, 184, 93, 0.14);
}

.tutorial-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.tutorial-section h3 {
  margin: 0 0 12px;
  color: var(--hud-gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.tutorial-control-list,
.tutorial-bullet-list {
  margin: 0;
  padding: 0;
}

.tutorial-control-list {
  display: grid;
  gap: 10px;
}

.tutorial-control-list div {
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tutorial-control-list dt,
.tutorial-control-list dd,
.tutorial-bullet-list li {
  min-width: 0;
  color: var(--hud-text-muted);
  font-size: 0.94rem;
  line-height: 1.42;
}

.tutorial-control-list dt {
  color: var(--hud-text);
  font-weight: 900;
}

.tutorial-control-list dd {
  margin: 0;
}

.tutorial-bullet-list {
  display: grid;
  gap: 9px;
  list-style: none;
}

.tutorial-bullet-list li {
  position: relative;
  padding-left: 18px;
}

.tutorial-bullet-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hud-gold);
  box-shadow: 0 0 10px rgba(231, 184, 93, 0.48);
}

.tutorial-keycap,
.tutorial-control-list kbd {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid rgba(231, 184, 93, 0.42);
  border-radius: 5px;
  background: rgba(2, 8, 10, 0.72);
  color: var(--hud-text);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.38);
}

@media (max-width: 640px) {
  .tutorial-overlay {
    padding: 10px;
  }

  .tutorial-shell {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .tutorial-header,
  .tutorial-footer {
    padding: 14px;
  }

  .tutorial-guide {
    padding: 16px 14px 18px;
  }

  .tutorial-control-list div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

.hud-icon-btn.skill-tree-toggle {
  position: relative;
  font-size: 1.26rem;
  letter-spacing: 0;
}

.hud-icon-btn.skill-tree-toggle--ready {
  color: var(--hud-gold);
  border-color: var(--hud-rim-active);
}

.skill-tree-point-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid rgba(255, 238, 178, 0.75);
  background: #b83242;
  color: #fff7db;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 24px;
  text-align: center;
  box-shadow: 0 0 12px rgba(184, 50, 66, 0.62);
}

.skill-tree-point-badge.hidden {
  display: none !important;
}

body.skill-tree-open {
  overflow: hidden;
}

.skill-tree-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: block;
  color: var(--hud-text);
  pointer-events: all;
}

.skill-tree-overlay.hidden {
  display: none !important;
}

.skill-tree-terrain {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(3, 8, 11, 0.98), rgba(7, 26, 27, 0.94) 48%, rgba(2, 6, 10, 0.98));
}

.skill-tree-terrain::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 32%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.54));
  opacity: 0.88;
}

.skill-tree-shell {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 24px;
  padding: 34px;
  overflow: auto;
  background: linear-gradient(180deg, rgba(3, 9, 12, 0.28), rgba(3, 9, 12, 0.78));
}

.skill-tree-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  min-height: 96px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(231, 184, 93, 0.24);
}

.skill-tree-heading {
  min-width: 0;
}

.skill-tree-kicker,
.skill-tree-detail-branch {
  display: block;
  color: #9ddfcb;
  font-family: 'Cinzel', serif;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.skill-tree-heading h2 {
  margin: 2px 0 0;
  color: #fff5d0;
  font-family: 'Macondo Swash Caps', 'Cinzel', serif;
  font-size: 4.8rem;
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.38), 0 0 24px rgba(231, 184, 93, 0.22);
}

.skill-tree-points {
  display: grid;
  grid-template-columns: auto minmax(0, 128px);
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 13px 18px;
  border: 1px solid rgba(231, 184, 93, 0.38);
  background: rgba(4, 18, 19, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 26px rgba(0, 0, 0, 0.26);
}

.skill-tree-points span:first-child {
  color: #fff4c2;
  font-family: 'Cinzel', serif;
  font-size: 2.35rem;
  font-weight: 900;
  line-height: 1;
}

.skill-tree-points span:last-child {
  color: rgba(238, 248, 244, 0.76);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
}

.skill-tree-close {
  all: unset;
  box-sizing: border-box;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 184, 93, 0.34);
  background: rgba(6, 16, 18, 0.82);
  color: #fff5d0;
  font-size: 2.2rem;
  cursor: pointer;
}

.skill-tree-close:hover {
  border-color: rgba(255, 238, 178, 0.82);
  color: #f3b54a;
}

.skill-tree-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 500px);
  gap: 24px;
}

.skill-tree-map-frame {
  position: relative;
  min-width: 0;
  min-height: 650px;
  overflow: hidden;
  border: 1px solid rgba(231, 184, 93, 0.3);
  background:
    linear-gradient(90deg, rgba(231, 184, 93, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(231, 184, 93, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(6, 25, 29, 0.9), rgba(2, 8, 12, 0.96));
  background-size: 52px 52px, 52px 52px, auto;
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 20px 40px rgba(0, 0, 0, 0.34);
}

.skill-tree-map-frame.is-dragging {
  cursor: grabbing;
}

.skill-tree-map-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 5;
  display: flex;
  gap: 10px;
}

.skill-tree-map-controls button {
  all: unset;
  box-sizing: border-box;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 184, 93, 0.32);
  background: rgba(4, 18, 19, 0.84);
  color: #fff4c2;
  font-size: 1.45rem;
  font-weight: 900;
  cursor: pointer;
}

.skill-tree-map-controls button:hover {
  border-color: rgba(255, 238, 178, 0.82);
}

.skill-tree-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1280px;
  height: 1120px;
  margin-left: -640px;
  margin-top: -560px;
  transform-origin: center;
  transition: transform 180ms ease;
}

.skill-tree-map-frame.is-dragging .skill-tree-canvas {
  transition: none;
}

.skill-tree-links,
.skill-tree-nodes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.skill-link {
  fill: none;
  stroke: rgba(141, 154, 153, 0.62);
  stroke-width: 1.65;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.72));
  vector-effect: non-scaling-stroke;
}

.skill-link.is-active {
  stroke: #7fcfbd;
  stroke-width: 2.15;
}

.skill-link.is-learned {
  stroke: #f3b54a;
  stroke-width: 2.45;
}

.skill-tree-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 230px;
  height: 230px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto minmax(0, 48px) auto;
  align-content: center;
  justify-items: center;
  gap: 9px;
  padding: 28px;
  border: 1px solid rgba(255, 238, 178, 0.76);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 245, 208, 0.14), transparent 48%),
    linear-gradient(180deg, rgba(21, 48, 49, 0.96), rgba(6, 16, 18, 0.98));
  box-shadow:
    inset 0 0 0 7px rgba(3, 9, 12, 0.72),
    inset 0 0 0 9px rgba(231, 184, 93, 0.2),
    0 24px 38px rgba(0, 0, 0, 0.42);
  color: #fff5d0;
  text-align: center;
  transform: translate(-50%, -50%);
}

.skill-tree-center-level {
  color: #9ddfcb;
  font-family: 'Cinzel', serif;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-center-name-label {
  color: rgba(238, 248, 244, 0.68);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-ship-name {
  box-sizing: border-box;
  width: min(100%, 158px);
  height: 42px;
  border: 1px solid rgba(231, 184, 93, 0.36);
  border-radius: 999px;
  background: rgba(1, 8, 10, 0.58);
  color: #fff5d0;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  outline: none;
  padding: 0 14px;
  text-align: center;
}

.skill-tree-ship-name:focus {
  border-color: rgba(255, 238, 178, 0.86);
  box-shadow: 0 0 0 3px rgba(157, 223, 203, 0.18);
}

.skill-tree-rename-ship {
  all: unset;
  box-sizing: border-box;
  min-width: 100px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(157, 223, 203, 0.42);
  border-radius: 999px;
  background: rgba(157, 223, 203, 0.14);
  color: #d8fff4;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.skill-tree-rename-ship:hover,
.skill-tree-rename-ship:focus-visible {
  border-color: rgba(255, 238, 178, 0.78);
  color: #fff5d0;
}

.skill-tree-rename-ship:disabled {
  opacity: 0.52;
  cursor: default;
}

.skill-node {
  all: unset;
  position: absolute;
  box-sizing: border-box;
  width: 118px;
  height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 16px 13px;
  border: 1px solid rgba(185, 198, 194, 0.34);
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(38, 59, 58, 0.98), rgba(8, 20, 23, 0.98));
  color: #c8d9d4;
  text-align: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition:
    transform 170ms ease,
    filter 170ms ease,
    color 170ms ease,
    opacity 170ms ease;
  filter:
    drop-shadow(0 18px 14px rgba(0, 0, 0, 0.42))
    drop-shadow(0 0 0 rgba(0, 0, 0, 0));
}

.skill-node::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.skill-node.is-inner-ring {
  width: 108px;
  height: 108px;
  padding: 14px 12px;
  background:
    linear-gradient(180deg, rgba(74, 92, 73, 0.98), rgba(13, 43, 42, 0.98));
}

.skill-node[data-branch='pirate'] {
  border-color: rgba(216, 84, 84, 0.46);
}

.skill-node[data-branch='merchant'] {
  border-color: rgba(243, 181, 74, 0.48);
}

.skill-node[data-branch='naval'],
.skill-node[data-branch='naval-officer'] {
  border-color: rgba(116, 168, 222, 0.5);
}

.skill-node[data-branch='explorer'] {
  border-color: rgba(119, 216, 164, 0.5);
}

.skill-node:hover,
.skill-node:focus-visible,
.skill-node.is-selected {
  color: #fff7db;
  transform: translate(-50%, -59%) scale(1.04);
  filter:
    drop-shadow(0 26px 18px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 18px rgba(157, 223, 203, 0.18));
}

.skill-node.is-learned {
  background:
    linear-gradient(180deg, rgba(107, 125, 48, 0.98), rgba(20, 68, 53, 0.98));
  color: #fff7db;
}

.skill-node.is-learned::before {
  border-color: #f3b54a;
}

.skill-node.is-available {
  background:
    linear-gradient(180deg, rgba(47, 177, 146, 0.98), rgba(15, 91, 102, 0.98));
  color: #f2fffb;
  animation: skill-node-ready 1800ms ease-in-out infinite;
}

.skill-node.is-available::before {
  border-color: #d5fff2;
}

.skill-node.is-locked {
  background:
    linear-gradient(180deg, rgba(70, 77, 80, 0.96), rgba(32, 37, 40, 0.98));
  color: #8e999b;
  cursor: not-allowed;
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.38)) grayscale(0.25);
}

.skill-node.is-locked::before {
  border-color: #6a7072;
}

.skill-node-branch {
  color: #9ddfcb;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.skill-node-name {
  color: inherit;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.skill-node-effect {
  color: #e8ddba;
  font-size: 0.56rem;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.skill-node.is-locked .skill-node-branch,
.skill-node.is-locked .skill-node-effect {
  color: #7f898b;
}

@keyframes skill-node-ready {
  0%,
  100% {
    filter:
      drop-shadow(0 18px 16px rgba(0, 0, 0, 0.42))
      drop-shadow(0 0 9px rgba(157, 223, 203, 0.24));
  }
  50% {
    filter:
      drop-shadow(0 22px 18px rgba(0, 0, 0, 0.46))
      drop-shadow(0 0 20px rgba(243, 181, 74, 0.32));
  }
}

.skill-tree-detail {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px;
  overflow: auto;
  border: 1px solid rgba(231, 184, 93, 0.3);
  background: rgba(3, 13, 16, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 20px 40px rgba(0, 0, 0, 0.3);
}

.skill-tree-detail h3 {
  margin: 0;
  color: #fff5d0;
  font-family: 'Cinzel', serif;
  font-size: 2.25rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.skill-tree-detail p {
  margin: 0;
  color: rgba(238, 248, 244, 0.78);
  font-size: 1.16rem;
  font-weight: 650;
  line-height: 1.45;
}

.skill-tree-detail-effect {
  padding: 16px 18px;
  border-left: 5px solid #f3b54a;
  background: rgba(231, 184, 93, 0.1);
  color: #fff5d0;
  font-family: 'Courier New', monospace;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
}

.skill-tree-detail-prereq {
  min-height: 52px;
  color: rgba(238, 248, 244, 0.68);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.35;
}

.skill-tree-learn {
  margin-top: auto;
  min-height: 64px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 238, 178, 0.62);
  background: linear-gradient(180deg, #f3b54a, #9ddfcb);
  color: #071417;
  font-family: 'Cinzel', serif;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.skill-tree-learn:disabled {
  border-color: rgba(238, 248, 244, 0.18);
  background: rgba(238, 248, 244, 0.12);
  color: rgba(238, 248, 244, 0.48);
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .skill-node,
  .skill-tree-canvas,
  .skill-node.is-available {
    animation: none;
    transition: none;
  }
}

@media (max-width: 980px) {
  .skill-tree-shell {
    padding: 22px;
    gap: 18px;
  }

  .skill-tree-header {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 86px;
  }

  .skill-tree-heading h2 {
    font-size: 4rem;
  }

  .skill-tree-points {
    order: 3;
    grid-column: 1 / -1;
    justify-self: start;
  }

  .skill-tree-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 1fr) auto;
  }

  .skill-tree-map-frame {
    min-height: 430px;
  }

  .skill-tree-detail {
    max-height: 300px;
  }

  .skill-node {
    width: 112px;
    height: 112px;
    padding: 14px 11px;
  }

  .skill-node.is-inner-ring {
    width: 102px;
    height: 102px;
  }

  .skill-tree-center {
    width: 210px;
    height: 210px;
    padding: 24px;
  }

  .skill-node-branch {
    font-size: 0.54rem;
  }

  .skill-node-name {
    font-size: 0.78rem;
  }

  .skill-node-effect {
    font-size: 0.62rem;
  }
}

@media (max-width: 640px) {
  .skill-tree-shell {
    padding: 14px;
  }

  .skill-tree-header {
    min-height: 68px;
    gap: 12px;
  }

  .skill-tree-heading h2 {
    font-size: 3rem;
  }

  .skill-tree-points {
    min-height: 62px;
  }

  .skill-tree-points span:first-child {
    font-size: 2rem;
  }

  .skill-tree-points span:last-child {
    font-size: 0.82rem;
  }

  .skill-tree-close {
    width: 56px;
    height: 56px;
    font-size: 1.8rem;
  }

  .skill-tree-body {
    grid-template-rows: minmax(400px, 1fr) auto;
  }

  .skill-tree-map-frame {
    min-height: 400px;
  }

  .skill-tree-map-controls button {
    width: 44px;
    height: 44px;
  }

  .skill-node {
    width: 104px;
    height: 104px;
    padding: 13px 10px;
  }

  .skill-node.is-inner-ring {
    width: 96px;
    height: 96px;
  }

  .skill-tree-center {
    width: 190px;
    height: 190px;
    padding: 22px;
  }

  .skill-tree-ship-name {
    width: 138px;
    height: 38px;
    font-size: 0.9rem;
  }

  .skill-node-branch {
    font-size: 0.5rem;
  }

  .skill-node-name {
    font-size: 0.72rem;
  }

  .skill-node-effect {
    font-size: 0.58rem;
  }
}

/* Reimagined nautical progression overlay. */
.skill-tree-overlay {
  --skill-ocean: #041115;
  --skill-deep: #02070b;
  --skill-ink: #061c21;
  --skill-gold: #e7b85d;
  --skill-gold-bright: #fff1b7;
  --skill-seaglass: #8fe7d2;
  --skill-muted: rgba(229, 239, 233, 0.72);
  --skill-piracy: #c95745;
  --skill-trade: #8be6cb;
  --skill-combat: #83b7ed;
  --skill-sailing: #e7c45d;
  color: #f6f0d5;
}

.skill-tree-terrain {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(2, 5, 9, 0.28), rgba(2, 5, 9, 0.84)),
    linear-gradient(28deg, transparent 0 52%, rgba(139, 231, 210, 0.08) 62%, transparent 76%),
    linear-gradient(154deg, transparent 0 44%, rgba(231, 184, 93, 0.08) 56%, transparent 70%),
    linear-gradient(115deg, #02060a 0%, #071a1d 38%, #041015 68%, #02060a 100%);
}

.skill-tree-terrain::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(231, 184, 93, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(231, 184, 93, 0.035) 1px, transparent 1px),
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(143, 231, 210, 0.035) 27px 28px);
  background-size: 88px 88px, 88px 88px, auto;
  opacity: 0.72;
}

.skill-tree-terrain::after {
  background:
    radial-gradient(circle at 16% 18%, rgba(244, 241, 218, 0.2), transparent 7%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 20%),
    linear-gradient(180deg, transparent 56%, rgba(1, 6, 8, 0.72));
  opacity: 1;
}

.skill-tree-shell {
  padding: clamp(18px, 2.1vw, 34px);
  gap: clamp(12px, 1.4vw, 20px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(231, 184, 93, 0.05), transparent 28%, transparent 72%, rgba(143, 231, 210, 0.045)),
    linear-gradient(180deg, rgba(2, 7, 10, 0.12), rgba(2, 7, 10, 0.78));
}

.skill-tree-header {
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr) auto auto;
  gap: clamp(12px, 1.6vw, 24px);
  min-height: 74px;
  padding: 0;
  border-bottom: 0;
}

.skill-tree-heading {
  grid-column: 2;
  text-align: center;
  align-self: start;
}

.skill-tree-kicker,
.skill-tree-detail-branch {
  color: var(--skill-seaglass);
  font-size: clamp(0.72rem, 0.9vw, 0.98rem);
  letter-spacing: 0;
  text-shadow: 0 0 16px rgba(143, 231, 210, 0.22);
}

.skill-tree-heading h2 {
  margin: 0;
  color: var(--skill-gold-bright);
  font-size: clamp(3rem, 4.4vw, 5.6rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.78),
    0 0 22px rgba(231, 184, 93, 0.34);
}

.skill-tree-points {
  grid-column: 3;
  grid-template-columns: minmax(54px, auto) auto;
  min-height: 58px;
  padding: 10px 16px;
  border-color: rgba(231, 184, 93, 0.58);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(13, 35, 38, 0.92), rgba(4, 13, 16, 0.94)),
    radial-gradient(circle at 50% 45%, rgba(143, 231, 210, 0.14), transparent 58%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 241, 183, 0.08),
    0 14px 28px rgba(0, 0, 0, 0.32);
}

.skill-tree-points span:first-child {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 231, 210, 0.58);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(24, 77, 83, 0.98), rgba(4, 14, 18, 0.96));
  color: #e9fff7;
  font-size: 2rem;
  box-shadow: 0 0 18px rgba(143, 231, 210, 0.34);
}

.skill-tree-points span:last-child {
  color: var(--skill-gold-bright);
  font-size: 0.84rem;
  letter-spacing: 0;
}

.skill-tree-close {
  grid-column: 4;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border-color: rgba(231, 184, 93, 0.5);
  background: radial-gradient(circle, rgba(18, 42, 44, 0.96), rgba(3, 10, 13, 0.98));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
}

.skill-tree-body {
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
  grid-template-areas: "detail map";
  gap: clamp(14px, 1.8vw, 26px);
  min-height: 0;
}

.skill-tree-map-frame {
  grid-area: map;
  min-height: 0;
  height: 100%;
  border-color: rgba(231, 184, 93, 0.38);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(143, 231, 210, 0.055), transparent 30%, transparent 70%, rgba(231, 184, 93, 0.055)),
    linear-gradient(180deg, rgba(231, 184, 93, 0.035), transparent 36%, rgba(143, 231, 210, 0.04)),
    linear-gradient(90deg, rgba(231, 184, 93, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(231, 184, 93, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(6, 25, 29, 0.74), rgba(2, 8, 12, 0.88));
  background-size: auto, auto, 72px 72px, 72px 72px, auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 95px rgba(0, 0, 0, 0.45),
    0 24px 48px rgba(0, 0, 0, 0.34);
}

.skill-tree-map-frame::before,
.skill-tree-map-frame::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.skill-tree-map-frame::before {
  inset: 7%;
  border: 1px solid rgba(231, 184, 93, 0.22);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(143, 231, 210, 0.04),
    0 0 70px rgba(231, 184, 93, 0.07);
}

.skill-tree-map-frame::after {
  right: 5%;
  bottom: 7%;
  width: min(15vw, 210px);
  aspect-ratio: 1;
  border: 1px solid rgba(231, 184, 93, 0.2);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(231, 184, 93, 0.18) 50%, transparent 50.5%),
    linear-gradient(0deg, transparent 49.5%, rgba(231, 184, 93, 0.18) 50%, transparent 50.5%);
  opacity: 0.52;
}

.skill-tree-map-controls {
  top: 14px;
  left: 14px;
  gap: 8px;
}

.skill-tree-map-controls button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(5, 16, 19, 0.8);
  color: var(--skill-gold-bright);
}

.skill-tree-canvas {
  width: 1280px;
  height: 820px;
  margin-left: -640px;
  margin-top: -410px;
}

.skill-tree-chart-ring,
.skill-tree-chart-axis,
.skill-tree-path-label {
  position: absolute;
  pointer-events: none;
}

.skill-tree-chart-ring {
  left: 50%;
  top: 50%;
  border: 1px solid rgba(231, 184, 93, 0.25);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 24px rgba(143, 231, 210, 0.04);
}

.skill-tree-chart-ring--outer {
  width: 86%;
  height: 86%;
}

.skill-tree-chart-ring--middle {
  width: 61%;
  height: 61%;
  border-color: rgba(143, 231, 210, 0.2);
}

.skill-tree-chart-ring--inner {
  width: 34%;
  height: 34%;
  border-color: rgba(255, 241, 183, 0.25);
}

.skill-tree-chart-axis {
  left: 50%;
  top: 50%;
  background: linear-gradient(90deg, transparent, rgba(231, 184, 93, 0.32), transparent);
  transform: translate(-50%, -50%);
  opacity: 0.74;
}

.skill-tree-chart-axis--horizontal {
  width: 90%;
  height: 1px;
}

.skill-tree-chart-axis--vertical {
  width: 1px;
  height: 90%;
  background: linear-gradient(180deg, transparent, rgba(231, 184, 93, 0.32), transparent);
}

.skill-tree-path-label {
  z-index: 2;
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', serif;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.8);
}

.skill-tree-path-label--piracy {
  left: 23%;
  top: 17%;
  color: #ffc4ad;
}

.skill-tree-path-label--trade {
  right: 17%;
  top: 17%;
  color: #d9fff4;
}

.skill-tree-path-label--combat {
  left: 20%;
  bottom: 15%;
  color: #d8ebff;
}

.skill-tree-path-label--sailing {
  right: 16%;
  bottom: 15%;
  color: #ffe7a4;
}

.skill-tree-links {
  z-index: 1;
}

.skill-link {
  stroke: rgba(120, 133, 133, 0.5);
  stroke-width: 1.95;
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.82))
    drop-shadow(0 0 5px rgba(231, 184, 93, 0.12));
}

.skill-link[data-branch='piracy'] {
  stroke: rgba(201, 87, 69, 0.48);
}

.skill-link[data-branch='trade'] {
  stroke: rgba(139, 230, 203, 0.46);
}

.skill-link[data-branch='combat'] {
  stroke: rgba(131, 183, 237, 0.46);
}

.skill-link[data-branch='sailing'] {
  stroke: rgba(231, 196, 93, 0.48);
}

.skill-link.is-active {
  stroke: rgba(143, 231, 210, 0.88);
  stroke-width: 2.35;
}

.skill-link.is-learned {
  stroke: var(--skill-gold-bright);
  stroke-width: 2.85;
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.78))
    drop-shadow(0 0 9px rgba(231, 184, 93, 0.52));
}

.skill-tree-nodes {
  z-index: 3;
}

.skill-tree-center {
  width: 206px;
  height: 206px;
  grid-template-rows: auto auto minmax(0, 40px) auto;
  gap: 7px;
  padding: 23px;
  border-width: 2px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 241, 183, 0.2), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(143, 231, 210, 0.12), transparent 63%),
    linear-gradient(180deg, rgba(18, 43, 45, 0.98), rgba(4, 14, 18, 0.99));
  box-shadow:
    inset 0 0 0 8px rgba(1, 8, 10, 0.74),
    inset 0 0 0 10px rgba(231, 184, 93, 0.24),
    0 0 44px rgba(231, 184, 93, 0.18),
    0 24px 42px rgba(0, 0, 0, 0.5);
}

.skill-tree-center::before,
.skill-tree-center::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.skill-tree-center::before {
  width: 292px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(231, 184, 93, 0.82), transparent);
}

.skill-tree-center::after {
  width: 1px;
  height: 292px;
  background: linear-gradient(180deg, transparent, rgba(231, 184, 93, 0.82), transparent);
}

.skill-tree-center-level,
.skill-tree-center-name-label,
.skill-tree-rename-ship,
.skill-node-branch {
  letter-spacing: 0;
}

.skill-tree-center-level {
  color: var(--skill-seaglass);
}

.skill-tree-ship-name {
  height: 38px;
  border-radius: 50px;
  border-color: rgba(231, 184, 93, 0.46);
  background: rgba(0, 7, 10, 0.66);
  font-size: 0.92rem;
}

.skill-tree-rename-ship {
  min-height: 30px;
  border-radius: 50px;
}

.skill-node {
  width: 92px;
  height: 92px;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 8px;
  border-width: 2px;
  border-color: rgba(185, 198, 194, 0.42);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(25, 45, 47, 0.98), rgba(5, 15, 18, 0.98));
  color: #e5efe9;
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.62),
    0 16px 18px rgba(0, 0, 0, 0.46),
    0 0 0 rgba(231, 184, 93, 0);
}

.skill-node::before {
  inset: 5px;
  border-color: rgba(255, 241, 183, 0.1);
}

.skill-node.is-inner-ring {
  width: 82px;
  height: 82px;
  grid-template-rows: 40px minmax(0, 1fr);
  padding: 7px;
}

.skill-node-icon-ring {
  box-sizing: border-box;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 241, 183, 0.34);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 241, 183, 0.16), rgba(3, 13, 16, 0.72));
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.32);
}

.skill-node.is-inner-ring .skill-node-icon-ring {
  width: 39px;
  height: 39px;
}

.skill-node-icon {
  font-family: 'Cinzel', 'Apple Symbols', 'Segoe UI Symbol', serif;
  font-size: 1.45rem;
  line-height: 1;
  color: currentColor;
  text-shadow: 0 0 12px currentColor;
}

.skill-node-name {
  max-width: 100%;
  color: inherit;
  font-size: 0.58rem;
  line-height: 1.02;
  letter-spacing: 0;
  text-transform: uppercase;
}

.skill-node.is-inner-ring .skill-node-name {
  font-size: 0.54rem;
}

.skill-node-branch {
  color: rgba(229, 239, 233, 0.56);
  font-size: 0.48rem;
}

.skill-node-effect {
  display: none;
}

.skill-node[data-branch='piracy'] {
  border-color: rgba(201, 87, 69, 0.72);
  color: #ffd1c0;
}

.skill-node[data-branch='trade'] {
  border-color: rgba(139, 230, 203, 0.72);
  color: #d8fff5;
}

.skill-node[data-branch='combat'] {
  border-color: rgba(131, 183, 237, 0.74);
  color: #d8ebff;
}

.skill-node[data-branch='sailing'] {
  border-color: rgba(231, 196, 93, 0.78);
  color: #ffe7a4;
}

.skill-node:hover,
.skill-node:focus-visible,
.skill-node.is-selected {
  transform: translate(-50%, -58%) scale(1.08);
  filter: none;
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.48),
    0 24px 22px rgba(0, 0, 0, 0.5),
    0 0 26px rgba(143, 231, 210, 0.22);
}

.skill-node.is-learned {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 241, 183, 0.26), transparent 46%),
    linear-gradient(180deg, rgba(109, 94, 36, 0.98), rgba(18, 55, 45, 0.98));
  color: var(--skill-gold-bright);
}

.skill-node.is-learned .skill-node-icon-ring {
  border-color: rgba(255, 241, 183, 0.82);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.36),
    0 0 20px rgba(231, 184, 93, 0.36);
}

.skill-node.is-available {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 241, 183, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(35, 111, 99, 0.98), rgba(7, 47, 55, 0.98));
  animation: skill-node-ready 1700ms ease-in-out infinite;
}

.skill-node.is-locked {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.06), transparent 44%),
    linear-gradient(180deg, rgba(49, 57, 58, 0.96), rgba(12, 18, 20, 0.98));
  color: #747f82;
  opacity: 0.72;
  filter: grayscale(0.38);
}

.skill-tree-detail {
  grid-area: detail;
  gap: 16px;
  padding: 18px;
  border-color: rgba(231, 184, 93, 0.38);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(8, 24, 27, 0.9), rgba(3, 11, 14, 0.94)),
    linear-gradient(180deg, rgba(143, 231, 210, 0.08), transparent 44%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 241, 183, 0.05),
    0 22px 42px rgba(0, 0, 0, 0.38);
}

.skill-tree-detail::before {
  content: '';
  width: 100%;
  height: 118px;
  border: 1px solid rgba(231, 184, 93, 0.24);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 38%),
    linear-gradient(90deg, transparent, rgba(143, 231, 210, 0.12), transparent),
    linear-gradient(180deg, rgba(2, 8, 12, 0.2), rgba(2, 8, 12, 0.72)),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(231, 184, 93, 0.07) 23px 24px);
}

.skill-tree-detail h3 {
  font-size: clamp(1.65rem, 2vw, 2.4rem);
  letter-spacing: 0;
}

.skill-tree-detail p {
  color: var(--skill-muted);
  font-size: 0.96rem;
}

.skill-tree-detail-effect {
  border-left-color: var(--skill-seaglass);
  border-radius: 0 6px 6px 0;
  background: rgba(143, 231, 210, 0.1);
  color: var(--skill-gold-bright);
  font-size: 0.94rem;
}

.skill-tree-detail-prereq {
  min-height: 42px;
  color: rgba(229, 239, 233, 0.68);
  font-size: 0.84rem;
}

.skill-tree-learn {
  min-height: 54px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--skill-gold-bright), var(--skill-gold));
  letter-spacing: 0;
}

.skill-tree-learn:disabled {
  background: rgba(229, 239, 233, 0.1);
}

@media (max-width: 1100px) {
  .skill-tree-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .skill-tree-heading {
    grid-column: 1;
    text-align: left;
  }

  .skill-tree-points {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .skill-tree-close {
    grid-column: 2;
  }

  .skill-tree-body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "detail";
  }

  .skill-tree-map-frame {
    min-height: 540px;
  }

  .skill-tree-detail {
    max-height: 250px;
  }

  .skill-tree-detail::before {
    display: none;
  }
}

@media (max-width: 700px) {
  .skill-tree-shell {
    overflow: auto;
  }

  .skill-tree-heading h2 {
    font-size: 2.75rem;
  }

  .skill-tree-map-frame {
    min-height: 430px;
  }

  .skill-tree-canvas {
    width: 1060px;
    height: 760px;
    margin-left: -530px;
    margin-top: -380px;
  }

  .skill-tree-path-label {
    font-size: 1rem;
  }

  .skill-node {
    width: 82px;
    height: 82px;
    grid-template-rows: 40px minmax(0, 1fr) auto;
  }

  .skill-node.is-inner-ring {
    width: 74px;
    height: 74px;
  }

  .skill-node-icon-ring {
    width: 38px;
    height: 38px;
  }

  .skill-node-name {
    font-size: 0.5rem;
  }

  .skill-tree-center {
    width: 172px;
    height: 172px;
  }
}

/* Skill tree redesign. Keep this block after the legacy tree rules. */
body.skill-tree-open {
  overflow: hidden;
}

body.skill-tree-open #game-container {
  visibility: hidden;
}

.skill-tree-overlay {
  --skill-bg: #02070a;
  --skill-panel: rgba(4, 14, 18, 0.9);
  --skill-panel-strong: rgba(2, 8, 11, 0.96);
  --skill-line: rgba(226, 174, 79, 0.34);
  --skill-gold: #d9a843;
  --skill-gold-bright: #fff0b5;
  --skill-ink: #061419;
  --skill-text: #f7efd2;
  --skill-muted: rgba(237, 232, 204, 0.7);
  --skill-piracy: #c83d3a;
  --skill-trade: #47d7c4;
  --skill-combat: #63a5ee;
  --skill-exploration: #edc84f;
  position: fixed;
  inset: 0;
  z-index: 900;
  display: block;
  color: var(--skill-text);
  pointer-events: all;
}

.skill-tree-overlay.hidden {
  display: none !important;
}

.skill-tree-terrain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(1, 5, 8, 0.38), rgba(1, 5, 8, 0.9)),
    linear-gradient(90deg, rgba(216, 168, 67, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(216, 168, 67, 0.03) 1px, transparent 1px),
    radial-gradient(ellipse at 68% 34%, rgba(27, 74, 73, 0.42), transparent 38%),
    radial-gradient(ellipse at 34% 55%, rgba(68, 31, 28, 0.32), transparent 34%),
    linear-gradient(120deg, #02070a 0%, #05181d 40%, #051116 72%, #02070a 100%);
  background-size: auto, 72px 72px, 72px 72px, auto, auto, auto;
}

.skill-tree-terrain::before,
.skill-tree-terrain::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.skill-tree-terrain::before {
  background:
    repeating-linear-gradient(18deg, transparent 0 86px, rgba(216, 168, 67, 0.08) 87px 88px),
    repeating-linear-gradient(108deg, transparent 0 124px, rgba(71, 215, 196, 0.05) 125px 126px);
  opacity: 0.68;
}

.skill-tree-terrain::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 18%),
    radial-gradient(ellipse at center, transparent 34%, rgba(0, 0, 0, 0.52) 100%);
}

.skill-tree-moon {
  position: absolute;
  left: 76px;
  top: 58px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.92), rgba(209, 224, 223, 0.72) 36%, rgba(122, 151, 153, 0.42) 62%, transparent 66%);
  opacity: 0.45;
  filter: blur(0.2px);
}

.skill-tree-compass-rose {
  position: absolute;
  right: 70px;
  bottom: 66px;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(216, 168, 67, 0.2);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(216, 168, 67, 0.34) 50%, transparent 50.3%),
    linear-gradient(0deg, transparent 49.7%, rgba(216, 168, 67, 0.34) 50%, transparent 50.3%),
    linear-gradient(45deg, transparent 49.7%, rgba(216, 168, 67, 0.18) 50%, transparent 50.3%),
    linear-gradient(135deg, transparent 49.7%, rgba(216, 168, 67, 0.18) 50%, transparent 50.3%);
  opacity: 0.58;
}

.skill-tree-shell {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 86px minmax(0, 1fr);
  gap: 16px;
  padding: 22px 30px 28px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(216, 168, 67, 0.08), transparent 18%, transparent 82%, rgba(71, 215, 196, 0.06)),
    linear-gradient(180deg, rgba(2, 7, 10, 0.08), rgba(2, 7, 10, 0.78));
}

.skill-tree-header {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(286px, 360px) minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 18px;
  padding: 0;
  border: 0;
}

.skill-tree-heading {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
  text-align: center;
}

.skill-tree-kicker,
.skill-tree-detail-branch {
  display: block;
  color: #8fe7d2;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 15px rgba(71, 215, 196, 0.24);
}

.skill-tree-heading h2 {
  margin: 0;
  color: var(--skill-gold-bright);
  font-family: 'Macondo Swash Caps', 'Cinzel', Georgia, serif;
  font-size: 4.8rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 0.82;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.8),
    0 0 22px rgba(216, 168, 67, 0.38);
}

.skill-tree-points {
  grid-column: 3;
  box-sizing: border-box;
  min-width: 260px;
  min-height: 62px;
  display: grid;
  grid-template-columns: auto 58px auto;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border: 1px solid rgba(216, 168, 67, 0.62);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(9, 28, 32, 0.95), rgba(2, 8, 11, 0.96)),
    radial-gradient(circle at 50% 45%, rgba(71, 215, 196, 0.14), transparent 60%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 181, 0.08),
    0 14px 28px rgba(0, 0, 0, 0.38);
}

.skill-tree-level-label,
.skill-tree-points span:last-child {
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-level-label strong {
  color: var(--skill-text);
  font-size: 1.42rem;
  font-weight: 900;
}

.skill-tree-points span:first-child {
  width: auto;
  height: auto;
  display: inline;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.skill-tree-points #skill-tree-points-value {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(71, 215, 196, 0.7);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, rgba(71, 215, 196, 0.38), rgba(3, 20, 24, 0.98) 68%);
  color: #eafff8;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  box-shadow:
    inset 0 0 0 5px rgba(0, 0, 0, 0.28),
    0 0 18px rgba(71, 215, 196, 0.38);
}

.skill-tree-close {
  all: unset;
  grid-column: 4;
  box-sizing: border-box;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 168, 67, 0.58);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(18, 42, 44, 0.96), rgba(3, 10, 13, 0.98));
  color: var(--skill-gold-bright);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
}

.skill-tree-close:hover,
.skill-tree-close:focus-visible {
  border-color: var(--skill-gold-bright);
  color: #ffffff;
}

.skill-tree-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(286px, 360px) minmax(0, 1fr);
  grid-template-areas: "detail map";
  gap: 18px;
}

.skill-tree-detail {
  grid-area: detail;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid rgba(216, 168, 67, 0.48);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(7, 21, 24, 0.92), rgba(2, 8, 11, 0.96)),
    linear-gradient(90deg, rgba(71, 215, 196, 0.06), transparent 44%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 181, 0.06),
    0 22px 42px rgba(0, 0, 0, 0.4);
}

.skill-tree-detail::before {
  display: none;
}

.skill-tree-vessel-panel {
  min-height: 0;
  display: grid;
  gap: 10px;
}

.skill-tree-ship-portrait {
  position: relative;
  min-height: 154px;
  border: 1px solid rgba(216, 168, 67, 0.28);
  border-radius: 6px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 38%),
    linear-gradient(180deg, rgba(5, 18, 24, 0.12), rgba(2, 7, 10, 0.7)),
    radial-gradient(ellipse at 50% 78%, rgba(71, 215, 196, 0.18), transparent 55%),
    linear-gradient(180deg, rgba(12, 35, 42, 0.94), rgba(2, 9, 14, 0.98));
}

.skill-tree-ship-portrait::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  height: 34px;
  background:
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(255, 240, 181, 0.12) 39px 40px),
    linear-gradient(180deg, rgba(71, 215, 196, 0.14), transparent);
  opacity: 0.76;
}

.skill-tree-ship-silhouette {
  position: absolute;
  left: 50%;
  bottom: 38px;
  width: 192px;
  height: 82px;
  transform: translateX(-50%);
}

.skill-tree-ship-silhouette::before {
  content: '';
  position: absolute;
  left: 16px;
  right: 14px;
  bottom: 0;
  height: 28px;
  border-radius: 0 0 52px 52px;
  background:
    linear-gradient(180deg, #43301d, #120b08);
  clip-path: polygon(0 16%, 88% 16%, 100% 46%, 82% 100%, 14% 100%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.58);
}

.skill-tree-ship-silhouette::after {
  content: '';
  position: absolute;
  left: 42px;
  bottom: 25px;
  width: 106px;
  height: 56px;
  background:
    linear-gradient(90deg, transparent 50%, rgba(40, 28, 18, 0.7) 51% 54%, transparent 55%),
    linear-gradient(135deg, transparent 0 22%, rgba(241, 232, 202, 0.92) 23% 50%, transparent 51%),
    linear-gradient(45deg, transparent 0 31%, rgba(204, 196, 172, 0.82) 32% 58%, transparent 59%);
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.52));
}

.skill-tree-path-status {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(71, 215, 196, 0.28);
  border-radius: 6px;
  background: rgba(71, 215, 196, 0.08);
  color: #dffff7;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.skill-tree-stats {
  display: grid;
  gap: 6px;
}

.skill-tree-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 30px;
  padding: 0 10px;
  border-bottom: 1px solid rgba(216, 168, 67, 0.16);
  color: var(--skill-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.skill-tree-stat-row strong {
  color: var(--skill-gold-bright);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

.skill-tree-detail-copy {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.skill-tree-detail h3 {
  margin: 0;
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 2rem;
  letter-spacing: 0;
  line-height: 1.04;
}

.skill-tree-detail p {
  margin: 0;
  color: var(--skill-muted);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.36;
}

.skill-tree-detail-effect {
  padding: 12px 14px;
  border-left: 4px solid #47d7c4;
  border-radius: 0 6px 6px 0;
  background: rgba(71, 215, 196, 0.1);
  color: var(--skill-gold-bright);
  font-family: 'Courier New', monospace;
  font-size: 0.96rem;
  font-weight: 900;
  line-height: 1.25;
}

.skill-tree-detail-prereq {
  min-height: 40px;
  color: rgba(237, 232, 204, 0.68);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.32;
}

.skill-tree-learn {
  margin-top: auto;
  min-height: 54px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 240, 181, 0.7);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--skill-gold-bright), var(--skill-gold));
  color: #071417;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
}

.skill-tree-learn:disabled {
  border-color: rgba(237, 232, 204, 0.18);
  background: rgba(237, 232, 204, 0.1);
  color: rgba(237, 232, 204, 0.48);
  cursor: default;
}

.skill-tree-map-frame {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(216, 168, 67, 0.42);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(201, 61, 58, 0.08), transparent 28%, transparent 72%, rgba(71, 215, 196, 0.07)),
    linear-gradient(180deg, rgba(216, 168, 67, 0.04), transparent 44%, rgba(99, 165, 238, 0.06)),
    linear-gradient(90deg, rgba(216, 168, 67, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(216, 168, 67, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(5, 20, 25, 0.72), rgba(2, 8, 12, 0.9));
  background-size: auto, auto, 76px 76px, 76px 76px, auto;
  cursor: grab;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 110px rgba(0, 0, 0, 0.5),
    0 24px 48px rgba(0, 0, 0, 0.36);
}

.skill-tree-map-frame.is-dragging {
  cursor: grabbing;
}

.skill-tree-map-frame::before {
  content: '';
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(216, 168, 67, 0.2);
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 2px rgba(71, 215, 196, 0.04),
    0 0 70px rgba(216, 168, 67, 0.07);
}

.skill-tree-map-frame::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 80%;
  background: linear-gradient(180deg, transparent, rgba(216, 168, 67, 0.36), transparent);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.skill-tree-map-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.skill-tree-map-controls button {
  all: unset;
  box-sizing: border-box;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 168, 67, 0.48);
  border-radius: 50%;
  background: rgba(5, 16, 19, 0.84);
  color: var(--skill-gold-bright);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
}

.skill-tree-map-controls button:hover,
.skill-tree-map-controls button:focus-visible {
  border-color: var(--skill-gold-bright);
  color: #ffffff;
}

.skill-tree-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1320px;
  height: 860px;
  margin-left: -660px;
  margin-top: -430px;
  transform-origin: center;
  transition: transform 180ms ease;
}

.skill-tree-map-frame.is-dragging .skill-tree-canvas {
  transition: none;
}

.skill-tree-web-glow {
  position: absolute;
  inset: 16%;
  border: 1px solid rgba(216, 168, 67, 0.18);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(216, 168, 67, 0.1), transparent 33%),
    conic-gradient(from 0deg, rgba(201, 61, 58, 0.12), rgba(71, 215, 196, 0.12), rgba(237, 200, 79, 0.12), rgba(99, 165, 238, 0.12), rgba(201, 61, 58, 0.12));
  opacity: 0.82;
  pointer-events: none;
}

.skill-tree-chart-ring,
.skill-tree-chart-axis,
.skill-tree-path-label {
  position: absolute;
  pointer-events: none;
}

.skill-tree-chart-ring {
  left: 50%;
  top: 50%;
  border: 1px solid rgba(216, 168, 67, 0.26);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 24px rgba(71, 215, 196, 0.04);
}

.skill-tree-chart-ring--outer {
  width: 88%;
  height: 88%;
}

.skill-tree-chart-ring--middle {
  width: 63%;
  height: 63%;
  border-color: rgba(71, 215, 196, 0.22);
}

.skill-tree-chart-ring--inner {
  width: 34%;
  height: 34%;
  border-color: rgba(255, 240, 181, 0.28);
}

.skill-tree-chart-axis {
  left: 50%;
  top: 50%;
  background: linear-gradient(90deg, transparent, rgba(216, 168, 67, 0.34), transparent);
  transform: translate(-50%, -50%);
  opacity: 0.72;
}

.skill-tree-chart-axis--horizontal {
  width: 91%;
  height: 1px;
}

.skill-tree-chart-axis--vertical {
  width: 1px;
  height: 91%;
  background: linear-gradient(180deg, transparent, rgba(216, 168, 67, 0.34), transparent);
}

.skill-tree-path-label {
  z-index: 4;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.36rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.72),
    0 0 16px rgba(0, 0, 0, 0.8);
}

.skill-tree-path-label--piracy {
  left: 20%;
  top: 15%;
  color: #ffc4b8;
}

.skill-tree-path-label--trade {
  right: 15%;
  top: 15%;
  color: #d9fff6;
}

.skill-tree-path-label--combat {
  left: 17%;
  bottom: 14%;
  color: #d8ebff;
}

.skill-tree-path-label--exploration {
  right: 12%;
  bottom: 14%;
  color: #ffe7a4;
}

.skill-tree-links,
.skill-tree-nodes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.skill-tree-links {
  z-index: 2;
}

.skill-link {
  fill: none;
  stroke: rgba(126, 137, 133, 0.48);
  stroke-width: 1.95;
  stroke-linecap: round;
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.84))
    drop-shadow(0 0 5px rgba(216, 168, 67, 0.12));
  vector-effect: non-scaling-stroke;
}

.skill-link[data-branch='piracy'] {
  stroke: rgba(201, 61, 58, 0.5);
}

.skill-link[data-branch='trade'] {
  stroke: rgba(71, 215, 196, 0.5);
}

.skill-link[data-branch='combat'] {
  stroke: rgba(99, 165, 238, 0.52);
}

.skill-link[data-branch='exploration'] {
  stroke: rgba(237, 200, 79, 0.52);
}

.skill-link.is-active {
  stroke: rgba(143, 231, 210, 0.9);
  stroke-width: 2.35;
}

.skill-link.is-learned {
  stroke: var(--skill-gold-bright);
  stroke-width: 2.85;
  filter:
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.78))
    drop-shadow(0 0 9px rgba(216, 168, 67, 0.55));
}

.skill-tree-nodes {
  z-index: 5;
}

.skill-tree-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  box-sizing: border-box;
  width: 220px;
  height: 220px;
  display: grid;
  grid-template-rows: 62px auto auto 38px auto;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 18px 22px;
  border: 2px solid rgba(255, 240, 181, 0.78);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 240, 181, 0.18), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(71, 215, 196, 0.14), transparent 63%),
    linear-gradient(180deg, rgba(18, 43, 45, 0.98), rgba(4, 14, 18, 0.99));
  color: var(--skill-text);
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow:
    inset 0 0 0 8px rgba(1, 8, 10, 0.74),
    inset 0 0 0 10px rgba(216, 168, 67, 0.24),
    0 0 44px rgba(216, 168, 67, 0.2),
    0 24px 42px rgba(0, 0, 0, 0.52);
}

.skill-tree-center::before,
.skill-tree-center::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.skill-tree-center::before {
  width: 320px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 168, 67, 0.82), transparent);
}

.skill-tree-center::after {
  width: 1px;
  height: 320px;
  background: linear-gradient(180deg, transparent, rgba(216, 168, 67, 0.82), transparent);
}

.skill-tree-center-ship {
  position: relative;
  width: 96px;
  height: 54px;
}

.skill-tree-center-ship::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 10px;
  bottom: 4px;
  height: 15px;
  border-radius: 0 0 34px 34px;
  background: linear-gradient(180deg, #614427, #180d08);
  clip-path: polygon(0 18%, 88% 18%, 100% 46%, 82% 100%, 12% 100%);
}

.skill-tree-center-ship::after {
  content: '';
  position: absolute;
  left: 29px;
  bottom: 18px;
  width: 48px;
  height: 34px;
  background:
    linear-gradient(90deg, transparent 48%, rgba(44, 30, 19, 0.72) 49% 54%, transparent 55%),
    linear-gradient(135deg, transparent 0 22%, rgba(245, 236, 207, 0.95) 23% 54%, transparent 55%),
    linear-gradient(45deg, transparent 0 32%, rgba(206, 198, 175, 0.85) 33% 62%, transparent 63%);
}

.skill-tree-center-level,
.skill-tree-center-name-label,
.skill-tree-rename-ship {
  color: #8fe7d2;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-center-name-label {
  color: rgba(237, 232, 204, 0.68);
}

.skill-tree-ship-name {
  box-sizing: border-box;
  width: 154px;
  height: 38px;
  border: 1px solid rgba(216, 168, 67, 0.48);
  border-radius: 50px;
  background: rgba(0, 7, 10, 0.68);
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  outline: none;
  padding: 0 12px;
  text-align: center;
}

.skill-tree-ship-name:focus {
  border-color: var(--skill-gold-bright);
  box-shadow: 0 0 0 3px rgba(71, 215, 196, 0.16);
}

.skill-tree-rename-ship {
  all: unset;
  box-sizing: border-box;
  min-width: 96px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(71, 215, 196, 0.46);
  border-radius: 50px;
  background: rgba(71, 215, 196, 0.14);
  color: #dffff7;
  cursor: pointer;
}

.skill-tree-rename-ship:hover,
.skill-tree-rename-ship:focus-visible {
  border-color: var(--skill-gold-bright);
  color: var(--skill-gold-bright);
}

.skill-tree-rename-ship:disabled {
  opacity: 0.52;
  cursor: default;
}

.skill-node {
  --node-color: var(--skill-gold);
  --node-glow: rgba(216, 168, 67, 0.28);
  all: unset;
  position: absolute;
  box-sizing: border-box;
  width: 88px;
  height: 88px;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 8px;
  border: 2px solid color-mix(in srgb, var(--node-color) 70%, #ffffff 10%);
  border-radius: 50%;
  background:
    conic-gradient(from 20deg, rgba(255, 255, 255, 0.18), transparent 14%, rgba(0, 0, 0, 0.24) 30%, rgba(255, 255, 255, 0.12) 46%, transparent 64%, rgba(0, 0, 0, 0.3) 82%, rgba(255, 255, 255, 0.18)),
    radial-gradient(circle at 42% 30%, rgba(255, 255, 255, 0.36), transparent 28%),
    radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--node-color) 70%, #ffffff 8%), color-mix(in srgb, var(--node-color) 42%, #02070a 58%) 68%);
  color: #f8f2df;
  text-align: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition:
    transform 170ms ease,
    color 170ms ease,
    opacity 170ms ease,
    box-shadow 170ms ease;
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.55),
    inset 0 0 22px rgba(255, 255, 255, 0.08),
    0 16px 18px rgba(0, 0, 0, 0.48),
    0 0 16px var(--node-glow);
}

.skill-node::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 240, 181, 0.18);
  border-radius: 50%;
  clip-path: polygon(50% 0, 82% 16%, 100% 50%, 82% 84%, 50% 100%, 18% 84%, 0 50%, 18% 16%);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 36%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.26), transparent 46%);
  pointer-events: none;
}

.skill-node.is-inner-ring {
  width: 76px;
  height: 76px;
  grid-template-rows: 38px minmax(0, 1fr);
  padding: 7px;
}

.skill-node[data-branch='piracy'] {
  --node-color: var(--skill-piracy);
  --node-glow: rgba(201, 61, 58, 0.34);
}

.skill-node[data-branch='trade'] {
  --node-color: var(--skill-trade);
  --node-glow: rgba(71, 215, 196, 0.34);
}

.skill-node[data-branch='combat'] {
  --node-color: var(--skill-combat);
  --node-glow: rgba(99, 165, 238, 0.36);
}

.skill-node[data-branch='exploration'] {
  --node-color: var(--skill-exploration);
  --node-glow: rgba(237, 200, 79, 0.36);
}

.skill-node-icon-ring {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 240, 181, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 44% 34%, rgba(255, 255, 255, 0.3), transparent 32%),
    radial-gradient(circle, rgba(255, 240, 181, 0.18), rgba(3, 13, 16, 0.72));
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.34);
}

.skill-node.is-inner-ring .skill-node-icon-ring {
  width: 36px;
  height: 36px;
}

.skill-node-icon {
  font-family: 'Cinzel', 'Apple Symbols', 'Segoe UI Symbol', serif;
  font-size: 1.38rem;
  line-height: 1;
  color: currentColor;
  text-shadow: 0 0 12px currentColor;
}

.skill-node-name {
  position: relative;
  z-index: 2;
  max-width: 100%;
  color: inherit;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.02;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.skill-node.is-inner-ring .skill-node-name {
  font-size: 0.5rem;
}

.skill-node-branch,
.skill-node-effect {
  display: none;
}

.skill-node:hover,
.skill-node:focus-visible,
.skill-node.is-selected {
  color: #ffffff;
  transform: translate(-50%, -58%) scale(1.08);
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.42),
    inset 0 0 24px rgba(255, 255, 255, 0.12),
    0 24px 22px rgba(0, 0, 0, 0.52),
    0 0 28px var(--node-glow);
}

.skill-node.is-learned {
  border-color: var(--skill-gold-bright);
  color: var(--skill-gold-bright);
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.48),
    inset 0 0 26px rgba(255, 240, 181, 0.14),
    0 18px 20px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(216, 168, 67, 0.54);
}

.skill-node.is-available {
  animation: skill-node-ready 1700ms ease-in-out infinite;
}

.skill-node.is-locked {
  color: #767f81;
  cursor: not-allowed;
  opacity: 0.62;
  filter: grayscale(0.5);
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.62),
    0 10px 13px rgba(0, 0, 0, 0.44);
}

@keyframes skill-node-ready {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 5px rgba(1, 7, 10, 0.5),
      inset 0 0 22px rgba(255, 255, 255, 0.08),
      0 16px 18px rgba(0, 0, 0, 0.48),
      0 0 16px var(--node-glow);
  }
  50% {
    box-shadow:
      inset 0 0 0 5px rgba(1, 7, 10, 0.42),
      inset 0 0 28px rgba(255, 255, 255, 0.14),
      0 20px 22px rgba(0, 0, 0, 0.52),
      0 0 34px var(--node-glow);
  }
}

@media (prefers-reduced-motion: reduce) {
  .skill-tree-canvas,
  .skill-node,
  .skill-node.is-available {
    animation: none;
    transition: none;
  }
}

@media (max-width: 1100px) {
  .skill-tree-shell {
    height: 100%;
    overflow: auto;
  }

  .skill-tree-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }

  .skill-tree-heading {
    grid-column: 1;
    justify-self: start;
    text-align: left;
  }

  .skill-tree-points {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .skill-tree-close {
    grid-column: 2;
    grid-row: 1;
  }

  .skill-tree-body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "detail";
  }

  .skill-tree-map-frame {
    min-height: 560px;
  }

  .skill-tree-detail {
    max-height: 420px;
  }
}

@media (max-width: 700px) {
  .skill-tree-shell {
    grid-template-rows: auto minmax(0, 1fr);
    padding: 16px;
  }

  .skill-tree-heading h2 {
    font-size: 3rem;
  }

  .skill-tree-points {
    min-width: 230px;
    grid-template-columns: auto 52px auto;
  }

  .skill-tree-points #skill-tree-points-value {
    width: 52px;
    height: 52px;
    font-size: 1.7rem;
  }

  .skill-tree-map-frame {
    min-height: 460px;
  }

  .skill-tree-canvas {
    width: 1080px;
    height: 760px;
    margin-left: -540px;
    margin-top: -380px;
  }

  .skill-tree-path-label {
    font-size: 1rem;
  }

  .skill-node {
    width: 78px;
    height: 78px;
    grid-template-rows: 38px minmax(0, 1fr);
  }

  .skill-node.is-inner-ring {
    width: 68px;
    height: 68px;
  }

  .skill-node-icon-ring {
    width: 36px;
    height: 36px;
  }

  .skill-node-name {
    font-size: 0.48rem;
  }

  .skill-tree-center {
    width: 174px;
    height: 174px;
    grid-template-rows: 40px auto auto 34px auto;
  }

  .skill-tree-center::before {
    width: 250px;
  }

  .skill-tree-center::after {
    height: 250px;
  }

  .skill-tree-center-ship {
    width: 74px;
    height: 38px;
  }

  .skill-tree-ship-name {
    width: 124px;
    height: 34px;
    font-size: 0.78rem;
  }
}

/* Skill tree cleanup from browser comments: web-only, fixed view, spaced gem nodes. */
.skill-tree-shell {
  grid-template-rows: 94px minmax(0, 1fr);
  gap: 4px;
  padding: 18px 28px 26px;
}

.skill-tree-header {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
}

.skill-tree-heading {
  grid-column: 1;
  justify-self: center;
  text-align: center;
  transform: translateX(110px);
}

.skill-tree-body {
  grid-template-columns: 1fr;
  grid-template-areas: "map";
  gap: 0;
}

.skill-tree-detail {
  display: none !important;
}

.skill-tree-map-frame {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.skill-tree-map-frame.is-dragging {
  cursor: default;
}

.skill-tree-map-frame::before {
  inset: 4%;
  border-color: rgba(216, 168, 67, 0.18);
}

.skill-tree-map-frame::after {
  display: none;
}

.skill-tree-map-controls {
  display: none !important;
}

.skill-tree-canvas {
  width: min(1780px, calc(100vw - 76px));
  height: min(800px, calc(100vh - 132px));
  margin: 0;
  transform: translate(-50%, -50%);
}

.skill-tree-web-glow {
  inset: 5%;
}

.skill-tree-chart-ring--outer {
  width: 94%;
  height: 94%;
}

.skill-tree-chart-ring--middle {
  width: 70%;
  height: 70%;
}

.skill-tree-chart-ring--inner {
  width: 40%;
  height: 40%;
}

.skill-tree-chart-axis--horizontal {
  width: 96%;
}

.skill-tree-chart-axis--vertical {
  height: 96%;
}

.skill-node {
  width: 80px;
  height: 80px;
  grid-template-rows: 40px minmax(0, 1fr);
  padding: 7px;
}

.skill-node.is-inner-ring {
  width: 72px;
  height: 72px;
  grid-template-rows: 34px minmax(0, 1fr);
}

.skill-node-icon-ring {
  width: 38px;
  height: 38px;
  border-color: color-mix(in srgb, var(--node-color) 62%, #fff0b5 38%);
}

.skill-node.is-inner-ring .skill-node-icon-ring {
  width: 32px;
  height: 32px;
}

.skill-node-icon {
  font-size: 1.16rem;
  color: color-mix(in srgb, var(--node-color) 62%, #fff8db 38%);
}

.skill-node-name {
  font-size: 0.5rem;
}

.skill-node.is-inner-ring .skill-node-name {
  font-size: 0.45rem;
}

.skill-node.is-locked {
  color: color-mix(in srgb, var(--node-color) 68%, #f7efd2 32%);
  cursor: pointer;
  opacity: 0.88;
  filter: none;
  border-color: color-mix(in srgb, var(--node-color) 62%, #f7efd2 12%);
  box-shadow:
    inset 0 0 0 5px rgba(1, 7, 10, 0.62),
    inset 0 0 20px color-mix(in srgb, var(--node-color) 20%, transparent 80%),
    0 12px 15px rgba(0, 0, 0, 0.46),
    0 0 12px color-mix(in srgb, var(--node-color) 30%, transparent 70%);
}

.skill-node.is-locked .skill-node-icon-ring {
  border-color: color-mix(in srgb, var(--node-color) 58%, #f7efd2 20%);
  background:
    radial-gradient(circle at 44% 34%, color-mix(in srgb, var(--node-color) 28%, #ffffff 16%), transparent 34%),
    radial-gradient(circle, color-mix(in srgb, var(--node-color) 24%, transparent 76%), rgba(3, 13, 16, 0.78));
}

.skill-node.is-locked .skill-node-icon,
.skill-node.is-locked .skill-node-name {
  color: color-mix(in srgb, var(--node-color) 74%, #f7efd2 26%);
}

@media (max-width: 1100px) {
  .skill-tree-heading {
    transform: none;
  }

  .skill-tree-body {
    grid-template-areas: "map";
  }

  .skill-tree-map-frame {
    min-height: 560px;
  }
}

@media (max-width: 700px) {
  .skill-tree-canvas {
    width: min(1180px, calc(100vw - 32px));
    height: min(760px, calc(100vh - 156px));
  }
}

/* Skill tree final chrome removal: direct web, styled stat tooltip. */
.skill-tree-overlay {
  overflow: hidden;
}

.skill-tree-shell,
.skill-tree-header,
.skill-tree-body,
.skill-tree-map-frame {
  display: contents !important;
}

.skill-tree-heading,
.skill-tree-kicker,
.skill-tree-heading h2,
.skill-tree-center {
  display: none !important;
}

.skill-tree-map-frame::before,
.skill-tree-map-frame::after {
  display: none !important;
}

.skill-tree-points {
  position: absolute;
  top: 18px;
  right: 96px;
  z-index: 6;
}

.skill-tree-close {
  position: absolute;
  top: 18px;
  right: 28px;
  z-index: 7;
}

.skill-tree-canvas {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 2;
  width: min(1820px, calc(100vw - 44px));
  height: min(850px, calc(100vh - 82px));
  margin: 0;
  transform: translate(-50%, -50%);
}

.skill-node-name {
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  text-wrap: balance;
}

.skill-node.has-long-name .skill-node-name {
  font-size: 0.42rem;
  line-height: 1.06;
}

.skill-node.is-inner-ring.has-long-name .skill-node-name {
  font-size: 0.38rem;
}

.skill-tree-tooltip {
  --tooltip-color: var(--skill-gold);
  position: absolute;
  z-index: 30;
  box-sizing: border-box;
  width: min(270px, 26vw);
  min-width: 210px;
  display: grid;
  gap: 7px;
  padding: 12px 14px 13px;
  border: 1px solid color-mix(in srgb, var(--tooltip-color) 58%, #fff0b5 18%);
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 30%),
    radial-gradient(circle at 14% 0%, color-mix(in srgb, var(--tooltip-color) 20%, transparent 80%), transparent 52%),
    linear-gradient(180deg, rgba(5, 18, 22, 0.97), rgba(1, 7, 10, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 181, 0.08),
    inset 0 0 28px color-mix(in srgb, var(--tooltip-color) 10%, transparent 90%),
    0 18px 34px rgba(0, 0, 0, 0.55),
    0 0 18px color-mix(in srgb, var(--tooltip-color) 20%, transparent 80%);
  color: var(--skill-text);
  pointer-events: none;
  transform: translate(16px, -50%);
}

.skill-tree-tooltip[hidden] {
  display: none !important;
}

.skill-tree-tooltip.is-left {
  transform: translate(calc(-100% - 16px), -50%);
}

.skill-tree-tooltip.is-above {
  transform: translate(16px, calc(-100% - 14px));
}

.skill-tree-tooltip.is-left.is-above {
  transform: translate(calc(-100% - 16px), calc(-100% - 14px));
}

.skill-tree-tooltip[data-branch='piracy'] {
  --tooltip-color: var(--skill-piracy);
}

.skill-tree-tooltip[data-branch='trade'] {
  --tooltip-color: var(--skill-trade);
}

.skill-tree-tooltip[data-branch='combat'] {
  --tooltip-color: var(--skill-combat);
}

.skill-tree-tooltip[data-branch='exploration'] {
  --tooltip-color: var(--skill-exploration);
}

.skill-tree-tooltip-branch,
.skill-tree-tooltip-status {
  color: color-mix(in srgb, var(--tooltip-color) 62%, #fff0b5 38%);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-tooltip-title {
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.08;
  text-transform: uppercase;
}

.skill-tree-tooltip-effect {
  padding: 8px 10px;
  border-left: 3px solid var(--tooltip-color);
  background: color-mix(in srgb, var(--tooltip-color) 12%, rgba(0, 0, 0, 0.72) 88%);
  color: #fff6cf;
  font-family: 'Courier New', monospace;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.18;
}

.skill-tree-tooltip-status {
  color: rgba(237, 232, 204, 0.72);
  font-size: 0.64rem;
}

@media (max-width: 700px) {
  .skill-tree-points {
    top: 12px;
    right: 78px;
    min-width: 190px;
    transform: scale(0.88);
    transform-origin: right top;
  }

  .skill-tree-close {
    top: 12px;
    right: 16px;
    transform: scale(0.88);
    transform-origin: right top;
  }

  .skill-tree-tooltip {
    width: min(240px, 72vw);
  }
}

/* Skill tree structural repair: one readable modal, one real tree surface. */
.skill-tree-overlay {
  --skill-bg: #02070a;
  --skill-panel: rgba(4, 14, 18, 0.94);
  --skill-panel-strong: rgba(2, 8, 11, 0.98);
  --skill-line: rgba(226, 174, 79, 0.36);
  --skill-gold: #d9a843;
  --skill-gold-bright: #fff0b5;
  --skill-text: #f7efd2;
  --skill-muted: rgba(237, 232, 204, 0.7);
  --skill-piracy: #c84b45;
  --skill-trade: #47d7c4;
  --skill-combat: #73b4ff;
  --skill-exploration: #edc84f;
  overflow: hidden;
  background: #02070a;
}

.skill-tree-overlay .skill-tree-shell {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 1.2vw, 18px);
  padding: clamp(14px, 1.6vw, 28px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(216, 168, 67, 0.08), transparent 18%, transparent 82%, rgba(71, 215, 196, 0.06)),
    linear-gradient(180deg, rgba(2, 7, 10, 0.05), rgba(2, 7, 10, 0.72));
}

.skill-tree-overlay .skill-tree-header {
  position: relative;
  z-index: 5;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 1vw, 16px);
  min-height: clamp(50px, 5.4vw, 72px);
  padding: 0;
}

.skill-tree-overlay .skill-tree-heading {
  display: block !important;
  min-width: 0;
  justify-self: start;
  text-align: left;
  transform: none !important;
}

.skill-tree-overlay .skill-tree-kicker {
  display: block !important;
  color: var(--skill-trade);
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(0.68rem, 0.8vw, 0.86rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.skill-tree-overlay .skill-tree-heading h2 {
  display: block !important;
  margin: 4px 0 0;
  color: var(--skill-gold-bright);
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(2rem, 3.4vw, 3.9rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.82),
    0 0 20px rgba(216, 168, 67, 0.28);
}

.skill-tree-overlay .skill-tree-points {
  position: absolute !important;
  top: 0 !important;
  right: clamp(64px, 5vw, 82px) !important;
  z-index: 6;
  transform: none !important;
  transform-origin: center !important;
  box-sizing: border-box;
  min-width: clamp(210px, 17vw, 286px);
  min-height: clamp(52px, 4.8vw, 66px);
  display: grid !important;
  grid-template-columns: auto clamp(48px, 3.8vw, 60px) auto;
  align-items: center;
  gap: clamp(8px, 0.75vw, 14px);
  padding: 7px 14px;
  border: 1px solid rgba(216, 168, 67, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.07), rgba(0, 0, 0, 0.18)),
    rgba(4, 14, 18, 0.92);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 240, 181, 0.06);
}

.skill-tree-overlay .skill-tree-points #skill-tree-points-value {
  width: clamp(48px, 3.8vw, 60px);
  height: clamp(48px, 3.8vw, 60px);
}

.skill-tree-overlay .skill-tree-close {
  all: unset;
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  z-index: 7;
  box-sizing: border-box;
  width: clamp(48px, 4vw, 60px);
  height: clamp(48px, 4vw, 60px);
  display: grid !important;
  place-items: center;
  border: 1px solid rgba(216, 168, 67, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.08), rgba(0, 0, 0, 0.22)),
    rgba(4, 14, 18, 0.94);
  color: var(--skill-gold-bright);
  font-size: clamp(1.6rem, 2vw, 2.1rem);
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
}

.skill-tree-overlay .skill-tree-body {
  min-height: 0;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "map";
  gap: 0;
}

.skill-tree-overlay .skill-tree-detail {
  grid-area: detail;
  min-width: 0;
  min-height: 0;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: clamp(12px, 1vw, 16px);
  overflow: hidden;
  border: 1px solid rgba(216, 168, 67, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.055), rgba(0, 0, 0, 0.16)),
    rgba(4, 14, 18, 0.94);
  box-shadow:
    0 20px 42px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 240, 181, 0.05);
}

.skill-tree-overlay .skill-tree-detail::before {
  display: none !important;
}

.skill-tree-overlay .skill-tree-vessel-panel {
  display: grid;
  gap: 10px;
}

.skill-tree-overlay .skill-tree-ship-portrait {
  min-height: clamp(112px, 11vh, 160px);
}

.skill-tree-overlay .skill-tree-path-status {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid rgba(71, 215, 196, 0.30);
  border-radius: 6px;
  background: rgba(71, 215, 196, 0.08);
  color: #dffff7;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.skill-tree-overlay .skill-tree-stats {
  display: grid;
  gap: 5px;
}

.skill-tree-overlay .skill-tree-stat-row {
  min-height: 26px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(216, 168, 67, 0.15);
}

.skill-tree-overlay .skill-tree-detail-copy {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.skill-tree-overlay .skill-tree-detail-branch {
  display: block;
  color: var(--skill-trade);
  font-size: 0.74rem;
  letter-spacing: 0.10em;
}

.skill-tree-overlay .skill-tree-detail h3 {
  margin: 0;
  color: var(--skill-gold-bright);
  font-size: clamp(1.35rem, 1.7vw, 2rem);
  line-height: 1.05;
}

.skill-tree-overlay .skill-tree-detail p {
  margin: 0;
  color: var(--skill-muted);
  font-size: clamp(0.9rem, 0.92vw, 1rem);
  line-height: 1.34;
}

.skill-tree-overlay .skill-tree-detail-effect {
  padding: 11px 12px;
  border-left: 4px solid var(--skill-trade);
  border-radius: 0 6px 6px 0;
  background: rgba(71, 215, 196, 0.10);
  color: var(--skill-gold-bright);
  font-family: 'Courier New', monospace;
  font-size: clamp(0.84rem, 0.9vw, 0.98rem);
  font-weight: 900;
}

.skill-tree-overlay .skill-tree-detail-prereq {
  min-height: 38px;
  color: rgba(237, 232, 204, 0.68);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.28;
}

.skill-tree-overlay .skill-tree-learn {
  min-height: 48px;
  margin-top: auto;
  border-radius: 6px;
}

.skill-tree-overlay .skill-tree-map-frame {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: block !important;
  overflow: hidden;
  border: 1px solid rgba(216, 168, 67, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(201, 75, 69, 0.08), transparent 28%, transparent 72%, rgba(71, 215, 196, 0.07)),
    linear-gradient(180deg, rgba(216, 168, 67, 0.04), transparent 44%, rgba(115, 180, 255, 0.06)),
    linear-gradient(90deg, rgba(216, 168, 67, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(216, 168, 67, 0.055) 1px, transparent 1px),
    rgba(2, 8, 12, 0.90);
  background-size: auto, auto, 72px 72px, 72px 72px, auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    inset 0 0 110px rgba(0, 0, 0, 0.46),
    0 24px 48px rgba(0, 0, 0, 0.36);
  cursor: default;
}

.skill-tree-overlay .skill-tree-map-frame::before {
  content: "";
  position: absolute;
  inset: 6%;
  display: block !important;
  border: 1px solid rgba(216, 168, 67, 0.18);
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 2px rgba(71, 215, 196, 0.04),
    0 0 70px rgba(216, 168, 67, 0.07);
}

.skill-tree-overlay .skill-tree-map-frame::after {
  display: none !important;
}

.skill-tree-overlay .skill-tree-map-controls {
  display: none !important;
}

.skill-tree-overlay .skill-tree-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: calc(100% - 48px);
  height: calc(100% - 48px);
  margin: 0;
  transform: translate(-50%, -50%) !important;
  transform-origin: center center;
}

.skill-tree-overlay .skill-tree-web-glow {
  inset: 6%;
}

.skill-tree-overlay .skill-tree-chart-ring--outer {
  width: 93%;
  height: 93%;
}

.skill-tree-overlay .skill-tree-chart-ring--middle {
  width: 68%;
  height: 68%;
}

.skill-tree-overlay .skill-tree-chart-ring--inner {
  width: 38%;
  height: 38%;
}

.skill-tree-overlay .skill-tree-path-label {
  display: block !important;
  font-size: clamp(0.86rem, 1vw, 1.24rem);
  letter-spacing: 0.08em;
}

.skill-tree-overlay .skill-tree-center {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  z-index: 6;
  box-sizing: border-box;
  width: clamp(162px, 12vw, 220px);
  height: clamp(162px, 12vw, 220px);
  display: grid !important;
  grid-template-rows: auto 44px auto 34px auto;
  align-content: center;
  justify-items: center;
  gap: 5px;
  padding: clamp(14px, 1.1vw, 20px);
  border: 2px solid rgba(255, 240, 181, 0.75);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 240, 181, 0.18), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(71, 215, 196, 0.14), transparent 63%),
    linear-gradient(180deg, rgba(18, 43, 45, 0.98), rgba(4, 14, 18, 0.99));
  color: var(--skill-text);
  text-align: center;
  transform: translate(-50%, -50%) !important;
  box-shadow:
    inset 0 0 0 7px rgba(1, 8, 10, 0.74),
    inset 0 0 0 9px rgba(216, 168, 67, 0.22),
    0 0 38px rgba(216, 168, 67, 0.2),
    0 22px 38px rgba(0, 0, 0, 0.52);
}

.skill-tree-overlay .skill-tree-center::before,
.skill-tree-overlay .skill-tree-center::after {
  display: none !important;
}

.skill-tree-overlay .skill-tree-center-level,
.skill-tree-overlay .skill-tree-center-name-label,
.skill-tree-overlay .skill-tree-rename-ship {
  display: block;
}

.skill-tree-overlay .skill-tree-center-ship {
  display: block !important;
}

.skill-tree-overlay .skill-tree-ship-name {
  width: min(146px, 76%);
  height: 34px;
  font-size: clamp(0.76rem, 0.78vw, 0.92rem);
}

.skill-tree-overlay .skill-node {
  width: clamp(68px, 4.8vw, 86px);
  height: clamp(68px, 4.8vw, 86px);
  grid-template-rows: clamp(32px, 2.6vw, 42px) minmax(0, 1fr);
  padding: 7px;
}

.skill-tree-overlay .skill-node.is-inner-ring {
  width: clamp(62px, 4.2vw, 76px);
  height: clamp(62px, 4.2vw, 76px);
  grid-template-rows: clamp(29px, 2.2vw, 36px) minmax(0, 1fr);
}

.skill-tree-overlay .skill-node-icon-ring {
  width: clamp(32px, 2.6vw, 42px);
  height: clamp(32px, 2.6vw, 42px);
}

.skill-tree-overlay .skill-node.is-inner-ring .skill-node-icon-ring {
  width: clamp(28px, 2.2vw, 34px);
  height: clamp(28px, 2.2vw, 34px);
}

.skill-tree-overlay .skill-node-name {
  max-width: 100%;
  font-size: clamp(0.42rem, 0.46vw, 0.56rem);
  line-height: 1.04;
  overflow-wrap: anywhere;
}

.skill-tree-overlay .skill-node.has-long-name .skill-node-name {
  font-size: clamp(0.36rem, 0.40vw, 0.46rem);
}

.skill-tree-overlay .skill-node {
  width: clamp(120px, 7.4vw, 154px);
  height: clamp(120px, 7.4vw, 154px);
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: var(--skill-text);
  overflow: visible;
  box-shadow: none;
}

.skill-tree-overlay .skill-node.is-inner-ring {
  width: clamp(106px, 6.5vw, 136px);
  height: clamp(106px, 6.5vw, 136px);
}

.skill-tree-overlay .skill-node::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 5%;
  border: 2px solid color-mix(in srgb, var(--node-color) 62%, #fff0b5 24%);
  border-radius: 50%;
  background: transparent;
  clip-path: none;
  pointer-events: none;
  opacity: 0.72;
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.28),
    0 0 18px color-mix(in srgb, var(--node-color) 30%, transparent 70%);
}

.skill-tree-overlay .skill-node::after {
  content: "";
  position: absolute;
  z-index: 4;
  right: 7%;
  bottom: 8%;
  width: 20%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.72);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.skill-tree-overlay .skill-node-image-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  border-radius: 50%;
  filter:
    drop-shadow(0 16px 18px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 14px color-mix(in srgb, var(--node-color) 24%, transparent 76%));
  transition:
    filter 170ms ease,
    opacity 170ms ease,
    transform 170ms ease;
}

.skill-tree-overlay .skill-node-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.skill-tree-overlay .skill-node-icon-ring,
.skill-tree-overlay .skill-node-icon,
.skill-tree-overlay .skill-node-name,
.skill-tree-overlay .skill-node-branch,
.skill-tree-overlay .skill-node-effect {
  display: none !important;
}

.skill-tree-overlay .skill-node:hover,
.skill-tree-overlay .skill-node:focus-visible,
.skill-tree-overlay .skill-node.is-selected {
  color: #ffffff;
  transform: translate(-50%, -59%) scale(1.1);
  box-shadow: none;
}

.skill-tree-overlay .skill-node:hover .skill-node-image-wrap,
.skill-tree-overlay .skill-node:focus-visible .skill-node-image-wrap,
.skill-tree-overlay .skill-node.is-selected .skill-node-image-wrap {
  filter:
    drop-shadow(0 24px 22px rgba(0, 0, 0, 0.54))
    drop-shadow(0 0 28px color-mix(in srgb, var(--node-color) 45%, transparent 55%));
}

.skill-tree-overlay .skill-node.is-learned::before {
  inset: 0;
  border-color: var(--skill-gold-bright);
  opacity: 1;
  box-shadow:
    inset 0 0 20px rgba(255, 240, 181, 0.18),
    0 0 24px rgba(216, 168, 67, 0.58);
}

.skill-tree-overlay .skill-node.is-learned::after {
  opacity: 1;
  transform: scale(1);
  border: 1px solid rgba(255, 240, 181, 0.9);
  background:
    radial-gradient(circle at 38% 34%, #ffffff, transparent 32%),
    radial-gradient(circle, var(--skill-gold-bright), var(--skill-gold) 72%);
  box-shadow: 0 0 16px rgba(216, 168, 67, 0.62);
}

.skill-tree-overlay .skill-node.is-available::before {
  border-color: color-mix(in srgb, var(--node-color) 52%, #ffffff 48%);
  opacity: 1;
}

.skill-tree-overlay .skill-node.is-locked {
  opacity: 0.92;
  filter: none;
}

.skill-tree-overlay .skill-node.is-locked .skill-node-image-wrap {
  opacity: 0.66;
  filter:
    grayscale(0.32)
    saturate(0.8)
    brightness(0.72)
    drop-shadow(0 10px 14px rgba(0, 0, 0, 0.48));
}

.skill-tree-overlay .skill-node.is-locked::before {
  border-color: color-mix(in srgb, var(--node-color) 42%, #f7efd2 10%);
  opacity: 0.46;
  box-shadow: none;
}

@media (max-width: 680px) {
  .skill-tree-overlay .skill-node {
    width: clamp(84px, 20vw, 110px);
    height: clamp(84px, 20vw, 110px);
  }

  .skill-tree-overlay .skill-node.is-inner-ring {
    width: clamp(76px, 18vw, 98px);
    height: clamp(76px, 18vw, 98px);
  }
}

@media (max-width: 980px) {
  .skill-tree-overlay .skill-tree-shell {
    overflow: auto;
  }

  .skill-tree-overlay .skill-tree-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .skill-tree-overlay .skill-tree-points {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .skill-tree-overlay .skill-tree-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "map"
      "detail";
  }

  .skill-tree-overlay .skill-tree-map-frame {
    min-height: 560px;
  }

  .skill-tree-overlay .skill-tree-detail {
    max-height: 420px;
  }
}

@media (max-width: 680px) {
  .skill-tree-overlay .skill-tree-shell {
    padding: 12px;
  }

  .skill-tree-overlay .skill-tree-heading h2 {
    font-size: 2.1rem;
  }

  .skill-tree-overlay .skill-tree-points {
    min-width: 0;
    width: calc(100% - 64px);
    right: 54px !important;
    grid-template-columns: auto 46px auto;
  }

  .skill-tree-overlay .skill-tree-points #skill-tree-points-value {
    width: 46px;
    height: 46px;
  }

  .skill-tree-overlay .skill-tree-map-frame {
    min-height: 500px;
  }

  .skill-tree-overlay .skill-tree-canvas {
    width: calc(100% - 26px);
    height: calc(100% - 26px);
  }
}

.hud-chip-label {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-text-muted);
}

.hud-chip-value {
  font-family: 'Cinzel', serif;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--hud-text);
  letter-spacing: 0.03em;
}

/* ─── SHIP HEALTH HUD (override old absolute positioning) ─── */
#hud-bar #ship-health-hud,
body.app-playing.boat-mode #hud-bar #ship-health-hud {
  position: static !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  width: auto !important;
  min-width: 720px !important;
  max-width: 960px !important;
  padding: 20px 42px 22px !important;
  border-radius: var(--hud-r) !important;
  border: 0 !important;
  border-left: 1px solid var(--hud-rim-subtle) !important;
  border-right: 1px solid var(--hud-rim-subtle) !important;
  background: var(--hud-glass) !important;
  backdrop-filter: var(--hud-blur) !important;
  -webkit-backdrop-filter: var(--hud-blur) !important;
  box-shadow: var(--hud-shadow) !important;
  color: var(--hud-text) !important;
  pointer-events: all !important;
  z-index: auto !important;
  display: flex !important;
  flex-direction: column;
  gap: 18px;
}

#hud-bar .ship-health-meter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

#hud-bar .ship-condition-meter {
  min-width: 0;
}

/* Must override the .hidden rule's display:none !important by removing hidden class via JS —
   but we need the element to appear as flex when not hidden */
#hud-bar #ship-health-hud.hidden {
  display: none !important;
}

#hud-bar .ship-health-hud-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 0;
}

#hud-bar .ship-health-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#hud-bar .ship-health-value {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--hud-text);
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#hud-bar .ship-health-track,
#hud-bar .ship-morale-track {
  height: 21px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: none !important;
  box-shadow: none !important;
  overflow: hidden;
}

#hud-bar .ship-health-fill,
#hud-bar .ship-morale-fill {
  height: 100% !important;
  border-radius: 999px;
  transition: transform 300ms ease, background 300ms ease;
  transform-origin: left center;
}

#hud-bar .ship-health-fill {
  background: linear-gradient(90deg, #2cc76a, #50e88a) !important;
}

#hud-bar .ship-morale-fill {
  background: linear-gradient(90deg, #38bdf8, #2cc76a) !important;
}

#hud-bar .ship-health-hud.low .ship-health-fill {
  background: linear-gradient(90deg, var(--hud-amber), #f7d06a) !important;
}

#hud-bar .ship-health-hud.critical .ship-health-fill {
  background: linear-gradient(90deg, var(--hud-red), #f97316) !important;
}

#hud-bar .ship-health-hud.morale-low .ship-morale-fill {
  background: linear-gradient(90deg, var(--hud-amber), #f7d06a) !important;
}

#hud-bar .ship-health-hud.morale-critical .ship-morale-fill,
#hud-bar .ship-health-hud.mutiny .ship-morale-fill {
  background: linear-gradient(90deg, var(--hud-red), #fb7185) !important;
}

#hud-bar .ship-health-hud.mutiny {
  border-left-color: rgba(248, 113, 113, 0.62) !important;
  border-right-color: rgba(248, 113, 113, 0.62) !important;
  box-shadow:
    var(--hud-shadow),
    0 0 26px rgba(220, 38, 38, 0.24) !important;
}

#hud-bar .ship-health-hud.morale-warning {
  border-left-color: rgba(248, 113, 113, 0.72) !important;
  border-right-color: rgba(248, 113, 113, 0.72) !important;
  box-shadow:
    var(--hud-shadow),
    0 0 30px rgba(220, 38, 38, 0.3) !important;
}

#hud-bar .crew-morale-warning {
  min-height: 64px;
  margin-top: 0;
  padding: 15px 24px;
  border-radius: var(--hud-r);
  border: 1px solid rgba(248, 113, 113, 0.72);
  background:
    linear-gradient(180deg, rgba(127, 29, 29, 0.94), rgba(69, 10, 10, 0.9)),
    rgba(69, 10, 10, 0.9);
  box-shadow:
    0 0 24px rgba(220, 38, 38, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: #fff7ed;
  font-family: 'Cinzel', serif;
  font-size: 1.78rem;
  font-weight: 700;
  line-height: 1.08;
}

@media (max-width: 760px) {
  #hud-bar #ship-health-hud,
  body.app-playing.boat-mode #hud-bar #ship-health-hud {
    min-width: min(96vw, 580px) !important;
    max-width: min(96vw, 580px) !important;
    padding: 16px 20px 18px !important;
  }

  #hud-bar .ship-health-meter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #hud-bar .crew-morale-warning {
    min-height: 54px;
    padding: 12px 16px;
    font-size: 1.2rem;
  }
}

/* ─── CARGO HUD ─── */
.hud-cargo {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 210px;
  max-width: 270px;
  padding: 9px 15px 10px;
  border-radius: var(--hud-r);
  border: 0;
  border-left: 1px solid var(--hud-rim-subtle);
  border-right: 1px solid var(--hud-rim-subtle);
  background: var(--hud-glass);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
}

body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo {
  position: fixed;
  top: calc(var(--hud-edge-size) + 10px);
  right: calc(var(--hud-gold-size) + 18px);
  z-index: 360;
  border: 1px solid var(--hud-rim-subtle);
}

.hud-cargo.hidden {
  display: none !important;
}

.player-death-banner {
  position: fixed;
  left: 50%;
  top: 33%;
  z-index: 2501;
  width: min(96%, 1600px);
  color: rgba(238, 248, 244, 0.96);
  font-family: 'Cinzel', serif;
  font-size: clamp(5.5rem, 13vw, 12rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.88;
  text-align: center;
  text-shadow:
    0 5px 0 rgba(4, 9, 11, 0.56),
    0 20px 48px rgba(0, 0, 0, 0.74),
    0 0 30px rgba(231, 184, 93, 0.16);
  text-transform: uppercase;
  transform: translate(-50%, -50%);
  overflow-wrap: anywhere;
  pointer-events: none;
}

.player-death-banner.hidden {
  display: none !important;
}

.player-death-message {
  position: fixed;
  left: 50%;
  top: calc(33% + clamp(82px, 9vw, 146px));
  z-index: 2501;
  width: min(760px, calc(100% - 40px));
  color: rgba(238, 248, 244, 0.9);
  font-family: 'Cinzel', serif;
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  font-weight: 600;
  line-height: 1.28;
  text-align: center;
  text-shadow:
    0 8px 28px rgba(0, 0, 0, 0.76),
    0 1px 0 rgba(4, 9, 11, 0.76);
  transform: translateX(-50%);
  pointer-events: none;
}

.player-death-message.hidden {
  display: none !important;
}

.player-death-panel {
  position: fixed;
  left: 50%;
  top: calc(33% + clamp(88px, 10vw, 160px));
  z-index: 2502;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(280px, calc(100% - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--hud-text);
  transform: translateX(-50%);
  pointer-events: all;
}

body.player-death-mutiny .player-death-panel {
  top: calc(33% + clamp(154px, 15vw, 232px));
}

.player-death-panel.hidden {
  display: none !important;
}

.player-respawn-button {
  width: 100%;
  min-height: 58px;
  padding: 0 24px;
  border-radius: var(--hud-r);
  border: 1px solid var(--hud-rim-active);
  background: rgba(6, 13, 16, 0.84);
  box-shadow: var(--hud-shadow);
  color: var(--hud-text);
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background var(--hud-ease),
    border-color var(--hud-ease),
    color var(--hud-ease),
    opacity var(--hud-ease);
}

.player-respawn-button:not(:disabled):hover {
  background: rgba(231, 184, 93, 0.22);
  color: var(--hud-gold);
}

.player-respawn-button:disabled {
  cursor: default;
  opacity: 0.56;
}

@media (max-width: 620px) {
  .player-death-banner {
    top: 31%;
    width: calc(100% - 24px);
    font-size: clamp(3.2rem, 18vw, 6.5rem);
  }

  .player-death-panel {
    top: calc(31% + 88px);
    width: min(240px, calc(100% - 32px));
  }

  .player-death-message {
    top: calc(31% + 76px);
    width: calc(100% - 30px);
    font-size: clamp(0.95rem, 4vw, 1.15rem);
  }

  body.player-death-mutiny .player-death-panel {
    top: calc(31% + 156px);
  }
}

.hud-cargo-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.hud-cargo-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-cargo-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--hud-text);
  line-height: 1.4;
}

.hud-cargo-item-name {
  color: var(--hud-gold);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.hud-cargo-item-amt {
  flex: 0 0 auto;
  color: var(--hud-text-muted);
  font-size: 0.78rem;
}

.hud-cargo-item--empty .hud-cargo-item-name,
.hud-cargo-item--empty .hud-cargo-item-amt {
  color: rgba(229, 210, 167, 0.44);
}

.hud-cargo-item--empty .hud-cargo-item-name {
  font-weight: 500;
}

.hud-cargo-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-top: 5px;
  margin-top: 2px;
  border-top: 1px solid rgba(210, 168, 72, 0.14);
}

.hud-cargo-value-row.hidden {
  display: none !important;
}

.hud-cargo-est-value {
  font-family: 'Cinzel', serif;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--hud-gold);
  letter-spacing: 0.02em;
}

/* ─── EXPERIENCE + GOLD — top right ─── */
.hud-xp-pill,
body.app-playing.boat-mode #hud-bar .hud-xp-pill {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 240px;
  min-height: var(--hud-edge-size);
  padding: 11px 16px 12px;
  border-right: 1px solid var(--hud-rim-subtle);
  border-bottom: 1px solid var(--hud-rim);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(0, 0, 0, 0.18)),
    var(--hud-glass);
  backdrop-filter: var(--hud-blur);
  -webkit-backdrop-filter: var(--hud-blur);
  box-shadow: var(--hud-shadow);
  color: var(--hud-text);
  pointer-events: all;
}

.hud-xp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.hud-xp-level {
  flex: 0 0 auto;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--hud-gold);
  letter-spacing: 0;
}

.hud-xp-progress-text {
  min-width: 0;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--hud-text-muted);
  letter-spacing: 0;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-xp-track {
  position: relative;
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid rgba(231, 184, 93, 0.28);
  border-radius: 999px;
  background: rgba(2, 8, 9, 0.74);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-xp-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(68, 214, 138, 0.92), rgba(231, 184, 93, 0.95));
  box-shadow: 0 0 12px rgba(231, 184, 93, 0.45);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease;
}

/* Override old absolute/hidden positioning from boat-mode and general #economy-hud rules */
#hud-bar #economy-hud,
body.app-playing.boat-mode #hud-bar #economy-hud,
body.boat-mode #hud-bar #economy-hud {
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  transform: none !important;
  opacity: 1 !important;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  width: var(--hud-gold-size);
  height: var(--hud-gold-size);
  padding: 0;
  border-radius: 50% !important;
  border: 1px solid var(--hud-rim-active) !important;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 224, 151, 0.20), transparent 33%),
    radial-gradient(circle at 50% 50%, rgba(231, 184, 93, 0.16), rgba(5, 11, 13, 0.96) 68%),
    conic-gradient(from 28deg, rgba(92, 221, 195, 0.36), rgba(231, 184, 93, 0.52), rgba(92, 221, 195, 0.36)) !important;
  backdrop-filter: var(--hud-blur) !important;
  -webkit-backdrop-filter: var(--hud-blur) !important;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.48),
    inset 0 0 0 5px rgba(5, 11, 13, 0.90),
    inset 0 0 0 6px rgba(255, 255, 255, 0.04) !important;
  font-size: inherit !important;
  white-space: nowrap;
  pointer-events: all;
  z-index: auto !important;
  min-width: 0;
}

.hud-gold-glyph {
  font-size: 2.35rem;
  color: var(--hud-gold);
  line-height: 1;
  opacity: 0.88;
  flex-shrink: 0;
}

.hud-gold-total {
  position: relative;
  display: block;
  min-width: 132px;
  padding: 9px 12px 11px;
  border: 2px solid rgba(231, 184, 93, 0.36);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 46%, rgba(0, 0, 0, 0.20) 47% 100%),
    rgba(3, 9, 10, 0.74);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45);
  font-family: 'Courier New', monospace;
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--hud-gold);
  line-height: 1.05;
  letter-spacing: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 50%;
}

.hud-gold-total::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.hud-gold-total.is-compact {
  font-size: 1.86rem;
}

.hud-gold-total.is-tiny {
  font-size: 1.6rem;
}

.hud-gold-total.is-flipping {
  animation: gold-score-flip 180ms steps(2, end) infinite;
}

@keyframes gold-score-flip {
  0% {
    transform: perspective(240px) rotateX(0deg);
    filter: brightness(1);
  }
  50% {
    transform: perspective(240px) rotateX(-58deg);
    filter: brightness(1.35);
  }
  100% {
    transform: perspective(240px) rotateX(0deg);
    filter: brightness(1);
  }
}

#hud-bar #economy-hud span {
  pointer-events: none;
}

/* Fleet display: hide in HUD (not user-requested) */
.hud-fleet-count {
  display: none !important;
}

body.app-playing #notification-panel,
body:not(.app-menu):not(.app-city-select):not(.app-loading) #notification-panel {
  position: absolute !important;
  display: flex !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  opacity: 1 !important;
  transform: translateX(-50%) !important;
  width: max-content !important;
  max-width: min(460px, calc(var(--ui-viewport-width) - 24px)) !important;
  margin-bottom: 0;
  pointer-events: all;
  z-index: 290;
}

/* ─── VEHICLE STATUS BAR — Dark Glass ─── */
.vehicle-status {
  bottom: 48px !important;
}

body.app-playing.boat-mode .vehicle-status-shell {
  background: var(--hud-glass-strong) !important;
  backdrop-filter: var(--hud-blur) !important;
  -webkit-backdrop-filter: var(--hud-blur) !important;
  border: 1px solid var(--hud-rim) !important;
  box-shadow: var(--hud-shadow) !important;
  color: var(--hud-text) !important;
}

.vehicle-status-title {
  color: var(--hud-text) !important;
  font-size: 1rem !important;
}

.vehicle-status-assignment {
  color: var(--hud-text-muted) !important;
  font-size: 0.9rem !important;
}

.vehicle-status-label {
  color: var(--hud-text-muted) !important;
}

.vehicle-status-value {
  color: var(--hud-text) !important;
}

.vehicle-status-tier {
  background: rgba(210, 168, 72, 0.14) !important;
  border-color: var(--hud-rim) !important;
  color: var(--hud-gold) !important;
}

.vehicle-status-icon {
  background: rgba(210, 168, 72, 0.08) !important;
  border-color: var(--hud-rim) !important;
}

.vehicle-status-debug {
  border-top-color: var(--hud-rim) !important;
}

.vehicle-status-debug-header,
.vehicle-status-debug-value,
.vehicle-status-debug-pre {
  color: var(--hud-text) !important;
}

.vehicle-status-debug-key {
  color: var(--hud-text-muted) !important;
}

.vehicle-status-debug-refresh,
.vehicle-status-debug-pre {
  border-color: var(--hud-rim) !important;
  background: rgba(3, 9, 10, 0.42) !important;
}

.vehicle-status-debug-refresh {
  color: var(--hud-text) !important;
}

/* ─── IN-GAME SETTINGS PANEL — Dark Glass ─── */
.floating-menu {
  top: var(--hud-edge-size) !important;
  left: 0 !important;
  background: var(--hud-glass-strong) !important;
  backdrop-filter: var(--hud-blur) !important;
  -webkit-backdrop-filter: var(--hud-blur) !important;
  border: 1px solid var(--hud-rim) !important;
  box-shadow: var(--hud-shadow) !important;
  color: var(--hud-text) !important;
  border-radius: var(--hud-r) !important;
}

.floating-menu-header {
  border-color: var(--hud-rim-subtle) !important;
  color: var(--hud-text) !important;
  font-family: 'Cinzel', serif !important;
  font-size: 0.82rem !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
}

.floating-menu-button {
  background: rgba(210, 168, 72, 0.05) !important;
  border: 1px solid var(--hud-rim-subtle) !important;
  color: var(--hud-text) !important;
  border-radius: 7px !important;
  transition: background var(--hud-ease), border-color var(--hud-ease),
              color var(--hud-ease);
}

.floating-menu-button:hover {
  background: rgba(210, 168, 72, 0.11) !important;
  border-color: var(--hud-rim) !important;
  color: var(--hud-gold) !important;
}

.floating-menu-button.danger {
  border-color: rgba(232, 68, 68, 0.25) !important;
  color: #e07070 !important;
}

.floating-menu-button.danger:hover {
  background: rgba(232, 68, 68, 0.10) !important;
  border-color: rgba(232, 68, 68, 0.45) !important;
  color: #ff8080 !important;
}

.ghost-icon {
  color: var(--hud-text-muted) !important;
}

.ghost-icon:hover {
  color: var(--hud-text) !important;
}

/* ─── SUPPRESS OLD CONFLICTING HUD RULES ─── */
/* The old economy-hud had display rules that no longer apply */
body.boat-mode #hud-bar #economy-hud {
  display: flex !important;
}

body.app-playing.boat-mode #fleet-display {
  display: none !important;
}

/* ─── SCREEN-LOCKED GEOMETRIC HUD OVERRIDES ─── */
#ui-layer {
  color: var(--parchment-ink);
}

#ui-layer :is(button, input, select, textarea) {
  color: inherit;
}

.trade-ui-stack,
body.app-playing.boat-mode #trade-ui-stack {
  top: var(--hud-gold-size) !important;
  right: 0 !important;
  width: min(440px, var(--ui-viewport-width)) !important;
  gap: 0 !important;
}

.company-panel-toggle,
.diplomacy-panel-toggle,
body.app-playing.boat-mode .company-panel-toggle,
body.app-playing.boat-mode .diplomacy-panel-toggle {
  min-height: 62px !important;
  border-radius: 0 !important;
  border-color: var(--hud-rim) !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

.company-panel-toggle {
  max-width: none;
}

.company-panel-summary,
.company-panel-kicker,
.company-panel-section-title,
.company-panel-stat span,
.company-ship-label,
.diplomacy-company-meta,
.diplomacy-city-meta {
  color: var(--hud-text-muted) !important;
}

.company-panel-name,
.company-panel-title,
.company-panel-stat strong,
.company-city-name,
.company-ship-title,
.company-ship-value,
.diplomacy-company-name,
.diplomacy-city-name {
  color: var(--hud-text) !important;
}

.company-panel-menu,
.diplomacy-panel-menu,
body.app-playing.boat-mode .company-panel-menu,
body.app-playing.boat-mode .diplomacy-panel-menu {
  top: 100% !important;
  right: 0 !important;
  width: min(440px, var(--ui-viewport-width)) !important;
  max-height: calc(var(--ui-viewport-height) - var(--hud-edge-size) - 48px) !important;
  border-color: var(--hud-rim) !important;
  border-radius: 0 !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

.company-panel-stat,
.company-city-row,
.diplomacy-company-card,
.diplomacy-city-row,
.company-panel-empty,
.company-panel-ship {
  border-color: var(--hud-rim-subtle) !important;
  background: rgba(27, 48, 50, 0.72) !important;
  color: var(--hud-text-muted) !important;
}

.company-panel-close {
  border-color: var(--hud-rim-subtle) !important;
  background: rgba(92, 221, 195, 0.08) !important;
  color: var(--hud-text) !important;
}

.map-editor-panel,
.model-editor-panel,
.boat-model-editor-panel {
  bottom: 0 !important;
  border-radius: 0 !important;
  border-color: var(--hud-rim) !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

.map-editor-panel {
  left: 0 !important;
}

.model-editor-panel,
.boat-model-editor-panel {
  right: 0 !important;
}

.map-editor-panel:not(.is-active),
.model-editor-panel:not(.is-active),
.boat-model-editor-panel:not(.is-active) {
  width: 62px !important;
  max-height: 62px !important;
}

.map-editor-header,
.model-editor-header,
.boat-model-editor-header {
  grid-template-columns: 50px minmax(0, 1fr);
}

.map-editor-toggle,
.model-editor-toggle,
.boat-model-editor-toggle {
  width: 50px !important;
  height: 50px !important;
  border-color: var(--hud-rim-subtle) !important;
  background: rgba(92, 221, 195, 0.08) !important;
  color: var(--hud-text) !important;
  box-shadow: none !important;
}

.map-editor-toggle[aria-pressed='true'],
.model-editor-toggle[aria-pressed='true'],
.boat-model-editor-toggle[aria-pressed='true'] {
  border-color: var(--hud-rim-active) !important;
  background: rgba(231, 184, 93, 0.16) !important;
  color: var(--hud-gold) !important;
}

.map-editor-terrain,
.model-editor-resource,
.model-editor-part,
.model-editor-action,
.boat-model-editor-display,
.boat-model-editor-controls,
.boat-model-editor-component-select,
.boat-model-editor-component-delete,
.boat-model-editor-color,
.boat-model-editor-action {
  border-color: var(--hud-rim-subtle) !important;
  background: rgba(27, 48, 50, 0.72) !important;
  color: var(--hud-text) !important;
}

.map-editor-kicker,
.model-editor-kicker,
.boat-model-editor-kicker,
.model-editor-status,
.boat-model-editor-status,
.map-editor-status,
.boat-model-editor-component-meta,
.boat-model-editor-section-heading,
.boat-model-editor-preview-bar {
  color: var(--hud-text-muted) !important;
}

.map-editor-terrain.is-selected,
.model-editor-part[aria-pressed='true'],
.boat-model-editor-component.is-selected .boat-model-editor-component-select {
  border-color: var(--hud-rim-active) !important;
  background: rgba(231, 184, 93, 0.14) !important;
}

.notification-entry,
.permanent-entry {
  border-color: var(--hud-rim) !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

.gold-console-entry {
  background: var(--hud-glass-strong) !important;
  box-shadow: var(--hud-shadow) !important;
}

.notification-detail {
  color: var(--hud-text-muted) !important;
}

#ui-layer .docking-progress {
  bottom: 48px !important;
  border-color: var(--hud-rim) !important;
  border-radius: 0 !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

#ui-layer .docking-progress-ring,
#ui-layer .docking-progress-core {
  border-color: var(--hud-rim-subtle) !important;
  background-color: rgba(27, 48, 50, 0.82) !important;
}

#ui-layer .docked-harbor-panel {
  border-color: var(--hud-rim) !important;
  border-radius: 0 !important;
  background: var(--hud-glass-strong) !important;
  color: var(--hud-text) !important;
  box-shadow: var(--hud-shadow) !important;
}

#ui-layer .docked-harbor-panel .harbor-panel-header {
  border-color: var(--hud-rim) !important;
  background: rgba(19, 36, 38, 0.98) !important;
}

#ui-layer .docked-harbor-berth,
#ui-layer .docked-harbor-market-row,
#ui-layer .docked-harbor-upgrade-row,
#ui-layer .harbor-quest-row,
#ui-layer .docked-harbor-action,
#ui-layer .docked-harbor-market-buy,
#ui-layer .harbor-quest-action {
  border-color: var(--hud-rim-subtle) !important;
  background: rgba(27, 48, 50, 0.72) !important;
  color: var(--hud-text) !important;
}

#ui-layer .docked-harbor-market-status,
#ui-layer .docked-harbor-market-detail,
#ui-layer .harbor-quest-detail,
#ui-layer .docked-harbor-manual-status {
  color: var(--hud-text-muted) !important;
}

.trade-panel-shell {
  left: auto;
  right: 0;
}

.flow-edge-left,
#trade-import-panel {
  left: 0 !important;
}

.flow-edge-right,
#trade-export-panel {
  right: 0 !important;
}

.mobile-joystick {
  left: env(safe-area-inset-left) !important;
  bottom: env(safe-area-inset-bottom) !important;
}

@media (max-width: 820px) {
  .model-editor-panel.is-active,
  .boat-model-editor-panel.is-active {
    right: 0 !important;
    bottom: 0 !important;
    width: min(640px, var(--ui-viewport-width)) !important;
    max-height: var(--ui-viewport-height) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   NAUTICAL HUD PASS
   CSS-drawn brass/navy controls; preserves existing HUD IDs/data bindings.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --hud-glass: rgba(4, 12, 16, 0.76);
  --hud-glass-strong: rgba(3, 9, 12, 0.92);
  --hud-rim: rgba(198, 148, 67, 0.42);
  --hud-rim-active: rgba(238, 190, 91, 0.76);
  --hud-rim-subtle: rgba(198, 148, 67, 0.24);
  --hud-gold: #e8bd68;
  --hud-gold-dim: #9d7735;
  --hud-text: #f4efe0;
  --hud-text-muted: rgba(216, 204, 175, 0.72);
  --hud-green: #4ed88f;
  --hud-amber: #f1b953;
  --hud-red: #d6574d;
  --hud-edge-size: clamp(52px, 3.35vw, 64px);
  --hud-gold-size: clamp(86px, 7.4vw, 116px);
  --hud-r: 8px;
  --hud-shadow: 0 14px 32px rgba(0, 0, 0, 0.42),
                inset 0 1px 0 rgba(255, 244, 204, 0.08);
}

body.boat-mode:not(.app-loading) #hud-bar {
  min-height: calc(var(--hud-edge-size) + 18px);
  padding: max(5px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(2, 7, 10, 0.70), rgba(2, 7, 10, 0.28) 58%, transparent);
  border-bottom: 0;
  box-shadow: none;
}

body.boat-mode:not(.app-loading) #hud-tl,
body.boat-mode:not(.app-loading) #hud-tr {
  gap: clamp(4px, 0.42vw, 8px);
}

body.boat-mode:not(.app-loading) .hud-cluster--center {
  top: max(5px, env(safe-area-inset-top));
  max-width: min(52vw, 940px);
}

body.boat-mode:not(.app-loading) .hud-cluster--right {
  top: max(5px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  gap: clamp(4px, 0.42vw, 8px);
}

body.boat-mode:not(.app-loading) .hud-icon-btn {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--hud-edge-size);
  height: var(--hud-edge-size);
  border: 1px solid rgba(231, 184, 93, 0.44);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 236, 180, 0.09), rgba(255, 236, 180, 0.02) 34%, rgba(0, 0, 0, 0.30)),
    radial-gradient(circle at 50% 42%, rgba(27, 63, 69, 0.92), rgba(4, 13, 17, 0.98) 68%),
    linear-gradient(135deg, rgba(231, 184, 93, 0.24), transparent 28%, transparent 72%, rgba(231, 184, 93, 0.20));
  box-shadow:
    0 9px 22px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 238, 183, 0.06),
    inset 0 0 0 5px rgba(1, 7, 10, 0.56);
  color: var(--hud-gold);
  font-size: 0;
  line-height: 1;
  overflow: hidden;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.84);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

body.boat-mode:not(.app-loading) .hud-icon-btn::before {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: 0;
  border: 1px solid rgba(231, 184, 93, 0.22);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 40%),
    rgba(1, 7, 10, 0.24);
  pointer-events: none;
}

body.boat-mode:not(.app-loading) .hud-icon-btn::after {
  content: var(--hud-icon, "");
  position: relative;
  z-index: 2;
  color: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1.18rem, 1.28vw, 1.62rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

body.boat-mode:not(.app-loading) .hud-icon-btn:not(.broadside-reload) > :not(.skill-tree-point-badge) {
  display: none !important;
}

body.boat-mode:not(.app-loading) .hud-icon-btn:hover,
body.boat-mode:not(.app-loading) .hud-icon-btn:focus-visible,
body.boat-mode:not(.app-loading) .hud-icon-btn[aria-expanded='true'],
body.boat-mode:not(.app-loading) .hud-icon-btn[aria-pressed='false'],
body.boat-mode:not(.app-loading) .hud-icon-btn.quest-log-toggle--active,
body.boat-mode:not(.app-loading) .hud-icon-btn.skill-tree-toggle--ready {
  border-color: rgba(248, 211, 133, 0.78);
  color: #ffe1a0;
  filter: brightness(1.18) saturate(1.08);
  box-shadow:
    0 11px 26px rgba(0, 0, 0, 0.48),
    0 0 18px rgba(231, 184, 93, 0.22),
    inset 0 0 0 1px rgba(255, 238, 183, 0.10),
    inset 0 0 0 5px rgba(1, 7, 10, 0.50);
}

body.boat-mode:not(.app-loading) .hud-icon-btn:active {
  transform: translateY(1px) scale(0.97);
}

body.boat-mode:not(.app-loading) #settings-btn {
  --hud-icon: "⚙";
}

body.boat-mode:not(.app-loading) #day-night-toggle {
  --hud-icon: "◐";
}

body.boat-mode:not(.app-loading) #audio-settings-toggle {
  --hud-icon: "♪";
}

body.boat-mode:not(.app-loading) #tutorial-toggle {
  --hud-icon: "?";
}

body.boat-mode:not(.app-loading) #skill-tree-toggle {
  --hud-icon: "✦";
}

body.boat-mode:not(.app-loading) #quest-log-toggle {
  --hud-icon: "☷";
}

body.boat-mode:not(.app-loading) #day-night-toggle-icon {
  display: none;
}

body.boat-mode:not(.app-loading) .skill-tree-point-badge {
  right: 3px;
  top: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid rgba(255, 225, 154, 0.84);
  background: linear-gradient(180deg, rgba(184, 41, 38, 0.98), rgba(111, 22, 24, 0.98));
  color: #fff3d0;
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 18px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.36);
}

body.boat-mode:not(.app-loading) #hud-bar .audio-settings-menu,
body.boat-mode:not(.app-loading) .quest-log-panel,
body.boat-mode:not(.app-loading) .floating-menu {
  border: 1px solid var(--hud-rim) !important;
  border-radius: 8px !important;
  background:
    linear-gradient(180deg, rgba(255, 236, 180, 0.045), rgba(0, 0, 0, 0.18)),
    rgba(4, 13, 17, 0.94) !important;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.52),
    inset 0 0 0 1px rgba(255, 238, 183, 0.05) !important;
  color: var(--hud-text) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden) {
  width: clamp(600px, 46vw, 860px) !important;
  min-width: 0 !important;
  max-width: min(860px, calc(100vw - 420px)) !important;
  min-height: clamp(72px, 5.6vw, 96px);
  padding: clamp(13px, 1.15vw, 18px) clamp(30px, 3vw, 54px) !important;
  border: 0 !important;
  border-radius: 18px !important;
  background:
    linear-gradient(90deg, transparent, rgba(231, 184, 93, 0.13) 7%, transparent 15%, transparent 85%, rgba(231, 184, 93, 0.13) 93%, transparent),
    linear-gradient(180deg, rgba(255, 239, 187, 0.07), rgba(7, 18, 23, 0.72) 34%, rgba(2, 8, 12, 0.86)),
    rgba(3, 10, 14, 0.86) !important;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.48),
    0 0 18px rgba(231, 184, 93, 0.13),
    inset 0 0 0 1px rgba(236, 189, 101, 0.34) !important;
  gap: 8px;
  overflow: hidden;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not([data-health-ready='true']) {
  display: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-meter-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(18px, 2vw, 30px);
  align-items: center;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-condition-meter {
  display: grid;
  grid-template-columns: minmax(78px, auto) minmax(140px, 1fr);
  gap: 12px;
  align-items: center;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud-row {
  display: grid;
  gap: 1px;
  margin: 0;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-title {
  font-size: clamp(0.66rem, 0.62vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.20em;
  color: rgba(229, 210, 167, 0.66);
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-value {
  font-family: 'Courier New', monospace;
  font-size: clamp(1.18rem, 1.55vw, 1.82rem);
  font-weight: 800;
  color: #fff4d2;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.86);
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-track,
body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
  height: clamp(10px, 0.8vw, 14px) !important;
  border: 1px solid rgba(231, 184, 93, 0.22) !important;
  border-radius: 999px !important;
  background: rgba(1, 7, 10, 0.68) !important;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.72),
    0 1px 0 rgba(255, 244, 205, 0.05) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-fill {
  background: linear-gradient(90deg, #20b866, #60e891) !important;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.22);
}

body.boat-mode:not(.app-loading) #hud-bar .ship-morale-fill {
  background: linear-gradient(90deg, #47d6a5, #2bb7c5) !important;
  box-shadow: 0 0 14px rgba(71, 214, 165, 0.20);
}

body.boat-mode:not(.app-loading) #hud-bar .crew-morale-warning {
  min-height: 0;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: clamp(0.78rem, 0.84vw, 1rem);
  letter-spacing: 0.08em;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-cargo {
  top: calc(var(--hud-edge-size) + max(14px, env(safe-area-inset-top))) !important;
  right: max(12px, env(safe-area-inset-right)) !important;
  min-width: 220px;
  max-width: min(310px, calc(100vw - 24px));
  padding: 11px 16px 12px;
  border: 1px solid var(--hud-rim-subtle);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 239, 187, 0.05), rgba(0, 0, 0, 0.15)),
    rgba(3, 10, 14, 0.90);
  box-shadow: var(--hud-shadow);
}

body.boat-mode:not(.app-loading) .hud-chip-label {
  color: rgba(229, 210, 167, 0.64);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
}

body.boat-mode:not(.app-loading) .hud-chip-value,
body.boat-mode:not(.app-loading) .hud-cargo-est-value {
  color: #ffe3a2;
}

body.boat-mode:not(.app-loading) .hud-cargo-item-name {
  color: #f0c674;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-xp-pill {
  width: clamp(166px, 12vw, 230px);
  min-height: var(--hud-edge-size);
  padding: 9px 14px 10px;
  border: 1px solid var(--hud-rim-subtle);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 239, 187, 0.07), rgba(0, 0, 0, 0.20)),
    rgba(3, 10, 14, 0.86);
  box-shadow: var(--hud-shadow);
}

body.boat-mode:not(.app-loading) .hud-xp-level {
  color: #f0c674;
  font-size: clamp(0.86rem, 0.8vw, 1rem);
}

body.boat-mode:not(.app-loading) .hud-xp-progress-text {
  font-size: clamp(0.72rem, 0.68vw, 0.84rem);
  color: rgba(216, 204, 175, 0.68);
}

body.boat-mode:not(.app-loading) .hud-xp-track {
  height: 7px;
  margin-top: 6px;
  border-color: rgba(231, 184, 93, 0.26);
  background: rgba(0, 5, 8, 0.76);
}

body.app-playing #hud-bar #economy-hud,
body.app-playing #hud-bar #economy-hud:not(.hidden),
body.boat-mode:not(.app-loading) #hud-bar #economy-hud,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud:not(.hidden),
#hud-bar #economy-hud.hud-gold-pill,
#hud-bar #economy-hud.hud-gold-pill:not(.hidden) {
  position: relative !important;
  isolation: isolate;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center;
  align-items: center;
  gap: 0;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  transform: none !important;
  transform-origin: center center !important;
  opacity: 1 !important;
  width: var(--hud-gold-size) !important;
  min-width: var(--hud-gold-size) !important;
  max-width: var(--hud-gold-size) !important;
  height: var(--hud-gold-size) !important;
  min-height: var(--hud-gold-size) !important;
  max-height: var(--hud-gold-size) !important;
  padding: 0;
  border-radius: 50% !important;
  border: 1px solid var(--hud-rim-active) !important;
  background:
    radial-gradient(circle at 50% 45%, rgba(242, 193, 96, 0.16), transparent 34%),
    radial-gradient(circle at 50% 58%, rgba(2, 8, 11, 0.94), rgba(2, 6, 8, 0.98) 67%),
    rgba(3, 9, 12, 0.88) !important;
  box-shadow:
    0 15px 34px rgba(0, 0, 0, 0.50),
    0 0 18px rgba(231, 184, 93, 0.18),
    inset 0 0 0 6px rgba(2, 7, 10, 0.76),
    inset 0 0 0 1px rgba(255, 238, 183, 0.14) !important;
  overflow: hidden;
}

body.app-playing #hud-bar #economy-hud::before,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud::before,
#hud-bar #economy-hud.hud-gold-pill::before {
  content: "";
  position: absolute;
  inset: 12%;
  z-index: -1;
  border: 1px solid rgba(231, 184, 93, 0.28);
  border-radius: 50%;
  background: conic-gradient(
    from 45deg,
    rgba(231, 184, 93, 0.48),
    rgba(60, 105, 97, 0.16),
    rgba(231, 184, 93, 0.48)
  );
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
  mask: radial-gradient(circle, transparent 58%, #000 60%);
}

body.app-playing #hud-bar #economy-hud::after,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud::after,
#hud-bar #economy-hud.hud-gold-pill::after {
  content: "";
  position: absolute;
  top: 13%;
  left: 50%;
  width: 14%;
  aspect-ratio: 1;
  border: 2px solid rgba(231, 184, 93, 0.78);
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 0 0 10px rgba(231, 184, 93, 0.26);
}

body.app-playing #hud-bar .hud-gold-glyph,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-glyph,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-glyph {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 30%;
  height: 30%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, rgba(255, 238, 183, 0.36), transparent 38%),
    linear-gradient(180deg, rgba(231, 184, 93, 0.28), rgba(92, 65, 23, 0.14));
  color: var(--hud-gold);
  font-size: clamp(1rem, 1.4vw, 1.5rem);
  filter: brightness(1.05);
  transform: translateX(-50%);
  opacity: 0.98;
}

body.app-playing #hud-bar .hud-gold-total,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-total {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 24%;
  display: block !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #f3c970;
  font-family: 'Courier New', monospace;
  font-size: clamp(1.2rem, 1.55vw, 1.72rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 7px rgba(0, 0, 0, 0.92),
    0 0 12px rgba(231, 184, 93, 0.22);
}

body.app-playing #hud-bar .hud-gold-total::after,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total::after,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-total::after {
  display: none;
}

body.app-playing #hud-bar .hud-gold-total.is-compact,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total.is-compact,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-total.is-compact {
  font-size: clamp(1.02rem, 1.25vw, 1.42rem);
}

body.app-playing #hud-bar .hud-gold-total.is-tiny,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total.is-tiny,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-total.is-tiny {
  font-size: clamp(0.84rem, 1.04vw, 1.16rem);
}

body.app-playing #fleet-display,
body.boat-mode:not(.app-loading) #fleet-display {
  display: none !important;
}

body.boat-mode:not(.app-loading) .quest-compass {
  grid-template-columns: 30px minmax(0, 1fr) auto;
  min-width: min(420px, calc(100vw - 32px));
  max-width: min(520px, calc(100vw - 32px));
  height: calc(var(--hud-edge-size) - 2px);
  padding: 0 14px;
  border: 1px solid var(--hud-rim);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(12, 25, 28, 0.92), rgba(4, 12, 16, 0.82)),
    rgba(3, 10, 14, 0.90);
  box-shadow: var(--hud-shadow);
}

body.boat-mode:not(.app-loading) .quest-compass-arrow {
  width: 26px;
  height: 26px;
}

body.boat-mode:not(.app-loading) .quest-compass-title {
  color: #f3e7c6;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

body.boat-mode:not(.app-loading) .quest-compass-distance {
  color: #e8bd68;
  font-family: 'Courier New', monospace;
  font-size: 0.86rem;
}

body.boat-mode:not(.app-loading) .broadside-hud {
  top: auto;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  transform: translateX(-50%);
}

body.boat-mode:not(.app-loading) .broadside-hud::before {
  content: "";
  position: absolute;
  width: clamp(176px, 15vw, 236px);
  height: clamp(58px, 4.8vw, 78px);
  border: 1px solid rgba(231, 184, 93, 0.36);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(231, 184, 93, 0.15), transparent 42%),
    linear-gradient(180deg, rgba(4, 12, 16, 0.82), rgba(1, 5, 8, 0.90));
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 238, 183, 0.04);
}

body.boat-mode:not(.app-loading) .broadside-hud::after {
  content: "";
  position: absolute;
  width: clamp(206px, 17vw, 278px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(231, 184, 93, 0.52), transparent);
  pointer-events: none;
}

body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload {
  width: clamp(78px, 6.5vw, 100px);
  height: clamp(78px, 6.5vw, 100px);
  border: 1px solid var(--hud-rim-active);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(15, 37, 42, 0.96), rgba(3, 9, 12, 0.98) 68%),
    conic-gradient(from 18deg, rgba(231, 184, 93, 0.62), rgba(48, 88, 84, 0.34), rgba(231, 184, 93, 0.62));
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.52),
    0 0 22px rgba(231, 184, 93, 0.20),
    inset 0 0 0 5px rgba(2, 7, 10, 0.92);
}

body.boat-mode:not(.app-loading) .broadside-reload-icon {
  position: absolute;
  inset: 20%;
  z-index: 2;
  border-radius: 50%;
  color: var(--hud-gold);
  font-size: 0;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.72));
}

body.boat-mode:not(.app-loading) .broadside-reload-icon::before,
body.boat-mode:not(.app-loading) .broadside-reload-icon::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 42%;
  height: 18%;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    -7px 0 0 -2px currentColor,
    7px 0 0 -2px currentColor,
    0 0 10px rgba(231, 184, 93, 0.25);
  transform: rotate(24deg);
  transform-origin: center;
}

body.boat-mode:not(.app-loading) .broadside-reload-icon::after {
  transform: rotate(-24deg);
}

body.boat-mode:not(.app-loading) .broadside-reload-ring {
  inset: 10px;
  z-index: 1;
  background:
    conic-gradient(
      var(--hud-gold) calc(var(--broadside-reload-progress) * 360deg),
      rgba(42, 89, 88, 0.22) 0
    );
  box-shadow: 0 0 16px rgba(231, 184, 93, 0.28);
  opacity: 0.96;
}

body.boat-mode:not(.app-loading) .broadside-reload-timer {
  z-index: 3;
  color: #fff2c9;
  font-family: 'Courier New', monospace;
  font-size: clamp(1rem, 1.55vw, 1.35rem);
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.86);
}

body.boat-mode:not(.app-loading) .broadside-reload.is-reloading .broadside-reload-icon {
  opacity: 0.14;
}

@media (max-width: 1540px) {
  body.boat-mode:not(.app-loading) .hud-cluster--center {
    top: calc(var(--hud-edge-size) + max(10px, env(safe-area-inset-top)));
    max-width: calc(100vw - 24px);
  }

  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden) {
    width: min(640px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
  }
}

@media (max-width: 680px) {
  :root {
    --hud-edge-size: 48px;
    --hud-gold-size: 82px;
  }

  body.boat-mode:not(.app-loading) #hud-tr {
    max-width: calc(100vw - 12px);
    flex-wrap: wrap;
  }

  body.boat-mode:not(.app-loading) #hud-bar .hud-xp-pill {
    width: 150px;
  }

  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden) {
    padding: 12px 18px !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-meter-grid,
  body.boat-mode:not(.app-loading) #hud-bar .ship-condition-meter {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  body.boat-mode:not(.app-loading) .quest-compass {
    grid-template-columns: 26px minmax(0, 1fr);
    min-width: calc(100vw - 24px);
  }
}

@media (max-width: 620px) {
  .boat-model-editor-panel.is-active {
    width: min(440px, var(--ui-viewport-width)) !important;
  }
}

/* Button completion pass: scalable native symbols, no generated raster crops. */
:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .skill-tree-rename-ship,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-type-button,
  .wizard-actions button,
  .docked-harbor-action
)[data-command-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.58em;
}

:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-actions button,
  .docked-harbor-action
)[data-command-icon]::before,
.quest-log-select::before,
.harbor-quest-action::before,
#ui-layer .docked-harbor-market-buy::before {
  content: attr(data-command-icon);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  border: 1px solid color-mix(in srgb, currentColor 46%, transparent 54%);
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.10), rgba(0, 0, 0, 0.18)),
    rgba(2, 8, 10, 0.28);
  color: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.92em;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 240, 181, 0.05);
}

.skill-tree-rename-ship[data-command-icon]::before,
.wizard-type-button[data-command-icon]::before {
  content: attr(data-command-icon);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border: 0;
  background: transparent;
  color: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 900;
  line-height: 1;
}

#ui-layer .docked-harbor-action {
  position: relative;
  min-width: 0;
  border-width: 1px !important;
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.06), rgba(0, 0, 0, 0.16)),
    rgba(27, 48, 50, 0.78) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 181, 0.045),
    0 8px 18px rgba(0, 0, 0, 0.20);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

#ui-layer .docked-harbor-action:not(:disabled):hover,
#ui-layer .docked-harbor-action:not(:disabled):focus-visible,
#ui-layer .docked-harbor-market-buy:not(:disabled):hover,
#ui-layer .docked-harbor-market-buy:not(:disabled):focus-visible,
.quest-log-select:not(:disabled):hover,
.quest-log-select:not(:disabled):focus-visible,
.harbor-quest-action:not(:disabled):hover,
.harbor-quest-action:not(:disabled):focus-visible {
  border-color: var(--hud-rim-active) !important;
  color: var(--hud-gold) !important;
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.12), rgba(0, 0, 0, 0.14)),
    rgba(39, 67, 67, 0.90) !important;
}

#ui-layer .docked-harbor-action:not(:disabled):active,
#ui-layer .docked-harbor-market-buy:not(:disabled):active,
.quest-log-select:not(:disabled):active,
.harbor-quest-action:not(:disabled):active {
  transform: translateY(1px);
}

#harbor-manual-load:has(.docked-harbor-action-icon)::before {
  display: none;
}

#ui-layer .docked-harbor-action-label,
#ui-layer .docked-harbor-action {
  overflow-wrap: anywhere;
}

.quest-log-select,
.harbor-quest-action,
#ui-layer .docked-harbor-market-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48em;
  min-width: max-content;
}

.quest-log-select::before,
.harbor-quest-action::before {
  content: "›";
}

.quest-log-select:disabled::before {
  content: "✓";
}

#ui-layer .docked-harbor-market-buy::before {
  content: "¤";
}

.wizard-actions button,
.wizard-type-button {
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.wizard-actions button:not(:disabled):hover,
.wizard-actions button:not(:disabled):focus-visible,
.wizard-type-button:not(.active):hover,
.wizard-type-button:not(.active):focus-visible {
  border-color: var(--parchment-border-strong);
  background: var(--parchment-surface);
  color: var(--parchment-ink);
}

:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close
) {
  overflow: hidden;
  line-height: 1;
}

/* Imagegen polish pass: real material textures, not cropped button art. */
:root {
  --ui-panel-surface-image: url('../images/ui/nautical-panel-surface.jpg');
  --ui-chart-surface-image: url('../images/ui/nautical-chart-surface.jpg');
  --ui-button-surface-image: url('../images/ui/nautical-button-surface.jpg');
}

:is(
  .quest-log-panel,
  .docked-harbor-panel,
  .trade-wizard-dialog,
  .floating-menu,
  .company-panel-menu,
  .diplomacy-panel-menu,
  .tutorial-shell
) {
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.06), rgba(0, 0, 0, 0.18)),
    var(--ui-panel-surface-image),
    rgba(3, 12, 15, 0.92) !important;
  background-position: center, center, center !important;
  background-size: auto, cover, auto !important;
  background-blend-mode: normal, soft-light, normal;
  border-color: color-mix(in srgb, var(--hud-rim-active) 56%, transparent 44%) !important;
}

body.boat-mode:not(.app-loading) :is(
  #hud-bar #ship-health-hud,
  #hud-bar .hud-xp-pill,
  #hud-bar .hud-cargo,
  .quest-compass
) {
  background:
    linear-gradient(180deg, rgba(255, 239, 187, 0.07), rgba(0, 0, 0, 0.18)),
    var(--ui-panel-surface-image),
    rgba(3, 10, 14, 0.88) !important;
  background-position: center, center, center !important;
  background-size: auto, cover, auto !important;
  background-blend-mode: normal, soft-light, normal;
}

.skill-tree-overlay {
  background:
    radial-gradient(circle at 54% 46%, rgba(71, 215, 196, 0.10), transparent 44%),
    linear-gradient(180deg, rgba(2, 7, 10, 0.40), rgba(2, 7, 10, 0.90)),
    var(--ui-chart-surface-image),
    #02070a !important;
  background-position: center, center, center, center !important;
  background-size: auto, auto, cover, auto !important;
  background-blend-mode: normal, normal, multiply, normal;
}

.skill-tree-overlay .skill-tree-shell {
  background:
    linear-gradient(90deg, rgba(216, 168, 67, 0.08), transparent 18%, transparent 82%, rgba(71, 215, 196, 0.06)),
    linear-gradient(180deg, rgba(2, 7, 10, 0.02), rgba(2, 7, 10, 0.64)) !important;
}

.skill-tree-overlay .skill-tree-map-frame {
  background:
    linear-gradient(90deg, rgba(201, 75, 69, 0.08), transparent 28%, transparent 72%, rgba(71, 215, 196, 0.07)),
    linear-gradient(180deg, rgba(216, 168, 67, 0.05), transparent 44%, rgba(115, 180, 255, 0.06)),
    linear-gradient(90deg, rgba(216, 168, 67, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(216, 168, 67, 0.055) 1px, transparent 1px),
    var(--ui-chart-surface-image),
    rgba(2, 8, 12, 0.90) !important;
  background-position: center, center, 0 0, 0 0, center, center !important;
  background-size: auto, auto, 72px 72px, 72px 72px, cover, auto !important;
  background-blend-mode: normal, normal, normal, normal, multiply, normal;
}

:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .skill-tree-rename-ship,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-type-button,
  .wizard-actions button,
  .docked-harbor-action,
  .quest-log-select,
  .harbor-quest-action,
  .docked-harbor-market-buy,
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close,
  .skill-tree-map-controls button
) {
  background:
    linear-gradient(180deg, rgba(255, 241, 184, 0.11), rgba(0, 0, 0, 0.20)),
    var(--ui-button-surface-image),
    rgba(10, 27, 31, 0.82) !important;
  background-position: center, center, center !important;
  background-size: auto, 260px 260px, auto !important;
  background-blend-mode: normal, soft-light, normal;
}

:is(.floating-menu-button.danger, #in-game-exit-menu, #in-game-exit-game) {
  background:
    linear-gradient(180deg, rgba(255, 134, 134, 0.13), rgba(0, 0, 0, 0.22)),
    var(--ui-button-surface-image),
    rgba(45, 14, 17, 0.86) !important;
  background-position: center, center, center !important;
  background-size: auto, 260px 260px, auto !important;
  background-blend-mode: normal, soft-light, normal;
}

#ui-layer .harbor-quest-row,
#ui-layer .docked-harbor-market-row,
.quest-log-card,
.skill-tree-overlay .skill-tree-detail,
.trade-wizard-form {
  background:
    linear-gradient(180deg, rgba(255, 240, 181, 0.045), rgba(0, 0, 0, 0.12)),
    var(--ui-panel-surface-image),
    rgba(11, 29, 32, 0.76) !important;
  background-position: center, center, center !important;
  background-size: auto, cover, auto !important;
  background-blend-mode: normal, soft-light, normal;
}

.skill-tree-overlay .skill-tree-points {
  right: clamp(74px, 5.8vw, 96px) !important;
  min-width: clamp(154px, 12vw, 198px) !important;
  width: auto !important;
  min-height: clamp(48px, 4vw, 58px) !important;
  grid-template-columns: minmax(64px, auto) clamp(42px, 3.4vw, 52px) !important;
  gap: clamp(7px, 0.58vw, 11px) !important;
  padding: 6px 12px !important;
}

.skill-tree-overlay .skill-tree-points::after {
  display: none !important;
  content: none !important;
}

.skill-tree-overlay .skill-tree-level-label {
  grid-column: 1;
  display: inline-flex !important;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  color: rgba(255, 240, 181, 0.86);
  font-size: clamp(0.78rem, 0.84vw, 0.98rem) !important;
  letter-spacing: 0.04em !important;
}

.skill-tree-overlay .skill-tree-level-label strong {
  color: #fff5d0;
  font-size: clamp(1.18rem, 1.34vw, 1.55rem) !important;
  line-height: 0.9;
}

.skill-tree-overlay .skill-tree-points #skill-tree-points-value {
  grid-column: 2;
  width: clamp(42px, 3.4vw, 52px) !important;
  height: clamp(42px, 3.4vw, 52px) !important;
  min-width: 0;
  overflow: hidden;
  color: #eafff8;
  font-size: clamp(1.28rem, 1.5vw, 1.75rem) !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .skill-tree-overlay .skill-tree-points {
    right: 54px !important;
    min-width: min(178px, calc(100% - 68px)) !important;
    grid-template-columns: minmax(58px, auto) 44px !important;
  }
}

/* Pretty Game UI Development: generated nautical art pass */
:root {
  --pretty-hud-rail: url('../images/ui/generated/components/hud-top-rail.png');
  --pretty-meter-dual: url('../images/ui/generated/components/meter-dual-frame.png');
  --pretty-meter-single: url('../images/ui/generated/components/meter-single-frame.png');
  --pretty-gold-medallion: url('../images/ui/generated/components/gold-medallion-frame.png');
  --pretty-icon-normal: url('../images/ui/generated/components/icon-button-normal.png');
  --pretty-icon-active: url('../images/ui/generated/components/icon-button-active.png');
  --pretty-broadside-ring: url('../images/ui/generated/components/broadside-ring-frame.png');
  --pretty-compass-badge: url('../images/ui/generated/components/quest-compass-badge.png');
  --pretty-large-panel: url('../images/ui/generated/components/large-modal-panel.png');
  --pretty-medium-panel: url('../images/ui/generated/components/medium-panel.png');
  --pretty-chip: url('../images/ui/generated/components/notification-chip.png');
  --pretty-button-normal: url('../images/ui/generated/components/button-normal.png');
  --pretty-button-active: url('../images/ui/generated/components/button-active.png');
  --pretty-close-button: url('../images/ui/generated/components/close-button-frame.png');
  --pretty-divider: url('../images/ui/generated/components/divider-flourish.png');
  --hud-edge-size: 58px;
  --hud-gold-size: 138px;
  --hud-r: 6px;
  --hud-glass: rgba(4, 14, 17, 0.8);
  --hud-glass-strong: rgba(3, 10, 13, 0.92);
  --hud-rim: rgba(223, 174, 82, 0.38);
  --hud-rim-active: rgba(250, 211, 122, 0.72);
  --hud-rim-subtle: rgba(113, 225, 208, 0.18);
  --hud-text: #f3f7ea;
  --hud-text-muted: rgba(211, 229, 218, 0.76);
  --hud-gold: #edc36e;
  --hud-shadow: 0 13px 28px rgba(0, 0, 0, 0.46);
}

#hud-bar {
  top: 8px;
  left: 10px;
  right: 10px;
  min-height: 74px;
  padding: 8px 18px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}

#hud-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--pretty-hud-rail) center / 100% 100% no-repeat;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.38));
  pointer-events: none;
}

#hud-bar .hud-cluster {
  align-items: center;
  gap: 3px;
}

#hud-bar .hud-cluster--center {
  top: 8px;
  max-width: min(650px, calc(var(--ui-viewport-width) - 560px));
}

#hud-bar .hud-cluster--right {
  top: 8px;
  right: 18px;
  gap: 3px;
}

#hud-bar .hud-icon-btn,
.hud-icon-btn {
  width: var(--hud-edge-size);
  height: var(--hud-edge-size);
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-icon-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  color: var(--hud-text);
  font-size: 1.02rem;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.76);
}

#hud-bar .hud-icon-btn:hover,
#hud-bar .hud-icon-btn:focus-visible,
#hud-bar .hud-icon-btn[aria-expanded='true'],
#hud-bar .hud-icon-btn[aria-pressed='true'],
.hud-icon-btn.quest-log-toggle--active,
.hud-icon-btn.tutorial-toggle--active,
.hud-icon-btn.skill-tree-toggle--ready {
  background-image: var(--pretty-icon-active) !important;
  color: var(--hud-gold);
  outline: none;
}

#hud-bar .audio-settings-menu,
.menu-card,
.city-map-panel,
.quest-log-panel,
.skill-tree-overlay .skill-tree-detail,
.skill-tree-overlay .skill-tree-map-frame,
#ui-layer .docked-harbor-panel,
.trade-wizard-form {
  border: 28px solid transparent !important;
  border-image-source: var(--pretty-medium-panel) !important;
  border-image-slice: 72 !important;
  border-image-width: 28px !important;
  border-image-repeat: stretch !important;
  border-radius: 0 !important;
  background:
    linear-gradient(180deg, rgba(8, 27, 31, 0.88), rgba(3, 10, 13, 0.93)),
    rgba(3, 10, 13, 0.93) !important;
  background-clip: padding-box !important;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.44) !important;
}

#hud-bar .audio-settings-menu {
  min-width: 276px;
  padding: 6px 8px 8px;
}

#hud-bar #ship-health-hud,
body.app-playing.boat-mode #hud-bar #ship-health-hud {
  min-width: min(640px, calc(var(--ui-viewport-width) - 600px)) !important;
  max-width: 640px !important;
  min-height: 106px;
  padding: 23px 46px 22px !important;
  border: 0 !important;
  background: var(--pretty-meter-dual) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  gap: 8px;
}

#hud-bar .ship-health-meter-grid {
  gap: 24px;
  align-items: center;
}

#hud-bar .ship-health-hud-row {
  gap: 12px;
}

#hud-bar .ship-health-title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

#hud-bar .ship-health-value {
  font-size: 0.98rem;
  font-weight: 800;
  color: #fff7d6;
}

#hud-bar .ship-health-track,
#hud-bar .ship-morale-track {
  height: 13px !important;
  border: 1px solid rgba(235, 199, 114, 0.24) !important;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(255, 255, 255, 0.04)),
    rgba(3, 9, 10, 0.74) !important;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.52) !important;
}

#hud-bar .crew-morale-warning {
  min-height: 0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
}

.hud-xp-pill,
body.app-playing.boat-mode #hud-bar .hud-xp-pill {
  width: 212px;
  min-height: var(--hud-edge-size);
  padding: 13px 28px 12px 30px;
  border: 0 !important;
  background: var(--pretty-meter-single) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

.hud-xp-track {
  height: 8px;
  border-color: rgba(235, 199, 114, 0.28);
}

#hud-bar #economy-hud,
body.app-playing.boat-mode #hud-bar #economy-hud,
body.boat-mode #hud-bar #economy-hud {
  width: var(--hud-gold-size);
  height: calc(var(--hud-gold-size) + 14px);
  margin-top: -4px;
  border: 0 !important;
  background: var(--pretty-gold-medallion) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

.hud-gold-glyph {
  font-size: 1.54rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.62));
}

.hud-gold-total {
  min-width: 82px;
  padding: 4px 8px 5px;
  border: 1px solid rgba(237, 195, 110, 0.34);
  border-radius: 4px;
  background: rgba(2, 9, 10, 0.68);
  font-size: 1.34rem;
}

.hud-gold-total.is-compact {
  font-size: 1.12rem;
}

.hud-gold-total.is-tiny {
  font-size: 0.98rem;
}

.hud-cargo,
body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo,
.notification-entry,
.gold-console-entry,
#ui-layer .docking-progress {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-chip) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo {
  top: 50%;
  right: max(0px, env(safe-area-inset-right));
  transform: translateY(-50%);
  min-width: 240px;
  padding: 16px 28px 17px;
}

.quest-compass {
  min-width: 330px;
  height: var(--hud-edge-size);
  padding: 0 18px 0 10px;
  border: 0;
  background: var(--pretty-chip) center / 100% 100% no-repeat;
}

.quest-compass-arrow {
  width: 42px;
  height: 42px;
  background: var(--pretty-compass-badge) center / contain no-repeat;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.36));
}

.quest-compass-arrow::before {
  top: 7px;
  border-left-width: 6px;
  border-right-width: 6px;
  border-bottom-width: 17px;
}

.quest-log-panel {
  top: calc(var(--hud-edge-size) + 22px);
  right: 18px;
  width: min(456px, calc(100vw - 24px));
  padding: 6px 8px 10px;
}

.quest-log-row {
  border: 1px solid rgba(237, 195, 110, 0.22);
  border-radius: 4px;
  background: rgba(10, 29, 32, 0.72);
}

.broadside-hud {
  top: calc(var(--ui-viewport-height) - 128px);
}

.broadside-hud .broadside-reload {
  width: 88px;
  height: 88px;
  border: 0 !important;
  background:
    radial-gradient(circle, rgba(3, 10, 13, 0.92) 0 43%, transparent 44%) !important;
  box-shadow: none !important;
  isolation: isolate;
  overflow: visible;
}

.broadside-hud .broadside-reload::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 172px;
  height: 122px;
  background: var(--pretty-broadside-ring) center / contain no-repeat;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.46));
  pointer-events: none;
}

.broadside-reload-ring {
  inset: 16px;
}

.broadside-reload-ring,
.broadside-reload-icon,
.broadside-reload-timer {
  z-index: 1;
}

:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .skill-tree-rename-ship,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-type-button,
  .wizard-actions button,
  .docked-harbor-action,
  .quest-log-select,
  .harbor-quest-action,
  .docked-harbor-market-buy
) {
  min-height: 44px;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-button-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  color: var(--hud-text) !important;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .skill-tree-rename-ship,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-type-button,
  .wizard-actions button,
  .docked-harbor-action,
  .quest-log-select,
  .harbor-quest-action,
  .docked-harbor-market-buy
):hover:not(:disabled),
:is(
  .menu-action,
  .start-button,
  .tutorial-action,
  .skill-tree-learn,
  .skill-tree-rename-ship,
  .player-respawn-button,
  .model-editor-action,
  .boat-model-editor-action,
  .floating-menu-button,
  .wizard-type-button,
  .wizard-actions button,
  .docked-harbor-action,
  .quest-log-select,
  .harbor-quest-action,
  .docked-harbor-market-buy
):focus-visible {
  background-image: var(--pretty-button-active) !important;
  color: #fff4c2 !important;
  outline: none;
}

:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close,
  .skill-tree-map-controls button
) {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-close-button) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  color: var(--hud-text) !important;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

:is(.tutorial-shell, .skill-tree-overlay .skill-tree-shell) {
  border: 38px solid transparent !important;
  border-image-source: var(--pretty-large-panel) !important;
  border-image-slice: 78 !important;
  border-image-width: 38px !important;
  border-image-repeat: stretch !important;
  border-radius: 0 !important;
  background:
    linear-gradient(180deg, rgba(6, 22, 26, 0.94), rgba(2, 9, 13, 0.98)),
    rgba(2, 9, 13, 0.98) !important;
  background-clip: padding-box !important;
}

.tutorial-header,
.tutorial-footer,
.skill-tree-overlay .skill-tree-header {
  position: relative;
}

.tutorial-header::after,
.skill-tree-overlay .skill-tree-header::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -26px;
  width: min(460px, 48%);
  height: 38px;
  background: var(--pretty-divider) center / contain no-repeat;
  transform: translateX(-50%);
  pointer-events: none;
}

@media (max-width: 1180px) {
  #hud-bar {
    left: 6px;
    right: 6px;
    padding-left: 10px;
    padding-right: 10px;
  }

  #hud-bar .hud-cluster--center {
    top: calc(var(--hud-edge-size) + 18px);
    max-width: min(640px, calc(100vw - 20px));
  }

  #hud-bar #ship-health-hud,
  body.app-playing.boat-mode #hud-bar #ship-health-hud {
    min-width: min(640px, calc(100vw - 20px)) !important;
  }
}

@media (max-width: 760px) {
  :root {
    --hud-edge-size: 210px;
    --hud-gold-size: 190px;
  }

  #hud-bar {
    top: 12px;
    left: 8px;
    right: 8px;
    min-height: 238px;
    padding: 24px 28px 0;
  }

  #hud-bar .hud-cluster--right {
    right: 26px;
  }

  .hud-xp-pill,
  body.app-playing.boat-mode #hud-bar .hud-xp-pill {
    display: none;
  }

  #hud-bar .hud-icon-btn,
  .hud-icon-btn {
    font-size: 4rem;
  }

  #hud-bar #ship-health-hud,
  body.app-playing.boat-mode #hud-bar #ship-health-hud {
    min-width: min(760px, calc(100vw - 20px)) !important;
    max-width: 760px !important;
    min-height: 260px;
    padding: 58px 70px 54px !important;
  }

  #hud-bar .ship-health-meter-grid {
    gap: 20px;
  }

  #hud-bar .ship-health-title,
  #hud-bar .ship-health-value {
    font-size: 2.9rem;
  }

  #hud-bar .ship-health-track,
  #hud-bar .ship-morale-track {
    height: 34px !important;
  }

  .hud-gold-glyph {
    font-size: 4.2rem;
  }

  .hud-gold-total {
    min-width: 128px;
    font-size: 3.2rem;
  }

  .quest-log-panel {
    top: calc(var(--hud-edge-size) + 220px);
    right: 20px;
    width: min(820px, calc(100vw - 24px));
  }

  .broadside-hud .broadside-reload {
    width: 300px;
    height: 300px;
  }

  .broadside-hud .broadside-reload::before {
    width: 520px;
    height: 368px;
  }

  .broadside-reload-ring {
    inset: 58px;
  }

  .broadside-reload-icon {
    font-size: 5rem;
  }

  .broadside-reload-timer {
    font-size: 4.2rem;
  }

  :is(.tutorial-shell, .skill-tree-overlay .skill-tree-shell) {
    border-width: 24px !important;
    border-image-width: 24px !important;
  }
}

/* Pretty Game UI Development final cascade lock: keep generated art and tap sizes after legacy HUD overrides. */
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
body.app-playing.boat-mode #hud-bar #ship-health-hud {
  width: clamp(600px, 46vw, 760px) !important;
  min-width: 600px !important;
  max-width: 760px !important;
  min-height: 106px !important;
  padding: 23px 46px 22px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-meter-dual) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-title,
body.boat-mode:not(.app-loading) #hud-bar .ship-health-value {
  letter-spacing: 0.1em;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-track,
body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
  height: 13px !important;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-xp-pill {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-meter-single) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar #economy-hud,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud:not(.hidden),
#hud-bar #economy-hud.hud-gold-pill {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-gold-medallion) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
}

body.boat-mode:not(.app-loading) #hud-bar #economy-hud::before,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud::after,
#hud-bar #economy-hud.hud-gold-pill::before,
#hud-bar #economy-hud.hud-gold-pill::after {
  display: none !important;
}

body.boat-mode:not(.app-loading) .quest-compass,
body.boat-mode:not(.app-loading) #hud-bar .hud-cargo,
body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo,
.notification-entry,
.gold-console-entry,
#ui-layer .docking-progress {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pretty-chip) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.boat-mode:not(.app-loading) .quest-log-panel,
body.boat-mode:not(.app-loading) #hud-bar .audio-settings-menu,
.menu-card,
.city-map-panel,
.skill-tree-overlay .skill-tree-detail,
.skill-tree-overlay .skill-tree-map-frame,
#ui-layer .docked-harbor-panel,
.trade-wizard-form {
  border: 28px solid transparent !important;
  border-image-source: var(--pretty-medium-panel) !important;
  border-image-slice: 72 !important;
  border-image-width: 28px !important;
  border-image-repeat: stretch !important;
  border-radius: 0 !important;
  background:
    linear-gradient(180deg, rgba(8, 27, 31, 0.88), rgba(3, 10, 13, 0.93)),
    rgba(3, 10, 13, 0.93) !important;
  background-clip: padding-box !important;
}

body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload {
  width: 88px !important;
  height: 88px !important;
  border: 0 !important;
  background: radial-gradient(circle, rgba(3, 10, 13, 0.92) 0 43%, transparent 44%) !important;
  box-shadow: none !important;
  isolation: isolate;
  overflow: visible !important;
}

body.boat-mode:not(.app-loading) .broadside-hud {
  top: auto !important;
  bottom: max(54px, calc(env(safe-area-inset-bottom) + 54px)) !important;
  transform: translateX(-50%) !important;
}

body.boat-mode:not(.app-loading) .broadside-hud::before,
body.boat-mode:not(.app-loading) .broadside-hud::after {
  display: none !important;
}

body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  display: block !important;
  width: 172px;
  height: 122px;
  background: var(--pretty-broadside-ring) center / contain no-repeat;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.46));
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@media (max-width: 680px) {
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
  body.app-playing.boat-mode #hud-bar #ship-health-hud {
    width: 760px !important;
    min-width: 760px !important;
    max-width: 760px !important;
    min-height: 260px !important;
    padding: 58px 70px 54px !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-title,
  body.boat-mode:not(.app-loading) #hud-bar .ship-health-value {
    font-size: 2.9rem !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-track,
  body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
    height: 34px !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload {
    width: 300px !important;
    height: 300px !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud {
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px)) !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload::before {
    width: 520px;
    height: 368px;
  }

  body.boat-mode:not(.app-loading) .broadside-reload-ring {
    inset: 58px !important;
  }

  body.boat-mode:not(.app-loading) .broadside-reload-icon {
    font-size: 5rem !important;
  }
}

/* Pretty Game UI Development v2: reusable generated frames with live widget layers. */
:root {
  --pgui2-hud-rail: url('../images/ui/generated/v2/components/hud-rail.png');
  --pgui2-panel-medium: url('../images/ui/generated/v2/components/panel-medium.png');
  --pgui2-panel-large: url('../images/ui/generated/v2/components/panel-large.png');
  --pgui2-icon-normal: url('../images/ui/generated/v2/components/icon-button-normal.png');
  --pgui2-icon-active: url('../images/ui/generated/v2/components/icon-button-active.png');
  --pgui2-icon-muted: url('../images/ui/generated/v2/components/icon-button-muted.png');
  --pgui2-close: url('../images/ui/generated/v2/components/close-button.png');
  --pgui2-button-normal: url('../images/ui/generated/v2/components/button-normal.png');
  --pgui2-button-disabled: url('../images/ui/generated/v2/components/button-disabled.png');
  --pgui2-meter-dual: url('../images/ui/generated/v2/components/meter-dual-frame.png');
  --pgui2-ship-condition-meter: url('../images/ui/generated/v2/components/ship-condition-meter-wide.png');
  --pgui2-compass-compact: url('../images/ui/generated/v2/components/compass-frame-compact.png');
  --pgui2-compass-needle: url('../images/ui/generated/v2/components/compass-needle.png');
  --pgui2-gold-badge: url('../images/ui/generated/v2/components/gold-badge.png');
  --pgui2-chip: url('../images/ui/generated/v2/components/notification-chip.png');
  --pgui2-divider: url('../images/ui/generated/v2/components/divider-flourish.png');
  --pgui2-broadside-ring: url('../images/ui/generated/components/broadside-ring-frame.png');
  --cargo-panel-frame: url('../images/ui/generated/cargo-hold/cargo-panel-frame.png');
  --cargo-slot-filled: url('../images/ui/generated/cargo-hold/cargo-slot-filled.png');
  --cargo-slot-empty: url('../images/ui/generated/cargo-hold/cargo-slot-empty.png');
  --cargo-divider: url('../images/ui/generated/cargo-hold/cargo-divider.png');
  --rum-slot-normal: url('../images/ui/generated/rum-consumable/rum-slot-normal.png');
  --rum-slot-hover: url('../images/ui/generated/rum-consumable/rum-slot-hover.png');
  --rum-slot-disabled: url('../images/ui/generated/rum-consumable/rum-slot-disabled.png');
  --rum-bottle-icon: url('../images/ui/generated/rum-consumable/rum-bottle-icon.png');
  --rum-count-badge: url('../images/ui/generated/rum-consumable/rum-count-badge.png');
}

.rum-consumable-hud {
  position: fixed;
  display: none;
  right: max(18px, calc(env(safe-area-inset-right) + 18px));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
  z-index: 385;
  width: clamp(126px, 9.2vw, 156px);
  aspect-ratio: 1;
  pointer-events: none;
}

.rum-consumable-hud:not(.hidden),
body.boat-mode:not(.app-loading) .rum-consumable-hud:not(.hidden) {
  display: block;
}

body:not(.boat-mode) .rum-consumable-hud,
body.app-loading .rum-consumable-hud {
  display: none !important;
}

.rum-consumable-hud.hidden {
  display: none !important;
}

.rum-consumable-button {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--rum-slot-normal) center / 100% 100% no-repeat;
  color: #f7d184;
  cursor: pointer;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.48));
  pointer-events: all;
  transition:
    filter 160ms ease,
    transform 160ms ease;
}

.rum-consumable-button:not(:disabled):hover,
.rum-consumable-button:not(:disabled):focus-visible {
  background-image: var(--rum-slot-hover);
  filter:
    brightness(1.06)
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 12px rgba(242, 193, 96, 0.26));
  outline: none;
}

.rum-consumable-button:not(:disabled):active {
  transform: translateY(1px) scale(0.985);
}

.rum-consumable-button:disabled {
  background-image: var(--rum-slot-disabled);
  cursor: default;
  filter: grayscale(0.2) brightness(0.74) drop-shadow(0 10px 16px rgba(0, 0, 0, 0.38));
}

.rum-consumable-icon {
  position: absolute;
  left: 23%;
  top: 14%;
  width: 54%;
  height: 67%;
  background: var(--rum-bottle-icon) center / contain no-repeat;
  pointer-events: none;
}

.rum-consumable-button:disabled .rum-consumable-icon {
  opacity: 0.52;
}

.rum-consumable-count {
  position: absolute;
  right: -4%;
  bottom: -5%;
  display: grid;
  place-items: center;
  width: 38%;
  aspect-ratio: 1;
  background: var(--rum-count-badge) center / contain no-repeat;
  color: #fff0bf;
  font-family: 'Courier New', monospace;
  font-size: clamp(1.12rem, 1.28vw, 1.44rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 5px rgba(0, 0, 0, 0.92),
    0 0 8px rgba(0, 0, 0, 0.74);
  pointer-events: none;
}

@media (max-width: 760px) {
  .rum-consumable-hud {
    width: 160px;
    right: max(16px, calc(env(safe-area-inset-right) + 16px));
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  }

  .rum-consumable-count {
    font-size: 1.9rem;
  }
}

body.boat-mode:not(.app-loading) #hud-bar {
  top: env(safe-area-inset-top) !important;
  left: env(safe-area-inset-left) !important;
  right: env(safe-area-inset-right) !important;
  min-height: calc(var(--hud-edge-size) + 18px) !important;
  padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)) !important;
  border: 0 !important;
  background: linear-gradient(180deg, rgba(2, 8, 10, 0.74), rgba(2, 8, 10, 0.24) 64%, transparent) !important;
  box-shadow: none !important;
  overflow: visible;
}

body.boat-mode:not(.app-loading) #hud-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(var(--hud-edge-size) + 8px);
  z-index: -1;
  background: var(--pgui2-hud-rail) top center / auto 100% repeat-x;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

body.boat-mode:not(.app-loading) .hud-cluster--center {
  top: max(17px, calc(env(safe-area-inset-top) + 17px)) !important;
  left: 43% !important;
  max-width: min(980px, calc(var(--ui-viewport-width) - 430px)) !important;
  align-items: flex-start !important;
  gap: 14px !important;
}

body.boat-mode:not(.app-loading) .hud-cluster--right,
body.boat-mode:not(.app-loading) #hud-tl {
  top: max(9px, calc(env(safe-area-inset-top) + 9px)) !important;
  gap: 8px !important;
  align-items: flex-start !important;
}

body.boat-mode:not(.app-loading) .hud-icon-btn {
  width: var(--hud-edge-size) !important;
  height: var(--hud-edge-size) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-icon-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  color: #f4d487 !important;
  overflow: visible !important;
}

body.boat-mode:not(.app-loading) .hud-icon-btn::before {
  display: none !important;
}

body.boat-mode:not(.app-loading) .hud-icon-btn::after {
  color: currentColor !important;
  font-size: clamp(1.48rem, 1.62vw, 1.92rem) !important;
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.92),
    0 0 8px rgba(244, 212, 135, 0.28);
}

body.boat-mode:not(.app-loading) .hud-icon-btn:empty::after {
  content: var(--hud-icon, "");
}

body.boat-mode:not(.app-loading) .hud-icon-btn:hover,
body.boat-mode:not(.app-loading) .hud-icon-btn:focus-visible,
body.boat-mode:not(.app-loading) .hud-icon-btn[aria-expanded='true'],
body.boat-mode:not(.app-loading) .hud-icon-btn.quest-log-toggle--active,
body.boat-mode:not(.app-loading) .hud-icon-btn.skill-tree-toggle--ready {
  background-image: var(--pgui2-icon-active) !important;
  color: #fff0b3 !important;
  filter: brightness(1.04);
}

body.boat-mode:not(.app-loading) .hud-icon-btn[aria-pressed='false'],
body.boat-mode:not(.app-loading) .hud-icon-btn:disabled {
  background-image: var(--pgui2-icon-muted) !important;
  color: rgba(223, 205, 156, 0.58) !important;
}

body.boat-mode:not(.app-loading) .skill-tree-point-badge {
  right: -2px !important;
  top: -3px !important;
  border-color: rgba(255, 230, 166, 0.94) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
body.app-playing.boat-mode #hud-bar #ship-health-hud {
  position: relative !important;
  display: block !important;
  width: clamp(500px, 33.5vw, 640px) !important;
  min-width: clamp(500px, 33.5vw, 640px) !important;
  max-width: 640px !important;
  min-height: 0 !important;
  height: auto !important;
  aspect-ratio: 640 / 150;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-ship-condition-meter) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
  gap: 0 !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-meter-grid {
  position: absolute;
  inset: 0;
  display: block !important;
  height: 100%;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-condition-meter {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  min-width: 0;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud-row {
  position: absolute !important;
  left: 12.8125%;
  width: 18%;
  height: 14.6667%;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-condition-meter:nth-child(1) .ship-health-hud-row {
  top: 32.6667%;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-condition-meter:nth-child(2) .ship-health-hud-row {
  top: 62%;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-title {
  display: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-value {
  width: 100%;
  font-family: 'Cinzel', Georgia, serif !important;
  font-size: clamp(0.86rem, 0.98vw, 1.18rem) !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  color: #fff0c5 !important;
  text-align: center !important;
  white-space: nowrap;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.92),
    0 0 8px rgba(2, 8, 12, 0.86) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-track,
body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
  position: absolute !important;
  left: 33.4375%;
  width: 53.28125%;
  height: 6.6667% !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-track {
  top: 37.3333%;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
  top: 66.6667%;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-fill,
body.boat-mode:not(.app-loading) #hud-bar .ship-morale-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit !important;
  min-width: 0;
  transform-origin: left center;
  will-change: transform;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-fill {
  background: linear-gradient(90deg, #2db86d, #6df09e 68%, #e8f6b6) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-morale-fill {
  background: linear-gradient(90deg, #41c5c3, #58e0a3 72%, #d9f2af) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud.low .ship-health-fill {
  background: linear-gradient(90deg, #d99a31, #f5d46d) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud.critical .ship-health-fill,
body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud.morale-critical .ship-morale-fill,
body.boat-mode:not(.app-loading) #hud-bar .ship-health-hud.mutiny .ship-morale-fill {
  background: linear-gradient(90deg, #b8292d, #ff7468) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .crew-morale-warning {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 100%;
  min-height: 0 !important;
  margin-top: 4px !important;
  padding: 7px 12px !important;
  border: 1px solid rgba(248, 113, 113, 0.72) !important;
  border-radius: 6px !important;
  background: rgba(77, 17, 17, 0.92) !important;
  font-size: clamp(0.74rem, 0.8vw, 0.95rem) !important;
  letter-spacing: 0.08em !important;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-xp-pill,
body.app-playing.boat-mode #hud-bar .hud-xp-pill {
  width: clamp(226px, 14.6vw, 292px) !important;
  min-width: clamp(226px, 14.6vw, 292px) !important;
  min-height: var(--hud-edge-size) !important;
  height: var(--hud-edge-size) !important;
  padding: 11px 22px 12px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-button-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.boat-mode:not(.app-loading) .hud-xp-row {
  gap: 12px !important;
  align-items: baseline !important;
}

body.boat-mode:not(.app-loading) .hud-xp-level {
  color: #f5ce78 !important;
  font-size: clamp(0.82rem, 0.76vw, 0.98rem) !important;
  letter-spacing: 0.06em !important;
}

body.boat-mode:not(.app-loading) .hud-xp-progress-text {
  font-family: 'Courier New', monospace !important;
  color: rgba(239, 222, 179, 0.76) !important;
  font-size: clamp(0.66rem, 0.62vw, 0.78rem) !important;
}

body.boat-mode:not(.app-loading) .hud-xp-track {
  height: 8px !important;
  margin-top: 5px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(0, 4, 7, 0.58) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.72) !important;
}

body.boat-mode:not(.app-loading) .hud-xp-fill {
  border-radius: inherit !important;
  background: linear-gradient(90deg, #3fb8d8, #6fe6e0, #f3d27b) !important;
  box-shadow: 0 0 12px rgba(111, 230, 224, 0.24);
}

body.app-playing #hud-bar #economy-hud,
body.app-playing #hud-bar #economy-hud:not(.hidden),
body.boat-mode:not(.app-loading) #hud-bar #economy-hud,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud:not(.hidden),
#hud-bar #economy-hud.hud-gold-pill,
#hud-bar #economy-hud.hud-gold-pill:not(.hidden) {
  display: grid !important;
  grid-template-columns: 52px minmax(0, 1fr) !important;
  align-items: center !important;
  justify-items: center !important;
  width: clamp(176px, 12.8vw, 228px) !important;
  min-width: clamp(176px, 12.8vw, 228px) !important;
  max-width: clamp(176px, 12.8vw, 228px) !important;
  height: var(--hud-edge-size) !important;
  min-height: var(--hud-edge-size) !important;
  max-height: var(--hud-edge-size) !important;
  padding: 0 20px 0 14px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-gold-badge) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  overflow: visible !important;
}

body.app-playing #hud-bar #economy-hud::before,
body.app-playing #hud-bar #economy-hud::after,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud::before,
body.boat-mode:not(.app-loading) #hud-bar #economy-hud::after,
#hud-bar #economy-hud.hud-gold-pill::before,
#hud-bar #economy-hud.hud-gold-pill::after {
  display: none !important;
}

body.app-playing #hud-bar .hud-gold-glyph,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-glyph,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-glyph {
  display: none !important;
}

body.app-playing #hud-bar .hud-gold-total,
body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total,
#hud-bar #economy-hud.hud-gold-pill .hud-gold-total {
  position: static !important;
  grid-column: 2;
  width: 100% !important;
  color: #f7d184 !important;
  font-family: 'Courier New', monospace !important;
  font-size: clamp(1rem, 1.06vw, 1.25rem) !important;
  line-height: 1 !important;
  text-align: center !important;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.92) !important;
}

body.boat-mode:not(.app-loading) .quest-compass {
  --quest-compass-rose-center-x: 13.838%;
  --quest-compass-rose-width: 27.676%;
  --quest-compass-message-right-pad: 8.5%;
  --quest-compass-needle-width: 56px;
  --quest-compass-needle-height: 96px;
  position: relative !important;
  grid-template-columns: var(--quest-compass-rose-width) minmax(0, 1fr) !important;
  grid-template-rows: 1fr 1fr !important;
  column-gap: 0 !important;
  row-gap: 0 !important;
  align-items: center !important;
  width: clamp(360px, 22vw, 383px) !important;
  min-width: clamp(360px, 22vw, 383px) !important;
  max-width: clamp(360px, 22vw, 383px) !important;
  height: auto !important;
  aspect-ratio: 383 / 106;
  padding: 0 24px 0 10px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-compass-compact) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

body.boat-mode:not(.app-loading) .quest-compass-arrow {
  position: absolute !important;
  left: var(--quest-compass-rose-center-x) !important;
  top: 50% !important;
  z-index: 1 !important;
  width: var(--quest-compass-needle-width) !important;
  height: var(--quest-compass-needle-height) !important;
  margin-left: calc(var(--quest-compass-needle-width) * -0.5) !important;
  margin-top: calc(var(--quest-compass-needle-height) * -0.5) !important;
  background: var(--pgui2-compass-needle) center / contain no-repeat;
  transform-origin: 50% 50% !important;
  filter:
    drop-shadow(0 0 7px rgba(255, 232, 132, 0.92))
    drop-shadow(0 0 18px rgba(255, 175, 48, 0.7))
    drop-shadow(0 3px 6px rgba(0, 0, 0, 0.68));
  will-change: transform;
}

body.boat-mode:not(.app-loading) .quest-compass-arrow::before {
  display: none !important;
}

body.boat-mode:not(.app-loading) .quest-compass-title {
  grid-column: 2 !important;
  grid-row: 1 !important;
  align-self: end !important;
  color: #f4e5bc !important;
  font-size: clamp(0.7rem, 0.7vw, 0.88rem) !important;
  letter-spacing: 0.05em !important;
  padding-right: var(--quest-compass-message-right-pad) !important;
  text-align: center !important;
}

#hud-bar .music-track-select-control {
  font-family: 'Courier New', monospace !important;
  font-size: clamp(0.68rem, 0.68vw, 0.84rem) !important;
}

#hud-bar .music-track-select-control span {
  text-align: center;
}

#hud-bar .music-track-select {
  font-size: clamp(0.68rem, 0.68vw, 0.8rem) !important;
}

body.boat-mode:not(.app-loading) .quest-compass.quest-compass--empty {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
  padding: 0 24px !important;
}

body.boat-mode:not(.app-loading) .quest-compass.quest-compass--empty .quest-compass-arrow,
body.boat-mode:not(.app-loading) .quest-compass.quest-compass--empty .quest-compass-distance {
  display: none !important;
}

body.boat-mode:not(.app-loading) .quest-compass.quest-compass--empty .quest-compass-title {
  grid-column: 1;
  width: 100%;
  text-align: center;
}

body.boat-mode:not(.app-loading) .quest-compass-distance {
  grid-column: 2 !important;
  grid-row: 2 !important;
  align-self: start !important;
  color: #f4ce77 !important;
  font-family: 'Courier New', monospace !important;
  font-size: clamp(0.68rem, 0.68vw, 0.84rem) !important;
  padding-right: var(--quest-compass-message-right-pad) !important;
  text-align: center !important;
}

body.boat-mode:not(.app-loading) .quest-log-panel,
body.boat-mode:not(.app-loading) #hud-bar .audio-settings-menu,
#ui-layer .docked-harbor-panel,
.trade-wizard-form,
.menu-card,
.city-map-panel {
  border: 32px solid transparent !important;
  border-image-source: var(--pgui2-panel-medium) !important;
  border-image-slice: 58 fill !important;
  border-image-width: 32px !important;
  border-image-repeat: stretch !important;
  border-radius: 0 !important;
  background: rgba(32, 22, 13, 0.88) !important;
  background-clip: padding-box !important;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.48) !important;
  color: #2b2114 !important;
}

body.boat-mode:not(.app-loading) .quest-log-panel {
  top: calc(var(--hud-edge-size) + 22px) !important;
  width: min(560px, calc(var(--ui-viewport-width) - 36px)) !important;
  min-width: min(420px, calc(var(--ui-viewport-width) - 36px)) !important;
  padding: 12px 16px 16px !important;
}

body.boat-mode:not(.app-loading) .quest-log-header,
body.boat-mode:not(.app-loading) .audio-settings-header {
  min-height: 34px !important;
  color: #2b2114 !important;
  border-bottom: 1px solid rgba(85, 52, 23, 0.22);
}

body.boat-mode:not(.app-loading) .quest-log-empty,
body.boat-mode:not(.app-loading) .quest-log-title,
body.boat-mode:not(.app-loading) .music-track-select-control span,
body.boat-mode:not(.app-loading) .audio-volume-control span {
  color: #302416 !important;
}

body.boat-mode:not(.app-loading) .quest-log-detail,
body.boat-mode:not(.app-loading) #hud-bar output {
  color: rgba(48, 36, 22, 0.72) !important;
}

body.boat-mode:not(.app-loading) .quest-log-close,
body.boat-mode:not(.app-loading) #hud-bar .audio-settings-close {
  width: 34px !important;
  height: 34px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-close) center / 100% 100% no-repeat !important;
  color: #f2d188 !important;
  font-size: 0 !important;
}

body.boat-mode:not(.app-loading) .quest-log-close::after,
body.boat-mode:not(.app-loading) #hud-bar .audio-settings-close::after {
  content: '×';
  font-size: 1.2rem;
  line-height: 1;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

body.boat-mode:not(.app-loading) .quest-log-select,
#ui-layer .docked-harbor-action,
#ui-layer .docked-harbor-market-buy,
#ui-layer .harbor-quest-action {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-button-normal) center / 100% 100% no-repeat !important;
  color: #f0d28c !important;
  box-shadow: none !important;
}

body.boat-mode:not(.app-loading) .quest-log-select:disabled,
#ui-layer .docked-harbor-action:disabled,
#ui-layer .docked-harbor-market-buy:disabled,
#ui-layer .harbor-quest-action:disabled {
  background-image: var(--pgui2-button-disabled) !important;
  color: rgba(238, 226, 198, 0.56) !important;
}

#ui-layer .docked-harbor-action:not(:disabled):hover,
#ui-layer .docked-harbor-action:not(:disabled):focus-visible,
#ui-layer .docked-harbor-market-buy:not(:disabled):hover,
#ui-layer .docked-harbor-market-buy:not(:disabled):focus-visible,
#ui-layer .harbor-quest-action:not(:disabled):hover,
#ui-layer .harbor-quest-action:not(:disabled):focus-visible {
  background: var(--pgui2-button-normal) center / 100% 100% no-repeat !important;
  color: #fff2bf !important;
  outline: none;
}

body.boat-mode:not(.app-loading) .quest-log-row,
#ui-layer .docked-harbor-berth,
#ui-layer .docked-harbor-market-row,
#ui-layer .docked-harbor-upgrade-row,
#ui-layer .harbor-quest-row {
  border: 0 !important;
  border-radius: 0 !important;
  background: rgba(86, 55, 26, 0.11) !important;
  box-shadow: inset 0 0 0 1px rgba(105, 70, 35, 0.16);
  color: #302416 !important;
}

#ui-layer .docked-harbor-panel .harbor-quest-detail {
  color: #111111 !important;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.25;
  text-shadow: none;
}

body.boat-mode:not(.app-loading) .quest-log-row--current {
  background: rgba(194, 142, 67, 0.18) !important;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-cargo,
body.boat-mode:not(.app-loading) .quest-compass.hidden + #ship-health-hud + .hud-cargo,
.notification-entry,
.gold-console-entry,
#ui-layer .docking-progress {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-chip) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-cargo,
body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo {
  top: calc(var(--ui-viewport-height) * 0.5) !important;
  right: max(18px, env(safe-area-inset-right)) !important;
  transform: translateY(-50%) !important;
}

#hud-bar .hud-cargo {
  position: absolute !important;
  top: calc(var(--ui-viewport-height) * 0.5) !important;
  right: max(18px, env(safe-area-inset-right)) !important;
  bottom: auto !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  z-index: 560 !important;
}

body.boat-mode:not(.app-loading) #hud-bar .hud-cargo,
body.app-playing.boat-mode #hud-bar .hud-cargo,
body.boat-mode #hud-bar .hud-cargo,
#hud-bar .hud-cargo {
  box-sizing: border-box !important;
  width: 284px !important;
  min-width: 284px !important;
  max-width: 284px !important;
  gap: 8px !important;
  padding: 18px 22px 20px !important;
  border: 24px solid transparent !important;
  border-image-source: var(--cargo-panel-frame) !important;
  border-image-slice: 64 fill !important;
  border-image-width: 24px !important;
  border-image-repeat: stretch !important;
  background: rgba(5, 12, 17, 0.86) !important;
  color: #f7e6ba !important;
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.38) !important;
  pointer-events: none;
}

#hud-bar .hud-cargo-header {
  min-height: 18px;
  padding: 0 4px 3px;
  border-bottom: 0;
}

#hud-bar .hud-cargo-items {
  gap: 5px;
}

#hud-bar .hud-cargo-item {
  box-sizing: border-box;
  min-height: 34px;
  padding: 7px 13px 8px;
  background: var(--cargo-slot-filled) center / 100% 100% no-repeat;
  color: #f9e4ad;
  font-size: 0.76rem;
  line-height: 1.05;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
}

#hud-bar .hud-cargo-item--empty {
  background-image: var(--cargo-slot-empty);
}

#hud-bar .hud-cargo-item-name {
  color: #f0c674;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}

#hud-bar .hud-cargo-item-amt {
  color: rgba(248, 226, 179, 0.72);
  font-size: 0.69rem;
}

#hud-bar .hud-cargo-item--empty .hud-cargo-item-name,
#hud-bar .hud-cargo-item--empty .hud-cargo-item-amt {
  color: rgba(236, 213, 166, 0.56);
}

#hud-bar .hud-cargo-value-row {
  min-height: 30px;
  margin-top: 0;
  padding: 12px 8px 0;
  border-top: 0;
  background: var(--cargo-divider) top center / 100% 10px no-repeat;
}

body.boat-mode:not(.app-loading) .broadside-hud {
  top: auto !important;
  bottom: env(safe-area-inset-bottom) !important;
  transform: translateX(-50%) !important;
}

body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload {
  width: 94px !important;
  height: 94px !important;
  border: 0 !important;
  border-radius: 50% !important;
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload::before {
  content: '' !important;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  display: block !important;
  width: 184px !important;
  height: 128px !important;
  background: var(--pgui2-broadside-ring) center / contain no-repeat !important;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.46));
  transform: translate(-50%, -50%) !important;
  pointer-events: none;
}

body.skill-tree-open #hud-bar,
body.skill-tree-open #broadside-hud,
body.skill-tree-open #rum-consumable-hud,
body.skill-tree-open .mobile-joystick,
body.tutorial-open #hud-bar,
body.tutorial-open #broadside-hud,
body.tutorial-open #rum-consumable-hud,
body.tutorial-open .mobile-joystick {
  display: none !important;
}

body.skill-tree-open a[href*="vibej.am"],
body.tutorial-open a[href*="vibej.am"] {
  display: none !important;
}

body.boat-mode:not(.app-loading) .broadside-reload-ring {
  inset: 13px !important;
  z-index: 1 !important;
}

@media (max-width: 680px) {
  :root {
    --hud-edge-size: 210px;
    --hud-gold-size: 210px;
  }

  body.boat-mode:not(.app-loading) #hud-bar {
    min-height: 244px !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar::before {
    height: 244px;
  }

  body.boat-mode:not(.app-loading) .hud-cluster--center {
    top: 245px !important;
    left: 50% !important;
    max-width: var(--ui-viewport-width) !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 14px !important;
  }

  body.boat-mode:not(.app-loading) #hud-tr {
    max-width: 920px !important;
    flex-wrap: nowrap !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
  body.app-playing.boat-mode #hud-bar #ship-health-hud {
    width: min(1120px, calc(var(--ui-viewport-width) - 52px)) !important;
    min-width: 0 !important;
    max-width: min(1120px, calc(var(--ui-viewport-width) - 52px)) !important;
    height: auto !important;
    aspect-ratio: 640 / 150;
    padding: 0 !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-title {
    display: none !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-value {
    font-size: clamp(1.85rem, 4.2vw, 3.25rem) !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .ship-health-track,
  body.boat-mode:not(.app-loading) #hud-bar .ship-morale-track {
    height: 6.6667% !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar .hud-xp-pill,
  body.app-playing.boat-mode #hud-bar .hud-xp-pill {
    width: 620px !important;
    min-width: 620px !important;
    height: 210px !important;
    padding: 38px 58px 42px !important;
  }

  body.boat-mode:not(.app-loading) .hud-xp-level {
    font-size: 2.7rem !important;
  }

  body.boat-mode:not(.app-loading) .hud-xp-progress-text {
    font-size: 2.2rem !important;
  }

  body.boat-mode:not(.app-loading) .hud-xp-track {
    height: 27px !important;
    margin-top: 16px !important;
  }

  body.app-playing #hud-bar #economy-hud,
  body.boat-mode:not(.app-loading) #hud-bar #economy-hud,
  #hud-bar #economy-hud.hud-gold-pill {
    width: 500px !important;
    min-width: 500px !important;
    max-width: 500px !important;
    height: 210px !important;
    min-height: 210px !important;
    max-height: 210px !important;
    grid-template-columns: 124px minmax(0, 1fr) !important;
    padding: 0 52px 0 36px !important;
  }

  body.app-playing #hud-bar .hud-gold-total,
  body.boat-mode:not(.app-loading) #hud-bar .hud-gold-total,
  #hud-bar #economy-hud.hud-gold-pill .hud-gold-total {
    font-size: 3.05rem !important;
  }

  body.boat-mode:not(.app-loading) .quest-compass {
    --quest-compass-needle-width: 112px;
    --quest-compass-needle-height: 192px;
    --quest-compass-message-right-pad: 8.5%;
    width: 760px !important;
    min-width: 760px !important;
    max-width: 760px !important;
    height: auto !important;
    aspect-ratio: 383 / 106;
    grid-template-columns: var(--quest-compass-rose-width) minmax(0, 1fr) !important;
    padding: 0 58px 0 24px !important;
  }

  body.boat-mode:not(.app-loading) .quest-compass-arrow {
    width: var(--quest-compass-needle-width) !important;
    height: var(--quest-compass-needle-height) !important;
  }

  body.boat-mode:not(.app-loading) .quest-compass-title {
    font-size: 2.25rem !important;
  }

  body.boat-mode:not(.app-loading) .quest-compass-distance {
    font-size: 2.15rem !important;
  }

  body.boat-mode:not(.app-loading) .quest-log-panel {
    top: 485px !important;
    right: 18px !important;
    width: 900px !important;
    max-height: calc(var(--ui-viewport-height) - 540px) !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud {
    bottom: env(safe-area-inset-bottom) !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload {
    width: 304px !important;
    height: 304px !important;
  }

  body.boat-mode:not(.app-loading) .broadside-hud .broadside-reload::before {
    width: 540px !important;
    height: 378px !important;
  }
}

/* Pretty Game UI Development v2 specificity lock for legacy HUD selectors. */
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload),
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload) {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-icon-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  font-size: 0 !important;
}

body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)::after,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)::after {
  position: absolute !important;
  inset: 0 !important;
  display: grid !important;
  place-items: center !important;
  font-size: clamp(1.48rem, 1.62vw, 1.92rem) !important;
}

body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):hover,
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):focus-visible,
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)[aria-expanded='true'],
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn.quest-log-toggle--active,
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn.skill-tree-toggle--ready,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):hover,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):focus-visible,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)[aria-expanded='true'],
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn.quest-log-toggle--active,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn.skill-tree-toggle--ready {
  background: var(--pgui2-icon-active) center / 100% 100% no-repeat !important;
}

body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)[aria-pressed='false'],
body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):disabled,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload)[aria-pressed='false'],
body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-icon-btn:not(.broadside-reload):disabled {
  background: var(--pgui2-icon-muted) center / 100% 100% no-repeat !important;
}

body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar #experience-hud.hud-xp-pill,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar #experience-hud.hud-xp-pill {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-button-normal) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar #quest-compass.quest-compass,
body.boat-mode:not(.app-loading) #ui-layer #hud-bar #quest-compass.quest-compass {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--pgui2-compass-compact) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
}

@media (max-width: 760px) {
  body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar #experience-hud.hud-xp-pill,
  body.boat-mode:not(.app-loading) #ui-layer #hud-bar #experience-hud.hud-xp-pill {
    position: absolute !important;
    top: 900px !important;
    right: 18px !important;
    z-index: 5 !important;
    display: flex !important;
    width: 620px !important;
    min-width: 620px !important;
    max-width: 620px !important;
    height: 154px !important;
    min-height: 154px !important;
    max-height: 154px !important;
    padding: 34px 56px 38px !important;
  }

  body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-level,
  body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-level {
    font-size: 2.25rem !important;
  }

  body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-progress-text,
  body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-progress-text {
    font-size: 1.85rem !important;
  }

  body.app-playing.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-track,
  body.boat-mode:not(.app-loading) #ui-layer #hud-bar .hud-xp-track {
    height: 22px !important;
    margin-top: 13px !important;
  }
}

/* Generated infamy meter. */
:root {
  --infamy-meter-frame-art: url('../images/ui/generated/infamy-meter/components/infamy-meter-frame.png');
  --infamy-track-empty-art: url('../images/ui/generated/infamy-meter/components/infamy-track-empty.png');
  --infamy-fill-crimson-art: url('../images/ui/generated/infamy-meter/components/infamy-fill-crimson.png');
  --infamy-icon-medallion-art: url('../images/ui/generated/infamy-meter/components/infamy-icon-medallion.png');
  --infamy-value-badge-art: url('../images/ui/generated/infamy-meter/components/infamy-value-badge.png');
  --infamy-warning-glow-art: url('../images/ui/generated/infamy-meter/components/infamy-warning-glow.png');
}

#infamy-meter.infamy-meter {
  --infamy-fill-percent: 0%;
  display: none;
  position: absolute;
  top: 53%;
  left: max(18px, env(safe-area-inset-left));
  width: 110px;
  height: 382px;
  transform: translateY(-50%);
  transform-origin: center left;
  pointer-events: none;
  z-index: 314;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
}

body.app-playing.boat-mode:not(.app-loading) #infamy-meter.infamy-meter {
  display: block;
}

body.skill-tree-open #infamy-meter.infamy-meter,
body.tutorial-open #infamy-meter.infamy-meter,
body.player-ship-sunk #infamy-meter.infamy-meter {
  display: none !important;
}

#infamy-meter .infamy-meter-frame,
#infamy-meter .infamy-meter-track,
#infamy-meter .infamy-meter-fill,
#infamy-meter .infamy-meter-icon,
#infamy-meter .infamy-meter-badge,
#infamy-meter .infamy-meter-glow {
  position: absolute;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

#infamy-meter .infamy-meter-frame {
  top: 38px;
  left: 20px;
  width: 70px;
  height: 264px;
  background-image: var(--infamy-meter-frame-art);
  opacity: 0.96;
}

#infamy-meter .infamy-meter-track {
  top: 75px;
  left: 39px;
  width: 32px;
  height: 196px;
  overflow: hidden;
  border-radius: 999px;
  background-image: var(--infamy-track-empty-art);
  box-shadow: inset 0 0 12px rgba(5, 3, 2, 0.72);
}

#infamy-meter .infamy-meter-fill {
  right: 5px;
  bottom: 8px;
  left: 5px;
  height: var(--infamy-fill-percent);
  max-height: calc(100% - 16px);
  min-height: 0;
  border-radius: 999px 999px 18px 18px;
  background-image: var(--infamy-fill-crimson-art);
  background-position: center bottom;
  opacity: 0.95;
  transition: height 240ms ease, opacity 240ms ease;
}

#infamy-meter .infamy-meter-icon {
  top: 0;
  left: 50%;
  width: 66px;
  height: 66px;
  transform: translateX(-50%);
  background-image: var(--infamy-icon-medallion-art);
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.52));
}

#infamy-meter .infamy-meter-glow {
  top: 60px;
  left: 50%;
  width: 58px;
  height: 170px;
  transform: translateX(-50%);
  background-image: var(--infamy-warning-glow-art);
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 220ms ease, transform 220ms ease;
}

#infamy-meter .infamy-meter-badge {
  bottom: 0;
  left: 50%;
  display: grid;
  width: 104px;
  height: 61px;
  padding: 8px 12px 9px;
  transform: translateX(-50%);
  place-items: center;
  align-content: center;
  box-sizing: border-box;
  background-image: var(--infamy-value-badge-art);
  color: #fff0d1;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.88);
}

#infamy-meter .infamy-meter-title {
  font-size: 0.5rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

#infamy-meter .infamy-meter-value {
  margin-top: 1px;
  color: #ffdf82;
  font-size: 1.28rem;
  font-weight: 1000;
}

#infamy-meter .infamy-meter-label {
  max-width: 100%;
  overflow: hidden;
  color: #ffd2c0;
  font-size: 0.48rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

#infamy-meter.is-clear .infamy-meter-fill {
  opacity: 0;
}

#infamy-meter.is-wanted .infamy-meter-glow {
  opacity: 0.3;
}

#infamy-meter.is-notorious .infamy-meter-glow {
  opacity: 0.66;
  transform: translateX(-50%) scale(1.06);
}

#infamy-meter.is-notorious .infamy-meter-value,
#infamy-meter.is-notorious .infamy-meter-label {
  color: #ff6f53;
}

@media (max-width: 680px) {
  #infamy-meter.infamy-meter {
    top: 40%;
    left: max(14px, env(safe-area-inset-left));
    width: 138px;
    height: 488px;
  }

  #infamy-meter .infamy-meter-frame {
    top: 50px;
    left: 25px;
    width: 88px;
    height: 332px;
  }

  #infamy-meter .infamy-meter-track {
    top: 96px;
    left: 51px;
    width: 36px;
    height: 238px;
  }

  #infamy-meter .infamy-meter-icon {
    width: 78px;
    height: 78px;
  }

  #infamy-meter .infamy-meter-glow {
    top: 84px;
    width: 70px;
    height: 210px;
  }

  #infamy-meter .infamy-meter-badge {
    width: 132px;
    height: 77px;
    padding: 10px 14px 11px;
  }

  #infamy-meter .infamy-meter-title {
    font-size: 0.62rem;
  }

  #infamy-meter .infamy-meter-value {
    font-size: 1.56rem;
  }

  #infamy-meter .infamy-meter-label {
    font-size: 0.56rem;
  }
}

/* HUD reward/docking placement pass. */
body.app-playing #notification-panel,
body:not(.app-menu):not(.app-city-select):not(.app-loading) #notification-panel {
  position: absolute !important;
  top: max(84px, calc(env(safe-area-inset-top) + 84px)) !important;
  right: max(18px, env(safe-area-inset-right)) !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  align-items: flex-end !important;
  width: auto !important;
  max-width: min(420px, calc(var(--ui-viewport-width) - 36px)) !important;
  pointer-events: none;
  z-index: 315;
}

#permanent-notifications.notification-list,
#gold-console.gold-console {
  align-items: flex-end !important;
  width: auto !important;
  max-width: 100% !important;
}

.notification-entry,
.gold-console-entry {
  box-sizing: border-box;
  width: fit-content !important;
  min-width: min(258px, calc(var(--ui-viewport-width) - 36px));
  max-width: min(420px, calc(var(--ui-viewport-width) - 36px)) !important;
}

.gold-console-entry {
  min-height: 70px;
  padding: 17px 34px 18px !important;
  gap: 0 !important;
  justify-content: center;
}

.gold-console-icon {
  display: none !important;
}

.gold-console-message {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ui-layer .docking-progress {
  left: max(18px, env(safe-area-inset-left)) !important;
  right: auto !important;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 22px)) !important;
  transform: none !important;
  min-width: min(450px, calc(var(--ui-viewport-width) - 36px)) !important;
  max-width: min(540px, calc(var(--ui-viewport-width) - 36px)) !important;
}

@media (max-width: 680px) {
  body.app-playing #notification-panel,
  body:not(.app-menu):not(.app-city-select):not(.app-loading) #notification-panel {
    top: 254px !important;
    right: 18px !important;
    width: auto !important;
    max-width: min(560px, calc(var(--ui-viewport-width) - 36px)) !important;
  }

  .notification-entry,
  .gold-console-entry {
    min-width: min(360px, calc(var(--ui-viewport-width) - 36px));
    max-width: min(560px, calc(var(--ui-viewport-width) - 36px)) !important;
  }

  .gold-console-entry {
    min-height: 98px;
    padding: 26px 58px 28px !important;
    font-size: 1.75rem !important;
  }

  #ui-layer .docking-progress {
    left: 18px !important;
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 24px)) !important;
    min-width: min(560px, calc(var(--ui-viewport-width) - 36px)) !important;
    max-width: min(760px, calc(var(--ui-viewport-width) - 36px)) !important;
  }
}

/* Generated close buttons include their own X; hide fallback text overlays. */
:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close
) {
  position: relative !important;
  flex: 0 0 42px !important;
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  box-shadow: none !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
}

:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close
)::before,
:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close
)::after {
  content: none !important;
}

:is(
  .panel-close-button,
  .ghost-icon,
  .audio-settings-close,
  .tutorial-close,
  .quest-log-close,
  .skill-tree-close,
  .company-panel-close
)::before {
  content: '' !important;
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  width: 42px !important;
  height: 42px !important;
  background: var(--pgui2-close) center / contain no-repeat !important;
  transform: translate(-50%, -50%) !important;
  pointer-events: none;
}

:is(
  .harbor-panel-header,
  .trade-wizard-header,
  .floating-menu-header,
  .audio-settings-header,
  .quest-log-header,
  .tutorial-header,
  .skill-tree-header,
  .company-panel-header
) {
  overflow: visible !important;
}

/* Skill progression web: no left detail panel or center flagship widget. */
.skill-tree-overlay .skill-tree-body {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "map" !important;
}

.skill-tree-overlay .skill-tree-map-frame {
  grid-area: map !important;
}

.skill-tree-overlay .skill-tree-detail,
.skill-tree-overlay .skill-tree-center,
.skill-tree-overlay .skill-tree-center-ship {
  display: none !important;
}

/* Final lock for image-only skill nodes. Keep after older generated UI cascades. */
.skill-tree-overlay #skill-tree-nodes .skill-node {
  width: clamp(112px, 6.8vw, 142px) !important;
  height: clamp(112px, 6.8vw, 142px) !important;
  display: block !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node.is-inner-ring {
  width: clamp(100px, 5.9vw, 126px) !important;
  height: clamp(100px, 5.9vw, 126px) !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node::before {
  content: "" !important;
  position: absolute !important;
  inset: 5% !important;
  z-index: 3 !important;
  border: 2px solid color-mix(in srgb, var(--node-color) 62%, #fff0b5 24%) !important;
  border-radius: 50% !important;
  outline: 0 !important;
  background: transparent !important;
  clip-path: none !important;
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.28),
    0 0 18px color-mix(in srgb, var(--node-color) 30%, transparent 70%) !important;
  pointer-events: none !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node::after {
  border-radius: 50% !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node-image-wrap {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  border: 0 !important;
  border-radius: 50% !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node-image {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
}

.skill-tree-overlay #skill-tree-nodes .skill-node-icon-ring,
.skill-tree-overlay #skill-tree-nodes .skill-node-icon,
.skill-tree-overlay #skill-tree-nodes .skill-node-name,
.skill-tree-overlay #skill-tree-nodes .skill-node-branch,
.skill-tree-overlay #skill-tree-nodes .skill-node-effect {
  display: none !important;
}

@media (max-width: 680px) {
  .skill-tree-overlay #skill-tree-nodes .skill-node {
    width: clamp(78px, 18vw, 96px) !important;
    height: clamp(78px, 18vw, 96px) !important;
  }

  .skill-tree-overlay #skill-tree-nodes .skill-node.is-inner-ring {
    width: clamp(70px, 16vw, 86px) !important;
    height: clamp(70px, 16vw, 86px) !important;
  }
}

/* Amsterdam story mission UI. */
:root {
  --amsterdam-story-mission-icons: url('../images/ui/generated/story-amsterdam/amsterdam-mission-icons.png');
  --amsterdam-story-resource-icons: url('../images/ui/generated/story-amsterdam/amsterdam-resource-icons.png');
  --story-complete-panel: url('../images/ui/generated/story-complete/components/interlude-panel.png');
  --story-complete-emblem-frame: url('../images/ui/generated/story-complete/components/emblem-frame.png');
  --story-complete-progress-frame: url('../images/ui/generated/story-complete/components/progress-frame.png');
  --story-complete-progress-fill: url('../images/ui/generated/story-complete/components/progress-fill.png');
  --story-complete-progress-sweep: url('../images/ui/generated/story-complete/components/progress-sweep-gold.png');
  --story-complete-button-normal: url('../images/ui/generated/story-complete/components/button-normal.png');
  --story-complete-button-hover: url('../images/ui/generated/story-complete/components/button-hover.png');
  --story-complete-button-pressed: url('../images/ui/generated/story-complete/components/button-pressed.png');
  --story-complete-divider: url('../images/ui/generated/story-complete/components/divider-flourish.png');
  --story-complete-corner-vignette: url('../images/ui/generated/story-complete/components/corner-vignette-gold.png');
}

.story-mission-badge,
.story-mission-icon {
  background-image: var(--amsterdam-story-mission-icons);
  background-position: var(--story-icon-x, 0%) var(--story-icon-y, 0%);
  background-repeat: no-repeat;
  background-size: 500% 200%;
}

.story-resource-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  background-image: var(--amsterdam-story-resource-icons);
  background-position: var(--story-resource-x, 0%) var(--story-resource-y, 0%);
  background-repeat: no-repeat;
  background-size: 500% 400%;
}

.story-mission-badge {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 5px 9px rgba(0, 0, 0, 0.28));
}

.story-mission-badge--large,
.story-resource-icon--large {
  width: 132px;
  height: 132px;
}

.story-complete-interlude {
  position: absolute;
  inset: 0;
  z-index: 1360;
  display: grid;
  place-items: center;
  padding: 30px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(19, 45, 56, 0.72), rgba(5, 10, 14, 0.9) 64%),
    rgba(2, 6, 9, 0.88);
  pointer-events: auto;
}

.story-complete-interlude.hidden {
  display: none !important;
}

.story-complete-corners {
  position: absolute;
  inset: clamp(18px, 4vh, 46px) clamp(18px, 4vw, 54px);
  background: var(--story-complete-corner-vignette) center / 100% 100% no-repeat;
  opacity: 0.34;
  filter: drop-shadow(0 0 18px rgba(239, 195, 92, 0.28));
  pointer-events: none;
}

.story-complete-card {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  width: min(960px, calc(var(--ui-viewport-width) - 48px));
  min-height: min(560px, calc(var(--ui-viewport-height) - 48px));
  max-height: calc(var(--ui-viewport-height) - 48px);
  padding: 82px 94px 54px;
  background: var(--story-complete-panel) center / 100% 100% no-repeat;
  color: #2b2012;
  text-align: center;
  filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.58));
}

.story-complete-emblem {
  position: absolute;
  top: 18px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 120px;
  height: 130px;
  background: var(--story-complete-emblem-frame) center / contain no-repeat;
  transform: translateX(-50%);
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.28));
}

.story-complete-emblem-icon {
  width: 60px;
  height: 60px;
  background-image: var(--amsterdam-story-mission-icons);
  background-position: var(--story-icon-x, 0%) var(--story-icon-y, 0%);
  background-repeat: no-repeat;
  background-size: 500% 200%;
}

.story-complete-kicker {
  margin-top: 42px;
  color: #7f4d0b;
  font-size: 0.76rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-complete-card h2 {
  margin: 7px 0 8px;
  max-width: 680px;
  color: #24180d;
  font-size: 2rem;
  line-height: 1.04;
  text-shadow: 0 1px 0 rgba(255, 246, 204, 0.7);
}

.story-complete-body {
  margin: 0;
  max-width: 650px;
  color: #3a2d1d;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.32;
}

.story-complete-reward {
  margin-top: 9px;
  color: #7d4b0a;
  font-size: 0.9rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-complete-art {
  display: grid;
  place-items: center;
  width: min(190px, 40%);
  max-height: 122px;
  margin-top: 10px;
}

.story-complete-art.hidden {
  display: none !important;
}

.story-complete-art img {
  display: block;
  max-width: 100%;
  max-height: 122px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.32));
}

.story-complete-divider {
  width: min(420px, 60%);
  height: 42px;
  margin: 8px 0 2px;
  background: var(--story-complete-divider) center / contain no-repeat;
  opacity: 0.9;
}

.story-complete-progress {
  --story-progress-from: 0%;
  --story-progress-to: 10%;
  display: grid;
  gap: 5px;
  width: min(650px, 100%);
}

.story-complete-progress-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 44px;
  color: #50310d;
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-complete-progress-track {
  position: relative;
  width: 100%;
  height: 72px;
  background: var(--story-complete-progress-frame) center / 100% 100% no-repeat;
  overflow: visible;
}

.story-complete-progress-fill {
  position: absolute;
  left: 7.5%;
  top: 42%;
  width: var(--story-progress-from);
  max-width: 85%;
  height: 22%;
  overflow: hidden;
  background: var(--story-complete-progress-fill) left center / 100% 100% no-repeat;
  transition: width 1.55s cubic-bezier(0.22, 0.78, 0.21, 1);
}

.story-complete-interlude.is-playing .story-complete-progress-fill {
  width: var(--story-progress-to);
}

.story-complete-progress-sweep {
  position: absolute;
  top: -70%;
  right: -34%;
  width: min(260px, 70%);
  height: 240%;
  background: var(--story-complete-progress-sweep) center / 100% 100% no-repeat;
  opacity: 0;
  filter: drop-shadow(0 0 12px rgba(255, 225, 122, 0.78));
  transform: translateX(-260%);
}

.story-complete-interlude.is-playing .story-complete-progress-sweep {
  animation: storyCompleteSweep 1.35s 0.16s ease-out forwards;
}

@keyframes storyCompleteSweep {
  0% {
    opacity: 0;
    transform: translateX(-260%);
  }

  18%,
  76% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
    transform: translateX(72%);
  }
}

.story-complete-next {
  margin: 4px 0 14px;
  max-width: 620px;
  color: rgba(51, 37, 20, 0.8);
  font-size: 0.82rem;
  font-weight: 850;
}

.story-complete-continue {
  width: 208px;
  height: 68px;
  border: 0;
  background: var(--story-complete-button-normal) center / 100% 100% no-repeat;
  color: #fff3bf !important;
  font-size: 0.92rem;
  font-weight: 1000;
  text-transform: uppercase;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.82);
  cursor: pointer;
}

.story-complete-continue:not(:disabled):hover,
.story-complete-continue:not(:disabled):focus-visible {
  background-image: var(--story-complete-button-hover);
  color: #ffffff !important;
  outline: none;
}

.story-complete-continue:not(:disabled):active {
  background-image: var(--story-complete-button-pressed);
}

.story-complete-continue:disabled {
  opacity: 0.74;
  cursor: default;
}

body.boat-mode:not(.app-loading) .quest-log-row--story,
#ui-layer .harbor-quest-row--story {
  grid-template-columns: 46px minmax(0, 1fr) auto !important;
}

body.boat-mode:not(.app-loading) .quest-log-row--story {
  background: rgba(198, 148, 57, 0.2) !important;
  box-shadow: inset 0 0 0 1px rgba(183, 132, 45, 0.38) !important;
}

#ui-layer .harbor-quest-row--story {
  background:
    linear-gradient(90deg, rgba(227, 172, 66, 0.26), rgba(52, 125, 126, 0.13)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(214, 160, 58, 0.42),
    0 0 16px rgba(37, 147, 142, 0.15) !important;
}

#ui-layer .docked-harbor-panel.harbor-panel--story-origin {
  box-shadow:
    0 20px 46px rgba(0, 0, 0, 0.48),
    0 0 0 3px rgba(219, 161, 55, 0.55),
    0 0 32px rgba(219, 161, 55, 0.22) !important;
}

#ui-layer .docked-harbor-panel.harbor-panel--story-target {
  box-shadow:
    0 20px 46px rgba(0, 0, 0, 0.48),
    0 0 0 3px rgba(44, 172, 159, 0.52),
    0 0 32px rgba(44, 172, 159, 0.2) !important;
}

#ui-layer .harbor-panel--story-origin .docked-harbor-label,
#ui-layer .harbor-panel--story-origin .docked-harbor-market-status {
  color: #80500d !important;
}

#ui-layer .harbor-panel--story-target .docked-harbor-label,
#ui-layer .harbor-panel--story-target .docked-harbor-market-status {
  color: #0a5d60 !important;
}

.story-requirement-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.story-requirement-chip {
  display: inline-flex;
  align-items: center;
  max-width: 184px;
  min-height: 34px;
  gap: 5px;
  padding: 3px 8px 3px 4px;
  border: 1px solid rgba(97, 71, 34, 0.22);
  background: rgba(255, 246, 212, 0.54);
  color: #2f2417;
  font-size: 0.74rem;
  font-weight: 900;
  overflow: hidden;
}

.story-requirement-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-requirement-chip--complete {
  border-color: rgba(38, 124, 77, 0.5);
  background: rgba(95, 176, 106, 0.24);
}

.story-requirement-chip--more {
  min-width: 38px;
  justify-content: center;
  padding: 5px 9px;
}

.story-mission-panel,
.story-jettison-panel {
  position: absolute;
  inset: 0;
  z-index: 1320;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(7, 13, 16, 0.62);
  pointer-events: auto;
}

.story-mission-panel.hidden,
.story-jettison-panel.hidden {
  display: none !important;
}

.story-mission-shell,
.story-jettison-shell {
  width: min(820px, calc(var(--ui-viewport-width) - 48px));
  max-height: min(820px, calc(var(--ui-viewport-height) - 54px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 34px solid transparent;
  border-image-source: var(--pgui2-panel-large);
  border-image-slice: 64 fill;
  border-image-width: 34px;
  border-image-repeat: stretch;
  background: rgba(235, 211, 158, 0.94);
  background-clip: padding-box;
  color: #2f2417;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.story-jettison-shell {
  width: min(560px, calc(var(--ui-viewport-width) - 48px));
}

.story-mission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 40px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid rgba(93, 66, 31, 0.2);
}

.story-mission-kicker {
  color: #7c4b0c;
  font-size: 0.78rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-mission-close {
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--pgui2-close) center / 100% 100% no-repeat;
  color: #f5d88f;
  font-size: 0;
  cursor: pointer;
}

.story-mission-close::after {
  content: "×";
  font-size: 1.18rem;
  line-height: 1;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.68);
}

.story-mission-body {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  padding: 18px 6px 14px;
  overflow-y: auto;
}

.story-mission-icon {
  width: 124px;
  height: 124px;
  align-self: start;
  justify-self: center;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.32));
}

.story-mission-copy {
  min-width: 0;
}

.story-mission-copy h2 {
  margin: 0 0 10px;
  color: #261c10;
  font-size: 1.46rem;
  line-height: 1.05;
}

.story-mission-blurb {
  display: grid;
  gap: 8px;
  color: #3a2d1d;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.32;
}

.story-mission-requirements-wrap {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.story-mission-requirements-wrap.hidden {
  display: none !important;
}

.story-mission-section-label {
  color: #7c4b0c;
  font-size: 0.76rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-mission-requirements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.story-requirement-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid rgba(96, 68, 33, 0.22);
  background: rgba(255, 247, 220, 0.56);
}

.story-requirement-row--complete {
  background: rgba(93, 168, 103, 0.24);
}

.story-requirement-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.story-requirement-title {
  overflow: hidden;
  color: #2d2114;
  font-size: 0.86rem;
  font-weight: 1000;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-requirement-detail {
  overflow: hidden;
  color: rgba(49, 37, 22, 0.76);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-requirement-status {
  color: #6e470e;
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-requirement-row--complete .story-requirement-status {
  color: #145c35;
}

.story-mission-event-art {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 12px;
  border: 1px solid rgba(96, 68, 33, 0.2);
  background: rgba(71, 47, 20, 0.1);
}

.story-mission-event-art.hidden {
  display: none !important;
}

.story-mission-event-art img {
  display: block;
  max-width: min(320px, 92%);
  max-height: 280px;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
}

.story-mission-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 4px 2px;
  border-top: 1px solid rgba(93, 66, 31, 0.18);
}

.story-mission-start {
  min-width: 150px;
  min-height: 42px;
  border: 0;
  background: var(--pgui2-button-normal) center / 100% 100% no-repeat;
  color: #fff4c4 !important;
  font-size: 0.86rem;
  font-weight: 1000;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.82);
  cursor: pointer;
}

.story-mission-start:not(:disabled):hover,
.story-mission-start:not(:disabled):focus-visible {
  color: #ffffff !important;
  outline: none;
}

.story-mission-start.hidden {
  display: none !important;
}

.story-mission-start:disabled {
  background-image: var(--pgui2-button-disabled);
  color: rgba(238, 226, 198, 0.56) !important;
  cursor: default;
}

.story-jettison-message {
  margin: 12px 2px;
  color: #332414;
  font-size: 0.9rem;
  font-weight: 800;
}

.story-jettison-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px 2px;
}

.story-jettison-option {
  display: grid;
  gap: 2px;
  min-height: 52px;
  padding: 9px 12px;
  border: 1px solid rgba(96, 68, 33, 0.24);
  background: rgba(255, 247, 220, 0.6);
  color: #2f2417;
  text-align: left;
  cursor: pointer;
}

.story-jettison-option:hover,
.story-jettison-option:focus-visible {
  border-color: rgba(44, 172, 159, 0.62);
  outline: none;
}

.story-jettison-option-title {
  font-size: 0.9rem;
  font-weight: 1000;
}

.story-jettison-option-detail,
.story-jettison-empty {
  color: rgba(49, 37, 22, 0.74);
  font-size: 0.76rem;
  font-weight: 800;
}

@media (max-width: 700px) {
  .story-mission-panel,
  .story-jettison-panel,
  .story-complete-interlude {
    padding: 12px;
  }

  .story-complete-card {
    width: min(650px, calc(var(--ui-viewport-width) - 22px));
    min-height: min(470px, calc(var(--ui-viewport-height) - 22px));
    padding: 66px 44px 38px;
  }

  .story-complete-emblem {
    top: 14px;
    width: 92px;
    height: 100px;
  }

  .story-complete-emblem-icon {
    width: 48px;
    height: 48px;
  }

  .story-complete-kicker {
    margin-top: 28px;
  }

  .story-complete-card h2 {
    font-size: 1.4rem;
  }

  .story-complete-body {
    font-size: 0.84rem;
  }

  .story-complete-divider {
    height: 28px;
    margin-top: 4px;
  }

  .story-complete-progress-labels {
    padding: 0 26px;
  }

  .story-complete-progress-track {
    height: 56px;
  }

  .story-complete-next {
    margin-bottom: 8px;
  }

  .story-mission-shell,
  .story-jettison-shell {
    width: min(620px, calc(var(--ui-viewport-width) - 22px));
    max-height: calc(var(--ui-viewport-height) - 22px);
  }

  .story-mission-body {
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 12px;
  }

  .story-mission-icon {
    width: 86px;
    height: 86px;
  }

  .story-mission-requirements {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Pretty Game UI Development: broadside reload panel with live left-to-right fill. */
:root {
  --broadside-reload-frame: url('../images/ui/generated/broadside-reload/components/broadside-reload-frame.png');
  --broadside-reload-frame-hot: url('../images/ui/generated/broadside-reload/components/broadside-reload-frame-hot.png');
  --broadside-reload-track-art: url('../images/ui/generated/broadside-reload/components/broadside-reload-track.png');
  --broadside-reload-fill-art: url('../images/ui/generated/broadside-reload/components/broadside-reload-fill.png');
  --broadside-reload-fill-cap-art: url('../images/ui/generated/broadside-reload/components/broadside-fill-cap.png');
  --broadside-reload-cannon-art: url('../images/ui/generated/broadside-reload/components/broadside-cannon-medallion.png');
  --broadside-reload-timer-art: url('../images/ui/generated/broadside-reload/components/broadside-timer-badge.png');
}

@keyframes broadside-reload-flow {
  from {
    background-position: 0% 50%, 0% 50%;
  }

  to {
    background-position: 135% 50%, 100% 50%;
  }
}

@keyframes broadside-ready-breathe {
  0%,
  100% {
    filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.48))
      drop-shadow(0 0 8px rgba(232, 177, 68, 0.16));
  }

  50% {
    filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.5))
      drop-shadow(0 0 16px rgba(255, 198, 86, 0.34));
  }
}

body.boat-mode:not(.app-loading) #broadside-hud.broadside-hud {
  top: auto !important;
  bottom: max(0px, env(safe-area-inset-bottom)) !important;
  left: 50% !important;
  z-index: 395;
  width: min(calc(var(--ui-viewport-width) - 24px), 560px);
  height: clamp(72px, 6.2vw, 96px);
  transform: translateX(-50%) !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload {
  --broadside-reload-progress-pct: 100%;
  --broadside-reload-empty-pct: 0%;
  position: relative;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  isolation: isolate;
  overflow: visible !important;
  transition:
    filter 160ms ease,
    transform 160ms ease;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload::before {
  content: '' !important;
  position: absolute;
  inset: 0 !important;
  z-index: 0;
  display: block !important;
  width: auto !important;
  height: auto !important;
  background: var(--broadside-reload-frame) center / 100% 100% no-repeat !important;
  filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.48));
  transform: none !important;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload::after {
  content: '' !important;
  position: absolute;
  left: 28.5%;
  right: 16.4%;
  top: 32%;
  z-index: 1;
  height: 38%;
  background: var(--broadside-reload-track-art) center / 100% 100% no-repeat;
  opacity: 0.98;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:not(:disabled):hover,
body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:focus-visible {
  outline: none;
  transform: translateY(-2px);
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:not(:disabled):hover::before,
body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:focus-visible::before,
body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-ready::before {
  background-image: var(--broadside-reload-frame-hot) !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:focus-visible::before {
  filter: drop-shadow(0 15px 20px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 18px rgba(255, 226, 133, 0.44));
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-ready::before {
  animation: broadside-ready-breathe 2.2s ease-in-out infinite;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:active {
  transform: translateY(1px) scale(0.99);
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-ring {
  position: absolute;
  left: 30.4% !important;
  top: 42% !important;
  z-index: 2 !important;
  width: 49.2% !important;
  height: 18% !important;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 245, 179, 0.1), rgba(255, 217, 97, 0.34), rgba(255, 245, 179, 0.06)),
    var(--broadside-reload-fill-art) left center / 100% 100% no-repeat !important;
  box-shadow:
    0 0 12px rgba(235, 174, 45, 0.36),
    0 0 22px rgba(211, 89, 20, 0.18);
  mask: none !important;
  -webkit-mask: none !important;
  opacity: 1 !important;
  pointer-events: none;
  transform: none !important;
  transform-origin: left center;
  clip-path: inset(0 var(--broadside-reload-empty-pct, 0%) 0 0);
  -webkit-clip-path: inset(0 var(--broadside-reload-empty-pct, 0%) 0 0);
  transition:
    clip-path 80ms linear,
    -webkit-clip-path 80ms linear,
    opacity 140ms ease;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-ring::after {
  content: '';
  position: absolute;
  left: var(--broadside-reload-progress-pct, 100%);
  top: 50%;
  width: clamp(26px, 2.7vw, 38px);
  height: clamp(36px, 3.7vw, 54px);
  background: var(--broadside-reload-fill-cap-art) center / contain no-repeat;
  filter: drop-shadow(0 0 10px rgba(255, 191, 56, 0.48));
  opacity: 0.92;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-reloading .broadside-reload-ring {
  animation: broadside-reload-flow 1.15s linear infinite;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-icon {
  position: absolute !important;
  inset: auto !important;
  left: 5.4% !important;
  top: 50% !important;
  z-index: 4;
  display: block;
  width: clamp(52px, 5.1vw, 74px);
  height: clamp(52px, 5.1vw, 74px);
  border-radius: 50%;
  background: var(--broadside-reload-cannon-art) center / contain no-repeat;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0;
  text-shadow: none !important;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.62));
  opacity: 1 !important;
  transform: translateY(-50%) !important;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-icon::before,
body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-icon::after {
  content: none !important;
  display: none !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-reloading .broadside-reload-icon {
  filter: saturate(0.72) brightness(0.82) drop-shadow(0 5px 8px rgba(0, 0, 0, 0.64));
  opacity: 0.72 !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-timer {
  position: absolute !important;
  inset: auto !important;
  right: 5.8% !important;
  left: auto !important;
  top: 50% !important;
  z-index: 5 !important;
  display: none !important;
  place-items: center;
  width: clamp(46px, 4.7vw, 66px);
  height: clamp(46px, 4.7vw, 66px);
  background: var(--broadside-reload-timer-art) center / contain no-repeat;
  color: #fff1c1 !important;
  font-family: 'Courier New', monospace;
  font-size: clamp(1rem, 1.55vw, 1.34rem) !important;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow:
    0 2px 5px rgba(0, 0, 0, 0.9),
    0 0 9px rgba(245, 183, 64, 0.4);
  transform: translateY(-50%);
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-reloading .broadside-reload-timer {
  display: grid !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-ready .broadside-reload-timer {
  display: none !important;
}

body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload:disabled {
  opacity: 1 !important;
  cursor: wait;
}

@media (max-width: 680px) {
  body.boat-mode:not(.app-loading) #broadside-hud.broadside-hud {
    width: min(calc(var(--ui-viewport-width) - 18px), 430px) !important;
    height: clamp(78px, 18vw, 108px) !important;
  }

  body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-icon {
    width: clamp(60px, 13vw, 86px);
    height: clamp(60px, 13vw, 86px);
  }

  body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload-timer {
    width: clamp(52px, 12vw, 76px);
    height: clamp(52px, 12vw, 76px);
    font-size: clamp(1.08rem, 4.1vw, 1.6rem) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-ready::before,
  body.boat-mode:not(.app-loading) #broadside-hud .broadside-reload.is-reloading .broadside-reload-ring {
    animation: none !important;
  }
}

/* Pretty Game UI Development: animated ship condition bars with live labels. */
:root {
  --ship-condition-frame-art: url('../images/ui/generated/ship-condition-bars/components/condition-dual-frame-labeled.png');
  --ship-condition-fill-hull-art: url('../images/ui/generated/ship-condition-bars/components/condition-fill-hull.png');
  --ship-condition-fill-morale-art: url('../images/ui/generated/ship-condition-bars/components/condition-fill-morale.png');
  --ship-condition-track-left: 27.45%;
  --ship-condition-track-width: 63.85%;
  --ship-condition-track-height: 17.5%;
  --ship-condition-health-top: 36.75%;
  --ship-condition-morale-top: 65.4%;
}

@keyframes ship-condition-fill-drift {
  0% {
    background-position: 0 50%, 0 50%;
  }

  100% {
    background-position: 84px 50%, 0 50%;
  }
}

@keyframes ship-condition-glint {
  0%,
  58% {
    transform: translateX(-120%) skewX(-18deg);
    opacity: 0;
  }

  72% {
    opacity: 0.78;
  }

  100% {
    transform: translateX(132%) skewX(-18deg);
    opacity: 0;
  }
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
body.app-playing.boat-mode #hud-bar #ship-health-hud:not(.hidden) {
  position: relative !important;
  display: block !important;
  width: clamp(560px, 39vw, 760px) !important;
  min-width: clamp(560px, 39vw, 760px) !important;
  max-width: 760px !important;
  aspect-ratio: 1676 / 465 !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--ship-condition-frame-art) center / 100% 100% no-repeat !important;
  box-shadow: none !important;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  overflow: visible !important;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.hidden,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not([data-health-ready='true']) {
  display: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-meter-grid {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-condition-meter {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  min-width: 0 !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-hud-row {
  position: absolute !important;
  left: 7.6% !important;
  width: 21.3% !important;
  height: 15.2% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-condition-meter:nth-child(1) .ship-health-hud-row {
  top: 33.2% !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-condition-meter:nth-child(2) .ship-health-hud-row {
  top: 61.6% !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-title {
  display: none !important;
  width: 100% !important;
  color: #fff0c4 !important;
  font-family: 'Cinzel', Georgia, serif !important;
  font-size: clamp(1rem, 1.02vw, 1.24rem) !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  letter-spacing: 0.04em !important;
  text-align: center !important;
  text-shadow:
    0 2px 3px rgba(31, 17, 5, 0.92),
    0 0 9px rgba(255, 236, 170, 0.32) !important;
  white-space: nowrap;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-value {
  display: none !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-track,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-track {
  position: absolute !important;
  left: var(--ship-condition-track-left) !important;
  width: var(--ship-condition-track-width) !important;
  height: var(--ship-condition-track-height) !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
  isolation: isolate;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-track {
  top: var(--ship-condition-health-top) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-track {
  top: var(--ship-condition-morale-top) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-fill,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-fill {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  border-radius: inherit !important;
  transform: none !important;
  transform-origin: left center !important;
  clip-path: inset(0 var(--hud-fill-empty-pct, 0%) 0 0 round 999px);
  -webkit-clip-path: inset(0 var(--hud-fill-empty-pct, 0%) 0 0 round 999px);
  background-repeat: repeat-x, no-repeat !important;
  background-size: 180px 100%, 100% 100% !important;
  background-position: 0 50%, 0 50% !important;
  filter: saturate(1.08) brightness(1.04);
  animation: ship-condition-fill-drift 5.8s linear infinite;
  will-change: clip-path, background-position;
  transition:
    clip-path 170ms ease-out,
    -webkit-clip-path 170ms ease-out,
    filter 180ms ease;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-fill {
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 237, 122, 0.2) 45%, rgba(255, 255, 255, 0.08)),
    var(--ship-condition-fill-hull-art) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-fill {
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(160, 255, 225, 0.22) 48%, rgba(255, 255, 255, 0.08)),
    var(--ship-condition-fill-morale-art) !important;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-fill::after,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-fill::after {
  content: '';
  position: absolute;
  inset: 9% -26%;
  border-radius: inherit;
  background: linear-gradient(
    100deg,
    transparent 0%,
    transparent 38%,
    rgba(255, 255, 255, 0.08) 44%,
    rgba(255, 245, 176, 0.62) 50%,
    rgba(255, 255, 255, 0.08) 56%,
    transparent 64%,
    transparent 100%
  );
  mix-blend-mode: screen;
  animation: ship-condition-glint 3.9s ease-in-out infinite;
  pointer-events: none;
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.low .ship-health-fill {
  background-image:
    linear-gradient(90deg, rgba(98, 48, 7, 0.36), rgba(255, 204, 84, 0.46), rgba(255, 238, 166, 0.24)),
    var(--ship-condition-fill-hull-art) !important;
  filter: hue-rotate(38deg) saturate(1.24) brightness(1.05);
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.critical .ship-health-fill {
  background-image:
    linear-gradient(90deg, rgba(130, 14, 18, 0.78), rgba(255, 70, 62, 0.62), rgba(255, 190, 130, 0.28)),
    var(--ship-condition-fill-hull-art) !important;
  filter: hue-rotate(118deg) saturate(1.55) brightness(1.02);
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.morale-critical .ship-morale-fill,
body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.mutiny .ship-morale-fill {
  background-image:
    linear-gradient(90deg, rgba(130, 14, 18, 0.78), rgba(255, 70, 62, 0.62), rgba(255, 190, 130, 0.28)),
    var(--ship-condition-fill-morale-art) !important;
  filter: hue-rotate(150deg) saturate(1.5) brightness(1.02);
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud.morale-low .ship-morale-fill {
  filter: hue-rotate(28deg) saturate(1.15) brightness(1.03);
}

body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .crew-morale-warning {
  left: 12% !important;
  right: 12% !important;
  top: 93% !important;
  z-index: 6 !important;
}

@media (max-width: 680px) {
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud:not(.hidden),
  body.app-playing.boat-mode #hud-bar #ship-health-hud:not(.hidden) {
    width: min(1040px, calc(var(--ui-viewport-width) - 36px)) !important;
    min-width: 0 !important;
    max-width: min(1040px, calc(var(--ui-viewport-width) - 36px)) !important;
    aspect-ratio: 1676 / 465 !important;
  }

  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-title {
    font-size: clamp(1.85rem, 4vw, 3rem) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-fill,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-fill,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-health-fill::after,
  body.boat-mode:not(.app-loading) #hud-bar #ship-health-hud .ship-morale-fill::after {
    animation: none !important;
  }
}
