@font-face {
    font-family: 'Minecraft';
    src: url('assets/Minecraft.ttf') format('truetype');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Minecraft', 'Courier New', monospace;
    background-image: url('assets/background.png');
    background-size: 16px 16px;
    background-repeat: repeat;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 5%, 40px);
    max-width: 100vw;
    overflow-x: hidden;
}

.minecraft-title {
    font-size: clamp(1.8em, 6vw, 3em);
    font-weight: bold;
    text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.8),
                 2px 2px 0px rgba(0, 0, 0, 0.5);
    color: #fffe04;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-transform: uppercase;
    animation: titlePulse 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.minecraft-subtitle {
    color: #aaaaaa;
    text-align: center;
    font-size: 0.9em;
    letter-spacing: 2px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.menu-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.menu-panel {
    background: #25496b;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 12px 24px rgba(0, 0, 0, 0.8);
    padding: clamp(40px, 8%, 60px);
    width: 100%;
    max-width: 600px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.menu-panel:hover {
    transform: translateY(-2px);
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 16px 32px rgba(0, 0, 0, 0.9);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-button,
.action-button,
.modal-button {
    background: linear-gradient(180deg, #8b8b8b 0%, #6b6b6b 50%, #4a4a4a 100%);
    border: 3px outset #ffffff;
    border-bottom-color: #000000;
    border-right-color: #000000;
    color: #ffffff;
    font-family: 'Minecraft', 'Courier New', monospace;
    font-size: clamp(0.9em, 2vw, 1.2em);
    font-weight: bold;
    padding: clamp(12px, 2%, 16px) clamp(24px, 4%, 36px);
    cursor: pointer;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    transition: all 0.15s ease;
    position: relative;
    letter-spacing: 1px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.menu-button:hover,
.action-button:hover,
.modal-button:hover {
    background: linear-gradient(180deg, #9b9b9b 0%, #7b7b7b 50%, #5a5a5a 100%);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), 0 0 10px rgba(255, 254, 4, 0.3);
    transform: translateY(-1px);
}

.menu-button:active,
.action-button:active,
.modal-button:active {
    background: linear-gradient(180deg, #6b6b6b 0%, #5a5a5a 50%, #4a4a4a 100%);
    border: 2px inset #ffffff;
    border-bottom-color: #ffffff;
    border-right-color: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
}

.action-button.secondary {
    background: linear-gradient(180deg, #7b5e4a 0%, #6b4e3a 50%, #5b3e2a 100%);
    border-color: #aa8866;
}

.action-button.secondary:hover {
    background: linear-gradient(180deg, #8b6e5a 0%, #7b5e4a 50%, #6b4e3a 100%);
}

.button-text {
    display: inline-block;
}

.palette-container {
    background: #25496b;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 8px 16px rgba(0, 0, 0, 0.8);
    padding: clamp(30px, 5%, 45px);
    width: 100%;
    max-width: 1100px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.palette-header {
    text-align: center;
    margin-bottom: 30px;
    color: #fffe04;
}

.palette-header h2 {
    font-size: clamp(2em, 6vw, 3em);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

.palette-name-input {
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #fffe04;
    padding: 12px 16px;
    font-family: 'Minecraft', 'Courier New', monospace;
    font-size: 1.2em;
    text-align: center;
    max-width: 400px;
}

.palette-name-input:focus {
    outline: none;
    border-color: #fffe04;
    box-shadow: 0 0 8px rgba(255, 254, 4, 0.5);
}

.palette-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(80px, 12vw, 120px), 1fr));
    gap: clamp(10px, 2%, 20px);
    margin: clamp(20px, 4%, 30px) 0;
    background: #1a1a1a;
    padding: clamp(20px, 4%, 30px);
    border: 2px solid #444444;
    min-height: 200px;
}

.builder-header {
    text-align: center;
    margin-bottom: 20px;
    color: #fffe04;
    background: #1a1a1a;
    padding: 20px;
    border: 2px solid #444444;
    border-radius: 2px;
}

.builder-header h2 {
    font-size: clamp(1.5em, 5vw, 2em);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    margin-bottom: 8px;
    word-wrap: break-word;
}

.builder-header p {
    color: #aaaaaa;
    margin-bottom: 0;
    font-size: 0.9em;
    word-wrap: break-word;
}

.block {
    aspect-ratio: 1;
    border: 2px solid #333333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    background-position: center;
    background-size: 100%;
    background-repeat: no-repeat;
}

.block:hover {
    transform: scale(1.08);
    border-color: #ffffff;
}

.block-name {
    position: absolute;
    bottom: -25px;
    font-size: 0.7em;
    color: #aaaaaa;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
}

.blocks-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(60px, 8vw, 110px), 1fr));
    gap: clamp(10px, 2%, 15px);
    background: #1a1a1a;
    padding: clamp(20px, 3%, 30px);
    border: 2px solid #444444;
    max-height: 500px;
    overflow-y: auto;
    margin: 20px 0;
}

.block-option {
    aspect-ratio: 1;
    border: 2px solid #333333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background-position: center;
    background-size: 100%;
    background-repeat: no-repeat;
    position: relative;
    min-width: 60px;
    min-height: 60px;
}

.block-option:hover {
    transform: scale(1.08);
    border-color: #ffffff;
}

.block-option.selected {
    border: 3px solid #ffffff;
    transform: scale(1.05);
}

.selected-count {
    position: absolute;
    top: -20px;
    right: 0;
    background: #fffe04;
    color: #000000;
    padding: 4px 8px;
    font-size: 1em;
    border-radius: 3px;
    font-weight: bold;
}

.palette-actions,
.builder-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.action-button {
    min-width: 150px;
}

.custom-builder {
    background: #25496b;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 8px 16px rgba(0, 0, 0, 0.8);
    padding: clamp(30px, 4%, 45px);
    width: 100%;
    max-width: 1400px;
}

.builder-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: clamp(20px, 3%, 30px);
    align-items: start;
}

.builder-main {
    display: flex;
    flex-direction: column;
}

.search-box {
    margin: 15px 0;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #fffe04;
    font-family: 'Minecraft', 'Courier New', monospace;
    font-size: 1em;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #fffe04;
    box-shadow: 0 0 12px rgba(255, 254, 4, 0.4);
}

.search-input::placeholder {
    color: #666666;
}

.builder-preview {
    background: #1a1a1a;
    border: 2px solid #444444;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: fit-content;
    overflow-y: visible;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fffe04;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    padding-bottom: 10px;
    border-bottom: 2px solid #444444;
}

.preview-header h3 {
    font-size: clamp(1.1em, 2vw, 1.3em);
}

.block-count {
    background: #fffe04;
    color: #1a1a1a;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: bold;
}

.preview-isometric {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.preview-isometric .block {
    aspect-ratio: 1;
    min-height: 60px;
}

.preview-flat {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.preview-flat .block {
    aspect-ratio: auto;
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.preview-stats {
    display: none;
}

.palette-stats {
    display: none;
}

.saved-container {
    background: #25496b;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 8px 16px rgba(0, 0, 0, 0.8);
    padding: clamp(30px, 4%, 45px);
    width: 100%;
    max-width: 1100px;
}

.saved-header {
    text-align: center;
    margin-bottom: 20px;
    color: #fffe04;
}

.saved-header h2 {
    font-size: clamp(1.8em, 6vw, 2.5em);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.saved-count {
    color: #aaaaaa;
    font-size: 0.9em;
    display: block;
    margin-top: 5px;
}

.saved-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.saved-palette-item {
    background: #1a1a1a;
    border: 2px solid #444444;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.saved-palette-item:hover {
    border-color: #fffe04;
    box-shadow: 0 0 12px rgba(255, 254, 4, 0.5);
    transform: translateY(-2px);
}

.saved-palette-name {
    color: #fffe04;
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
}

.saved-palette-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
    margin-bottom: 10px;
    padding: 8px 0;
}

.saved-block-preview {
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    border: 1px solid #444444;
    border-radius: 2px;
}

.saved-palette-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
}

.saved-palette-item-actions button {
    padding: 6px 10px;
    font-size: 0.85em;
    min-height: auto;
}

.saved-date {
    color: #888888;
    font-size: 0.8em;
    margin-top: 8px;
    text-align: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #25496b;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 8px 16px rgba(0, 0, 0, 0.8);
    padding: 30px;
    text-align: center;
    max-width: 400px;
}

.modal-content p {
    color: #ffffff;
    margin-bottom: 20px;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-button {
    margin: 0;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #666666;
    border: 2px solid #1a1a1a;
}

::-webkit-scrollbar-thumb:hover {
    background: #888888;
}

@media (max-width: 1024px) {
    .builder-container {
        grid-template-columns: 1fr 250px;
    }
}

@media (max-width: 768px) {
    .minecraft-title {
        font-size: clamp(2em, 8vw, 3em);
    }

    .menu-panel {
        max-width: 100%;
        padding: 30px;
    }

    .palette-container,
    .custom-builder,
    .saved-container {
        padding: clamp(20px, 3%, 30px);
    }
    
    .builder-container {
        grid-template-columns: 1fr;
    }
    
    .builder-preview {
        max-height: none;
        order: -1;
        margin-bottom: 20px;
    }

    .palette-blocks,
    .blocks-selector {
        grid-template-columns: repeat(auto-fit, minmax(clamp(60px, 10vw, 90px), 1fr));
        gap: clamp(8px, 2%, 12px);
    }

    .saved-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    body {
        padding: clamp(8px, 3%, 16px);
    }

    .minecraft-title {
        font-size: clamp(1.8em, 7vw, 2.5em);
    }

    .minecraft-subtitle {
        font-size: 0.8em;
    }

    .menu-panel {
        padding: 20px;
    }

    .menu-buttons {
        gap: 12px;
    }

    .palette-container,
    .custom-builder,
    .saved-container {
        padding: 15px;
    }

    .palette-blocks,
    .blocks-selector {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 6px;
        padding: 15px;
    }

    .palette-actions,
    .builder-actions {
        gap: 8px;
        margin-top: 15px;
    }

    .action-button {
        min-width: 100px;
        padding: 10px 16px;
        font-size: 0.9em;
    }

    .saved-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .saved-palette-preview {
        grid-template-columns: repeat(4, 1fr);
    }

    .search-input {
        font-size: 0.95em;
        padding: 10px 12px;
    }

    .builder-preview {
        padding: 15px;
    }

    .preview-isometric {
        grid-template-columns: 1fr;
    }

    .palette-name-input {
        max-width: 100%;
        font-size: 1em;
    }

    .modal-content {
        margin: 20px;
        padding: clamp(20px, 5%, 30px);
    }
}

/* Import Container Styles */
.import-container {
    background: #2a2a2a;
    border: 4px solid #1a1a1a;
    box-shadow: inset 2px 2px 0px rgba(255, 255, 255, 0.2),
                inset -2px -2px 0px rgba(0, 0, 0, 0.5),
                0px 8px 16px rgba(0, 0, 0, 0.8);
    padding: clamp(30px, 5%, 45px);
    width: 100%;
    max-width: 900px;
    animation: slideIn 0.3s ease;
}

.import-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.import-header {
    text-align: center;
    color: #fffe04;
}

.import-header h2 {
    font-size: clamp(1.5em, 5vw, 2.5em);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

.import-header p {
    color: #cccccc;
    font-size: 1em;
}

.import-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.import-method {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.import-method h3 {
    color: #fffe04;
    font-size: 1.1em;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);
}

.import-textarea {
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #cccccc;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    min-height: 200px;
    resize: vertical;
    color-scheme: dark;
}

.import-textarea:focus {
    outline: none;
    border-color: #fffe04;
    box-shadow: 0 0 8px rgba(255, 254, 4, 0.5);
}

.import-file {
    background: #1a1a1a;
    border: 2px solid #666666;
    color: #cccccc;
    padding: 12px 16px;
    font-family: 'Minecraft', 'Courier New', monospace;
    cursor: pointer;
}

.import-file::-webkit-file-upload-button {
    background: #444444;
    border: 2px solid #666666;
    color: #fffe04;
    padding: 8px 16px;
    cursor: pointer;
    font-family: 'Minecraft', 'Courier New', monospace;
    font-weight: bold;
}

.import-file::-webkit-file-upload-button:hover {
    background: #555555;
    border-color: #fffe04;
}

.import-hint {
    color: #888888;
    font-size: 0.85em;
    margin-top: 5px;
}

.import-preview {
    background: #1a1a1a;
    border: 2px solid #666666;
    border-radius: 4px;
    padding: 15px;
}

.import-preview h3 {
    color: #fffe04;
    margin-bottom: 10px;
    font-size: 1em;
}

.import-preview .preview-flat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

@media (max-width: 800px) {
    .import-methods {
        grid-template-columns: 1fr;
    }
    
    .import-textarea {
        min-height: 150px;
    }
}

@media (max-width: 600px) {
    .minecraft-title {
        font-size: 3em;
    }

    .menu-panel {
        padding: 30px;
        min-width: auto;
    }

    .palette-container,
    .custom-builder,
    .saved-container,
    .import-container {
        padding: 25px;
    }

    .palette-blocks,
    .blocks-selector {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 10px;
    }

    .saved-list {
        grid-template-columns: 1fr;
    }
}
