:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --text: #0f172a;
  --text-inv: #e8eef9;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.1);
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --win: #f8fafc;
  --title: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  --title-idle: linear-gradient(180deg, #64748b 0%, #475569 100%);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  --z-win: 20;
  --z-task: 100;
  --z-start: 110;
  --z-boot: 200;
  --radius: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.16s;
  --dur-med: 0.24s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  background: #020617;
  color: var(--text-inv);
  -webkit-tap-highlight-color: transparent;
  /* Stop touch/trackpad from panning the desktop under windows */
  touch-action: none;
}

button,
input {
  font: inherit;
}

a {
  color: var(--accent);
}

/* ========== BOOT (modern, clean) ========== */
.boot {
  position: fixed;
  inset: 0;
  z-index: var(--z-boot);
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 30%, #1e293b 0%, #020617 70%);
}

.boot[hidden] {
  display: none !important;
}

.boot-inner {
  text-align: center;
  width: min(360px, calc(100% - 2.5rem));
}

.boot-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  box-shadow: 0 12px 40px rgba(37, 99, 235, 0.35);
  overflow: hidden;
}

.boot-mark.boot-avatar {
  background: #cbd5e1;
  padding: 0;
}

.boot-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.boot-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #f1f5f9;
}

.boot-sub {
  margin: 0.35rem 0 1.5rem;
  color: #94a3b8;
  font-size: 0.9rem;
}

.boot-bar {
  height: 3px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.28s ease;
}

.boot-status {
  margin: 0.85rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
  font-family: var(--mono);
  min-height: 1.2em;
}

.boot-skip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 1.15rem auto 0;
  padding: 0.45rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-soft),
    border-color var(--dur-fast) var(--ease-soft),
    background var(--dur-fast) var(--ease-soft);
}

.boot-skip:hover,
.boot-skip:focus-visible {
  color: #e2e8f0;
  border-color: rgba(226, 232, 240, 0.55);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.boot-skip:active {
  transform: scale(0.98);
}

.boot-prompt {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: #cbd5e1;
  letter-spacing: 0.02em;
  animation: pulse 1.4s ease-in-out infinite;
}

.boot-prompt[hidden] {
  display: none !important;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* ========== DESKTOP ========== */
.desktop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-soft);
}

.desktop.is-ready {
  opacity: 1;
}

.desktop[hidden] {
  display: none !important;
  opacity: 0;
}

.wallpaper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #0b1220;
  /* Never receive drag/pan — windows only */
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

.wallpaper-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  image-rendering: auto;
  /* Prevent mobile browsers from re-flipping via EXIF orientation */
  image-orientation: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

/* Desktop TechBackground framing */
.wallpaper-img-desktop {
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
  object-position: center center;
}

.wallpaper-overlay {
  position: absolute;
  inset: 0;
  /* Lighter overlay so the high-res image stays sharp and visible */
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.06) 0%, rgba(2, 6, 23, 0.22) 100%);
  pointer-events: none;
}

.icon-grid {
  position: absolute;
  top: 16px;
  left: 14px;
  bottom: 56px;
  z-index: 30; /* above wallpaper on PC and mobile */
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px 16px;
  max-height: calc(100% - 70px);
  pointer-events: auto;
}

.desk-icon {
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  cursor: pointer;
  border-radius: 10px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  transition:
    background var(--dur-fast) var(--ease-soft),
    border-color var(--dur-fast) var(--ease-soft),
    transform var(--dur-fast) var(--ease-out);
}

.desk-icon:hover,
.desk-icon:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  outline: none;
  transform: translateY(-2px);
}

.desk-icon:active {
  transform: translateY(0) scale(0.98);
}

.desk-icon-img {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  display: block;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.35);
  transition:
    box-shadow var(--dur-fast) var(--ease-soft),
    transform var(--dur-fast) var(--ease-out);
}

.desk-icon:hover .desk-icon-img,
.desk-icon:focus-visible .desk-icon-img {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  transform: scale(1.04);
}

