/* ================================================================
   XCOIN — Global neutral asset terminal (retro exchange UI)
   ================================================================ */

/* --- CUSTOM PROPERTIES ---------------------------------------- */
:root {
  --win-bg: #c0c0c0;
  --win-light: #dfdfdf;
  --win-mid: #bfbfbf;
  --win-dark: #808080;
  --win-darker: #404040;
  --win-shadow: #000;
  --win-titlebar: #000080;
  --win-titlebar-end: #1084d0;
  --win-titlebar-inactive: #808080;
  --win-titlebar-inactive-end: #b4b4b4;

  --term-green: #00ff41;
  --term-amber: #ffb000;
  --term-cyan: #00e5ff;
  --term-white: #e0e0e0;
  --term-bg: #0c0c0c;
  --term-bg-alt: #0a1a0a;

  --profit: #00ff00;
  --loss: #ff3333;
  --alert: #ff0000;
  --highlight: #ffff00;

  --font-terminal: 'VT323', 'Courier New', monospace;
  --font-pixel: 'Press Start 2P', monospace;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --ticker-height: 28px;
  --clocks-height: 24px;
  --taskbar-height: 36px;
  --ad-height: 32px;
  /* Fixed chrome height for window maximize / layout */
  --header-stack: calc(var(--ticker-height) + var(--clocks-height) + var(--ad-height));
}

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

html {
  overflow: hidden;
  height: 100%;
}

body {
  font-family: var(--font-terminal);
  background: #000;
  color: var(--term-green);
  overflow: hidden;
  height: 100%;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='2' height='16' fill='white'/%3E%3Crect width='16' height='2' y='7' fill='white'/%3E%3C/svg%3E") 8 8, crosshair;
  user-select: none;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

.hidden { display: none !important; }

::selection {
  background: var(--win-titlebar);
  color: #fff;
}

/* --- CRT OVERLAY ---------------------------------------------- */
#crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

.crt-flicker {
  position: absolute;
  inset: 0;
  background: rgba(18, 16, 16, 0);
  animation: crt-flicker 0.15s infinite;
}

.crt-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

@keyframes crt-flicker {
  0%   { opacity: 0.27861; }
  5%   { opacity: 0.34769; }
  10%  { opacity: 0.23604; }
  15%  { opacity: 0.90626; }
  20%  { opacity: 0.18128; }
  25%  { opacity: 0.83891; }
  30%  { opacity: 0.65583; }
  35%  { opacity: 0.67807; }
  40%  { opacity: 0.26559; }
  45%  { opacity: 0.84693; }
  50%  { opacity: 0.96019; }
  55%  { opacity: 0.08594; }
  60%  { opacity: 0.20313; }
  65%  { opacity: 0.71988; }
  70%  { opacity: 0.53455; }
  75%  { opacity: 0.37288; }
  80%  { opacity: 0.71428; }
  85%  { opacity: 0.70419; }
  90%  { opacity: 0.7003;  }
  95%  { opacity: 0.36108; }
  100% { opacity: 0.24387; }
}

/* --- GLITCH OVERLAY ------------------------------------------- */
#glitch-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
}

#glitch-overlay.active {
  animation: glitch-block 0.2s steps(3) forwards;
}

@keyframes glitch-block {
  0%   { opacity: 1; background: rgba(255,0,0,0.05); transform: translate(2px, -1px); }
  25%  { opacity: 1; background: rgba(0,255,0,0.05); transform: translate(-3px, 2px); }
  50%  { opacity: 1; background: rgba(0,0,255,0.05); transform: translate(1px, -3px); }
  75%  { opacity: 1; background: rgba(255,0,0,0.03); transform: translate(-2px, 1px); }
  100% { opacity: 0; transform: translate(0); }
}

.glitch-tear {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 255, 65, 0.15);
  transform: translateX(8px);
}

/* --- BOOT SCREEN ---------------------------------------------- */
#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

#boot-screen.fade-out {
  animation: crt-off 0.6s ease-in forwards;
}

