@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

@font-face {
    font-family: 'DETERMINATION Mono';
    src: url('https://cartr.gitlab.io/undertale-fonts/webfonts/determinationmonoweb-webfont.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'DETERMINATION Sans';
    src: url('https://cartr.gitlab.io/undertale-fonts/webfonts/determinationmonoweb-webfont.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    letter-spacing: -1px; /* Makes the letters closer together */
}

@font-face {
    font-family: 'Undertale Sans';
    src: url('https://cartr.gitlab.io/undertale-fonts/webfonts/sans-webfont.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Undertale Papyrus';
    src: url('https://cartr.gitlab.io/undertale-fonts/webfonts/papyrus-webfont.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    user-select: none; /* Prevents text selection */
}

body {
    background-color: black;
    color: white;
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

body.minimal-ui {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 0;
}

body.minimal-ui .container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    max-width: none;
}

body.minimal-ui .dialogue-box {
    width: inherit;
    min-width: inherit;
    max-width: inherit;
}

body.minimal-ui .controls,
body.minimal-ui .help-button,
body.minimal-ui .music-button {
    display: none;
}

.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    gap: 20px;
}

.dialogue-box {
    border: 4px solid white;
    padding: 20px;
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    border-color: var(--dialogue-outline-color, white);
}

.tab-button {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 12px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid white;
    cursor: pointer;
    z-index: 5;
    font-family: 'DETERMINATION Mono', monospace;
}

.tab-button:hover {
    background-color: #444;
}

body.minimal-ui .tab-button {
    display: block; /* Ensure tab button remains visible in minimal UI mode */
}

.text-content {
    white-space: pre-wrap;
    line-height: 1.5;
    margin-bottom: 10px;
    font-size: 16px;
    word-break: break-word;
    max-width: var(--line-wrap-width, 100%);
    text-align: left; /* Default text alignment */
}

.cursor {
    display: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

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

textarea {
    padding: 10px;
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: white;
    border: 2px solid white;
    resize: vertical;
    min-height: 100px;
}

.buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.font-selector {
    background-color: #222;
    color: white;
    border: 2px solid white;
    padding: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    margin-left: 10px;
}

button {
    padding: 8px 16px;
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #444;
}

label {
    margin-left: 10px;
}

input[type="range"] {
    width: 100px;
}

.size-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.size-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.size-control label {
    font-size: 10px;
    white-space: nowrap;
}

.size-control input {
    width: 80px;
}

.value-display {
    font-size: 10px;
    min-width: 30px;
    text-align: center;
}

.portrait-container {
    display: flex;
    gap: 20px;
    width: 100%;
}

.portrait {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated !important;
}

.audio-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.audio-control label {
    font-size: 10px;
    white-space: nowrap;
}

.wave-effect {
    display: inline-block;
    position: relative;
    animation: wave 2s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(calc(-5px * var(--wave-intensity, 1))); }
}

.shake-effect {
    display: inline-block;
    position: relative;
    animation: shake 0.1s linear infinite;
}

@keyframes shake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(calc(1px * var(--shake-intensity, 1)), calc(1px * var(--shake-intensity, 1))); }
    50% { transform: translate(calc(-1px * var(--shake-intensity, 1)), calc(1px * var(--shake-intensity, 1))); }
    75% { transform: translate(calc(1px * var(--shake-intensity, 1)), calc(-1px * var(--shake-intensity, 1))); }
    100% { transform: translate(calc(-1px * var(--shake-intensity, 1)), calc(-1px * var(--shake-intensity, 1))); }
}

.twitch-effect {
    display: inline-block;
    position: relative;
}

.twitch-effect.active {
    animation: twitch 0.2s ease-in-out;
}

@keyframes twitch {
    0% { transform: translate(0, 0); }
    20% { transform: translate(calc(3px * var(--twitch-intensity, 1)), calc(2px * var(--twitch-intensity, 1))); }
    40% { transform: translate(calc(-2px * var(--twitch-intensity, 1)), calc(-2px * var(--twitch-intensity, 1))); }
    60% { transform: translate(calc(2px * var(--twitch-intensity, 1)), calc(1px * var(--twitch-intensity, 1))); }
    80% { transform: translate(calc(-1px * var(--twitch-intensity, 1)), calc(1px * var(--twitch-intensity, 1))); }
    100% { transform: translate(0, 0); }
}

.icon-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.icon-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#icon-name {
    padding: 5px;
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: white;
    border: 2px solid white;
    font-size: 10px;
}

.icon-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-selector {
    background-color: #222;
    color: white;
    border: 2px solid white;
    padding: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
}

.icon-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    max-height: 120px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #444;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    position: relative;
}

.icon-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border: 1px solid #444;
    background-color: #333;
}

