@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;600;700&family=Silkscreen:wght@400;700&family=Inter:wght@400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   1. DESKTOP VIEW (Default: Screens > 600px)
   ============================================================ */
body {
    font-family: 'Pixelify Sans', 'Silkscreen', monospace, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background: radial-gradient(circle at center, #0c1412 0%, #020304 100%);
    color: #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    user-select: none;
    letter-spacing: 0.5px;
    touch-action: manipulation;
}

#appContainer {
    width: 384px;
    height: 600px;
    position: relative;
    overflow: hidden;
    background: #050709;
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 163, 0.25);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 25px rgba(0, 229, 163, 0.15);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    touch-action: manipulation;
}

/* ============================================================
   2. MOBILE VIEW (Smartphones <= 400px)
   ============================================================ */
@media (max-width: 400px), (display-mode: standalone) and (max-width: 500px) {
    body {
        background: #040608;
        padding: 0;
        margin: 0;
    }

    #appContainer {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
}

#roomCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    cursor: default;
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;
}

img, .user-avatar, .mini-icon img {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* ===== SCROLLBARS (PIXEL STYLE) ===== */
::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #000000;
    border: 1px solid rgba(0, 229, 163, 0.2);
}

::-webkit-scrollbar-thumb {
    background: #00b894;
    border: 1px solid #00e5a3;
}

::-webkit-scrollbar-thumb:hover {
    background: #00e5a3;
}

/* ===== DYNAMIC ISLAND (RETRO PIXEL NOTCH) ===== */
.dynamic-island {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 28px;
    background: #080a0e;
    border: 2px solid #00e5a3;
    border-radius: 6px;
    box-shadow: 2px 2px 0 #000000, 0 0 10px rgba(0, 229, 163, 0.25);
    z-index: 200;
    transition: width 0.32s cubic-bezier(0.34, 1.25, 0.64, 1), 
                height 0.32s cubic-bezier(0.34, 1.25, 0.64, 1), 
                box-shadow 0.25s ease,
                background 0.25s ease;
    overflow: hidden;
    user-select: none;
}

.dynamic-island.collapsed {
    width: 42px;
    height: 28px;
    cursor: pointer;
}

.dynamic-island.collapsed:hover {
    transform: translateX(-50%) translateY(-1px);
    box-shadow: 3px 3px 0 #000000, 0 0 14px rgba(0, 229, 163, 0.5);
    background: #0c1017;
}

.dynamic-island.expanded {
    width: max-content;
    min-width: 200px;
    max-width: calc(100% - 16px);
    height: 38px;
    background: #080a0e;
    border-color: #00e5a3;
    box-shadow: 3px 3px 0 #000000, 0 0 18px rgba(0, 229, 163, 0.3);
    cursor: default;
}

.dynamic-island.search-open {
    width: calc(100% - 16px);
    max-width: 360px;
    height: 40px;
    background: #080a0e;
    border-color: #00e5a3;
    box-shadow: 3px 3px 0 #000000, 0 0 20px rgba(0, 229, 163, 0.35);
    cursor: default;
}

/* Collapsed Mini View */
.island-collapsed {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 100%;
    height: 100%;
}

.mini-icon {
    font-size: 0.95em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.island-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    height: 100%;
    gap: 4px;
}

.island-view.hidden {
    display: none !important;
}

/* User Badge */
.island-user-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #11151c;
    border: 1px solid rgba(0, 229, 163, 0.3);
    border-radius: 4px;
    box-shadow: 1px 1px 0 #000000;
    cursor: pointer;
    font-size: 0.72em;
    font-weight: 700;
    color: #e2e8f0;
    max-width: 82px;
    flex-shrink: 1;
    transition: all 0.15s ease;
}

.island-user-badge:hover {
    background: #00b894;
    color: #040608;
    border-color: #00e5a3;
}

.island-user-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
    border: 1px solid #00e5a3;
    flex-shrink: 0;
}