@keyframes crt-off {
  0%   { transform: scale(1, 1); filter: brightness(1); opacity: 1; }
  40%  { transform: scale(1.3, 0.01); filter: brightness(3); opacity: 1; }
  70%  { transform: scale(1.3, 0.01); filter: brightness(5); opacity: 0.7; }
  100% { transform: scale(0, 0); filter: brightness(0); opacity: 0; }
}

#boot-terminal {
  width: 100%;
  max-width: 720px;
  max-height: 70vh;
  overflow-y: auto;
  font-family: var(--font-terminal);
  font-size: 18px;
  line-height: 1.5;
  color: var(--term-green);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
  scrollbar-width: none;
}

#boot-terminal::-webkit-scrollbar {
  display: none;
}

#boot-output .boot-line {
  white-space: pre-wrap;
  word-break: break-all;
}

#boot-output .boot-line.warning {
  color: var(--term-amber);
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.4);
}

#boot-output .boot-line.error {
  color: var(--alert);
  text-shadow: 0 0 6px rgba(255, 0, 0, 0.4);
}

#boot-output .boot-line.success {
  color: var(--profit);
}

#boot-output .boot-line.cyan {
  color: var(--term-cyan);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

#boot-output .cursor-blink::after {
  content: '█';
  animation: blink-cursor 0.6s step-end infinite;
}

@keyframes blink-cursor {
  50% { opacity: 0; }
}

/* Boot progress bar */
#boot-progress {
  margin-top: 16px;
}

#boot-progress-track {
  width: 100%;
  height: 20px;
  border: 1px solid var(--term-green);
  background: transparent;
}

#boot-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--term-green);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
  transition: width 0.1s linear;
}

#boot-progress-label {
  text-align: center;
  margin-top: 4px;
  font-size: 14px;
  color: var(--term-green);
}

/* Enter button */
#boot-enter {
  margin-top: 40px;
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #000;
  background: var(--win-bg);
  border: 3px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  padding: 16px 48px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--win-darker),
    2px 2px 0 #000;
  animation: enter-pulse 1.5s ease-in-out infinite;
}

#boot-enter:hover {
  background: #d4d4d4;
}

#boot-enter:active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  box-shadow:
    inset 1px 1px 0 var(--win-darker),
    inset -1px -1px 0 #fff;
  transform: translate(1px, 1px);
}

@keyframes enter-pulse {
  0%, 100% { box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--win-darker), 2px 2px 0 #000, 0 0 20px rgba(0,255,65,0.2); }
  50%      { box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--win-darker), 2px 2px 0 #000, 0 0 40px rgba(0,255,65,0.5); }
}

/* --- DESKTOP -------------------------------------------------- */
#desktop {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #008080;
}

#desktop.boot-in {
  animation: crt-on 0.4s ease-out forwards;
}

@keyframes crt-on {
  0%   { transform: scale(0, 0.01); filter: brightness(5); }
  50%  { transform: scale(1.1, 0.01); filter: brightness(3); }
  70%  { transform: scale(1.1, 1.05); filter: brightness(1.5); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}

/* --- DESKTOP BACKGROUND --------------------------------------- */
#desktop-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #001a0a;
  overflow: hidden;
}

.noise-layer {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 4;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  animation: noise-drift 0.5s steps(4) infinite;
}

@keyframes noise-drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, -3%); }
  50%  { transform: translate(1%, 2%); }
  75%  { transform: translate(-1%, 1%); }
  100% { transform: translate(2%, -2%); }
}

.grid-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-image:
    linear-gradient(rgba(0, 255, 65, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 214, 0, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

/* --- WORLD MAP HOST (jsVectorMap) ----------------------------- */
#world-map-host {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.62;
  filter: saturate(0.85) contrast(1.08);
  pointer-events: auto;
}

#world-map-host .jvm-container {
  background: transparent !important;
}

#world-map-host .jvm-tooltip {
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
  background: rgba(6, 20, 12, 0.95) !important;
  border: 1px solid var(--term-green) !important;
  color: var(--term-green) !important;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.25) !important;
}

.map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-terminal);
  font-size: 16px;
  color: var(--term-amber);
  padding: 24px;
  text-align: center;
}

