@font-face {
    font-family: 'PixelatedElegance';
    src: url('PixelatedEleganceRegular-ovawB.ttf') format('truetype');
}

:root {
    --bg-color: #000000;
    --sidebar-color: #000000;
    --accent-color: #ffffff;
    --danger-color: #ffffff;
    --text-primary: #fefefe;
    --text-secondary: #888888;
    --border-color: #333333;
    --hover-color: #222222;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

#start-screen, 
#start-screen *, 
h1, 
.day-title, 
#day-display, 
#tasks-popup, 
.tasks-header, 
.task-item, 
#roomba-hud, 
#roomba-hud *, 
#roomba-help-legend, 
#roomba-help-legend *, 
#interaction-text, 
.m-btn, 
.btn, 
#btn-start-game, 
#btn-map-maker {
    font-family: 'PixelatedElegance', monospace !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    justify-content: center;
    align-items: center;
    background: #000000;
}

.hero-box {
    text-align: center;
}

h1 {
    font-size: 5rem;
    letter-spacing: 0.5rem;
    margin-bottom: 2rem;
    font-family: 'JetBrains Mono', monospace;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

/* Buttons & Icons */
.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.asset-item {
    display: flex;
    gap: 4px;
    width: 100%;
    margin-top: 4px;
}

.asset-item .tool {
    flex: 1;
    margin-bottom: 0;
    padding: 6px 10px;
    font-size: 11px;
    height: 32px;
}

.tool-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.tool-row .tool {
    margin-bottom: 0;
    flex: 1;
}

.icon-tool {
    max-width: 44px;
    font-size: 11px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-btn {
    padding: 8px;
    font-size: 10px;
    flex: 1;
}

button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.primary-btn { background-color: var(--text-primary); color: var(--bg-color); }
.primary-btn:hover { background-color: #ddd; transform: translateY(-2px); }

.secondary-btn { background-color: transparent; border: 1px solid var(--text-primary); color: var(--text-primary); }
.secondary-btn:hover { background-color: var(--text-primary); color: #000000; }

.danger-btn { background-color: transparent; color: var(--danger-color); border: 1px solid var(--danger-color); font-size: 0.8rem; }
.danger-btn:hover { background-color: var(--danger-color); color: white; }

.hidden-tool-btn {
    background: transparent;
    color: transparent;
    border: none;
    padding: 0.8rem 1.5rem;
    width: 200px;
    height: 50px;
    cursor: default;
}

/* Sidebar */
.sidebar {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    background-color: var(--sidebar-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar-header h2 { font-size: 1.2rem; letter-spacing: 2px; color: var(--text-secondary); }

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.scroll-container::-webkit-scrollbar { width: 4px; }
.scroll-container::-webkit-scrollbar-track { background: transparent; }
.scroll-container::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.section {
    margin-bottom: 1.5rem;
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 1rem;
}

.section label {
    display: block;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tool-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.tool {
    text-align: center;
    background-color: #1a1a1a;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool:hover {
    background-color: #2a2a2a;
    border-color: #444;
}

.tool.active {
    border-color: var(--accent-color);
    background-color: #111;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Viewport */
#map-viewport { flex: 1; position: relative; overflow: hidden; background-color: var(--bg-color); }
body.game-mode { cursor: none; background-color: #000; }
body.game-mode #map-maker-ui { width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; background: #000; }
body.game-mode #map-viewport { width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; }
body.game-mode .scrollbar { display: none !important; }
body.game-mode #game-canvas { width: 100% !important; height: 100% !important; object-fit: contain; }

/* Scrollbars */
.scrollbar { position: absolute; z-index: 20; overflow: auto; background-color: rgba(0,0,0,0.3); }
.v-scroll { top: 0; right: 0; width: 10px; height: 100%; }
.h-scroll { bottom: 0; left: 320px; height: 10px; width: calc(100% - 320px); }
#scroll-content-v { width: 1px; height: 3200px; }
#scroll-content-h { height: 1px; width: 3200px; }
.scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* Mobile Controls */
#mobile-controls { position: absolute; bottom: 30px; left: 30px; display: flex; pointer-events: none; z-index: 1000; }
#mobile-controls.hidden { display: none !important; }
.d-pad { display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto; }
.d-pad-mid { display: flex; gap: 36px; }
.m-btn { 
    width: 44px; 
    height: 44px; 
    background: transparent; 
    border: 2px solid #000000; 
    color: #000000; 
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 20px; 
    /* White outline surrounding the black border on both the inside and outside */
    box-shadow: 0 0 0 2px #ffffff, inset 0 0 0 2px #ffffff;
    /* White pixel outline surrounding the black arrow text */
    text-shadow: 
        -2px -2px 0 #ffffff,  
         2px -2px 0 #ffffff,
        -2px  2px 0 #ffffff,
         2px  2px 0 #ffffff,
        -2px  0px 0 #ffffff,
         2px  0px 0 #ffffff,
         0px -2px 0 #ffffff,
         0px  2px 0 #ffffff;
}
.m-btn:active { 
    background: #000000; 
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: 0 0 0 2px #000000, inset 0 0 0 2px #000000;
    text-shadow: 
        -2px -2px 0 #000000,  
         2px -2px 0 #000000,
        -2px  2px 0 #000000,
         2px  2px 0 #000000,
        -2px  0px 0 #000000,
         2px  0px 0 #000000,
         0px -2px 0 #000000,
         0px  2px 0 #000000;
}

@media (hover: none) and (pointer: coarse) { body.game-mode { cursor: auto; } }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--sidebar-color);
    padding: 2rem;
    border-radius: 12px;
    width: 600px;
}

#export-area {
    width: 100%; height: 300px;
    background-color: #121212;
    color: #ffffff;
    border: 1px solid #333;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    margin: 1.5rem 0;
    border-radius: 6px;
}

/* Day Display Overlay (Day Display style) */
#day-display {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: transparent;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    pointer-events: auto;
}
#day-display.hidden {
    display: none !important;
}
#day-transition-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2999;
}
.day-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: 4px solid #ffffff;
    padding: 24px 48px;
    box-shadow: 0 0 0 4px #000000;
    background-color: #000000;
    text-align: center;
    z-index: 3001;
    opacity: 1;
    transition: opacity 0.4s ease;
}

/* Today's Tasks Popup */
#tasks-popup {
    position: absolute;
    bottom: -220px; /* Hidden offscreen initially */
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    background: #fefefe;
    border: 4px solid #000000;
    color: #000000;
    padding: 16px;
    z-index: 1400;
    font-family: 'Courier New', Courier, monospace;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Smooth springy slide-up */
    box-shadow: 0 0 0 2px #ffffff;
}
#tasks-popup.visible {
    bottom: 30px; /* Slide up into view */
}
.tasks-header {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 2px solid #000000;
    padding-bottom: 6px;
    margin-bottom: 12px;
}
.task-item {
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}
.task-checkbox {
    font-family: monospace;
    font-size: 16px;
    letter-spacing: 1px;
    white-space: nowrap; /* Prevent bracket and space from wrapping to next line */
}
.task-item.completed .task-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Mobile Tasks Toggle Button */
#mobile-tasks-btn-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    pointer-events: none;
}
#mobile-tasks-btn-container.hidden {
    display: none !important;
}
#m-tasks-btn {
    pointer-events: auto;
}

