* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    font-family: 'Geneva', 'Chicago', 'Charcoal', 'Lucida Grande', Helvetica, sans-serif;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

/* ── Desktop background: muted purple/lavender ── */
.desktop {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: #9999bb;
    background-image:
        linear-gradient(45deg, #8888aa 25%, transparent 25%, transparent 75%, #8888aa 75%),
        linear-gradient(45deg, #8888aa 25%, transparent 25%, transparent 75%, #8888aa 75%);
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
}

/* ── Menu bar ── */
.menubar {
    position: relative;
    width: 100%;
    height: 26px;
    background: #eee;
    border-bottom: 1px solid #000;
    display: flex;
    align-items: center;
    padding: 0 8px;
    z-index: 100;
    flex-shrink: 0;
}
.menubar .apple-logo {
    width: 14px;
    height: 16px;
    margin-right: 8px;
    margin-top: -2px;
    margin-left: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.menubar .apple-logo svg {
    width: 14px;
    height: 16px;
    display: block;
}
.menubar .menu-items {
    display: flex;
    align-items: center;
    flex: 1;
    height: 100%;
}
.menubar .menu-items span {
    padding: 0 8px;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0;
    cursor: default;
    height: 100%;
    display: flex;
    align-items: center;
    color: #000;
}
.menubar .menu-items span.disabled {
    color: #888;
}
.menubar .menu-items span.active {
    background: #000;
    color: #fff;
}
.menubar .menu-right {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 8px;
}
.menubar .clock {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0;
    white-space: nowrap;
    color: #000;
}
.menu-trigger { position: relative; }

/* ── Dropdown menu ── */
.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #000;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    min-width: 140px;
    padding: 2px 0;
    font-family: 'Geneva', 'Chicago', Helvetica, sans-serif;
}
.menu-dropdown.visible {
    display: block;
}
.menu-dropdown .menu-item {
    padding: 2px 12px;
    font-size: 13px;
    font-weight: normal;
    cursor: default;
    white-space: nowrap;
    color: #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}
.menu-dropdown .menu-item:hover {
    background: #000;
    color: #fff;
}
.menu-dropdown .menu-item.disabled {
    color: #888;
}
.menu-dropdown .menu-item.disabled:hover {
    background: transparent;
    color: #888;
}
.menu-dropdown .menu-separator {
    height: 1px;
    background: #888;
    margin: 3px 8px;
}
.menu-dropdown .menu-item .shortcut {
    color: inherit;
    font-size: 13px;
}

/* ── Resize handle ── */
.window-grow-bar {
    height: 16px;
    background: #ccc;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.resize-handle {
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 5;
    background: #ccc;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}
.resize-handle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background:
        repeating-linear-gradient(
            -45deg,
            transparent 0px,
            transparent 1px,
            #fff 1px,
            #fff 2px,
            #888 2px,
            #888 3px,
            transparent 3px,
            transparent 6px
        );
}

/* ── Mac OS 7.5 Alert Dialog ── */
.mac-alert-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9998;
    background: transparent;
}
.mac-alert-overlay.visible { display: block; }
.mac-alert {
    position: fixed;
    z-index: 9999;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Geneva', 'Chicago', Helvetica, sans-serif;
    font-size: 12px;
    min-width: 260px;
}
.mac-alert-outer {
    border: 2px solid #000;
    background: #000;
    padding: 3px;
}
.mac-alert-inner {
    background: #ddd;
    padding: 16px 20px 12px;
}
.mac-alert-inner::before {
    content: '';
    display: block;
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    border-bottom: 1px solid #888;
    border-right: 1px solid #888;
    pointer-events: none;
}
.mac-alert-icon {
    float: left;
    width: 32px;
    height: 32px;
    margin-right: 12px;
    font-size: 28px;
    line-height: 32px;
    text-align: center;
}
.mac-alert-text {
    margin-bottom: 16px;
    font-size: 12px;
    line-height: 1.4;
    color: #000;
}
.mac-alert-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.mac-alert-btn {
    font-family: 'Geneva', 'Chicago', Helvetica, sans-serif;
    font-size: 12px;
    padding: 4px 16px;
    cursor: default;
    border: none;
    background: #ddd;
    color: #000;
    position: relative;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    border-bottom: 1px solid #666;
    border-right: 1px solid #666;
}
.mac-alert-btn:active {
    border-top: 1px solid #666;
    border-left: 1px solid #666;
    border-bottom: 1px solid #fff;
    border-right: 1px solid #fff;
}
.mac-alert-btn.default {
    outline: 3px solid #000;
    outline-offset: 0px;
    font-weight: bold;
}

/* ── Window ── */
.window {
    position: absolute;
    background: #ccc;
    display: flex;
    flex-direction: column;
    max-width: 95vw;
    max-height: calc(100vh - 30px);
    z-index: 10;
    border: 1px solid #000;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #555,
        inset 2px 2px 0 #ddd,
        inset -2px -2px 0 #888,
        1px 1px 0 #000;
    padding: 3px;
    padding-top: 0;
}

/* ── Title bar ── */
.titlebar {
    height: 20px;
    background: #ddd;
    border-bottom: 1px solid #000;
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
    cursor: grab;
    padding: 0 2px;
    overflow: hidden;
}
.titlebar:active { cursor: grabbing; }

/* Horizontal stripes behind title */
.titlebar-lines-left,
.titlebar-lines-right {
    position: absolute;
    top: 3px;
    bottom: 3px;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        #fff 0px, #fff 1px,
        #aaa 1px, #aaa 2px
    );
}
.titlebar-lines-left {
    left: 24px;
    right: calc(50% + 38px);
}
.titlebar-lines-right {
    left: calc(50% + 38px);
    right: 4px;
}
.titlebar:has(.titlebar-right-boxes[style*="flex"]) .titlebar-lines-right {
    right: 24px;
}

.titlebar-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    background: #ddd;
    padding: 0 8px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0;
    white-space: nowrap;
    line-height: 20px;
}

