@charset "UTF-8";

:root {
    /* Primary Colors */
    --color-primary: #FFD700;
    --color-primary-glow: rgba(255, 215, 0, 0.3);

    /* Text Colors */
    --color-text-light: #f0f0f0;
    --color-text-medium: #c0c0c0;
    --color-text-muted: #888;

    /* Background Colors */
    --color-bg-dark: #1a1a1a;
    --color-bg-card: #1c1c1c;
    --color-bg-panel: #2a2a2a;
    --color-bg-input: #181818;
    --color-bg-elevated: #1e1e1e;

    /* Border Colors */
    --color-border-dark: #333;
    --color-border-medium: #444;
    --color-border-light: #555;

    /* Gradients */
    --gradient-panel: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    --gradient-hover: linear-gradient(135deg, #333 0%, #222 100%);

    /* Semi-transparent surfaces */
    --color-surface-subtle: rgba(255, 255, 255, 0.04);
    --color-surface-hover: rgba(255, 255, 255, 0.08);

    /* Primary (gold) surfaces */
    --color-primary-surface: rgba(255, 215, 0, 0.12);
    --color-primary-border: rgba(255, 215, 0, 0.4);

    /* Shadows */
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Shared spin animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

button, a, label, input, select, .tooltip-trigger, .control-img, [role="button"] {
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
}

body {
    margin: 0;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 10px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

#app:empty {
    visibility: hidden;
}

#app {
    display: contents;
}

.img-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-block;
}

.img-button img {
    display: block;
    height: auto;
}

#canvas-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background-color: #000000;
    outline: none;
    place-items: center;

    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -khtml-user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
}

#loading-gif-overlay {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    width: 100%;
    height: 100%;
    max-width: calc(100dvh * (640 / 480));
    max-height: calc(100dvw * (480 / 640));
    aspect-ratio: 640 / 480;
    box-sizing: border-box;
    outline: none;
}

#canvas {
    display: none !important;
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    background-color: #000000;
    border: none;
    z-index: 1;
    outline: none;
}

#loading-gif-overlay {
    background-color: #000000;
    border: none;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    background-color: #000000;
    padding: 20px;
    border-radius: 10px;
    width: 900px;
    max-width: 95vw;
    touch-action: manipulation;
}

#top-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}

.video-container {
    position: relative;
    display: flex;
    justify-content: center;
}

#install-video {
    max-width: 100%;
    width: 300px;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    border: none;
    box-sizing: border-box;
}

#sound-toggle-emoji {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 26px;
    color: white;
    text-shadow: 0 0 3px black;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease-in-out;
    z-index: 10;
    padding: 2px;
    user-select: none;
}

#sound-toggle-emoji:hover {
    opacity: 1;
}

/* Logo button wrapper should not affect layout */
#top-content > .img-button {
    display: contents;
}

#island-logo-img {
    max-width: 100%;
    width: 400px;
    height: auto;
    display: block;
    aspect-ratio: 567 / 198;
    cursor: default;
}

#controls-wrapper {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    max-width: 700px;
    padding: 10px 0;
}

.control-img {
    cursor: pointer;
    height: auto;
    max-width: 18%;
    display: block;
    transition: transform 0.1s ease-in-out;
}

.control-img:hover {
    transform: scale(1.08);
}

#run-game-btn {
    aspect-ratio: 135 / 164;
}

#configure-btn {
    aspect-ratio: 130 / 147;
}

#free-stuff-btn {
    aspect-ratio: 134 / 149;
}

#read-me-btn {
    aspect-ratio: 134 / 149;
}

#cancel-btn {
    aspect-ratio: 93 / 145;
}

#install-btn {
    aspect-ratio: 94 / 166;
}

#uninstall-btn {
    aspect-ratio: 122 / 144;
}

.footer-disclaimer {
    font-size: 0.7em;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.4;
    max-width: 600px;
    width: 90%;
}

.footer-disclaimer p {
    margin: 4px 0;
}

.footer-disclaimer a {
    color: var(--color-text-muted);
    text-decoration: underline;
}

.footer-disclaimer a:hover {
    color: var(--color-text-medium);
}

.app-footer {
    width: 100%;
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid var(--color-border-dark);
}

.app-footer p {
    margin: 0;
    font-size: 0.8em;
    color: #777;
    font-family: 'Consolas', 'Menlo', monospace;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .app-footer p {
        font-size: 0.65em;
    }
}

.page-wrapper {
    display: none;
    width: 100%;
}

.page-wrapper.active {
    display: contents;
}

.page-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    color: var(--color-text-light);
    width: 100%;
    touch-action: manipulation;
}

.page-back-button {
    align-self: flex-start;
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease-in-out;
    margin-bottom: 20px;
}

