html, body {
  --ostrivec-header-height: 56px;
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0e16;
  overflow: hidden;
  color: white;
}

select option {
  color: #111;
  background: #fff;
}

.header{
  position: fixed;
  left: 0; right: 0; top: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(20,24,36,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
  backdrop-filter: blur(8px);
}

.reset-button, .upgrades-button, .upgrade-button, .close-button, .stage-button, .menu-toggle-button, .user-profile-button, .view-button{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #11182a;
  color: #eaeef6;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.reset-button { background: #2a1111; }
.reset-button:hover { background: #3a1818; }

.view-button { 
  background: #1a2a11; 
  padding: 8px 12px;
}
.view-button:hover { background: #243a18; }

.help-button {
  min-width: 36px;
  font-weight: 800;
  background: #1d2b48;
}

.problem-report-button {
  min-width: 36px;
  font-weight: 900;
  background: #4a2b10;
}

.problem-report-button:hover {
  background: #6a3a13;
}

.problem-report-dialog {
  position: fixed;
  top: calc(var(--ostrivec-header-height, 56px) + 16px);
  left: 16px;
  z-index: 10040;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - var(--ostrivec-header-height, 56px) - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #101724;
  color: #eaeef6;
  box-shadow: 0 20px 50px rgba(0,0,0,0.38);
}

.problem-report-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  cursor: move;
  user-select: none;
}

.problem-report-dialog-header h2 {
  margin: 0;
  font-size: 16px;
}

.problem-report-dialog-close {
  min-width: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #24161a;
  color: #fff;
  cursor: pointer;
}

.problem-report-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  min-height: 0;
}

.problem-report-dialog textarea {
  min-height: 110px;
  max-height: 220px;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.22);
  color: #f5f7fb;
  padding: 10px;
  font: 13px/1.45 Consolas, Monaco, monospace;
}

.problem-report-captures {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: calc(100vh - var(--ostrivec-header-height, 56px) - 260px);
  min-height: 80px;
}

.problem-report-captures-empty {
  padding: 10px;
  border-radius: 6px;
  border: 1px dashed rgba(255,255,255,0.16);
  color: rgba(234,238,246,0.72);
  font-size: 13px;
}

.problem-report-capture {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  overflow: hidden;
}

.problem-report-capture summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  user-select: none;
}

.problem-report-capture-name {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
}

.problem-report-capture-copy {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  background: rgba(255,255,255,0.1);
  color: rgba(245,247,251,0.9);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.problem-report-capture-copy:hover {
  background: rgba(255,255,255,0.16);
}

.problem-report-capture-meta {
  color: rgba(234,238,246,0.66);
  font-size: 12px;
}

.problem-report-capture-json {
  margin: 0;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.22);
  color: #f5f7fb;
  font: 12px/1.45 Consolas, Monaco, monospace;
  white-space: pre-wrap;
}

.problem-report-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.problem-report-dialog-actions button {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #1d2b48;
  color: #fff;
  cursor: pointer;
}

.problem-report-dialog-actions button.secondary {
  background: rgba(255,255,255,0.08);
}

.help-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10030;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.7);
}

.help-dialog {
  width: min(620px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.16);
  background: #101724;
  color: #eaeef6;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.help-dialog-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: #101724;
}

.help-dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.help-dialog-close {
  min-width: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #24161a;
  color: #fff;
  cursor: pointer;
}

.help-dialog-body {
  padding: 14px 16px 18px;
}

.help-dialog-body h3 {
  margin: 14px 0 8px;
  font-size: 14px;
  color: #ffffff;
}

.help-dialog-body h3:first-child {
  margin-top: 0;
}

.help-dialog-body ul {
  margin: 0;
  padding-left: 18px;
}

.help-dialog-body li {
  margin: 7px 0;
  line-height: 1.4;
}

