@import url('https://fonts.googleapis.com/css2?family=VT323&family=Tahoma&display=swap');

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

body {
  font-family: Tahoma, Verdana, "MS Sans Serif", sans-serif;
  font-size: 13px;
  /* Bliss-ish gradient: sky blue to grass green */
  background: linear-gradient(180deg,
    #4a91d6 0%,
    #6fb3e8 35%,
    #9fd0f0 48%,
    #78b84a 55%,
    #5a9e33 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-x: hidden;
}

.desktop {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 32px);
}

/* ---- Window chrome ---- */
.xp-window {
  background: #ece9d8;
  border: 1px solid #003c74;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}
.main-window {
  width: 100%;
  max-width: 520px;
}

.xp-titlebar {
  background: linear-gradient(180deg, #0058e6 0%, #3f8cf3 8%, #0058e6 40%, #0043a3 100%);
  color: #fff;
  padding: 4px 6px 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.xp-title {
  font-weight: bold;
  font-size: 12px;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.xp-controls { display: flex; gap: 3px; position: relative; }
.xp-ctl {
  width: 21px; height: 21px;
  background: linear-gradient(180deg, #5a9bf0, #1a5fc4);
  border: 1px solid #fff;
  border-radius: 3px;
  color: #fff;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-weight: bold;
}
.xp-ctl:hover { filter: brightness(1.15); }
.xp-close { background: linear-gradient(180deg, #f08a5a, #d43c1a); }
.close-tip {
  position: absolute;
  top: 26px; right: 0;
  background: #ffffcc;
  border: 1px solid #000;
  color: #000;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 30;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.xp-menubar {
  background: #ece9d8;
  border-bottom: 1px solid #aca899;
  padding: 3px 4px;
  display: flex;
  gap: 2px;
}
.xp-menu-item {
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 2px;
}
.xp-menu-item:hover { background: #316ac5; color: #fff; }

.xp-body { padding: 12px; }

/* ---- Cracktro marquee ---- */
.cracktro {
  background: #000;
  border: 2px inset #808080;
  overflow: hidden;
  padding: 4px 0;
  margin-bottom: 12px;
}
.cracktro-text {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: #33ff66;
  white-space: nowrap;
  display: inline-block;
  animation: scroll-left 22s linear infinite;
  text-shadow: 0 0 6px #33ff66;
}
@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ---- Logo row ---- */
.logo-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.logo-badge {
  font-family: 'VT323', monospace;
  font-size: 30px;
  background: linear-gradient(135deg, #ff004d, #ff8800);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  border: 2px outset #ff8800;
  text-shadow: 2px 2px 0 #000;
  transform: rotate(-4deg);
}
.logo-title { font-weight: bold; font-size: 15px; letter-spacing: 1px; color: #003c74; }
.logo-sub { font-size: 10px; color: #666; font-style: italic; }

/* ---- Key display ---- */
.key-display-wrap { margin-bottom: 12px; }
.key-label { font-size: 11px; margin-bottom: 4px; color: #333; }
.key-lcd {
  font-family: 'VT323', monospace;
  font-size: 30px;
  letter-spacing: 2px;
  background: #0a1a0a;
  color: #4dff88;
  border: 3px inset #888;
  padding: 12px 10px;
  text-align: center;
  text-shadow: 0 0 8px rgba(77,255,136,0.7);
  min-height: 56px;
  word-break: break-all;
}
.key-lcd.lcd-busy { color: #227744; }
.lcd-cursor { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- Progress ---- */
.xp-progress-wrap { margin-bottom: 12px; }
.xp-progress-msg {
  font-family: 'VT323', monospace;
  font-size: 15px;
  color: #003c74;
  margin-bottom: 4px;
}
.xp-progress-track {
  background: #fff;
  border: 2px inset #888;
  height: 20px;
  padding: 2px;
}
.xp-progress-fill {
  height: 100%;
  background: repeating-linear-gradient(90deg,
    #2c8f2c 0, #2c8f2c 8px, #3cb03c 8px, #3cb03c 12px);
  transition: width 0.09s linear;
}

/* ---- Buttons ---- */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.xp-btn {
  font-family: Tahoma, sans-serif;
  font-size: 12px;
  padding: 6px 12px;
  background: linear-gradient(180deg, #fff 0%, #ece9d8 45%, #d6d2c2 100%);
  border: 1px solid #707070;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 #fff;
  color: #000;
}
.xp-btn:hover:not(:disabled) { border-color: #316ac5; background: linear-gradient(180deg,#fff,#e8f0fc); }
.xp-btn:active:not(:disabled) { background: linear-gradient(180deg,#d6d2c2,#ece9d8); box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3); }
.xp-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.xp-btn-primary {
  font-weight: bold;
  background: linear-gradient(180deg, #7bc043 0%, #4a9e1e 100%);
  color: #fff;
  border-color: #2d6b0f;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
  flex: 1;
  min-width: 150px;
}
.xp-btn-primary:hover:not(:disabled) { background: linear-gradient(180deg,#8ed155,#59b825); }

/* ---- Fieldsets ---- */
.xp-fieldset {
  border: 1px solid #aca899;
  border-radius: 3px;
  padding: 10px;
  margin-bottom: 12px;
}
.xp-fieldset legend { font-size: 11px; font-weight: bold; padding: 0 4px; color: #003c74; }
.opt-radios { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.opt-radio, .opt-check { font-size: 12px; cursor: pointer; display: block; }
.opt-checks { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---- History ---- */
.history-box {
  background: #fff;
  border: 2px inset #888;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
}
.history-empty { color: #888; font-style: italic; padding: 8px; text-align: center; }
.history-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 4px;
  border-bottom: 1px dotted #ddd;
}
.history-key {
  font-family: 'VT323', monospace;
  font-size: 16px;
  flex: 1;
  color: #003c74;
  word-break: break-all;
}
.history-ed { font-size: 10px; color: #888; white-space: nowrap; }
.history-copy {
  background: none; border: 1px solid transparent;
  cursor: pointer; font-size: 12px; border-radius: 3px;
}
.history-copy:hover { border-color: #316ac5; background: #e8f0fc; }

/* ---- Status bar ---- */
.xp-statusbar {
  background: #ece9d8;
  border-top: 1px solid #aca899;
  display: flex;
  font-size: 11px;
}
.status-cell {
  padding: 3px 8px;
  border-right: 1px solid #aca899;
  border-top: 1px solid #fff;
}
.status-ready { color: #2d6b0f; font-weight: bold; }
.status-grow { flex: 1; text-align: right; border-right: none; }
.remix-link { color: #0033aa; text-decoration: none; }
.remix-link:hover { text-decoration: underline; }

/* ---- Scanlines ---- */
.scanlines .xp-body { position: relative; }
.scanlines .xp-body::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg,
    rgba(0,0,0,0.06) 0, rgba(0,0,0,0.06) 1px, transparent 1px, transparent 3px);
  pointer-events: none;
  z-index: 5;
}

/* ---- Modal ---- */
.xp-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 16px;
}
.xp-modal { width: 100%; max-width: 400px; }

/* ---- Achievement ---- */
.achievement-pop {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 60; cursor: pointer;
  background: rgba(0,0,0,0.3);
}
.achievement-inner {
  background: linear-gradient(180deg, #fffbe0, #ffe680);
  border: 3px ridge #d4a017;
  border-radius: 8px;
  padding: 24px 32px;
  text-align: center;
  font-weight: bold;
  color: #7a5a00;
  box-shadow: 0 0 40px rgba(255,215,0,0.6);
  animation: pop-in 0.4s ease;
  max-width: 320px;
}
@keyframes pop-in {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.achievement-star { font-size: 40px; color: #ffbf00; }
.achievement-hint { font-size: 10px; font-weight: normal; margin-top: 10px; color: #a88; }

/* ---- Turbo rain ---- */
.turbo-rain { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.turbo-key {
  position: absolute;
  top: -30px;
  font-family: 'VT323', monospace;
  font-size: 15px;
  color: #33ff66;
  text-shadow: 0 0 6px #33ff66;
  white-space: nowrap;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh); opacity: 0.3; }
}
.turbo-banner {
  position: fixed;
  top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 45;
  font-family: 'VT323', monospace;
  font-size: 26px;
  color: #ffea00;
  text-shadow: 0 0 12px #ff8800;
  background: rgba(0,0,0,0.6);
  padding: 4px 20px;
  border-radius: 4px;
  animation: blink 0.6s steps(2) infinite;
}

/* ---- Mobile ---- */
@media (max-width: 540px) {
  body { padding: 6px; font-size: 12px; }
  .main-window { max-width: 100%; }
  .key-lcd { font-size: 22px; }
  .cracktro-text { font-size: 15px; }
  .btn-row .xp-btn-primary { min-width: 100%; }
  .xp-title { font-size: 11px; }
}