.icon-item span {
    font-size: 8px;
    margin-top: 3px;
    text-align: center;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-sprite-btn {
    margin-top: 3px;
    padding: 2px 5px;
    font-size: 8px;
    font-family: 'DETERMINATION Mono', monospace;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    cursor: pointer;
}

.edit-sprite-btn:hover {
    background-color: #555;
}

.animation-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.animation-tab-btn {
    padding: 8px 16px;
    background-color: #222;
    color: white;
    border: 1px solid #444;
    cursor: pointer;
    font-family: 'DETERMINATION Mono', monospace;
    font-size: 14px;
    transition: background-color 0.2s;
}

.animation-tab-btn:hover {
    background-color: #333;
}

.animation-tab-btn.active {
    background-color: #444;
    border-color: #777;
}

.animation-tab-content {
    display: none;
}

.animation-tab-content.active {
    display: block;
}

.animation-settings {
    margin: 15px 0;
    padding: 10px;
    background-color: #222;
    border: 1px solid #444;
}

.animation-settings label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.loop-count-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}

.loop-count-container input {
    width: 80px;
    padding: 5px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
}

#delete-icon-btn {
    background-color: #552222;
}

#delete-icon-btn:hover {
    background-color: #773333;
}

.sprite-editor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1500;
    overflow: auto;
}

.sprite-editor-content {
    background-color: black;
    margin: 5% auto;
    padding: 20px;
    border: 4px solid white;
    width: 90%;
    max-width: 800px;
    color: white;
    font-family: 'DETERMINATION Mono', monospace;
}

.sprite-editor-content h2, .sprite-editor-content h3 {
    text-align: center;
    margin-bottom: 15px;
}

.frame-count {
    font-size: 0.9em;
    color: #aaa;
    font-weight: normal;
}

.sprite-frames-container {
    margin-bottom: 20px;
    border: 1px solid #444;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.3);
}

.sprite-frames-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    max-height: 250px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid #444;
    background-color: #222;
}

.sprite-frame-item {
    display: flex;
    flex-direction: column;
    width: 120px;
    background-color: #333;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    transition: transform 0.2s;
}

.sprite-frame-item:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.sprite-frame-preview {
    width: 100px;
    height: 100px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid #444;
}

.sprite-frame-info {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    margin-bottom: 5px;
}

.sprite-frame-controls {
    display: flex;
    gap: 5px;
}

.frame-delay-input {
    width: 60px;
    font-size: 10px;
    padding: 2px;
    background-color: #222;
    color: white;
    border: 1px solid #555;
}

.remove-frame-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 12px;
    background-color: #aa3333;
    color: white;
    border: none;
    cursor: pointer;
}

.sprite-editor-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.sprite-input-container {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sprite-timing-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sprite-timing-control input {
    background-color: #222;
    color: white;
    border: 1px solid #555;
    padding: 5px;
}

.sprite-preview-container {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.sprite-preview {
    width: 150px;
    height: 150px;
    border: 2px solid #444;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #222;
}

.sprite-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sprite-editor-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.sprite-editor-buttons button {
    padding: 10px 20px;
    font-family: 'DETERMINATION Mono', monospace;
    font-size: 14px;
    background-color: #222;
    color: white;
    border: 2px solid white;
    cursor: pointer;
}

.sprite-editor-buttons button:hover {
    background-color: #444;
}

#save-sprite-animation-btn {
    background-color: #225522;
}

#save-sprite-animation-btn:hover {
    background-color: #337733;
}

#cancel-sprite-editor-btn {
    background-color: #552222;
}

#cancel-sprite-editor-btn:hover {
    background-color: #773333;
}

.sound-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.sound-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#sound-name {
    padding: 5px;
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: white;
    border: 2px solid white;
    font-size: 10px;
}

.sound-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    max-height: 120px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #444;
}

.sound-item {
    background-color: #333;
    padding: 5px;
    border-radius: 3px;
    min-width: 100px;
}

.sound-item-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
}

.sound-item span {
    font-size: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
}

.play-sound-btn {
    padding: 2px 5px;
    font-size: 8px;
    background-color: #444;
    border: 1px solid #666;
    cursor: pointer;
}

.play-sound-btn:hover {
    background-color: #555;
}

.voice-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.voice-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#voice-name {
    padding: 5px;
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: white;
    border: 2px solid white;
    font-size: 10px;
}

.voice-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-selector {
    background-color: #222;
    color: white;
    border: 2px solid white;
    padding: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
}

.voice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    max-height: 120px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #444;
}

.voice-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    position: relative;
    background-color: #333;
    padding: 8px;
    border-radius: 3px;
}