.user-profile-button {
  background: #1a1a3a;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-profile-button:hover { background: #2a2a5a; }
.user-profile-button canvas { flex-shrink: 0; }

.menu-toggle-button { 
  background: #12301a; 
  display: flex;
  align-items: center;
  gap: 6px;
}
.menu-toggle-button:hover { background: #1a4024; }

.upgrade-button { background: #12301a; width: fit-content; }
.upgrade-button:hover { background: #1a4024; }
.upgrade-button.secondary { background: #11182a; }
.upgrade-button.secondary:hover { background: #1a2238; }
.upgrade-button.secondary.active { 
  background: #2a4024; 
  border-color: #4a8040;
  box-shadow: 0 0 8px rgba(74, 128, 64, 0.4);
}

.stage-controls{
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: 8px;
}

.view-controls{
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.stage-label, .zoom-label{
  color: #eaeef6;
  opacity: 0.9;
  font-size: 13px;
  padding: 0 8px;
  min-width: 90px;
  text-align: center;
}

.stage-button:disabled,
.upgrade-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.game-container{
  height: 100%;
  padding-top: var(--ostrivec-header-height);
  position: relative;
  z-index: 1;
}

.map-selector-bar {
  width: max-content;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #e8edf7;
  font-size: 0.92rem;
  position: absolute;
  bottom: 82px;
  left: 30px;
  z-index: 80;
  pointer-events: auto;
}

.map-selector-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #11182a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  cursor: pointer;
}

.map-selector-bar select {
  min-width: 180px;
  max-width: min(320px, 62vw);
  background: #11182a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 7px 10px;
}

.map-selector-bar.collapsed select {
  display: none;
}

.chat-launcher-bar {
  position: absolute;
  right: 30px;
  bottom: 82px;
  z-index: 80;
  pointer-events: auto;
}

.chat-toggle-button {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #11182a;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
}

.chat-unread-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.8);
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
}

.island-container{
  height: calc(100vh - var(--ostrivec-header-height));
  height: calc(100dvh - var(--ostrivec-header-height));
  width: 100%;
  overflow: hidden;
  cursor: grab;
  position: relative;
  z-index: 1;
  touch-action: none;
}

.island-container canvas {
  touch-action: none;
}

.mobile-build-actions {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 35;
  display: none;
  gap: 8px;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  padding-bottom: 8px;
}

.mobile-build-actions.visible {
  display: flex;
}

.mobile-build-action-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.28);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-build-action-button.confirm {
  background: #1f7a3f;
}

.mobile-build-action-button.cancel {
  background: #8a2631;
}

.island-container.dragging {
  cursor: grabbing;
}

.page-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 14, 0.62);
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease, visibility 0.2s ease;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.page-loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #eef2ff;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.page-loading-emblem {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  filter: grayscale(1) saturate(0.15) contrast(1.05) brightness(1.15);
  transform: translateY(0) scale(0.98);
  transition: filter 0.32s ease, transform 0.32s ease, background-color 0.32s ease;
}

.page-loading-emoji {
  font-size: 74px;
  line-height: 1;
  transform: translateY(-2px);
}

.page-loading-overlay.loaded .page-loading-emblem {
  filter: grayscale(0) saturate(1.08) contrast(1.02) brightness(1);
  transform: translateY(-2px) scale(1);
  background: rgba(255, 255, 255, 0.12);
}

.page-loading-scene {
  position: relative;
  width: min(240px, 68vw);
  aspect-ratio: 4 / 3;
}

.page-loading-sun {
  position: absolute;
  top: 8%;
  right: 12%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7c4 0%, #ffd66b 55%, #f6ad3c 100%);
  box-shadow: 0 0 30px rgba(255, 205, 96, 0.45);
  animation: page-loading-sun-drift 4.5s ease-in-out infinite;
}

.page-loading-cloud {
  position: absolute;
  width: 54px;
  height: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
}

.page-loading-cloud::before,
.page-loading-cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.page-loading-cloud::before {
  width: 24px;
  height: 24px;
  left: 6px;
  top: -10px;
}

.page-loading-cloud::after {
  width: 28px;
  height: 28px;
  right: 6px;
  top: -12px;
}

.page-loading-cloud-left {
  top: 17%;
  left: 13%;
  animation: page-loading-cloud-drift 8s linear infinite;
}

.page-loading-cloud-right {
  top: 27%;
  right: 15%;
  animation: page-loading-cloud-drift 10s linear infinite reverse;
}

.page-loading-water {
  position: absolute;
  inset: auto 0 0 0;
  height: 44%;
  border-radius: 0 0 20px 20px;
  background:
    linear-gradient(to bottom, rgba(79, 176, 222, 0.06), rgba(24, 93, 140, 0.46)),
    linear-gradient(180deg, rgba(9, 26, 45, 0) 0%, rgba(6, 48, 77, 0.78) 100%);
  overflow: hidden;
}

.page-loading-wave {
  position: absolute;
  left: -20%;
  right: -20%;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(240, 250, 255, 0.24);
  border-color: rgba(240, 250, 255, 0.24) transparent transparent transparent;
  animation: page-loading-wave-slide 2.8s linear infinite;
}

.page-loading-wave-1 {
  top: 20%;
}

.page-loading-wave-2 {
  top: 46%;
  animation-delay: -0.8s;
}

.page-loading-wave-3 {
  top: 70%;
  animation-delay: -1.6s;
}

.page-loading-island {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 88px;
  height: 54px;
  transform: translateX(-50%);
  border-radius: 60% 60% 46% 46% / 55% 55% 45% 45%;
  background: linear-gradient(180deg, #6d4f25 0%, #4f3517 55%, #3b2711 100%);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
  animation: page-loading-island-bob 2.6s ease-in-out infinite;
}

.page-loading-shore {
  position: absolute;
  inset: 8px 9px auto;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(246, 220, 161, 0.95), rgba(208, 170, 97, 0.82));
}

.page-loading-palm {
  position: absolute;
  bottom: 28px;
  width: 7px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7b5227 0%, #4e3115 100%);
  transform-origin: bottom center;
}

.page-loading-palm::before,
.page-loading-palm::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 20px;
  height: 10px;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(180deg, #51c878, #1d6f3f);
}

.page-loading-palm::before {
  left: -14px;
  transform: rotate(-38deg);
}

.page-loading-palm::after {
  right: -14px;
  transform: scaleX(-1) rotate(-38deg);
}

.page-loading-palm-left {
  left: 25px;
  transform: rotate(-8deg);
}

.page-loading-palm-right {
  right: 24px;
  transform: rotate(10deg);
  animation: page-loading-palm-sway 2.2s ease-in-out infinite;
}

.page-loading-hut {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 28px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 5px;
  background: linear-gradient(180deg, #c28b50, #8d5928);
}

.page-loading-hut::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: -10px;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 11px solid #5d3214;
}

.page-loading-boat {
  position: absolute;
  left: 22%;
  bottom: 22%;
  width: 44px;
  height: 16px;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(180deg, #3c2413, #1f1209);
  box-shadow: 0 2px 0 rgba(255,255,255,0.12) inset;
  animation: page-loading-boat-bob 1.8s ease-in-out infinite;
}

.page-loading-boat::before {
  content: "";
  position: absolute;
  left: 19px;
  bottom: 12px;
  width: 2px;
  height: 22px;
  background: rgba(255,255,255,0.72);
}

.page-loading-boat::after {
  content: "";
  position: absolute;
  left: 21px;
  bottom: 12px;
  width: 12px;
  height: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(192, 232, 255, 0.2));
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.page-loading-text {
  font-size: 15px;
  letter-spacing: 0;
}

@keyframes page-loading-island-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@keyframes page-loading-boat-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-2deg); }
}