/* Map wash + depth */
.map-atmosphere {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, transparent 0%, rgba(0, 0, 0, 0.45) 75%, rgba(0, 0, 0, 0.85) 100%),
    linear-gradient(180deg, rgba(0, 40, 20, 0.35) 0%, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
}

/* Faint “chart fragment” in the corner */
.chart-ghost {
  position: absolute;
  bottom: 120px;
  left: 12px;
  width: 180px;
  height: 70px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
  background:
    linear-gradient(135deg, transparent 40%, rgba(0, 255, 65, 0.4) 41%, transparent 42%),
    repeating-linear-gradient(90deg, rgba(255, 176, 0, 0.15) 0 1px, transparent 1px 8px);
  border-left: 1px solid rgba(0, 255, 65, 0.3);
  border-bottom: 1px solid rgba(255, 176, 0, 0.2);
}

/* --- HERO: XCOIN MARK ---------------------------------------- */
.hero-xcoin-layer {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 6;
  pointer-events: none;
  text-align: center;
  width: min(92vw, 440px);
}

.xcoin-logo-wrap {
  margin: 0 auto 8px;
  width: min(52vw, 220px);
  filter: drop-shadow(0 0 24px rgba(31, 218, 86, 0.35)) drop-shadow(0 4px 0 rgba(0, 0, 0, 0.5));
}

.xcoin-logo-img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 50%;
  border: 3px solid rgba(31, 218, 86, 0.85);
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.6);
  background: rgba(6, 26, 16, 0.5);
}

.hero-iso {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.35em;
  color: rgba(255, 214, 0, 0.75);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--font-pixel);
  font-size: clamp(18px, 5vw, 28px);
  color: var(--term-white);
  text-shadow:
    0 0 20px rgba(0, 255, 65, 0.5),
    2px 2px 0 #000;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}

.hero-tagline {
  font-family: var(--font-terminal);
  font-size: 20px;
  color: var(--term-green);
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
  margin-bottom: 4px;
}

.hero-micro {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(224, 224, 224, 0.65);
  line-height: 1.5;
  max-width: 360px;
  margin: 0 auto;
}

#iso-rotator {
  color: var(--term-amber);
  font-weight: 700;
}

/* --- RESERVE PANELS (flicker) -------------------------------- */
.reserve-panels {
  position: fixed;
  left: 12px;
  bottom: calc(var(--taskbar-height) + 52px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.reserve-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 140px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(0, 255, 65, 0.35);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--term-green);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.rp-label {
  color: var(--term-amber);
  font-weight: 700;
}

.rp-val {
  color: var(--term-white);
  font-variant-numeric: tabular-nums;
}

.flicker-panel {
  animation: panel-flicker 4.2s ease-in-out infinite;
}

.flicker-panel.delay-a { animation-delay: 1.1s; }
.flicker-panel.delay-b { animation-delay: 2.3s; }

@keyframes panel-flicker {
  0%, 88%, 100% { opacity: 1; filter: brightness(1); }
  90% { opacity: 0.82; filter: brightness(1.15); }
  92% { opacity: 0.95; filter: brightness(0.9); }
}

/* --- WORLD CLOCKS STRIP --------------------------------------- */
.world-clocks {
  position: fixed;
  top: var(--ticker-height);
  left: 0;
  right: 0;
  height: var(--clocks-height);
  z-index: 899;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 0 12px;
  background: linear-gradient(180deg, #0a1a0f 0%, #050a08 100%);
  border-bottom: 1px solid rgba(0, 255, 65, 0.2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(224, 224, 224, 0.85);
}

.wc-label {
  color: var(--term-amber);
  font-weight: 700;
  margin-right: 2px;
}

.wc-sep {
  color: rgba(0, 255, 65, 0.25);
  margin: 0 2px;
}

.wc-time {
  font-variant-numeric: tabular-nums;
  color: var(--term-green);
}

.wc-pulse {
  animation: blink-text 2s step-end infinite;
}

.desktop-scroll-spacer {
  height: 90vh;
  min-height: 600px;
  pointer-events: none;
}

/* --- TICKER BAR ----------------------------------------------- */
#ticker-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--ticker-height);
  background: linear-gradient(180deg, #0d0808 0%, #1a1208 100%);
  border-bottom: 1px solid rgba(255, 176, 0, 0.25);
  z-index: 900;
  overflow: hidden;
  display: flex;
  align-items: center;
}

#ticker-track {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#ticker-content {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-family: var(--font-terminal);
  font-size: 16px;
  animation: ticker-scroll 30s linear infinite;
}

#ticker-content .tick-item {
  margin-right: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#ticker-content .tick-symbol {
  color: var(--term-amber);
  font-weight: bold;
}

#ticker-content .tick-price {
  color: var(--term-white);
}

