* {
  box-sizing: border-box;
}

:root {
  /* XP Base Colors (Day) */
  --xp-blue-dark: #0A246A;
  --xp-blue-med: #A6CAF0;
  --xp-green: #378B1D;
  --xp-silver: #D4D0C8;
  --xp-blue-select: #316AC5;
  --xp-bg: #ECE9D8;
  --xp-window-bg: #FFFFFF;
  --xp-text-color: #000000;
  
  /* Taskbar */
  --taskbar-start: #245EDC;
  --taskbar-end: #3E80ED;
  --taskbar-border: #5794F7;

  /* Adventure Time Overlay */
  --at-pink: #FFC0CB;
  --at-green: #7EC850;
  --at-sky: #87CEEB;
  --at-bubblegum: #FF69B4;
  --at-ice: #ADD8E6;
  --at-teal: #00CED1;
  --at-candy-gradient: linear-gradient(180deg, #FF9EBB 0%, #FF69B4 50%, #FF1493 100%);
  
  /* Body Background */
  --body-bg-gradient: linear-gradient(180deg, #87CEEB 0%, #b8e2f2 60%, #98D8AA 60%, #7EC850 100%);
  --body-bg-color: #87CEEB;

  /* Friendly Shapes */
  --radius-window: 12px;
  --radius-btn: 12px;
  --radius-input: 8px;
  --radius-panel: 10px;
  
  /* Fonts */
  --font-system: "Trebuchet MS", "Comic Sans MS", "Chalkboard SE", sans-serif;
  --font-header: "Trebuchet MS", "Comic Sans MS", sans-serif;
}

/* Night Mode Overrides */
body.night-mode {
  /* Darker XP / Cyberpunk / Night Theme */
  --xp-blue-dark: #051235;
  --xp-blue-med: #2c3e50;
  --xp-green: #1e4d2b;
  --xp-silver: #4a5568;
  --xp-blue-select: #54a0ff;
  --xp-bg: #2f3640;
  --xp-window-bg: #1e272e;
  --xp-text-color: #dcdde1;
  
  --taskbar-start: #0f0f23;
  --taskbar-end: #1a1a3e;
  --taskbar-border: #2f3640;

  --body-bg-gradient: linear-gradient(180deg, #0f0f23 0%, #1a1a3e 60%, #0d1f3c 100%);
  --body-bg-color: #0f0f23;
}

body.night-mode .xp-window {
    border-color: #4a5568;
    background: var(--xp-window-bg);
    color: var(--xp-text-color);
}

body.night-mode .xp-window-title {
    background: linear-gradient(180deg, #192a56 0%, #273c75 100%);
}

body.night-mode .xp-window-content {
    background: #2f3640;
    color: #f5f6fa;
}

body.night-mode .editor-sidebar {
    background: #2f3640;
    border-color: #576574;
}

body.night-mode .editor-section-header {
    background: linear-gradient(180deg, #353b48 0%, #2f3640 100%);
    color: #dcdde1;
    border-bottom: 1px solid #576574;
}

body.night-mode .editor-section {
    border-color: #576574;
    background: #353b48;
}

body.night-mode .asset-item {
    background: #353b48;
    border-color: transparent;
}

body.night-mode .asset-item:hover {
    background: #576574;
    border-color: #54a0ff;
}

body.night-mode .asset-name {
    color: #dcdde1;
}

body.night-mode .xp-input, 
body.night-mode select, 
body.night-mode .browser-toolbar,
body.night-mode .address-bar,
body.night-mode .bookmarks-bar {
    background: #353b48;
    color: white;
    border-color: #576574;
}

body.night-mode .editor-header {
    background: #2f3640;
    border-color: #576574;
}

body.night-mode .editor-header span {
    color: #dcdde1 !important;
}

body {
  font-family: var(--font-system);
  background-color: var(--body-bg-color);
  background: var(--body-bg-gradient);
  color: var(--xp-text-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: background 0.5s ease;
  position: relative; /* For sun/stars positioning */
}

/* Sun & Stars Animation */
.site-sun {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #FFD700 0%, #FFA500 100%);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    z-index: -1; /* Behind all page content */
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1;
    transform: translateY(0);
}

.site-stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #ddd, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #ddd, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

body.night-mode .site-sun {
    opacity: 0;
    transform: translateY(50px);
}

body.night-mode .site-stars {
    opacity: 0.8;
}

/* === SPECIFIC PAGE OVERRIDES === */

/* Homepage: Introduction Window */
body.night-mode #intro-window .xp-window-content h1,
body.night-mode #intro-window .xp-window-content h2,
body.night-mode #intro-window .xp-window-content p {
    color: #FFFFFF !important;
}

/* Homepage: Population Counter */
body.night-mode #counter-window #user-count {
    color: #FFFFFF !important;
}

body.night-mode #counter-window div[style*="color: #595959"] {
    color: #aaa !important;
}

/* Homepage: Updates/News Window */
body.night-mode #news-window .xp-window-content {
    color: #FFFFFF !important;
}

body.night-mode #news-window .xp-window-content div {
    color: #e0e0e0 !important;
}

body.night-mode #news-window .xp-window-content b {
    color: #89CFF0 !important;
}

body.night-mode #news-window .xp-window-content a {
    color: #89CFF0 !important;
}

/* Keep promo banner title red for emphasis */
body.night-mode #news-window .xp-window-content div[style*="color: #c0392b"] {
    color: #ff6b6b !important;
}