@keyframes page-loading-palm-sway {
  0%, 100% { transform: rotate(10deg); }
  50% { transform: rotate(5deg); }
}

@keyframes page-loading-wave-slide {
  from { transform: translateX(0); }
  to { transform: translateX(18%); }
}

@keyframes page-loading-sun-drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

@keyframes page-loading-cloud-drift {
  from { transform: translateX(0); }
  to { transform: translateX(14px); }
}

/* Side Panel (Right) */
.improvements-panel {
  position: fixed;
  right: -360px;
  top: var(--ostrivec-header-height);
  width: 360px;
  height: calc(100vh - var(--ostrivec-header-height));
  height: calc(100dvh - var(--ostrivec-header-height));
  background: #0e1220;
  border-left: 1px solid rgba(255,255,255,0.10);
  z-index: 20;
  overflow-y: auto;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

.improvements-panel.open {
  right: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  position: sticky;
  top: 0;
  background: #0e1220;
  z-index: 1;
}

.panel-header h2 {
  margin: 0;
  color: #eaeef6;
  font-size: 18px;
}

.panel-close-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #24161a;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.panel-close-button:hover {
  background: #3a1d24;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.panel-section h3 {
  margin: 0 0 12px 0;
  color: #eaeef6;
  font-size: 14px;
  opacity: 0.9;
}