/* Stagger icons in when desktop first appears */
.desktop.is-ready .desk-icon {
  animation: iconIn 0.4s var(--ease-out) both;
}
.desktop.is-ready .desk-icon:nth-child(1) { animation-delay: 0.04s; }
.desktop.is-ready .desk-icon:nth-child(2) { animation-delay: 0.08s; }
.desktop.is-ready .desk-icon:nth-child(3) { animation-delay: 0.12s; }
.desktop.is-ready .desk-icon:nth-child(4) { animation-delay: 0.16s; }
.desktop.is-ready .desk-icon:nth-child(5) { animation-delay: 0.2s; }

@keyframes iconIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.desk-icon .label {
  font-size: 12px;
  text-align: center;
  line-height: 1.25;
  max-width: 84px;
  font-weight: 500;
}

/* ========== WINDOWS ========== */
.window-layer {
  position: absolute;
  inset: 0 0 48px 0;
  pointer-events: none;
}

.window {
  position: absolute;
  min-width: 320px;
  min-height: 280px;
  max-width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--win);
  color: var(--text);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.4);
  pointer-events: auto;
  overflow: hidden;
  resize: both;
  opacity: 1;
  transform: none;
  transition:
    box-shadow var(--dur-fast) var(--ease-soft),
    opacity var(--dur-med) var(--ease-soft),
    transform var(--dur-med) var(--ease-out);
}

/* Soft open: fade + slight rise */
.window.is-opening {
  animation: winIn 0.26s var(--ease-out) both;
}

.window.is-closing {
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
}

@keyframes winIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.window.is-mobile {
  resize: none;
  max-width: none;
  max-height: none;
  border-radius: 10px;
}

.window.active {
  z-index: calc(var(--z-win) + 5);
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.48);
}

.window.idle {
  z-index: var(--z-win);
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.32);
}

.window.minimized {
  display: none !important;
  pointer-events: none;
  visibility: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--title);
  color: #fff;
  cursor: grab;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
  /* Critical: drag titlebar only moves the window, not the page/background */
  touch-action: none;
}

.window.is-dragging {
  cursor: grabbing;
}

.window.is-dragging .titlebar {
  cursor: grabbing;
}

.window.idle .titlebar {
  background: var(--title-idle);
}

.titlebar:active {
  cursor: grabbing;
}

.titlebar .ico-img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.titlebar .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titlebar .controls {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 5;
}

.titlebar .controls button {
  width: 32px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background var(--dur-fast) var(--ease-soft), transform 0.12s var(--ease-out);
}

.titlebar .controls button:hover {
  background: rgba(255, 255, 255, 0.28);
}

.titlebar .controls button:active {
  transform: scale(0.94);
}

.titlebar .controls button.close:hover {
  background: #dc2626;
}

.win-body {
  flex: 1;
  overflow: auto;
  padding: 1.15rem 1.25rem 1.35rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  user-select: text;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  /* Allow vertical scroll inside windows without panning the desktop */
  touch-action: pan-y;
}

.win-body h2,
.win-body h3,
.win-body h4,
.win-body h5 {
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.lead {
  margin: 0 0 1rem;
  color: #334155;
  font-size: 0.98rem;
}

.intro-note {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  background: #f1f5f9;
  border-radius: 8px;
  color: #475569;
  font-size: 0.9rem;
}

/* Profile */
.profile-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.profile-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  background: #e2e8f0;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  border: 2px solid #fff;
}

.profile-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.role-line {
  margin: 0.15rem 0;
  font-weight: 600;
  color: #1d4ed8;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 1.15rem;
}

.stat {
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.05rem;
  font-family: var(--mono);
  font-weight: 600;
}

.stat span {
  font-size: 0.72rem;
  opacity: 0.75;
}

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin: 0 0 0.5rem !important;
}

.clean-list {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  color: #334155;
}

.clean-list li + li {
  margin-top: 0.4rem;
}

/* Experience */
.role-block {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.9rem;
  background: #fff;
}

.role-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #f1f5f9;
}

