* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Helvetica;
    height: 100vh;
    overflow: auto;
    background-color: #198eff;

}

.container {
    display: flex;
    position: relative;
    height: 100%;
}

.viewport {
    flex: 1 1 0;
    outline: none;
    position: relative;
    overflow: hidden;
    touch-action: none;
    container-type: inline-size;
    container-name: viewport;
}

.viewport:focus {
    outline: none;
}

.viewport canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

.controls {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(51, 51, 51, 0.85);
    color: #fff;
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 4px 4px 0 0;
    z-index: 10;
    white-space: nowrap;
}

@media (max-device-width: 768px) {
    .controls {
        display: none;
    }
}

.sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 30%;
    padding: 10px;
    background-color: #198eff;
    color: #fff;
}

.divider {
    border-top: 1px solid #06f;
    margin: 5px;
}

.section_title {
    font-size: 120%;
    font-weight: bold;
    margin: 0;
}

.section_title #textures_toggle {
    cursor: pointer;
    display: inline-block;
    padding: 0 4px;
    font-size: 80%;
    background-color: #00a5ff;
    vertical-align: middle;
    margin-right: 5px;
    border-radius: 4px;
    border: 1px solid #0081ff;
}

.section_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.default_controls {
    display: flex;
    align-items: center;
}

.default_controls .filename {
    font-size: 12px;
    color: #fff;
    margin: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
    text-align: center;
}

.tile_file {
    background-color: #009cff;
    margin: 5px 0;
    padding: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tile_file .designation {
    flex-shrink: 0;
    margin-right: 10px;
    width: 100px;
}

.tile_file .filename {
    flex: 1;
    font-size: 12px;
    color: #fff;
    margin: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.tile_file input[type="file"] {
    font-size: 11px;
    flex: 1;
    cursor: pointer;
    margin-right: 8px;
}

.tile_file#all {
    background-color: #00b7ff;
}

.clear-btn {
    background-color: #bc0000;
    color: #fff;
    border: none;
    padding: 2px 8px;
    margin-left: 5px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 3px;
}

.clear-btn:hover {
    background-color: #e00000;
}

.remove-btn {
    color: #bc0000;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    padding: 0 5px;
    flex-shrink: 0;
    visibility: hidden;
}

.remove-btn:hover {
    color: #e00000;
}

.list_entry {
    background-color: #00b7ff;
    padding: 5px;
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
}

.cube-header {
    display: flex;
    align-items: center;
    width: 100%;
}

.list_entry #expand {
    cursor: pointer;
    display: inline-block;
    padding: 0 4px;
    font-size: 80%;
    font-weight: bold;
    background-color: #00a5ff;
    vertical-align: middle;
    margin-right: 5px;
    border-radius: 4px;
    border: 1px solid #0081ff;
}

.list_entry .remove {
    background-color: #bc0000;
    color: #fff;
    border: none;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: auto;
}

.list_entry .remove:hover {
    background-color: #e00000;
}

.cfg_bar {
    margin-top: 5px;
    display: flex;
    gap: 10px;
    width: 100%;
}

.cfg_bar .fieldset {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.cfg_bar .fieldset > span {
    font-weight: bold;
    margin-bottom: 4px;
    text-align: left;
}

.field {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.field label {
    font-size: 12px;
    font-weight: bold;
}

.field input {
    width: 80px;
}

.export-container {
    position: relative;
    width: 100%;
}

.copy-btn {
    position: absolute;
    top: 16px;
    right: 4px;
    z-index: 1;
    background-color: #009cff;
    border: 1px solid #0081ff;
    border-radius: 3px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background-color 0.15s;
}

.copy-btn:hover {
    background-color: #00b7ff;
}

.copy-btn.copied {
    background-color: #28a745;
}

pre {
    overflow: auto;
    background-color: #fff;
    color: #000;
    padding: 5px 30px 5px 5px;
    box-sizing: border-box;
    width: 100%;
}

textarea {
    width: 100%;
    min-height: 100px;
    margin: 5px 0;
    resize: vertical;
    box-sizing: border-box;
}

.footer-links {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.footer-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    padding: 4px;
    width: 32px;
    height: 32px;
    transition: background-color 0.2s;
}

.footer-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.footer-attribution {
    font-size: 10px;
    text-align: center;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.8);
}

.language-selector {
    display: flex;
    justify-content: center;
    padding: 8px 0 4px;
}

.language-selector select {
    background-color: #00b7ff;
    color: #fff;
    border: 1px solid #0081ff;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.language-selector select option {
    background-color: #198eff;
    color: #fff;
}

.footer-attribution a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

@media (max-device-width: 768px) {
    .container {
        flex-direction: column;
    }

    .viewport {
        flex: 1 1 auto;
        width: 100%;
        min-height: 50vh;
        touch-action: none;
    }

    .controls {
        display: none;
    }

    .sidebar {
        flex: 1 1 auto;
        width: 100%;
        min-height: 300px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    .sidebar button {
        min-height: 44px;
        min-width: 44px;
        font-size: 16px;
        padding: 8px 12px;
    }

    .tile_file {
        min-height: 48px;
        padding: 8px;
    }

    .tile_file .designation {
        width: auto;
        font-size: 16px;
    }

    .remove-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .list_entry {
        padding: 8px;
    }

    .list_entry .remove {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .cfg_bar {
        gap: 12px;
    }

    .field {
        min-height: 44px;
        gap: 8px;
    }

    .field label {
        font-size: 14px;
    }

    .field input {
        width: 100%;
        min-height: 40px;
        font-size: 16px;
        padding: 4px 8px;
    }

    .field input[type="number"] {
        -moz-appearance: textfield;
    }

    .field input::-webkit-outer-spin-button,
    .field input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    textarea {
        min-height: 120px;
        font-size: 16px;
    }

    .controls {
        font-size: 12px;
        padding: 8px;
    }

    .section_header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .section_title {
        font-size: 18px;
    }

    .default_controls {
        flex-wrap: wrap;
    }

    .language-selector select {
        font-size: 16px;
        padding: 8px 12px;
        min-height: 44px;
    }
}