.panel-hint {
  font-size: 11px;
  opacity: 0.7;
  color: #eaeef6;
  margin: 0 0 12px 0;
}

.sync-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  color: #eaeef6;
  font-size: 13px;
  line-height: 1.3;
  opacity: 0.86;
}

.sync-status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #8b94a7;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
}

.sync-status-row.connected .sync-status-dot {
  background: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.15);
}

.sync-status-row.disconnected .sync-status-dot {
  background: #f44336;
  box-shadow: 0 0 0 3px rgba(244,67,54,0.14);
}

.phase-info {
  font-size: 13px;
  opacity: 0.85;
  color: #eaeef6;
  margin: 0 0 10px 0;
}

.phase-buttons{
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.upgrades-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-item{
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #0a0d16;
  transition: background 0.2s;
  justify-content: space-between;
}

.upgrade-item:hover {
  background: #0d1018;
}

.upgrade-item.disabled {
  opacity: 0.5;
}

.upgrade-preview{
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #05070d;
}

.upgrade-label{
  font-size: 12px;
  opacity: 0.9;
  color: #eaeef6;
  word-break: break-word;
}

.unavailable-hint {
  font-size: 10px;
  opacity: 0.6;
  color: #ff8080;
  margin-top: 2px;
}

/* Toggle */
.toggle{
  position: relative;
  width: 50px;
  height: 28px;
  display: inline-block;
}
.toggle input{ display:none; }
.slider{
  position:absolute;
  inset:0;
  background:#2a324a;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: .2s;
}
.slider:before{
  content:"";
  position:absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: #eaeef6;
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .slider{
  background: #2a6a3e;
}
.toggle input:checked + .slider:before{
  transform: translate(22px, -50%);
}
.toggle input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Scrollbar styling */
.improvements-panel::-webkit-scrollbar {
  width: 8px;
}
.improvements-panel::-webkit-scrollbar-track {
  background: #0b0e16;
}
.improvements-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.improvements-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

.money-history-button {
  appearance: none;
  border: 1px solid rgba(255, 215, 0, 0.35);
  background: rgba(18, 22, 34, 0.72);
  color: #ffd700;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 1.2em;
  font-weight: 700;
  cursor: pointer;
}

.money-history-button:hover,
.money-history-button:focus-visible {
  background: rgba(255, 215, 0, 0.12);
  outline: none;
}

.money-history-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 8, 14, 0.72);
}

.money-history-modal.open {
  display: flex;
}

.money-history-dialog {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(0,0,0,0.42);
  color: #f3f4f6;
}

.money-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.money-history-title {
  margin: 0;
  font-size: 18px;
}

.money-history-close {
  border: 0;
  background: rgba(255,255,255,0.08);
  color: #f3f4f6;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.money-history-body {
  overflow: auto;
  padding: 0;
}

.money-history-status {
  padding: 18px;
  color: #cbd5e1;
}

.money-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.money-history-table th,
.money-history-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: top;
}

.money-history-table th {
  position: sticky;
  top: 0;
  background: #111827;
  color: #cbd5e1;
  font-size: 12px;
  text-transform: uppercase;
}

.money-history-change.positive {
  color: #6ee7b7;
  font-weight: 700;
}

.money-history-change.negative {
  color: #fca5a5;
  font-weight: 700;
}

.money-history-muted {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 4px;
}

.island-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 128px;
  z-index: 10010;
  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - var(--ostrivec-header-height) - 42px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: #101724;
  color: #eaf0f7;
  box-shadow: 0 22px 70px rgba(0,0,0,0.46);
}

.island-chat-panel.open {
  display: flex;
}

.island-chat-panel.fullscreen {
  inset: calc(var(--ostrivec-header-height) + 12px) 12px 12px 12px;
  width: auto;
  height: auto;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: #121b2b;
}

.chat-title {
  margin: 0;
  font-size: 15px;
}

.chat-window-actions {
  display: inline-flex;
  gap: 6px;
}

.chat-icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #f8fafc;
  cursor: pointer;
}

.chat-pinned-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(250,204,21,0.28);
  background: #161d2b;
  cursor: pointer;
}