#ticker-content .tick-change.up {
  color: var(--profit);
}

#ticker-content .tick-change.down {
  color: var(--loss);
}

#ticker-content .tick-lore {
  color: rgba(255, 214, 0, 0.85);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#ticker-content .tick-lore::before {
  content: '» ';
  color: var(--term-green);
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- AD BANNERS ----------------------------------------------- */
.ad-banner {
  background: #1a0000;
  border-top: 2px solid #ffb000;
  border-bottom: 2px solid #ffb000;
  padding: 6px 20px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--highlight);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  z-index: 50;
  overflow: hidden;
}

#ad-banner-top {
  position: fixed;
  top: calc(var(--ticker-height) + var(--clocks-height));
  left: 0;
  right: 0;
  height: var(--ad-height);
}

#ad-banner-bottom {
  position: relative;
  margin-top: 1200px;
  width: 100%;
}

#ad-banner-side {
  position: fixed;
  top: calc(var(--header-stack) + 20px);
  right: 0;
  width: 140px;
  z-index: 50;
  flex-direction: column;
  gap: 12px;
  padding: 12px 8px;
  border-left: 2px solid #ffb000;
  border-top: none;
  border-bottom: none;
  writing-mode: initial;
  text-align: center;
  height: auto;
}

.ad-separator {
  color: var(--alert);
}

.ad-text {
  white-space: nowrap;
}

.blink {
  animation: blink-text 0.8s step-end infinite;
}

@keyframes blink-text {
  50% { opacity: 0; }
}

/* --- DESKTOP ICONS -------------------------------------------- */
#desktop-icons {
  position: absolute;
  top: calc(var(--header-stack) + 20px);
  left: 20px;
  display: grid;
  grid-template-columns: repeat(2, 90px);
  gap: 8px 12px;
  z-index: 10;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.desktop-icon:hover {
  background: rgba(0, 0, 128, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

.desktop-icon:active,
.desktop-icon.selected {
  background: rgba(0, 0, 128, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
}

.icon-image {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}

.icon-image svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.6));
}

.icon-image img.icon-img-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.6));
}

.icon-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
  text-align: center;
  text-shadow: 1px 1px 2px #000, -1px -1px 2px #000, 1px -1px 2px #000, -1px 1px 2px #000;
  word-break: break-all;
  line-height: 1.2;
  max-width: 80px;
}

/* --- WINDOWS SYSTEM ------------------------------------------- */
.window {
  position: absolute;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-shadow) var(--win-shadow) var(--win-light);
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--win-darker);
  display: flex;
  flex-direction: column;
  min-width: 250px;
  min-height: 120px;
}

.window.focused {
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--win-darker),
    4px 4px 0 rgba(0, 0, 0, 0.3);
}

/* Title bar */
.window-titlebar {
  background: linear-gradient(90deg, var(--win-titlebar), var(--win-titlebar-end));
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 4px 3px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  flex-shrink: 0;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window:not(.focused) .window-titlebar {
  background: linear-gradient(90deg, var(--win-titlebar-inactive), var(--win-titlebar-inactive-end));
}

.window-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.window-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.win-btn {
  width: 18px;
  height: 16px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #000;
  padding: 0;
}

.win-btn:active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
}

.win-close:hover {
  background: #c0392b;
  color: #fff;
}

/* Menu bar (optional) */
.window-menubar {
  background: var(--win-bg);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 0;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--win-dark);
  flex-shrink: 0;
}

.window-menubar span {
  padding: 2px 8px;
  cursor: default;
  color: #000;
}

.window-menubar span:hover {
  background: var(--win-titlebar);
  color: #fff;
}

