:root {
  --ink: #3a1024;
  --blush: #ffe4f2;
  --pink: #ff4d9a;
  --hot: #e0126a;
  --gold: #ffe14a;
  --desk: #1a0612;
  --up: #1fbf6a;
  --down: #ff3d7a;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: var(--desk);
  overflow-x: hidden;
}

#matrix {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.sparkles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.spark {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 8px;
  background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: 0.75;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(180deg); }
}

#intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 18px 72px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, #fff 0, #ffd0e8 28%, transparent 55%),
    linear-gradient(180deg, #ff8ec3, #ff4d9a 55%, #c2185b);
}
#intro.off { display: none; }
.intro-pic { display: none; }
.kicker, .sub, .tag {
  margin: 0;
  font-family: "VT323", monospace;
  letter-spacing: 0.08em;
}
.kicker { font-size: 28px; color: #fff; }
h1 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: clamp(46px, 10vw, 92px);
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 4px 4px 0 #a11258;
}
.sub { font-size: 28px; color: #3a1024; }
.tag { font-size: 22px; color: #fff; }
#enterBtn, #copyBtn, .links a, #startBtn {
  font-family: "VT323", monospace;
  font-size: 26px;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid #fff;
  border-right-color: #8a6a10;
  border-bottom-color: #8a6a10;
  box-shadow: 3px 3px 0 #7a1848;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 16px;
}
#enterBtn { margin-top: 10px; font-size: 32px; }
#enterBtn:hover, #copyBtn:hover, .links a:hover, #startBtn:hover { background: #fff3a0; }
#enterBtn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

#desk {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(1320px, 100%);
  margin-inline: auto;
  grid-template-columns: minmax(0, 640px) minmax(0, 640px);
  justify-content: center;
  gap: 12px;
  padding: 14px 14px 64px;
  align-items: start;
}
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mini-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mini-row .titlebar { font-size: 18px; }
.mini-row .body { padding: 6px 8px; }
.mini-row .lead, .fm p { margin: 0 0 4px; font-size: 15px; }

.win {
  background: var(--blush);
  border: 2px solid #fff;
  border-right-color: #7a2a52;
  border-bottom-color: #7a2a52;
  box-shadow: 4px 4px 0 #4a1028;
  min-width: 0;
}
#wCa { grid-column: 1 / -1; width: min(460px, 100%); justify-self: center; }
.win.gone { display: none; }
.win.lifted { position: absolute; z-index: 5; margin: 0; }

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 2px 8px;
  background: linear-gradient(90deg, #ff3d8a, #ff8ab8);
  color: #fff;
  font-family: "VT323", monospace;
  font-size: 22px;
  cursor: grab;
  user-select: none;
}
.titlebar i { font-style: normal; }
.tbs { display: flex; gap: 3px; }
.tbtn {
  width: 22px;
  height: 20px;
  padding: 0;
  font-family: "VT323", monospace;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  background: #ffd0e6;
  border: 2px solid #fff;
  border-right-color: #8a3a5c;
  border-bottom-color: #8a3a5c;
  cursor: pointer;
}
.body { padding: 10px; }
h2 {
  margin: 8px 0 0;
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: 36px;
  letter-spacing: 0.04em;
}
.lead { margin: 0 0 6px; font-weight: 800; }
p { margin: 0 0 8px; line-height: 1.35; }
.hero {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 220px;
  height: auto;
  margin: 0 auto;
  background: #ffb3d9;
  border: 2px solid #fff;
  border-right-color: #8a3a5c;
  border-bottom-color: #8a3a5c;
}
.world-body { padding: 6px; }
.world-body img { display: block; width: 100%; height: auto; }
.help-body { display: flex; flex-wrap: wrap; gap: 6px; }
.help-body p { flex-basis: 100%; margin: 0; }
.help-body button {
  font-family: "VT323", monospace;
  font-size: 18px;
  background: var(--gold);
  color: var(--ink);
  border: 2px solid #fff;
  border-right-color: #8a6a10;
  border-bottom-color: #8a6a10;
  cursor: pointer;
  padding: 2px 8px;
}
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fine { color: #7a3a58; font-size: 13px; margin: 8px 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}
.stats div {
  background: #fff;
  border: 2px solid #7a2a52;
  padding: 4px 6px;
  min-width: 0;
}
.stats span {
  display: block;
  font-family: "VT323", monospace;
  font-size: 16px;
  color: #8a3a5c;
}
.stats b {
  display: block;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats b.up { color: var(--up); }
.stats b.down { color: var(--down); }
.pair {
  margin: 8px 0;
  font-family: "VT323", monospace;
  font-size: 18px;
}

.charttools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.seg { display: flex; gap: 4px; }
.seg button {
  font-family: "VT323", monospace;
  font-size: 18px;
  background: #fff;
  color: var(--ink);
  border: 2px solid #7a2a52;
  cursor: pointer;
  padding: 0 8px;
}
.seg button.on { background: var(--pink); color: #fff; border-color: #7a1848; }

.chartbox {
  position: relative;
  height: 200px;
  margin-top: 8px;
  background: #2a1028;
  border: 2px solid #7a2a52;
}
#candles { display: block; width: 100%; height: 100%; }
.tip {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #fff;
  color: var(--ink);
  font-family: "VT323", monospace;
  font-size: 16px;
  padding: 2px 6px;
  pointer-events: none;
}

.folder { font-family: "VT323", monospace; font-size: 22px; margin-bottom: 6px; }
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  background: #f3c6dc;
  border: 2px solid #7a2a52;
  padding: 6px;
}
.thumb {
  margin: 0;
  padding: 0;
  border: 2px solid #fff;
  border-right-color: #8a3a5c;
  border-bottom-color: #8a3a5c;
  background: #fff;
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ca-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#caText {
  flex: 1 1 240px;
  font-family: "VT323", monospace;
  font-size: 18px;
  background: #fff;
  padding: 6px 8px;
  border: 2px solid #7a2a52;
  word-break: break-all;
}
#meter { width: 100%; accent-color: var(--hot); }
.meter-scale {
  display: flex;
  justify-content: space-between;
  font-family: "VT323", monospace;
  font-size: 18px;
}
.fm p { font-family: "VT323", monospace; font-size: 18px; }
.fm audio { width: 100%; height: 32px; }
.fm-row { display: flex; gap: 4px; margin-top: 4px; }
.fm-row button {
  font-family: "VT323", monospace;
  font-size: 18px;
  background: var(--gold);
  color: var(--ink);
  border: 2px solid #fff;
  border-right-color: #8a6a10;
  border-bottom-color: #8a6a10;
  cursor: pointer;
  padding: 0 8px;
}
#taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: linear-gradient(#ffb3d6, #ff8ec3);
  border-top: 2px solid #fff;
}
#startMenu {
  position: absolute;
  bottom: 48px;
  left: 8px;
  z-index: 2;
  background: var(--blush);
  border: 2px solid #fff;
  border-right-color: #7a2a52;
  border-bottom-color: #7a2a52;
  box-shadow: 4px 4px 0 #4a1028;
  display: flex;
  flex-direction: column;
  min-width: 160px;
}
#startMenu[hidden] { display: none; }
#startMenu button {
  text-align: left;
  font-family: "VT323", monospace;
  font-size: 22px;
  background: transparent;
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--ink);
}
#startMenu button:hover { background: var(--pink); color: #fff; }
#taskOpen { display: flex; gap: 4px; }
.task {
  font-family: "VT323", monospace;
  font-size: 18px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff;
  border: 2px solid #7a2a52;
  cursor: pointer;
}
.task.off { background: #ffd0e6; }
.ticker {
  flex: 1;
  overflow: hidden;
  font-family: "VT323", monospace;
  font-size: 20px;
  color: #5a1030;
}
.ticker span { display: inline-block; white-space: nowrap; animation: tick 22s linear infinite; }
@keyframes tick { to { transform: translateX(-50%); } }
#clock {
  font-family: "VT323", monospace;
  font-size: 22px;
  background: var(--blush);
  border: 2px solid #7a2a52;
  padding: 0 8px;
}

#viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(30, 6, 18, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}
#viewer[hidden] { display: none; }
#viewer figure { margin: 0; max-width: min(920px, 80vw); text-align: center; }
#mvImg { max-width: 100%; max-height: 72vh; object-fit: contain; background: #ffb3d9; }
#viewer figcaption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  font-family: "VT323", monospace;
  font-size: 26px;
  margin-top: 6px;
}
#mvPrev, #mvNext, #mvClose {
  font-size: 40px;
  width: 52px;
  height: 52px;
  border: 2px solid #fff;
  background: var(--pink);
  color: #fff;
  cursor: pointer;
}
#mvClose { position: absolute; top: 16px; right: 16px; }

@media (min-width: 861px) {
  #desk {
    display: block;
    width: 100%;
    min-height: 1040px;
    margin: 0;
  }
  #wAbout, #wWorld, #wMemes, #wChart, #wFm, #wMeter, #wCa {
    position: absolute;
  }
  #wAbout { left: 28px; top: 16px; width: 360px; }
  #wWorld { left: 320px; top: 8px; width: 540px; z-index: 2; }
  #wChart { left: 620px; top: 250px; width: 460px; z-index: 3; }
  #wMemes { left: 24px; top: 430px; width: 440px; }
  #wMeter { left: 760px; top: 620px; width: 280px; z-index: 4; }
  #wFm { left: 470px; top: 700px; width: 280px; }
  #wCa { left: 160px; top: 860px; width: 440px; }
  #wHelp { position: fixed; right: 16px; bottom: 60px; width: 230px; z-index: 25; }
}

@media (max-width: 860px) {
  #desk { grid-template-columns: 1fr; width: 100%; min-height: 0; }
  #wAbout, #wWorld, #wMemes, #wChart, #wFm, #wMeter, #wCa, #wHelp {
    position: static;
    width: auto;
    left: auto;
    top: auto;
  }
  .stack, .mini-row { display: contents; }
  .intro-pic {
    display: block;
    width: min(150px, 42vw);
    height: auto;
    margin: 0 auto 6px;
    border: 4px solid #fff;
    box-shadow: 6px 6px 0 #7a1848;
  }
  #intro h1 { font-size: 34px; }
  #wAbout { order: 1; }
  #wWorld { order: 2; }
  #wChart { order: 3; }
  #wMemes { order: 4; }
  #wCa { order: 5; width: auto; }
  #wFm { order: 6; }
  #wMeter { order: 7; }
  #wHelp { order: 8; }
  .win.lifted { position: relative; left: auto !important; top: auto !important; width: auto !important; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div:last-child { grid-column: 1 / -1; }
  #taskOpen { display: none; }
  .hero { max-height: 220px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mini-row { order: 5; grid-template-columns: 1fr; }
  .chartbox { height: 360px; }
  .ticker { display: none; }
  .titlebar { cursor: default; }
}

@media (prefers-reduced-motion: reduce) {
  .spark, .ticker span { animation: none; }
}