.chat-pinned-banner[hidden] {
  display: none;
}

.chat-pinned-content {
  flex: 1;
  min-width: 0;
}

.chat-pinned-label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #facc15;
  font-size: 12px;
  font-weight: 800;
}

.chat-pinned-counter {
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
}

.chat-pinned-text {
  margin-top: 2px;
  overflow: hidden;
  color: #f8fafc;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pinned-meta {
  margin-top: 2px;
  color: #94a3b8;
  font-size: 11px;
}

.chat-pinned-unpin {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #f8fafc;
  cursor: pointer;
  padding: 7px 9px;
  font-size: 12px;
}

.chat-pinned-switcher {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.chat-pinned-switcher button {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #f8fafc;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.chat-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
  background: #0b111d;
}

.chat-loading-status,
.chat-empty-status {
  padding: 8px 0;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

.chat-load-controls {
  display: none;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

.chat-load-controls.visible {
  display: flex;
}

.chat-load-controls button {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  background: #172033;
  color: #eaf0f7;
  cursor: pointer;
  padding: 7px 9px;
  font-size: 12px;
}

.chat-message {
  padding: 8px 9px;
  margin: 7px 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
}

.chat-message.own {
  background: rgba(37, 99, 235, 0.14);
}

.chat-message.mentioned {
  border-color: rgba(250, 204, 21, 0.7);
  background: rgba(250, 204, 21, 0.12);
}

.chat-message.pinned {
  border-color: rgba(250, 204, 21, 0.7);
}

.chat-message.active-pin {
  background: rgba(250, 204, 21, 0.13);
}

.chat-message.focus-pulse {
  animation: chat-focus-pulse 1.2s ease-out;
}

@keyframes chat-focus-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(250,204,21,0.5);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(250,204,21,0);
  }
}

.chat-message-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.chat-message-name {
  border: 0;
  padding: 0;
  background: transparent;
  color: #93c5fd;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.chat-message-pin-label {
  color: #facc15;
  font-weight: 700;
}

.chat-message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.38;
  font-size: 14px;
}

.chat-unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: #facc15;
  font-size: 12px;
  font-weight: 700;
}

.chat-unread-divider::before,
.chat-unread-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid rgba(250,204,21,0.45);
}

.chat-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
  background: #121b2b;
}

.chat-compose textarea {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: vertical;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: #0b111d;
  color: #f8fafc;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
}

.chat-send-button {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    overflow-y: auto;
    padding: 8px;
  }

  .header > * {
    flex-shrink: 0;
  }

  .money-display {
    gap: 8px !important;
    max-width: calc(100vw - 16px);
    order: 1;
  }

  .money-display > div,
  .money-history-button {
    font-size: 0.95em !important;
    white-space: nowrap;
  }

  .money-history-table th,
  .money-history-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .view-controls {
    order: 3;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    flex-wrap: wrap;
    gap: 6px;
  }

  .view-button,
  .menu-toggle-button,
  .user-profile-button {
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 8px;
    white-space: nowrap;
  }

  .user-profile-button {
    margin-left: 0;
    max-width: calc(100vw - 122px);
    min-width: 0;
    overflow: hidden;
  }

  #user-profile-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .menu-toggle-button {
    margin-left: auto;
  }

  .chat-launcher-bar {
    right: 16px;
    bottom: 74px;
  }

  .island-chat-panel {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    height: min(560px, calc(100dvh - var(--ostrivec-header-height) - 16px));
  }

  .island-chat-panel.fullscreen {
    inset: var(--ostrivec-header-height) 0 0 0;
    border-radius: 0;
  }

  .chat-compose {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .zoom-label {
    min-width: auto;
    padding: 8px 6px;
  }

  .improvements-panel {
    width: 100%;
    right: -100%;
  }
  
  .game-container.panel-open {
    margin-right: 0;
  }
}

/* Tab styles */
.tab-button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #11182a;
  color: #eaeef6;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
}

.tab-button:hover {
  background: #1a2238;
  border-color: rgba(255,255,255,0.2);
}

.tab-button.active {
  background: #12301a;
  border-color: #4a8040;
  color: #4CAF50;
  box-shadow: 0 0 8px rgba(74, 128, 64, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}