/* Window body */
.window-body {
  flex: 1;
  overflow: auto;
  border: 2px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  margin: 2px;
  background: #fff;
}

/* Resize handle */
.window-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(
    135deg,
    transparent 30%,
    var(--win-dark) 30%,
    var(--win-dark) 40%,
    transparent 40%,
    transparent 50%,
    var(--win-dark) 50%,
    var(--win-dark) 60%,
    transparent 60%,
    transparent 70%,
    var(--win-dark) 70%,
    var(--win-dark) 80%,
    transparent 80%
  );
}

/* --- WINDOW CONTENT: NOTEPAD ---------------------------------- */
.notepad-content {
  background: #fff;
  color: #000;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 12px;
  white-space: pre-wrap;
  min-height: 100%;
}

/* --- WINDOW CONTENT: TERMINAL --------------------------------- */
.terminal-content {
  background: var(--term-bg);
  color: var(--term-green);
  font-family: var(--font-terminal);
  font-size: 16px;
  line-height: 1.4;
  padding: 8px 10px;
  min-height: 100%;
  text-shadow: 0 0 4px rgba(0, 255, 65, 0.3);
}

.terminal-content .term-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-content .term-line.amber {
  color: var(--term-amber);
  text-shadow: 0 0 4px rgba(255, 176, 0, 0.3);
}

.terminal-content .term-line.red {
  color: var(--alert);
  text-shadow: 0 0 4px rgba(255, 0, 0, 0.3);
}

.terminal-content .term-line.cyan {
  color: var(--term-cyan);
}

.terminal-content .term-cursor::after {
  content: '█';
  animation: blink-cursor 0.6s step-end infinite;
}

/* --- WINDOW CONTENT: SPREADSHEET ------------------------------ */
.spreadsheet-content {
  background: #fff;
  min-height: 100%;
}

.spreadsheet-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.spreadsheet-content th {
  background: var(--win-bg);
  border: 1px solid var(--win-dark);
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  padding: 3px 8px;
  text-align: center;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
}

.spreadsheet-content td {
  border: 1px solid #c0c0c0;
  padding: 3px 8px;
  text-align: right;
  color: #000;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.spreadsheet-content td.label-cell {
  text-align: left;
  font-weight: 600;
  background: #f0f0f0;
}

.spreadsheet-content td.cell-up {
  color: #006600;
  background: #e6ffe6;
}

.spreadsheet-content td.cell-down {
  color: #cc0000;
  background: #ffe6e6;
}

.spreadsheet-content td.cell-flash {
  animation: cell-flash 0.3s ease;
}

@keyframes cell-flash {
  0%   { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}

.spreadsheet-header {
  background: var(--win-bg);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #000;
  border-bottom: 1px solid var(--win-dark);
  display: flex;
  align-items: center;
  gap: 4px;
}

.spreadsheet-cell-ref {
  background: #fff;
  border: 1px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  padding: 1px 4px;
  width: 60px;
  font-size: 11px;
}

.spreadsheet-formula {
  flex: 1;
  background: #fff;
  border: 1px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  padding: 1px 4px;
  font-size: 11px;
}

/* --- WINDOW CONTENT: CHART ------------------------------------ */
.chart-content {
  background: #0a0a14;
  min-height: 100%;
  padding: 8px;
}

.chart-content canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-header {
  font-family: var(--font-terminal);
  font-size: 14px;
  color: var(--term-green);
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #222;
}

.chart-price {
  font-size: 22px;
  font-weight: bold;
  color: var(--profit);
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.4);
}

.chart-label {
  color: var(--term-amber);
}

/* --- WINDOW CONTENT: INVEST CTA ------------------------------- */
.invest-content {
  background: var(--term-bg);
  color: var(--term-green);
  font-family: var(--font-terminal);
  font-size: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  text-align: center;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.3);
}

.invest-content .invest-prompt {
  margin-bottom: 24px;
  line-height: 1.6;
}

.invest-btn {
  font-family: var(--font-pixel);
  font-size: 14px;
  padding: 16px 40px;
  background: var(--profit);
  color: #000;
  border: 3px solid;
  border-color: #66ff66 #006600 #006600 #66ff66;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: invest-glow 1s ease-in-out infinite;
}