/* Close box — left side */
.close-box {
    position: relative;
    z-index: 2;
    width: 12px;
    height: 12px;
    min-width: 12px;
    border: 1px solid #666;
    background: #d0d0d0;
    margin: 0 4px 0 3px;
    cursor: default;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #999;
}

/* Zoom/collapse boxes — right side */
.titlebar-right-boxes {
    display: none;
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
}
.collapse-box {
    position: relative;
    width: 12px;
    height: 12px;
    min-width: 12px;
    border: 1px solid #666;
    background: #d0d0d0;
    margin: 0 3px 0 4px;
    cursor: default;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #999;
}
.collapse-box::before,
.collapse-box::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: #888;
}
.collapse-box::before {
    top: 4px;
}
.collapse-box::after {
    top: 7px;
}

/* ── Inactive window ── */
.window.inactive .titlebar-lines-left,
.window.inactive .titlebar-lines-right {
    background: none;
}
.window.inactive .close-box {
    visibility: hidden;
}
.window.inactive .titlebar-right-boxes {
    visibility: hidden;
}
.window.inactive {
    box-shadow:
        inset 1px 1px 0 #ddd,
        inset -1px -1px 0 #999,
        1px 1px 0 #000;
}

/* ── Window content ── */
.window-content {
    background: #000;
    position: relative;
    line-height: 0;
    overflow: hidden;
}

canvas { display: block; }

