  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
  html, body { height: 100%; margin: 0; overflow: hidden; }
  body {
    font-family: Tahoma, "Segoe UI", Verdana, sans-serif;
    font-size: 12px;
    color: #111;
  }

  /* ===================== BOOT SCREEN ===================== */
  #boot-screen {
    position: fixed; inset: 0; background: #000; z-index: 99999;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
    color: #fff; transition: opacity .6s ease;
  }
  #boot-screen .logo {
    font-size: 30px; font-weight: bold; letter-spacing: 1px;
    background: linear-gradient(90deg,#ff8a00,#e52e71 35%,#3f8cf3 70%,#5ecb3c);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    font-style: italic;
  }
  #boot-screen .barwrap { width: 220px; height: 12px; border: 1px solid #445; border-radius: 3px; overflow: hidden; background: #111; }
  #boot-screen .bar { width: 40%; height: 100%; background: linear-gradient(90deg,#1958D0,#5ecb3c); animation: bootmove 1.1s ease-in-out infinite; }
  @keyframes bootmove { 0%{ transform: translateX(-120%);} 100%{ transform: translateX(340%);} }
  #boot-screen.hide { opacity: 0; pointer-events: none; }

  /* ===================== DESKTOP ===================== */
  #desktop {
    position: fixed; inset: 0; overflow: hidden;
    background: #000;
  }
  #bg-img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
  }
  .cloud {
    position: absolute; background: rgba(255,255,255,.9); border-radius: 50px;
    filter: blur(.3px); box-shadow: 0 0 0 6px rgba(255,255,255,.55);
  }
  .hill {
    position: absolute; left: -10%; width: 120%; border-radius: 50%;
  }
  .hill.back { bottom: -18%; height: 34%; background: #6BAE46; opacity: .85; }
  .hill.front { bottom: -26%; height: 30%; background: #559636; }

  .desktop-icons {
    position: absolute; inset: 0; z-index: 2; pointer-events: none;
  }

  .desktop-icon {
    position: absolute; width: 120px; padding: 8px 6px; border-radius: 5px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    pointer-events: auto; touch-action: none; -webkit-user-drag: none;
  }
  .desktop-icon .ic { font-size: 52px; line-height: 1; filter: drop-shadow(1px 2px 2px rgba(0,0,0,.55)); }
  .desktop-icon .ic img { width: 64px; height: 64px; object-fit: contain; display: block; }
  .desktop-icon .ic .ic-fallback { display: none; }  .desktop-icon .lb {
    color: #fff; font-size: 13px; text-align: center; text-shadow: 1px 1px 2px rgba(0,0,0,.85);
    padding: 2px 6px; border-radius: 3px; max-width: 120px;
  }
  .desktop-icon.selected { background: rgba(50,100,210,.35); outline: 1px dotted rgba(255,255,255,.8); }
  .desktop-icon.selected .lb { background: #1550C9; outline: 1px dotted #fff; }

  /* GIF widget: static poster by default, click to play gif + sound. Có thể kéo-thả tự do. */
  .gif-widget {
    position: absolute; top: 16px; right: 16px; width: 140px; z-index: 5;
    display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: grab;
  }
  .gif-widget.dragging { cursor: grabbing; }
.gif-widget .frame { width: 130px; height: 130px; border: none; outline: none; border-radius: 6px; background: transparent; box-shadow: 2px 3px 10px rgba(0,0,0,.4); overflow: hidden; position: relative; }
  .gif-widget .frame .gif-layer {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  }
  #gif-poster { opacity: 1; transition: opacity .2s; z-index: 1; }
  #gif-anim { opacity: 0; z-index: 2; }
  .gif-widget.playing #gif-anim { opacity: 1; }
  .gif-widget .frame .ic-fallback {
    display: none; width: 100%; height: 100%; align-items: center; justify-content: center;
    font-size: 40px; color: #fff; background: linear-gradient(135deg,#2E62B0,#7CB955);
    position: absolute; inset: 0; z-index: 0;
  }
  /* overlay tối + icon tròn: CHỈ hiện khi hover, ẩn hoàn toàn lúc không hover (dù đang phát hay đang dừng) */
  .gif-widget .overlay {
    position: absolute; inset: 0; z-index: 3; pointer-events: none;
    background: rgba(0,0,0,.25); opacity: 0; transition: opacity .3s; border-radius: 4px;
  }
.gif-widget:hover .overlay { opacity: 1; }

/* Remove any unexpected white edge around gif frame (e.g., focus rings) */
.gif-widget .frame:focus,
.gif-widget .frame:active,
.gif-widget .frame *:focus,
.gif-widget .frame *:active { outline: none; }
  .gif-widget .play-badge {
    position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center;
    pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; transform: scale(.85);
  }
  .gif-widget:hover .play-badge { opacity: 1; transform: scale(1); }
  .gif-widget .play-badge span {
    width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.45);
    backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px;
  }
  .gif-widget .cap {
    color: #fff; font-size: 11px; text-align: center; text-shadow: 1px 1px 2px rgba(0,0,0,.85);
    padding: 1px 4px;
  }
  .volume-controls {
    position: absolute; left: 50%; bottom: -36px; transform: translateX(-50%);
    display: flex; gap: 6px; z-index: 60;
  }
  .volume-btn {
    border: none; border-radius: 999px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.95); color: #0f172a; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,.22);
    font-size: 16px; font-weight: 700; line-height: 1;
  }
  .volume-btn:hover { transform: scale(1.05); }

  .ad-card {
    position: absolute; z-index: 4; width: 290px; border-radius: 0; overflow: hidden;
    background: transparent; box-shadow: none; border: none; cursor: grab; user-select: none;
    touch-action: none; -webkit-user-drag: none;
    animation: adPopIn .5s ease both;
    transition: transform .25s ease, filter .25s ease, box-shadow .25s ease;
  }
  .ad-card:hover {
    transform: scale(1.04) translateY(-4px);
    filter: brightness(1.05);
    box-shadow: 0 12px 24px rgba(0,0,0,.25);
  }
  .ad-card.dragging { cursor: grabbing; transform: scale(1.02); }
  .ad-card img {
    display: block; width: 100%; height: auto; border-radius: 0;
    -webkit-user-drag: none; pointer-events: none;
  }
  @keyframes adPopIn {
    0% { opacity: 0; transform: scale(.92) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
  }
  .ad-card-1 {
    top: 500px; left: calc(70% - 10px);
    width: 480px;
  }
  .ad-card-2 {
    top: 150px; left: calc(50% + 225px);
    width: 330px;
    border-radius: 8px;
    /* faster, stronger pulse (overrides base adPopIn) */
    animation: ctaPulse 1.4s ease-in-out infinite !important;
    will-change: transform, box-shadow, filter;
  }
  .ad-card-2 img { border-radius: 8px; }
  /* pause the pulse while interacting so hover/drag feel deliberate */
  /* Không pause hiệu ứng khi hover (để ad-design luôn chạy) */
  .ad-card-2.dragging { animation-play-state: paused !important; }


  /* Faster infinite pulse: expands/shrinks with a clearer glow */
  @keyframes ctaPulse {
    0% {
      transform: scale(1);
      box-shadow:
        0 0 0 0 rgba(63,140,243,0),
        0 0 0 0 rgba(63,140,243,0),
        0 4px 10px rgba(0,0,0,.12);
      filter: brightness(1);
    }
    50% {
      transform: scale(1.07);
      box-shadow:
        0 0 0 2px rgba(63,140,243,.25),
        0 0 28px 10px rgba(63,140,243,.45),
        0 10px 22px rgba(0,0,0,.24);
      filter: brightness(1.07);
    }
    100% {
      transform: scale(1);
      box-shadow:
        0 0 0 0 rgba(63,140,243,0),
        0 0 0 0 rgba(63,140,243,0),
        0 4px 10px rgba(0,0,0,.12);
      filter: brightness(1);
    }
  }
  /* Respect users who prefer reduced motion */
  @media (prefers-reduced-motion: reduce) {
    .ad-card-2 { animation: adPopIn .5s ease both; }
  }

  .ad-card-3 {
    top: 500px; left: calc(50% - 500px);
    width: px;
  }

  /* ===================== WINDOWS ===================== */
  .window {
    position: absolute; display: none; flex-direction: column;
    width: 480px; min-width: 260px; height: 360px; min-height: 160px;
    background: #ECE9D8; border: 1px solid #0831D9; border-radius: 8px 8px 3px 3px;
    box-shadow: 3px 4px 18px rgba(0,0,0,.45);
    overflow: hidden; z-index: 1000;
  }
  .window.open { display: flex; }
  .window.maximized { top: 0 !important; left: 0 !important; width: 100% !important; height: calc(100% - 34px) !important; border-radius: 0; }

  .titlebar {
    height: 28px; flex: 0 0 auto; cursor: move;
    background: linear-gradient(to bottom, #3F94FE 0%, #1958D0 8%, #1958D0 92%, #0F3F9E 100%);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 3px 0 6px;
  }
  .window.inactive .titlebar {
    background: linear-gradient(to bottom, #97AFDD 0%, #7C97D1 50%, #6884BE 100%);
  }
  .titlebar .t-title {
    color: #fff; font-weight: bold; font-size: 12px; display: flex; align-items: center; gap: 6px;
    text-shadow: 1px 1px 1px rgba(0,0,0,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .t-controls { display: flex; gap: 2px; flex: 0 0 auto; }
  .t-btn {
    width: 21px; height: 20px; border-radius: 3px; border: 1px solid rgba(255,255,255,.5);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold;
    color: #fff; cursor: pointer; background: linear-gradient(to bottom,#5C93E8,#1B5BC4);
    text-shadow: 1px 1px 1px rgba(0,0,0,.3);
  }
  .t-btn.close { background: linear-gradient(to bottom,#F5988C,#C42B1C); }
  .t-btn:hover { filter: brightness(1.15); }
  .t-btn:active { filter: brightness(.85); }

  .menubar {
    flex: 0 0 auto; height: 21px; background: #ECE9D8; border-bottom: 1px solid #ACA899;
    display: flex; align-items: center; gap: 16px; padding: 0 8px; font-size: 11px; color: #222;
  }
  .menubar span:hover { text-decoration: underline; cursor: default; }

  .win-body {
    flex: 1 1 auto; overflow: auto; background: #fff; margin: 3px;
    border: 1px solid #7F9DB9; padding: 12px; line-height: 1.55;
  }
  .statusbar {
    flex: 0 0 auto; height: 20px; background: #ECE9D8; border-top: 1px solid #fff;
    font-size: 11px; color: #444; display: flex; align-items: center; padding: 0 8px;
  }

  .win-body h2 { margin: 0 0 6px; font-size: 15px; color: #123F9E; }
  .win-body h3 { margin: 14px 0 4px; font-size: 12.5px; color: #123F9E; border-bottom: 1px solid #d6d2c2; padding-bottom: 2px; }
  .win-body p { margin: 0 0 8px; }
  .win-body ul { margin: 4px 0 10px 18px; padding: 0; }

  /* About window */
  .about-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
  .avatar-box {
    width: 64px; height: 64px; border-radius: 4px; border: 2px solid #7F9DB9;
    background: linear-gradient(135deg,#ffd58a,#ff8a65); display: flex; align-items: center; justify-content: center;
    font-size: 30px; flex: 0 0 auto; overflow: hidden;
  }
  .avatar-box img { width: 100%; height: 100%; object-fit: cover; }
  .tag { color: #555; font-style: italic; }
  .skill-bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
  .skill-name { width: 120px; flex: 0 0 auto; font-size: 11px; }
  .skill-track { flex: 1; height: 12px; background: #d8d5c5; border: 1px solid #999; border-radius: 2px; overflow: hidden; }
  .skill-fill { height: 100%; background: repeating-linear-gradient(90deg,#3F8CF3 0 8px,#1958D0 8px 16px); }

  /* Explorer / project grid */
  .explorer-toolbar {
    flex: 0 0 auto; background: #ECE9D8; border-bottom: 1px solid #ACA899;
    padding: 4px 8px; font-size: 11px; color: #333;
  }
  .file-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(96px,1fr)); gap: 6px; }
  .file-icon { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 3px; cursor: pointer; text-align: center; }
  .empty-state { padding: 20px; text-align: center; color: #666; border: 1px dashed #bbb; border-radius: 6px; background: #f7f7f7; }
  .file-icon:hover { background: #E3ECFC; outline: 1px dotted #3F8CF3; }
  .file-icon .thumb {
    width: 56px; height: 44px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff;
    box-shadow: 1px 2px 3px rgba(0,0,0,.3); overflow: hidden;
  }
  .file-icon .fname { font-size: 11px; color: #123F9E; }
  .file-icon .fcat { font-size: 10px; color: #666; }

  /* Notepad */
  .win-body.notepad { font-family: "Courier New", monospace; white-space: pre-wrap; }

  /* Contact */
  .field-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .field-row label { width: 80px; flex: 0 0 auto; font-size: 11px; }
  .xp-input { flex: 1; border: 1px solid #7F9DB9; padding: 3px 5px; font-family: inherit; font-size: 12px; }
  .xp-btn {
    background: linear-gradient(to bottom,#FDFDFD,#ECE9D8 45%,#D9D6C5 55%,#ECE9D8);
    border: 1px solid #8b8b7a; border-radius: 3px; padding: 5px 14px; font-size: 11px; cursor: pointer;
  }
  .xp-btn:hover { border-color: #3F8CF3; }
  .xp-btn:active { background: #D9D6C5; }

  /* Links / IE */
  .link-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid #eee; }
  .link-row .ic { font-size: 18px; }
  .link-row a { color: #0645AD; text-decoration: none; }
  .link-row a:hover { text-decoration: underline; }

  /* ===================== TASKBAR ===================== */
  #taskbar {
    display: none !important;
  }
  #start-btn {
    height: 27px; padding: 0 14px 0 8px; border: 1px solid #1C5B0E; border-radius: 4px 12px 12px 4px;
    background: linear-gradient(to bottom,#8FDD5E,#4C9A2A 45%,#3C8121 55%,#59A934);
    color: #fff; font-weight: bold; font-style: italic; font-size: 14px;
    display: flex; align-items: center; gap: 6px; cursor: pointer; text-shadow: 1px 1px 1px rgba(0,0,0,.4);
    flex: 0 0 auto;
  }
  #start-btn:hover { filter: brightness(1.08); }
  #start-btn.active, #start-btn:active { background: linear-gradient(to bottom,#3C8121,#59A934); box-shadow: inset 1px 1px 4px rgba(0,0,0,.4); }
  .tb-divider { width: 2px; height: 24px; background: rgba(255,255,255,.18); box-shadow: 1px 0 rgba(0,0,0,.25); flex: 0 0 auto; }

  #taskbar-windows { display: flex; gap: 4px; flex: 1 1 auto; overflow: hidden; height: 27px; align-items: center; }
  .tb-item {
    height: 25px; padding: 0 10px; background: linear-gradient(to bottom,#3E76D6,#2A5DBA);
    border: 1px solid #143A8C; border-radius: 3px; color: #fff; font-size: 11px; display: none;
    align-items: center; gap: 5px; cursor: pointer; max-width: 160px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); flex: 0 1 auto;
  }
  .tb-item.shown { display: flex; }
  .tb-item.active { background: linear-gradient(to bottom,#0C3D9E,#1449AC); box-shadow: inset 1px 1px 4px rgba(0,0,0,.5); }

  #systray {
    flex: 0 0 auto; height: 25px; background: linear-gradient(to bottom,#1657C8,#0C3D9E);
    border-left: 1px solid #0E3A9A; padding: 0 10px; display: flex; align-items: center; gap: 6px;
    color: #fff; font-size: 11px; border-radius: 4px 0 0 4px;
  }

  /* ===================== START MENU ===================== */
  #start-menu {
    position: fixed; bottom: 34px; left: 2px; width: 330px; z-index: 20001;
    background: #fff; border: 2px solid #0F3F9E; border-radius: 8px 8px 0 0;
    box-shadow: 3px 3px 14px rgba(0,0,0,.5); display: none; overflow: hidden;
  }
  #start-menu.open { display: block; }
  .sm-header {
    background: linear-gradient(to right,#1958D0,#3F8CF3); color: #fff; padding: 8px 10px;
    display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 15px;
  }
  .sm-avatar {
    width: 42px; height: 42px; border-radius: 5px; background: linear-gradient(135deg,#ffd58a,#ff8a65);
    border: 2px solid rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; font-size: 20px;
    overflow: hidden;
  }
  .sm-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .sm-body { display: flex; min-height: 260px; }
  .sm-left { flex: 1; background: #fff; padding: 6px 0; }
  .sm-right { width: 128px; background: linear-gradient(to bottom,#7EA9E8,#9CBEEF); padding: 6px 0; }
  .sm-item { display: flex; align-items: center; gap: 10px; padding: 7px 14px; font-size: 12px; cursor: pointer; }
  .sm-item .ic { font-size: 18px; width: 20px; text-align: center; }
  .sm-item:hover { background: linear-gradient(to right,#2A6DE0,#3F8CF3); color: #fff; }
  .sm-sep { height: 1px; background: #dcdcdc; margin: 4px 10px; }
  .sm-right .sm-item { color: #0A2E6E; font-size: 11px; padding: 5px 12px; }
  .sm-right .sm-item:hover { background: rgba(255,255,255,.45); color: #0A2E6E; }
  .sm-footer { background: linear-gradient(to bottom,#1958D0,#123F9E); padding: 6px 10px; display: flex; justify-content: flex-end; }
  .sm-off-btn {
    background: linear-gradient(to bottom,#F5988C,#C42B1C); color: #fff; border: 1px solid rgba(255,255,255,.4);
    border-radius: 4px; padding: 5px 10px; font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 5px;
  }

  /* Shutdown overlay */
  #shutdown-screen {
    position: fixed; inset: 0; background: #000; color: #fff; z-index: 99998; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 16px; text-align: center;
  }
  #shutdown-screen.show { display: flex; }
  #shutdown-screen .big { font-size: 20px; }
  #shutdown-screen .small { font-size: 12px; color: #ccc; max-width: 320px; }
  #shutdown-screen .xp-btn { color: #111; }

  ::-webkit-scrollbar { width: 17px; height: 17px; }
  ::-webkit-scrollbar-track { background: #ECE9D8; }
  ::-webkit-scrollbar-thumb { background: linear-gradient(#ECE9D8,#C2BEA8); border: 1px solid #999; }

  @media (max-width: 640px) {
    .window { width: 92vw !important; height: 78vh !important; left: 4vw !important; top: 6vh !important; }
    .desktop-icons { gap: 14px; }
    #start-menu { width: 92vw; }
  }