.invest-btn:hover {
  background: #33ff33;
}

.invest-btn:active {
  border-color: #006600 #66ff66 #66ff66 #006600;
  transform: translate(1px, 1px);
}

@keyframes invest-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 255, 0, 0.4); }
  50%      { box-shadow: 0 0 40px rgba(0, 255, 0, 0.8), 0 0 80px rgba(0, 255, 0, 0.3); }
}

/* --- TASKBAR -------------------------------------------------- */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--taskbar-height);
  background: var(--win-bg);
  border-top: 2px solid;
  border-color: var(--win-light);
  display: flex;
  align-items: center;
  padding: 2px 4px;
  gap: 4px;
  z-index: 1000;
  box-shadow: inset 0 1px 0 #fff;
}

#start-button {
  height: 28px;
  padding: 2px 8px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  box-shadow: inset 1px 1px 0 #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: #000;
}

#start-button:active,
#start-button.active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  box-shadow: inset 1px 1px 0 var(--win-darker);
}

.start-logo {
  font-size: 16px;
}

#taskbar-divider {
  width: 2px;
  height: 24px;
  border-left: 1px solid var(--win-dark);
  border-right: 1px solid var(--win-light);
  margin: 0 2px;
}

#taskbar-windows {
  flex: 1;
  display: flex;
  gap: 2px;
  overflow: hidden;
}

.taskbar-btn {
  height: 24px;
  padding: 2px 8px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #000;
}

.taskbar-btn.active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  box-shadow: inset 1px 1px 0 var(--win-darker);
  background: #b0b0b0;
}

#taskbar-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 2px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #000;
  height: 24px;
}

.tray-blink {
  color: var(--profit);
  animation: blink-text 1s step-end infinite;
  font-size: 8px;
}

#taskbar-clock {
  font-variant-numeric: tabular-nums;
}

/* --- START MENU ----------------------------------------------- */
#start-menu {
  position: fixed;
  bottom: var(--taskbar-height);
  left: 4px;
  width: 200px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-shadow) var(--win-shadow) var(--win-light);
  box-shadow: inset 1px 1px 0 #fff, 4px 4px 0 rgba(0,0,0,0.3);
  z-index: 1001;
  display: flex;
}

.start-menu-sidebar {
  width: 24px;
  background: var(--win-titlebar);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 4px;
  letter-spacing: 2px;
}

.start-menu-sidebar span {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

#start-menu-items {
  flex: 1;
  list-style: none;
  padding: 4px 0;
}

#start-menu-items li {
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

#start-menu-items li:hover {
  background: var(--win-titlebar);
  color: #fff;
}

#start-menu-items li.menu-separator {
  height: 1px;
  background: var(--win-dark);
  margin: 4px 8px;
  padding: 0;
  cursor: default;
}

#start-menu-items li.menu-separator:hover {
  background: var(--win-dark);
  color: #000;
}

.menu-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-icon svg {
  width: 16px;
  height: 16px;
}

.menu-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

/* --- SCROLLBARS ----------------------------------------------- */
.window-body::-webkit-scrollbar {
  width: 16px;
  height: 16px;
}

.window-body::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--win-bg) 0% 25%, var(--win-mid) 0% 50%) 50% / 2px 2px;
}

.window-body::-webkit-scrollbar-thumb {
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
}

.window-body::-webkit-scrollbar-button {
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  width: 16px;
  height: 16px;
}

/* Desktop scrollbar */
#desktop::-webkit-scrollbar {
  width: 16px;
}

#desktop::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--win-bg) 0% 25%, var(--win-mid) 0% 50%) 50% / 2px 2px;
}

#desktop::-webkit-scrollbar-thumb {
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
}

/* --- ERROR DIALOG --------------------------------------------- */
.error-dialog {
  text-align: center;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #000;
}

.error-dialog .error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.error-dialog .error-message {
  margin-bottom: 16px;
  line-height: 1.5;
}

.error-dialog .error-btn {
  padding: 4px 24px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  color: #000;
}

.error-dialog .error-btn:active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
}