.page-back-button:hover {
    opacity: 1;
    color: var(--color-primary);
}

.page-inner-content {
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.page-inner-content h1 {
    color: var(--color-primary);
    /* LEGO yellow */
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.page-inner-content p {
    color: var(--color-text-medium);
    line-height: 1.6;
    font-size: 1.1em;
    margin-bottom: 15px;
    text-align: left;
}

.page-inner-content a {
    color: var(--color-primary);
    text-decoration: none;
}

.page-inner-content a:hover {
    text-decoration: underline;
}

#configure-page .page-inner-content.config-layout,
#save-editor .page-inner-content.config-layout,
#multiplayer-page .page-inner-content.config-layout {
    display: flex;
    background-color: var(--color-bg-input);
    border: 1px solid #303030;
    border-radius: 8px;
}

.config-art-panel {
    flex: 0 0 200px;
    border-radius: 8px 0 0 8px;
    aspect-ratio: 25 / 67;
}

.config-art-panel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px 0 0 8px;
}

.config-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-width: 0;
}

.config-form {
    flex-grow: 1;
}

/* Preset buttons */
.config-presets {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.preset-btn {
    padding: 8px 16px;
    background: var(--gradient-panel);
    border: 1px solid var(--color-border-medium);
    border-radius: 6px;
    color: var(--color-text-medium);
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--gradient-hover);
}

.preset-btn:active {
    transform: scale(0.98);
}

.preset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Config tabs */
.config-tabs {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.config-tab-buttons {
    display: flex;
    gap: 5px;
    border-bottom: 1px solid var(--color-border-dark);
    margin-bottom: 15px;
}

.config-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.config-tab-btn:hover {
    color: var(--color-text-medium);
}

.config-tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.config-tab-panel {
    display: none;
}

.config-tab-panel.active {
    display: block;
}

/* Collapsible section cards */
.config-section-card {
    background: var(--gradient-panel);
    border: 1px solid var(--color-bg-panel);
    border-radius: 8px;
    margin-bottom: 12px;
}

.config-section-card:last-child {
    margin-bottom: 0;
}

.config-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    color: var(--color-primary);
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    text-align: left;
}

.config-card-header::after {
    content: '+';
    font-size: 1.2em;
    color: #666;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.config-section-card:has(.config-card-content.open) .config-card-header::after {
    content: '−';
}


.config-card-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease, padding-bottom 0.3s ease;
    padding: 0 16px;
    padding-bottom: 0;
}

.config-card-content.open {
    grid-template-rows: 1fr;
    padding-bottom: 16px;
}

.config-card-content > div {
    min-height: 0;
    overflow: hidden;
}

@keyframes enable-tooltip-overflow {
    to { overflow: visible; }
}

.config-card-content.open > div {
    animation: enable-tooltip-overflow 0s 0.3s forwards;
}

/* Toggle switches */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    user-select: none;
    min-width: 0;
}

.toggle-switch label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--color-border-dark);
    border-radius: 24px;
    margin-right: 12px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background-color: var(--color-text-muted);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #3a5f3a;
}

.toggle-switch input:checked + .toggle-slider::after {
    left: 23px;
    background-color: var(--color-primary);
}

.toggle-label {
    color: var(--color-text-medium);
    font-size: 0.9em;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .toggle-label {
        white-space: normal;
    }
}

.toggle-switch .tooltip-trigger {
    margin-left: 8px;
    flex-shrink: 0;
}

.toggle-badge {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 8px;
    background-color: var(--color-border-dark);
    border-radius: 4px;
    font-size: 0.75em;
    color: var(--color-text-muted);
}

.toggle-badge-experimental {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    margin-left: 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    background: var(--color-primary);
    color: #000;
}

@media (max-width: 768px) {
    .toggle-badge,
    .toggle-badge-experimental {
        display: none;
    }
}

/* Config toast notification */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 30px;
}

.form-group-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #e0e0e0;
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.tooltip-trigger {
    position: relative;
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--color-border-medium);
    color: #eee;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    user-select: none;
}

/* Expand touch target for mobile devices */
@media (pointer: coarse) {
    .tooltip-trigger::before {
        content: '';
        position: absolute;
        inset: -12px;
    }
}

.tooltip-content {
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    max-width: 220px;
    background-color: var(--color-bg-panel);
    color: var(--color-text-light);
    padding: 0;
    border-radius: 5px;
    font-size: 0.85em;
    font-weight: normal;
    line-height: 1.4;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    max-height: 0;
}

/* Only use hover on devices with real hover support (not touch) */
@media (hover: hover) {
    .tooltip-trigger:hover>.tooltip-content {
        opacity: 1;
        visibility: visible;
        padding: 10px;
        max-height: none;
        overflow: visible;
    }
}