.org {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dates {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
}

.projects-label {
  margin: 0.85rem 0 0.55rem !important;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.project-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.project-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: #f8fafc;
  transition:
    border-color var(--dur-fast) var(--ease-soft),
    box-shadow var(--dur-fast) var(--ease-soft),
    transform var(--dur-fast) var(--ease-out);
}

.project-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.project-card h5 {
  font-size: 0.92rem;
  margin-bottom: 0.3rem !important;
}

.project-card p {
  margin: 0;
  font-size: 0.86rem;
  color: #475569;
  line-height: 1.45;
}

.project-card .tag {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2563eb;
}

.project-cards.personal {
  grid-template-columns: 1fr;
}

.project-card-with-icon {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.9rem;
  align-items: start;
}

.project-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center;
  /* No white border/pad — was background:#fff causing the white fringe */
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  border: none;
  background: transparent;
  display: block;
}

.project-card-body {
  min-width: 0;
}

.project-card-body h5 {
  margin-top: 0.1rem !important;
}

.btn-link {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  color: #1d4ed8;
}

.btn-link:hover {
  text-decoration: underline;
}

.edu-block {
  margin-top: 0.5rem;
  padding: 0.9rem 1rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.edu-block h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.5rem !important;
}

/* Skills */
.skill-sections {
  display: grid;
  gap: 0.95rem;
}

.skill-sections h3 {
  font-size: 0.92rem;
  margin-bottom: 0.45rem !important;
}

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

.chips span {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  color: #334155;
  transition:
    border-color var(--dur-fast) var(--ease-soft),
    background var(--dur-fast) var(--ease-soft),
    transform 0.12s var(--ease-out);
}

.chips span:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  transform: translateY(-1px);
}

/* Contact */
.contact-links {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.contact-links a {
  display: block;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #0f172a;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition:
    border-color var(--dur-fast) var(--ease-soft),
    background var(--dur-fast) var(--ease-soft),
    transform var(--dur-fast) var(--ease-out);
}

.contact-links a:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  transform: translateY(-1px);
}

.copy-btn {
  border: 0;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--dur-fast) var(--ease-soft), transform 0.12s var(--ease-out);
}

.copy-btn:hover {
  background: #1e293b;
}

.copy-btn:active {
  transform: scale(0.98);
}

/* Experience top bar — compact, visible without scrolling */
.experience-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 0.85rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.experience-toolbar-hint {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.35;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff !important;
  text-decoration: none;
  font-weight: 650;
  font-size: 0.88rem;
  white-space: nowrap;
  line-height: 1.2;
  transition: background var(--dur-fast) var(--ease-soft), transform 0.12s var(--ease-out), box-shadow var(--dur-fast) var(--ease-soft);
}

.btn-download:hover {
  background: #1e40af;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.28);
  transform: translateY(-1px);
}

.btn-download:active {
  transform: scale(0.98);
}

@media (max-width: 720px) {
  .experience-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.85rem;
  }

  .experience-toolbar-hint {
    font-size: 0.84rem;
    line-height: 1.3;
  }

  .experience-toolbar-hint[hidden] {
    display: none !important;
  }

  .btn-download {
    width: 100%;
    padding: 0.55rem 0.85rem;
  }

  /* iOS: single full-width button, no extra label */
  .experience-toolbar:has(.btn-download-full) {
    padding: 0.55rem;
  }

  .btn-download-full {
    width: 100%;
  }
}

.experience-toolbar-hint[hidden] {
  display: none !important;
}

.btn-download-full {
  width: 100%;
}

/* ========== TASKBAR / START ========== */
.taskbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  z-index: var(--z-task);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.start-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  font-size: 0.9rem;
  transition: filter var(--dur-fast) var(--ease-soft), transform 0.12s var(--ease-out), box-shadow var(--dur-fast) var(--ease-soft);
}

.start-btn:hover,
.start-btn.is-open,
.start-btn[aria-expanded="true"] {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.start-btn:active {
  transform: scale(0.98);
}

.start-logo {
  color: #bfdbfe;
  font-size: 0.75rem;
}

.task-buttons {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  min-width: 0;
}

.task-btn {
  height: 32px;
  max-width: 170px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background var(--dur-fast) var(--ease-soft),
    border-color var(--dur-fast) var(--ease-soft),
    opacity var(--dur-fast) var(--ease-soft),
    transform 0.12s var(--ease-out);
}

.task-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.task-btn:active {
  transform: scale(0.97);
}

.task-btn.active {
  background: rgba(59, 130, 246, 0.35);
  border-color: rgba(96, 165, 250, 0.45);
}

.task-btn.minimized {
  opacity: 0.7;
  border-style: dashed;
}

.tray {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--mono);
  font-size: 12px;
  color: #cbd5e1;
}