/* ── Help Guide (SimpleText style) ── */
.help-guide-content {
    background: #fff;
    padding: 12px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    flex: 1;
    min-height: 0;
    font-family: Geneva, Chicago, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #000;
    cursor: text;
}
.help-guide-content h1 {
    font-family: Chicago, Geneva, monospace;
    font-size: 14px;
    font-weight: bold;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.help-guide-content h2 {
    font-family: Chicago, Geneva, monospace;
    font-size: 12px;
    font-weight: bold;
    margin: 12px 0 4px 0;
    text-transform: uppercase;
}
.help-guide-content p {
    margin: 2px 0 6px 0;
}
.help-guide-content hr {
    border: none;
    border-top: 1px solid #000;
    margin: 8px 0;
}
.help-guide-content b {
    font-weight: bold;
}
.help-guide-content::-webkit-scrollbar {
    width: 16px;
}
.help-guide-content::-webkit-scrollbar-track {
    background:
        repeating-linear-gradient(
            90deg,
            #fff 0px, #fff 1px,
            #bbb 1px, #bbb 2px
        );
    border-left: 1px solid #000;
}
.help-guide-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border: 1px solid #000;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #888;
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent 0px,
            transparent 2px,
            #fff 2px,
            #fff 3px,
            #999 3px,
            #999 4px,
            transparent 4px,
            transparent 5px
        );
    background-size: calc(100% - 4px) calc(100% - 4px);
    background-position: center;
    background-repeat: no-repeat;
}
.help-guide-content::-webkit-scrollbar-button:single-button {
    background: #ccc;
    border: 1px solid #000;
    height: 16px;
    display: block;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #888;
}
.help-guide-content::-webkit-scrollbar-button:single-button:vertical:decrement {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpolygon points='5,0 10,6 0,6' fill='%23000'/%3E%3C/svg%3E");
    background-size: 8px 5px;
    background-repeat: no-repeat;
    background-position: center;
}
.help-guide-content::-webkit-scrollbar-button:single-button:vertical:increment {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpolygon points='0,0 10,0 5,6' fill='%23000'/%3E%3C/svg%3E");
    background-size: 8px 5px;
    background-repeat: no-repeat;
    background-position: center;
}

/* ── Desktop icon ── */
.icon-grid {
    position: absolute;
    top: 36px;
    right: 10px;
    bottom: 10px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap-reverse;
    align-content: flex-start;
    gap: 20px;
    z-index: 5;
    padding: 4px;
}

.desktop-icon {
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 0;
}
.desktop-icon .icon-img {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    margin-bottom: 4px;
}
.desktop-icon.selected .icon-img {
    filter: brightness(0.4) saturate(0.5);
}
.desktop-icon .icon-label {
    font-family: 'Geneva', 'Lucida Grande', Helvetica, sans-serif;
    font-size: 11px;
    font-weight: normal;
    text-align: center;
    color: #000;
    line-height: 1.2;
    white-space: nowrap;
    padding: 1px 3px;
    background: #fff;
}
.desktop-icon.selected .icon-label {
    background: #000;
    color: #fff;
}

/* ── Window hidden by default ── */
.window.hidden { display: none; }

/* ── Touch controls (mobile only) ── */
.window.inactive .tc-action-bar,
.window.inactive .tc-jet-btn,
.window.inactive .tc-jet-label { display: none !important; }