/* Active state for touch devices (controlled by JS) */
.tooltip-trigger.active>.tooltip-content {
    opacity: 1;
    visibility: visible;
    padding: 10px;
    max-height: none;
    overflow: visible;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: center;
}

.option-item input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.option-item label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--color-text-medium);
}

.option-item label::before {
    content: '';
    width: 14px;
    height: 14px;
    margin-right: 10px;
    background-color: var(--color-border-dark);
    border: 1px solid var(--color-border-light);
    transition: all 0.2s ease;
}

.option-item input:checked+label::before {
    background-color: var(--color-primary);
    border-color: #fff;
    box-shadow: 0 0 5px var(--color-primary);
}

.radio-group .option-item label::before {
    border-radius: 50%;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border-medium);
    outline: none;
    border-radius: 6px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #000;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #000;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '▼';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--color-primary);
    pointer-events: none;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    padding: 10px 15px;
    font-size: 0.9em;
    color: var(--color-text-medium);
    background-color: var(--color-border-dark);
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: var(--color-primary);
}

#install-btn {
    max-width: 50%;
    margin: 0 auto;
}

#uninstall-btn {
    max-width: 70%;
    margin: 0 auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #install-video {
        width: 260px;
    }

    #island-logo-img {
        width: 360px;
    }

    .control-img {
        max-width: 19%;
    }

    #sound-toggle-emoji {
        font-size: 24px;
        top: 8px;
        left: 8px;
    }

    .page-inner-content h1 {
        font-size: 2em;
    }

    .page-inner-content p {
        font-size: 1em;
    }

    .config-art-panel {
        display: none;
    }

    #configure-page .page-inner-content.config-layout,
    #save-editor .page-inner-content.config-layout,
    #multiplayer-page .page-inner-content.config-layout {
        background-color: transparent;
        border: none;
        padding: 0;
    }

    .config-main {
        background-color: var(--color-bg-input);
        border: 1px solid #303030;
        border-radius: 8px;
        padding: 15px;
    }

    .config-presets {
        flex-wrap: wrap;
    }

    .preset-btn {
        flex: 1;
        text-align: center;
    }

    .config-tab-buttons {
        flex-wrap: wrap;
        gap: 0;
    }

    .config-tab-btn {
        flex: 1 1 auto;
        padding: 8px 12px;
        font-size: 0.8em;
        text-align: center;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 480px) {
    #install-video {
        width: 90%;
        max-width: 280px;
    }

    #island-logo-img {
        width: 90%;
        max-width: 320px;
    }

    .control-img {
        max-width: 45%;
        margin: 3px 0;
    }

    #sound-toggle-emoji {
        font-size: 22px;
        top: 6px;
        left: 6px;
    }

    .page-content .page-back-button {
        font-size: 22px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
}


/* Notification popup (shared by update and goodbye popups) */
.notification-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    align-items: flex-end;
    gap: 0;
    animation: popup-bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popup-bounce {
    0% {
        transform: translateX(120%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-popup-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.update-speech-bubble {
    position: relative;
    background: var(--gradient-panel);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: 15px 18px;
    margin-bottom: 10px;
    margin-right: -20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    max-width: 200px;
}

.update-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    right: 30px;
    border-width: 12px 10px 0 10px;
    border-style: solid;
    border-color: var(--color-primary) transparent transparent transparent;
}

.update-speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 32px;
    border-width: 10px 8px 0 8px;
    border-style: solid;
    border-color: var(--color-bg-dark) transparent transparent transparent;
    z-index: 1;
}

.update-message {
    color: var(--color-text-light);
    font-size: 0.95em;
    font-weight: 500;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.update-reload-btn {
    width: 100%;
    padding: 10px 16px;
    background-color: var(--color-primary);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.update-reload-btn:hover {
    background-color: #fff;
    transform: scale(1.03);
}

.update-dismiss-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--color-border-dark);
    color: var(--color-text-muted);
    border: 2px solid var(--color-border-light);
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.update-dismiss-btn:hover {
    color: #fff;
    border-color: var(--color-primary);
    background: var(--color-border-medium);
}

.update-character {
    width: 120px;
    height: auto;
    border-radius: 12px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    animation: character-wave 2s ease-in-out infinite;
    animation-delay: 0.5s;
}

@keyframes character-wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(2deg);
    }
    75% {
        transform: rotate(-2deg);
    }
}

@media (max-width: 480px) {
    .notification-popup {
        bottom: 10px;
        right: 10px;
    }

    .update-speech-bubble {
        max-width: 160px;
        margin-right: -15px;
    }

    .update-character {
        width: 90px;
    }

    .update-message {
        font-size: 0.85em;
    }

    .update-reload-btn {
        font-size: 0.85em;
        padding: 8px 12px;
    }
}