.start-menu {
  position: absolute;
  left: 8px;
  bottom: 54px;
  z-index: var(--z-start);
  width: min(280px, calc(100vw - 16px));
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  transform-origin: bottom left;
  transition:
    opacity var(--dur-med) var(--ease-soft),
    transform var(--dur-med) var(--ease-out),
    visibility 0s linear var(--dur-med);
}

.start-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity var(--dur-med) var(--ease-soft),
    transform var(--dur-med) var(--ease-out),
    visibility 0s linear 0s;
}

.start-user {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.start-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: #e2e8f0;
  overflow: hidden;
  flex-shrink: 0;
}

.start-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.start-user strong {
  display: block;
  font-size: 0.95rem;
  color: #f1f5f9;
}

.start-user span {
  font-size: 0.78rem;
  color: #94a3b8;
}

.start-menu button,
.start-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #e2e8f0;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.start-menu button img,
.start-item img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
}

.start-menu button,
.start-link {
  transition: background var(--dur-fast) var(--ease-soft), transform 0.12s var(--ease-out);
}

.start-menu button:hover,
.start-link:hover {
  background: rgba(59, 130, 246, 0.22);
}

.start-menu button:active,
.start-link:active {
  transform: scale(0.98);
}

.start-danger {
  margin-top: 4px;
  color: #fca5a5 !important;
}

@media (max-width: 720px) {
  /* Mobile: dedicated portrait crop already centered on the energy figure */
  .wallpaper-img {
    object-fit: cover;
    object-position: center center;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    image-orientation: none;
  }

  .wallpaper-img-desktop {
    object-position: center center;
  }

  .wallpaper-overlay {
    background:
      linear-gradient(
        180deg,
        rgba(2, 6, 23, 0.28) 0%,
        rgba(2, 6, 23, 0.18) 40%,
        rgba(2, 6, 23, 0.55) 100%
      );
  }

  /* Keep icons in a left column (not a full-width top row) */
  .icon-grid {
    top: 12px;
    left: 8px;
    right: auto;
    bottom: 56px;
    width: auto;
    max-width: 100px;
    max-height: calc(100dvh - 70px);
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .desk-icon {
    width: 76px;
    padding: 8px 4px;
    gap: 5px;
  }

  .desk-icon-img {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 11px;
  }

  .desk-icon .label {
    font-size: 11px;
    max-width: 72px;
  }

  .window {
    max-width: none;
    max-height: none;
  }

  .stat-grid,
  .project-cards {
    grid-template-columns: 1fr 1fr;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
  }

  .win-body {
    font-size: 13.5px;
    padding: 1rem;
  }

  .project-card-with-icon {
    grid-template-columns: 48px 1fr;
    gap: 0.7rem;
  }

  .project-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
  }
}

/* Very narrow phones */
@media (max-width: 400px) {
  .wallpaper-img {
    object-position: center center;
  }
}

@media (max-width: 480px) {
  .stat-grid,
  .project-cards {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-prompt,
  .boot-bar-fill,
  .desktop.is-ready .desk-icon,
  .window.is-opening {
    animation: none !important;
  }

  .desktop,
  .desk-icon,
  .desk-icon-img,
  .window,
  .start-menu,
  .task-btn,
  .start-btn,
  .project-card,
  .chips span,
  .contact-links a,
  .copy-btn,
  .titlebar .controls button,
  .start-menu button,
  .start-link {
    transition: none !important;
  }

  .desk-icon:hover,
  .desk-icon:focus-visible,
  .desk-icon:hover .desk-icon-img,
  .project-card:hover,
  .chips span:hover,
  .contact-links a:hover {
    transform: none !important;
  }

  .start-menu {
    transform: none;
  }

  .window.is-closing {
    opacity: 0;
    transform: none;
  }
}
