:root{--yellow:#F0B90B;--stroke:#000;--win-bg:#C0C0C0;--blue:#000080}
*{box-sizing:border-box}
html,body{height:100%;margin:0;font-family:"MS Sans Serif",Tahoma,Verdana,sans-serif;background:linear-gradient(135deg,#9945ff 0%, #b57cff 55%, #ffffff 85%); background-attachment: fixed; color:#000; -webkit-user-select:none; user-select:none}
.desktop{position:relative;min-height:100%;overflow:hidden;outline:none}
.watermark{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none;opacity:.28}
.watermark img{
  max-width:min(70vmin,900px);
  height:auto;
  filter:drop-shadow(0 0 8px rgba(0,0,0,.08));
  transform-origin:center;
  will-change:transform;
  animation:watermark-sway 6s ease-in-out infinite;
}

@keyframes watermark-sway{
  0%{transform:rotate(-1.2deg) translateY(0)}
  50%{transform:rotate(1.2deg) translateY(-1.5px)}
  100%{transform:rotate(-1.2deg) translateY(0)}
}

@media (prefers-reduced-motion: reduce){
  .watermark img{animation:none}
}
.icons{position:absolute;inset:0;display:flex;flex-flow:column wrap;align-content:flex-start;gap:14px;height:calc(100vh - 60px);padding:22px}
.icon{width:100px;padding:6px;text-align:center;color:#fff;cursor:default;user-select:none;border-radius:4px;background:transparent;border:none}
.icon:focus-visible{outline:2px dotted #fff;outline-offset:4px}
.icon .box{width:48px;height:48px;margin:0 auto 6px;background:var(--win-bg);border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;display:grid;place-items:center;border-radius:4px;image-rendering:pixelated}
.icon img{width:16px;height:16px;image-rendering:pixelated}
.label{font-size:12px;line-height:1.1;color:#fff;text-shadow:1px 1px 0 #000}

/* Game window: custom cursor overlay (fallback for browsers without image cursor) */
#win-game, #win-game canvas{ cursor: none }
#win-game .content{ position:relative }
#win-game .game-cursor{
  position:absolute; top:0; left:0; z-index:10; width:18px; height:18px;
  background:url('./assets/img/stick-16.svg') no-repeat center/contain;
  pointer-events:none; opacity:.95;
  filter:drop-shadow(0 0 3px rgba(0,0,0,.25));
  transform:translate(-200px,-200px);
  transition:opacity .12s ease;
}
#win-game:hover .game-cursor{ opacity:1 }

/* Game d-pad layout */
.game-pad{ display:inline-grid; grid-template-columns:24px 24px 24px; grid-template-rows:24px 24px 24px; gap:4px; margin-left:8px; align-items:center }
.game-pad .kbd{ width:24px; height:24px; padding:0; font-size:12px; line-height:24px; text-align:center; }
.game-pad .kbd:focus-visible{ outline:2px dotted #000 }

.win{position:absolute;top:14%;left:22%;width:min(860px,92vw);min-width:300px;background:var(--win-bg);border-top:2px solid #FFFFFF;border-left:2px solid #FFFFFF;border-right:2px solid #000;border-bottom:2px solid #000;display:none;max-height:80vh;overflow:auto}
.win.active{display:block}
.titlebar{display:flex;align-items:center;justify-content:space-between;padding:6px 8px;background:var(--blue);color:#fff;user-select:none;cursor:move}
.title{font-weight:700}
.controls{display:flex;gap:6px}
.btn{width:16px;height:16px;background:var(--win-bg);border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;display:grid;place-items:center;cursor:default}
.btn.min::after{content:"_";font-weight:700;line-height:1;transform:translateY(-2px)}
.btn.max::after{content:"\25A1";font-size:12px;line-height:1}
.btn.close::after{content:"X";font-weight:700}
.content{padding:12px 12px 16px;color:#000}
.content h2{margin:4px 0 10px;font-size:18px}
.content a{color:var(--blue);text-decoration:underline;word-break:break-word}

.taskbar{position:absolute;left:0;right:0;bottom:0;height:44px;background:var(--win-bg);border-top:2px solid #FFFFFF;box-shadow:inset 0 2px 0 #808080;display:flex;align-items:center;gap:8px;padding:4px 6px}
.start{display:flex;align-items:center;gap:8px;padding:6px 12px;background:var(--blue);color:#fff;border:1px solid #000;box-shadow:inset -1px -1px 0 #00004d, inset 1px 1px 0 #b3c7ff;cursor:default}
.apps{display:flex;gap:6px;align-items:center;flex:1;overflow:auto}
.taskbtn{padding:4px 10px;background:var(--win-bg);border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;cursor:default;white-space:nowrap;border-radius:2px}
.taskbtn.active{background:#9e9e9e}
.tray{display:flex;gap:10px;align-items:center;margin-left:auto}
.date,.clock{color:#000;font-weight:700}

#startMenu{position:absolute;left:6px;bottom:48px;width:300px;background:var(--win-bg);border-top:2px solid #FFFFFF;border-left:2px solid #FFFFFF;border-right:2px solid #000;border-bottom:2px solid #000;display:none;z-index:9999}
#startMenu[aria-hidden="false"]{display:block}
#startMenu header{background:var(--blue);color:#fff;padding:4px 6px;font-weight:700;display:flex;align-items:center;justify-content:space-between;gap:5px}
#startMenu header .user{display:flex;align-items:center;gap:4px}
#startMenu header .avatar{width:18px;height:18px;border:1px solid #000;border-radius:4px;background:#fff;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;padding:2px}
#startMenu header .meta .name{font-weight:700;line-height:1}
#startMenu header .meta .tagline{font-size:10px;opacity:.9}
#startMenu header .search input{width:110px;max-width:38%;padding:2px 3px;border:1px solid #000;background:#FFF;color:#000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF}
#startMenu .menu{padding:4px}
#startMenu .start-layout{display:grid;grid-template-columns:1.05fr 0.65fr;gap:3px;padding:4px}
#startMenu .pane{min-width:0}
.menu .item{position:relative}
.menu .section{margin:0;padding:0}
.menu button{width:100%;text-align:left;padding:1px 3px;background:var(--win-bg);border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;cursor:default;margin-top:2px;display:flex;align-items:center;gap:3px;font-size:10px;line-height:1.1;min-height:22px}
#startMenu .menu img{width:12px !important;height:12px !important;image-rendering:pixelated;flex-shrink:0}
#startMenu .menu button{padding:0 3px;font-size:9px;line-height:1.05;min-height:18px;gap:3px}
#startMenu .menu button span{font-size:9px}
#startMenu .submenu{width:130px;padding:2px}
.menu button span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.menu button .right{margin-left:auto}
.menu button:focus-visible{outline:2px dotted #000}
.submenu{position:absolute;left:100%;top:0;width:140px;background:var(--win-bg);border-top:2px solid #FFFFFF;border-left:2px solid #FFFFFF;border-right:2px solid #000;border-bottom:2px solid #000;display:none;padding:3px}
.item:focus-within > .submenu, .item:hover > .submenu{display:block}

#viz{width:100%;height:140px;background:#9e9e9e;border:1px solid #000;border-radius:2px}
input#mediaUrl{width:100%;padding:6px 8px;border:1px solid #000;background:#FFF;color:#000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF}
textarea.notepad{width:100%;min-height:220px;border:1px solid #000;background:#fff;color:#000;padding:6px;resize:vertical;font-family:Consolas,'Courier New',monospace}

#startMenu .pane .section{display:grid;gap:2px}
#startMenu .pane button{width:100%;text-align:left;padding:0 3px;background:var(--win-bg);border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;cursor:default;display:flex;align-items:center;gap:3px;font-size:9px;line-height:1.05;min-height:18px}
#startMenu .pane button img{width:12px;height:12px;image-rendering:pixelated;flex-shrink:0}
#startMenu .pane button span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:9px}
#startMenu .pane .submenu{width:130px;padding:2px}
.menu button span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.menu button .right{margin-left:auto}
.menu button:focus-visible{outline:2px dotted #000}
.submenu{position:absolute;left:100%;top:0;width:140px;background:var(--win-bg);border-top:2px solid #FFFFFF;border-left:2px solid #FFFFFF;border-right:2px solid #000;border-bottom:2px solid #000;display:none;padding:3px}
.item:focus-within > .submenu, .item:hover > .submenu{display:block}

#viz{width:100%;height:140px;background:#9e9e9e;border:1px solid #000;border-radius:2px}
input#mediaUrl{width:100%;padding:6px 8px;border:1px solid #000;background:#FFF;color:#000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF}
textarea.notepad{width:100%;min-height:220px;border:1px solid #000;background:#fff;color:#000;padding:6px;resize:vertical;font-family:Consolas,'Courier New',monospace}

@media (max-width:700px){
  .icons{padding:12px;gap:10px}
  .icon{width:86px}
  .win{left:4%;width:92vw}
}
.notepad, .kbd, .mono { -webkit-user-select:text; user-select:text }
input, textarea { -webkit-user-select:text; user-select:text }

/* Tablet layout: 481px–1024px */
@media (min-width:481px) and (max-width:1024px){
  .icons{padding:16px;gap:12px;height:calc(100vh - 50px)}
  .icon{width:92px}
  .icon .box{width:48px;height:48px}
  .label{font-size:12px}

  .win{left:6%;top:10%;width:min(780px,88vw);max-height:75vh}
  .titlebar{padding:8px 10px}
  .controls{gap:8px}
  .btn{width:18px;height:18px}
  .btn.max::after{font-size:13px}
  .btn.min::after{transform:translateY(-3px)}

  .content{padding:12px 12px 16px}
  .content h2{font-size:17px}

  .taskbar{height:50px;padding:6px 8px}
  .start{padding:7px 12px;gap:8px}
  .taskbtn{min-height:24px;font-size:11px}
  .tray{gap:12px}

  #startMenu{width:min(420px,64vw);bottom:52px}
  #startMenu header{padding:6px 8px}
  #startMenu header .search input{width:50vw;max-width:62%}
  #startMenu .start-layout{grid-template-columns:1fr 1fr}
  #startMenu .menu img{width:14px !important;height:14px !important}
  #startMenu .menu button{min-height:22px;font-size:10px}
  #startMenu .menu button span{font-size:10px}
  #startMenu .submenu{width:160px}
}

/* Mobile layout: <=480px */
@media (max-width:480px){
  html, body{ -webkit-tap-highlight-color: transparent }
  .icons{padding:10px;gap:10px;height:calc(100vh - 60px)}
  .icon{width:86px;padding:6px}
  .icon .box{width:44px;height:44px;margin-bottom:6px}
  .label{font-size:12px;line-height:1.2}

  .win{left:2%;top:8%;width:96vw;max-height:70vh}
  .titlebar{padding:8px 10px}
  .controls{gap:10px}
  .btn{width:20px;height:20px}
  .btn.max::after{font-size:14px}
  .btn.min::after{transform:translateY(-3px)}
  .content{padding:10px 10px 14px}
  .content h2{font-size:16px}

  .taskbar{height:56px;padding:8px 10px;padding-bottom:calc(8px + env(safe-area-inset-bottom, 0px))}
  .start{padding:8px 12px;gap:10px}
  .taskbtn{min-height:28px;font-size:11px}
  .tray{gap:12px}

  #startMenu{width:92vw;left:4vw;bottom:62px;max-height:70vh;overflow:auto}
  #startMenu header{padding:8px 10px}
  #startMenu header .search input{width:60vw;max-width:70%}
  #startMenu .start-layout{grid-template-columns:1fr;gap:6px}
  #startMenu .menu img{width:14px !important;height:14px !important}
  #startMenu .menu button{min-height:26px;font-size:11px;gap:6px}
  #startMenu .menu button span{font-size:11px}

  /* Responsive polish: Game canvas and touch optimizations */
  #win-game canvas{width:100%;height:auto;max-width:100%}
  .icon, .btn, .start, .taskbtn{touch-action:manipulation}
  
  @media (max-width:480px){
    .icons{overflow:auto}
    #startMenu .pane.right{display:none}
    #ytContainer{max-height:220px}
  }
  @media (min-width:481px) and (max-width:1024px){
    #win-game canvas{max-height:54vh}
    #ytContainer{max-height:280px}
  }
  /* Submenu as inline stack on mobile for better tap UX */
  .submenu{position:static;left:auto;top:auto;width:auto;padding:4px;margin-left:0}
  .item:hover > .submenu{display:none}
  .item:focus-within > .submenu{display:block}
}

/* Smooth scrolling for windows content on touch */
.win{ -webkit-overflow-scrolling: touch }

/* Respect safe-area on devices with notch */
@supports(padding:max(0px)){
  .taskbar{padding-bottom:calc(6px + env(safe-area-inset-bottom, 0px))}
}
input#mediaUrl{width:100%;padding:6px 8px;border:1px solid #000;background:#FFF;color:#000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF}
textarea.notepad{width:100%;min-height:220px;border:1px solid #000;background:#fff;color:#000;padding:6px;resize:vertical;font-family:Consolas,'Courier New',monospace}
.tray{display:flex;align-items:center;gap:10px}
.tray .net{display:flex;align-items:center}
.tray .net img{display:block;filter:none}
input#mediaUrl{width:100%;padding:6px 8px;border:1px solid #000;background:#FFF;color:#000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF}
textarea.notepad{width:100%;min-height:220px;border:1px solid #000;background:#fff;color:#000;padding:6px;resize:vertical;font-family:Consolas,'Courier New',monospace}

/* Preloader (Windows classic) */
#preloader{position:fixed;inset:0;background:rgba(0,0,0,0.08);display:flex;align-items:center;justify-content:center;z-index:10000;transition:opacity .2s ease}
#preloader.hidden{opacity:0;pointer-events:none}
#preloader .pre-panel{width:min(360px,92vw);background:var(--win-bg);border-top:2px solid #FFFFFF;border-left:2px solid #FFFFFF;border-right:2px solid #000;border-bottom:2px solid #000}
#preloader .titlebar{cursor:default}
#preloader .pre-content{padding:12px}
#preloader .pre-progress{height:18px;border:1px solid #000;box-shadow:inset -1px -1px 0 #808080, inset 1px 1px 0 #FFF;background:#9e9e9e;border-radius:2px}
#preloader .pre-bar{height:100%;background:var(--blue);box-shadow:inset 0 0 0 1px #000;transition:width .12s linear}
#preloader .pre-percent{margin-top:6px;font-weight:700;color:#000;text-align:right}