.tc-action-bar {
    display: none !important;
    position: fixed;
    top: 38px;
    right: 8px;
    z-index: 300;
    gap: 8px;
    align-items: center;
    background: rgba(0,0,0,0.5);
    border-radius: 16px;
    padding: 4px 6px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.tc-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    font-size: 13px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
}
.tc-action-btn:active {
    background: rgba(255,255,255,0.25);
    color: #fff;
}
.tc-action-btn.tc-pause { font-size: 16px; letter-spacing: -2px; }
.tc-action-btn.tc-quit { font-size: 11px; font-weight: bold; }
.tc-action-btn.tc-skull { color: rgba(255,120,120,0.7); }
.tc-action-btn.tc-skull:active { color: #f88; }
.tc-jet-btn {
    display: none;
    position: fixed;
    right: 0;
    top: 40px;
    bottom: 0;
    width: 30%;
    z-index: 250;
    -webkit-tap-highlight-color: transparent;
    background: transparent;
    border: none;
}
.tc-jet-label {
    position: fixed;
    display: none;
    bottom: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 251;
    pointer-events: none;
    font-size: 9px;
    font-weight: bold;
    color: rgba(255,180,80,0.7);
    letter-spacing: 1px;
    align-items: center;
    justify-content: center;
}

#winHelpGuide { width: 440px; height: 400px; }

@media (hover: none) and (pointer: coarse) {
    .tc-action-bar { display: none; }
    .tc-jet-btn { display: block; }
    .tc-jet-label { display: flex; }
    .icon-grid { top: 48px; right: 6px; gap: 20px; bottom: 200px; }
    .menubar { height: 38px; }
    .menubar .menu-items span { font-size: 16px; padding: 0 9px; }
    .menubar .clock { font-size: 16px; }
    .menubar .apple-logo { width: 18px; height: 20px; margin-right: 10px; }
    .menubar .apple-logo svg { width: 18px; height: 20px; }
    .menu-dropdown { min-width: 160px; padding: 3px 0; }
    .menu-dropdown .menu-item { font-size: 14px; padding: 5px 12px; gap: 24px; }
    .menu-dropdown .menu-item .shortcut { font-size: 14px; }
    .menu-dropdown .menu-separator { margin: 4px 10px; }
    .close-box {
        width: 14px;
        height: 14px;
        min-width: 14px;
        border: 1px solid #000;
        background: #ddd;
        box-shadow:
            inset -1px -1px 0 #fff,
            inset 1px 1px 0 #999;
    }
}
/* Small screens (browser resize fallback) */
@media (max-width: 600px) {
    .icon-grid { top: 48px; right: 6px; gap: 20px; bottom: 200px; }
}

/* Large screens (desktop + tablet) — bigger UI chrome */
@media (min-width: 768px) {
    .icon-grid { top: 44px; right: 20px; gap: 32px; padding: 8px; }
    .desktop-icon .icon-img { width: 64px; height: 64px; }
    .desktop-icon .icon-label { font-size: 14px; }
    .menubar { height: 36px; padding: 0 12px; }
    .menubar .menu-items span { font-size: 16px; padding: 0 10px; }
    .menubar .clock { font-size: 16px; }
    .menubar .apple-logo { width: 18px; height: 20px; margin-right: 10px; }
    .menubar .apple-logo svg { width: 18px; height: 20px; }
    .menu-dropdown { min-width: 180px; padding: 4px 0; }
    .menu-dropdown .menu-item { font-size: 16px; padding: 4px 16px; gap: 32px; }
    .menu-dropdown .menu-item .shortcut { font-size: 16px; }
    .menu-dropdown .menu-separator { margin: 4px 10px; }
    .titlebar { height: 28px; padding: 0 4px; }
    .titlebar-text { font-size: 15px; line-height: 28px; padding: 0 10px; }
    .titlebar-lines-left { left: 32px; right: calc(50% + 50px); top: 5px; bottom: 5px; }
    .titlebar-lines-right { left: calc(50% + 50px); right: 6px; top: 5px; bottom: 5px; }
    .titlebar:has(.titlebar-right-boxes[style*="flex"]) .titlebar-lines-right { right: 32px; }
    .close-box { width: 16px; height: 16px; min-width: 16px; margin: 0 6px 0 4px; }
    .titlebar-right-boxes { right: 4px; }
    .collapse-box { width: 16px; height: 16px; min-width: 16px; margin: 0 4px 0 6px; }
    .collapse-box::before { top: 5px; }
    .collapse-box::after { top: 9px; }
}

/* Tablet-sized touch devices — lock windows, drop drag cursor */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) {
    .window {
        position: fixed !important;
        border: 1px solid #000;
        box-shadow:
            inset 1px 1px 0 #fff,
            inset -1px -1px 0 #555,
            inset 2px 2px 0 #ddd,
            inset -2px -2px 0 #888,
            1px 1px 0 #000;
        max-width: none;
        max-height: none;
    }
    .titlebar {
        cursor: default;
    }
}
/* ── Update banner ── */
.update-banner {
    display: none;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: #333;
    color: #fff;
    font-family: 'Geneva', Helvetica, sans-serif;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    -webkit-tap-highlight-color: transparent;
}
.update-banner.visible { display: block; }