/* Countdown Pill */
.island-countdown-pill {
    background: #11151c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    box-shadow: 1px 1px 0 #000000;
    padding: 2px 6px;
    font-size: 0.7em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

.island-countdown-pill.ready {
    border-color: #00e5a3;
    background: rgba(0, 229, 163, 0.2);
    color: #00e5a3;
    box-shadow: 0 0 8px rgba(0, 229, 163, 0.4);
}

/* Nav Icon Group */
.island-nav-group {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.island-icon-btn {
    background: #11151c;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 rgba(255, 255, 255, 0.15), 1px 1px 0 #000;
    color: #e2e8f0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.15s steps(2, start);
    line-height: 1;
}

.island-icon-btn:hover {
    background: #00b894;
    border-color: #00e5a3;
    color: #040608;
    transform: translateY(-1px);
}

.island-icon-btn:active {
    transform: translateY(1px);
    box-shadow: inset 1px 1px 0 #000, inset -1px -1px 0 rgba(255, 255, 255, 0.15);
}

.island-icon-btn.active {
    background: #00b894;
    border-color: #00e5a3;
    color: #040608;
    box-shadow: inset 1px 1px 0 #000, 0 0 8px rgba(0, 229, 163, 0.6);
}

/* Search Mode in Island */
.island-search {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
}

.search-icon-prefix {
    font-size: 0.8em;
    opacity: 0.8;
}

.island-search-input {
    flex: 1;
    background: #11151c;
    border: 1px solid rgba(0, 229, 163, 0.3);
    border-radius: 4px;
    outline: none;
    color: #f1f5f9;
    font-size: 0.78em;
    font-family: inherit;
    padding: 3px 6px;
    min-width: 0;
}

.island-search-input::placeholder {
    color: #64748b;
}

.island-search-submit {
    background: #00b894;
    color: #040608;
    border: 1px solid #00e5a3;
    border-radius: 4px;
    box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 rgba(255, 255, 255, 0.4), 1px 1px 0 #000;
    padding: 3px 8px;
    font-size: 0.72em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.island-search-submit:hover {
    background: #00e5a3;
}

.island-search-close {
    background: #11151c;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-family: inherit;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.island-search-close:hover {
    background: #e11d48;
    color: #ffffff;
    border-color: #ff4757;
}

/* ===== STATUS TOAST / BADGE (RETRO PIXEL BOX) ===== */
.status-badge {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: #080a0e;
    color: #f8fafc;
    padding: 6px 12px;
    font-weight: 700;
    font-size: 0.76em;
    font-family: inherit;
    border: 2px solid #00e5a3;
    border-radius: 4px;
    box-shadow: 3px 3px 0 #000000, 0 0 12px rgba(0, 229, 163, 0.3);
    opacity: 0;
    transition: opacity 0.2s steps(4, start), transform 0.2s steps(4, start);
    z-index: 300;
    pointer-events: none;
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 24px);
    width: max-content;
    line-height: 1.35;
}

.status-badge.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.status-badge.hidden {
    display: none;
}

/* ===== CUSTOM MODAL DIALOG (RETRO RPG DIALOG BOX) ===== */
.custom-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.custom-modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.custom-modal-card {
    background: #080a0e;
    border: 3px double #00e5a3;
    border-radius: 6px;
    box-shadow: 4px 4px 0 #000000, 0 0 24px rgba(0, 229, 163, 0.3);
    padding: 20px 18px 16px;
    width: 100%;
    max-width: 275px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: pixelPop 0.2s steps(3, start);
}

@keyframes pixelPop {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-icon {
    font-size: 2.2em;
    margin-bottom: 6px;
}

.modal-title {
    font-size: 1em;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 6px;
    letter-spacing: 0.6px;
}

.modal-message {
    font-size: 0.82em;
    color: #94a3b8;
    line-height: 1.45;
    margin-bottom: 16px;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 8px;
    width: 100%;
}

.modal-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.modal-btn.secondary {
    background: #11151c;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 rgba(255, 255, 255, 0.2), 2px 2px 0 #000;
}

.modal-btn.secondary:hover {
    background: #1e2430;
}

.modal-btn.primary {
    background: #00b894;
    color: #040608;
    border: 1px solid #00e5a3;
    box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 rgba(255, 255, 255, 0.5), 2px 2px 0 #000;
}

.modal-btn.primary:hover {
    background: #00e5a3;
    transform: translateY(-1px);
}

.modal-btn.danger {
    background: #e11d48;
    color: #ffffff;
    border: 1px solid #ff4757;
    box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 rgba(255, 255, 255, 0.4), 2px 2px 0 #000;
}

.modal-btn.danger:hover {
    background: #ff4757;
    transform: translateY(-1px);
}

/* ===== MAINTENANCE / IN-DEVELOPMENT OVERLAY (PIXEL ART) ===== */
.maintenance-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, #151a14 0%, #050709 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    user-select: none;
}

@keyframes floatLogo {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

.maintenance-card {
    background: #080a0e;
    border: 3px double #f1c40f;
    border-radius: 8px;
    box-shadow: 4px 4px 0 #000000, 0 0 30px rgba(241, 196, 15, 0.25);
    padding: 24px 18px 20px;
    width: 100%;
    max-width: 290px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: floatLogo 3s ease-in-out infinite;
}

.maintenance-icon {
    font-size: 3em;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 12px rgba(241, 196, 15, 0.6));
}

.maintenance-title {
    font-size: 1.15em;
    font-weight: 800;
    color: #f1c40f;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-shadow: 2px 2px 0 #000000;
}

.maintenance-badge {
    background: rgba(241, 196, 15, 0.15);
    border: 1px solid #f1c40f;
    color: #f1c40f;
    font-size: 0.72em;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 14px;
    box-shadow: 1px 1px 0 #000;
}

.maintenance-text {
    font-size: 0.78em;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 16px;
}

.maintenance-footer {
    font-size: 0.68em;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
    width: 100%;
}

.hidden {
    display: none !important;
}