/* Promo banner dark mode background */
body.night-mode #news-window .xp-window-content div[style*="background: linear-gradient"] {
    background: linear-gradient(135deg, #3d2024, #4a2030) !important;
    border-color: #6b3040 !important;
}

/* Account Page: Headers */
body.night-mode .account-window h4 {
    color: #FFFFFF !important;
}

/* Account Page: Labels */
body.night-mode .xp-label {
    color: #dcdde1;
}

/* Account Page: Subscription Box */
body.night-mode #tab-subscription > div[style*="background: #f5f5f5"] {
    background: #2f3640 !important;
    border: 1px solid #576574;
    color: #FFFFFF;
}

body.night-mode #sub-plan,
body.night-mode #sub-since,
body.night-mode #sub-next {
    color: #FFFFFF;
}

/* Make sure text in the sub box labels is also visible */
body.night-mode #tab-subscription > div span {
    color: #dcdde1;
}

/* === ACCOUNT: Referrals Tab Night Mode === */
body.night-mode #tab-referrals div[style*="background: #f5f5f5"] {
    background: #353b48 !important;
}
body.night-mode #tab-referrals div[style*="color: #595959"],
body.night-mode #tab-referrals span[style*="color: #595959"] {
    color: #aaa !important;
}
body.night-mode #tab-referrals div[style*="color: #767676"] {
    color: #888 !important;
}
body.night-mode #tab-referrals label[style*="color: #595959"] {
    color: #aaa !important;
}
body.night-mode #tab-referrals div[style*="background: #E3F2FD"] {
    background: #1a3a5c !important;
    border-color: #2a5a8c !important;
}
body.night-mode #tab-referrals div[style*="color: #1565C0"] {
    color: #54a0ff !important;
}
body.night-mode #tab-referrals ul[style*="color: #555"] {
    color: #bbb !important;
}
body.night-mode #tab-referrals div[style*="background: #e0e0e0"] {
    background: #576574 !important;
}
body.night-mode #tab-referrals h4[style*="color: #0A246A"],
body.night-mode #tab-referrals h5[style*="color: #0A246A"] {
    color: #7eb8ff !important;
}
body.night-mode #tab-referrals div[style*="color: #0A246A"] {
    color: #7eb8ff !important;
}
body.night-mode #recent-referrals {
    background: #353b48 !important;
}

/* === VISITOR: Signup Popup Night Mode === */
body.night-mode #signup-prompt-modal p {
    color: #dcdde1 !important;
}

/* === VISITOR PAGE: Browser Window Night Mode === */
body.night-mode .browser-window {
    border-color: #4a5568 !important;
}

body.night-mode .browser-window .xp-window-title {
    background: linear-gradient(180deg, #192a56 0%, #273c75 100%) !important;
}

/* Browser toolbar, menu bar, links bar */
body.night-mode .browser-window .browser-toolbar,
body.night-mode .browser-window div[style*="background: #ECE9D8"] {
    background: #353b48 !important;
    color: #dcdde1 !important;
    border-color: #576574 !important;
}

body.night-mode .browser-window .browser-toolbar span,
body.night-mode .browser-window div[style*="background: #ECE9D8"] span {
    color: #dcdde1 !important;
}

body.night-mode .browser-window .browser-toolbar button,
body.night-mode .browser-window .browser-toolbar .xp-btn {
    color: #dcdde1 !important;
}

body.night-mode .browser-window .browser-toolbar a,
body.night-mode .browser-window div[style*="background: #ECE9D8"] a {
    color: #dcdde1 !important;
}

body.night-mode .browser-window .browser-toolbar button:hover,
body.night-mode .browser-window .browser-toolbar .xp-btn:hover {
    background-color: #576574 !important;
}

/* Address bar */
body.night-mode .browser-window .browser-address {
    background: #2f3640 !important;
    color: #dcdde1 !important;
    border-color: #576574 !important;
}

/* Status bar */
body.night-mode .browser-window .status-bar {
    background: #353b48 !important;
    color: #dcdde1 !important;
    border-color: #576574 !important;
}

/* Links bar link buttons */
body.night-mode .browser-window .browser-toolbar a.xp-btn {
    color: #dcdde1 !important;
}

body.night-mode .browser-window .browser-toolbar a.xp-btn span {
    color: #aaa !important;
}

/* Taskbar items on visitor page */
body.night-mode .xp-taskbar .xp-task-item {
    color: #dcdde1 !important;
}

body.night-mode .xp-taskbar a.xp-task-item {
    color: #dcdde1 !important;
}

/* === MOBILE RESPONSIVE OVERRIDES === */
@media screen and (max-width: 768px) {
    /* Vertical Layout for Homepage Windows */
    .xp-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-top: 20px;
        padding-bottom: 60px; /* Space for taskbar */
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto;
    }

    /* Override absolute positioning for windows on mobile */
    .xp-window#intro-window,
    .xp-window#counter-window,
    .xp-window#showcase-window {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 90% !important;
        margin-bottom: 20px;
        transform: none !important;
    }

    /* Specific Window Adjustments */
    .xp-window#showcase-window {
        order: 3;
    }
    
    #showcase-globe {
        height: 250px !important; /* Slightly smaller on mobile */
    }

    /* Taskbar Mobile Styles - show text tab names */
    .xp-taskbar-items {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
    }
    .xp-taskbar-items::-webkit-scrollbar { display: none; }
}