.voice-item-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.voice-item span {
    font-size: 8px;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.play-voice-btn {
    padding: 2px 5px;
    font-size: 8px;
    background-color: #444;
    border: 1px solid #666;
    cursor: pointer;
}

.play-voice-btn:hover {
    background-color: #555;
}

.export-controls {
    margin-top: 20px;
    border: 2px solid white;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-controls h3 {
    margin-bottom: 10px;
    font-size: 14px;
}

.export-controls .size-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.export-controls select,
.export-controls input[type="number"] {
    background-color: #222;
    color: white;
    border: 2px solid white;
    padding: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
}

#export-progress {
    font-size: 12px;
    color: white;
}

#export-progress-bar {
    width: 100%;
    height: 15px;
    margin-top: 5px;
}

.ui-toggle-button {
    position: absolute;
    top: 10px;
    right: 70px;
    font-size: 20px;
    color: red;
    cursor: pointer;
    z-index: 1000;
}

.color-picker-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border: 1px solid white;
    z-index: 2000;
}

.color-picker-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: white;
}

.color-picker-content button {
    margin-top: 5px;
    width: 100%;
}

.help-button, .music-button {
    position: absolute;
    top: 10px;
    font-size: 20px;
    color: red;
    cursor: pointer;
    z-index: 1000;
}

.help-button {
    right: 10px;
}

.music-button {
    right: 40px;
}

.music-button.muted {
    text-decoration: line-through;
}

.sidebar-controls {
    display: none;
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 8px;
    border: 2px solid white;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.sidebar-btn {
    width: auto;
    min-width: 80px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #222;
    border: 1px solid white;
    color: white;
    font-size: 12px;
    font-family: 'DETERMINATION Mono', monospace;
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0 10px;
}

.sidebar-btn:hover {
    background-color: #444;
}

.sidebar-scale-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 10px;
    border-top: 1px solid #444;
}

.sidebar-scale-control label {
    font-size: 10px;
    color: white;
    font-family: 'DETERMINATION Mono', monospace;
    margin: 0;
}

.sidebar-scale-control input[type="range"] {
    width: 80px;
    height: 20px;
}

.sidebar-scale-value {
    font-size: 10px;
    color: white;
    font-family: 'DETERMINATION Mono', monospace;
}

.text-function-menu {
    position: absolute;
    z-index: 2000;
    background-color: #222;
    border: 2px solid white;
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-family: 'DETERMINATION Mono', monospace;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    min-width: 220px;
    max-width: 280px;
}

.menu-header {
    text-align: center;
    margin-bottom: 8px;
    font-size: 14px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.menu-section {
    margin-bottom: 8px;
}

.menu-btn {
    width: 100%;
    text-align: left;
    padding: 5px;
    background-color: #333;
    border: 1px solid #555;
    color: white;
    cursor: pointer;
    font-family: 'DETERMINATION Mono', monospace;
    transition: background-color 0.2s;
}

.menu-btn:hover {
    background-color: #444;
}

.color-options, .effect-options, .wait-options, .heart-options {
    display: none;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
    width: 100%;
}

.color-btn, .effect-btn, .wait-btn, .heart-btn {
    flex: 1 0 30%;
    padding: 5px;
    border: 1px solid #555;
    color: white;
    cursor: pointer;
    font-family: 'DETERMINATION Mono', monospace;
    font-size: 12px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.7);
}

.color-btn:hover, .effect-btn:hover, .wait-btn:hover, .heart-btn:hover {
    opacity: 0.8;
}

#custom-color-picker, #custom-wait-time, #custom-wforall-time, #custom-heart-color {
    margin-top: 5px;
    width: 100%;
    padding: 3px;
    background-color: #333;
    border: 1px solid #555;
    color: white;
}

.asterisk-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    font-size: 12px;
}

.asterisk-control label {
    margin: 0;
    cursor: pointer;
}

@media (max-width: 600px) {
    .container {
        flex-direction: column; /* Stack items vertically */
        align-items: stretch; /* Ensure full width */
    }

    .portrait-container {
        flex-direction: column; /* Stack portrait and text */
        align-items: center; /* Center the portrait */
    }

    .portrait {
        width: 80px; /* Smaller portrait size on mobile */
        height: 80px;
    }

    .dialogue-box {
        width: 100%; /* Dialogue box takes full width */
        height: auto; /* Adjust height automatically */
    }

    .controls {
        width: 100%; /* Controls take full width */
    }

    .buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    input[type="range"], .font-selector, .size-control, .audio-control, .icon-control, .sound-control {
        width: 100%;
        margin-left: 0;
        margin-top: 10px;
    }

    .size-controls {
        flex-direction: column; /* Stack size controls */
    }
    
    .size-control {
        width: 100%; /* Ensure each control takes full width */
        flex-direction: column; /* Stack label and input */
        align-items: flex-start; /* Align to the start */
    }

    .value-display {
        text-align: left; /* Align value display to the left */
        margin-left: 0;
    }

    textarea {
        width: 100%; /* Textarea takes full width */
    }
}