/* --- STATUS BAR (bottom of windows) --------------------------- */
.window-statusbar {
  background: var(--win-bg);
  border-top: 2px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #000;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.status-section {
  border: 1px solid;
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
  padding: 0 6px;
}

/* --- SOCIAL BAR (see index.html: XCOIN_EXTERNAL_LINKS) ---------- */
#social-bar {
  position: fixed;
  bottom: calc(var(--taskbar-height) + 8px);
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(200px, 42vw);
}

.social-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #000;
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  color: var(--term-green);
  font-family: var(--font-pixel);
  font-size: 8px;
  text-decoration: none;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
}

.social-link:hover {
  background: #0a1a0f;
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

.social-link svg {
  flex-shrink: 0;
}

.social-static {
  display: block;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px dashed rgba(255, 176, 0, 0.4);
  color: var(--term-amber);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  cursor: default;
}

/* --- REGION MODAL (map click) --------------------------------- */
.region-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.region-modal.hidden {
  display: none;
}

.region-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
}

.region-modal-panel {
  position: relative;
  width: min(400px, 94vw);
  background: var(--term-bg);
  border: 2px solid;
  border-color: var(--term-green) rgba(0, 80, 40, 0.8) rgba(0, 80, 40, 0.8) var(--term-green);
  box-shadow:
    0 0 0 1px #000,
    0 0 40px rgba(0, 255, 65, 0.15),
    inset 0 0 30px rgba(0, 40, 20, 0.4);
  font-family: var(--font-mono);
  color: var(--term-green);
}

.region-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(90deg, #002010, #0a3020);
  border-bottom: 1px solid rgba(0, 255, 65, 0.35);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.region-modal-close {
  background: transparent;
  border: none;
  color: var(--term-amber);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.region-modal-body {
  padding: 16px 14px;
}

.region-modal-code {
  font-size: 28px;
  font-weight: 700;
  color: var(--term-amber);
  margin-bottom: 10px;
  letter-spacing: 0.2em;
}

.region-modal-msg {
  font-family: var(--font-terminal);
  font-size: 17px;
  line-height: 1.45;
  color: var(--term-white);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.2);
  margin-bottom: 12px;
}

.region-modal-foot {
  font-size: 11px;
  color: rgba(224, 224, 224, 0.45);
  line-height: 1.4;
}

.region-modal-actions {
  padding: 0 14px 14px;
}

.region-modal-ok {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 28px;
  background: var(--win-bg);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  cursor: pointer;
  color: #000;
}

.region-modal-ok:active {
  border-color: var(--win-dark) var(--win-light) var(--win-light) var(--win-dark);
}

/* --- UTILITY -------------------------------------------------- */
.text-green  { color: var(--profit); }
.text-red    { color: var(--loss); }
.text-amber  { color: var(--term-amber); }
.text-cyan   { color: var(--term-cyan); }
.text-white  { color: var(--term-white); }

/* --- MISC ANIMATIONS ------------------------------------------ */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Screen tear effect */
.screen-tear {
  position: fixed;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 255, 65, 0.1);
  z-index: 9998;
  pointer-events: none;
  transform: translateX(5px);
  animation: tear-move 0.1s linear;
}

@keyframes tear-move {
  from { transform: translateX(-5px); }
  to   { transform: translateX(5px); }
}

/* Lag simulation overlay */
#lag-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: all;
  cursor: wait;
  display: none;
}

#lag-overlay.active {
  display: block;
}

/* --- RESPONSIVE ----------------------------------------------- */
@media (max-width: 768px) {
  #desktop-icons {
    grid-template-columns: repeat(2, 80px);
    gap: 4px 8px;
  }

  .icon-image { width: 32px; height: 32px; font-size: 26px; }
  .icon-image img.icon-img-logo { width: 32px; height: 32px; }
  .icon-label { font-size: 10px; }

  #ad-banner-side { display: none; }
  .reserve-panels { display: none; }
  .hero-title { font-size: 16px; }
  .xcoin-logo-wrap { width: min(44vw, 160px); }

  .window {
    min-width: 200px;
  }

  #boot-terminal { font-size: 14px; }
  #boot-enter { font-size: 12px; padding: 12px 32px; }
}