/* Days Tabs Manager */
.days-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 8px;
}
.day-tab {
    background: transparent;
    border: 2px solid #333333;
    color: #888888;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}
.day-tab:hover {
    border-color: #ffffff;
    color: #ffffff;
}
.day-tab.active {
    border-color: #ffffff;
    color: #ffffff;
    background: #ffffff;
    color: #000000;
}
.day-add-tab {
    background: transparent;
    border: 2px dashed #333333;
    color: #888888;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}
.day-add-tab:hover {
    border-color: #ffffff;
    color: #ffffff;
}

/* Today's Inventory Popup */
#inventory-popup {
    position: absolute;
    bottom: -250px; /* Hidden offscreen initially */
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    background: #fefefe;
    border: 4px solid #000000;
    color: #000000;
    padding: 16px;
    z-index: 1400;
    font-family: 'PixelatedElegance', monospace;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Smooth springy slide-up */
    box-shadow: 0 0 0 2px #ffffff;
}
#inventory-popup.visible {
    bottom: 30px; /* Slide up into view */
}
.inventory-header {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 2px solid #000000;
    padding-bottom: 6px;
    margin-bottom: 12px;
}
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.inventory-item {
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Collection Notification Toast */
#collection-popup {
    position: absolute;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 520px;
    text-align: center;
    background: #fefefe;
    border: 4px solid #000000;
    color: #000000;
    padding: 16px;
    z-index: 1500;
    font-family: 'PixelatedElegance', monospace;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 0 0 2px #ffffff;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#collection-popup.visible {
    bottom: 250px; /* Float nicely above the bottom popups */
}

/* Mobile Top-Right HUD Controls Container */
#mobile-hud-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1600;
}
#mobile-hud-buttons.hidden {
    display: none !important;
}

/* Font override to ensure PixelatedElegance is applied everywhere in popups, day overlays, and credits */
#day-display, 
#day-display *,
#tasks-popup, 
#tasks-popup *,
#inventory-popup, 
#inventory-popup *,
#collection-popup,
#collection-popup *,
#roomba-help-legend,
#roomba-help-legend *,
#game-over-screen, 
#game-over-screen *,
.inventory-header,
.inventory-item,
.day-title {
    font-family: 'PixelatedElegance', monospace !important;
}

/* Very small and compact 1-bit mobile HUD buttons */
.m-btn-small {
    background: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 6px;
    font-family: 'PixelatedElegance', monospace !important;
    font-size: 9px !important;
    font-weight: bold;
    padding: 6px 12px;
    height: auto;
    width: auto;
    letter-spacing: 0.5px;
    box-shadow: 0 0 0 2px #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    text-shadow: none !important;
}
.m-btn-small:active {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
    box-shadow: 0 0 0 2px #ffffff;
}

@media (max-width: 768px) {
    #roomba-hud {
        transform: scale(0.6) !important;
        transform-origin: top left !important;
        top: 15px !important;
        left: 15px !important;
    }
}
