body {
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
#errorPrinter {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 640px;
    height: 100px;
    transform: translate(-50%, -50%);
    text-align: center;
    text-shadow: 1px 1px 3px #000;
    font-size: 20px;
    color: #fff;
    z-index: 9;
}
#errorName {
    color: #ff0;
    font-weight: bold;
    -moz-user-select: text;
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
#errorMessage {
    color: #fff;
    -moz-user-select: text;
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
#retryButton {
    font-size: 20px;
    color: #fff;
    background-color: #000;
    border-radius: 8px;
    margin: 20px;
    padding: 10px;
}
#fpsCounterBox {
    position: absolute;
    left: 5px;
    top: 5px;
    width: 90px;
    height: 40px;
    background: #222;
    opacity: 0.8;
    z-index: 8;
}
#fpsCounterLabel {
    position: absolute;
    top: 0px;
    left: 0px;
    padding: 5px 10px;
    height: 30px;
    line-height: 32px;
    font-size: 12px;
    font-family: rmmz-numberfont, sans-serif;
    color: #fff;
    text-align: left;
}
#fpsCounterNumber {
    position: absolute;
    top: 0px;
    right: 0px;
    padding: 5px 10px;
    height: 30px;
    line-height: 30px;
    font-size: 24px;
    font-family: rmmz-numberfont, monospace;
    color: #fff;
    text-align: right;
}
#loadingSpinner {
    margin: auto;
    position: absolute;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    width: 120px;
    height: 120px;
    z-index: 10;
}
#loadingSpinnerImage {
    margin: 0px;
    padding: 0px;
    border-radius: 50%;
    width: 96px;
    height: 96px;
    border: 12px solid rgba(255, 255, 255, 0.25);
    border-top: 12px solid rgba(255, 255, 255, 1);
    animation: fadein 2s ease, spin 1.5s linear infinite;
}
@keyframes fadein {
    0% {
        opacity: 0;
    }
    20% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* UI */
#credits {
    position: fixed;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10000 !important;
    pointer-events: none;
}

#credits img,
#credits button,
#credits a {
    pointer-events: auto;
    transition: transform 0.15s ease, filter 0.15s ease;
}

#credits img:hover,
#credits button:hover,
#credits a:hover {
    transform: scale(0.85) !important; /* Se hace más pequeño */
    filter: brightness(1.2);
}

.img-button {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.img-button img {
    display: block;
    max-height: 48px;
    width: auto;
}

.img-button:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.img-button:active {
    transform: scale(0.95);
}

#fullscreen-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.15s ease;
}

#fullscreen-btn:hover {
    opacity: 0.9;
}

/* Hide fullscreen button */
:fullscreen #credits,
:-webkit-full-screen #game-controls {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

canvas {
    max-height: 100vh !important;
    max-width: 100vw !important;
    object-fit: contain;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    width: auto !important;
    height: 100vh !important;
}

/* Language selection screen */
.lang-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lang-box {
    text-align: center;
    color: #ffffff;
    font-family: sans-serif;
    max-width: 90vw;
    padding: 0 20px;
    box-sizing: border-box;
}

.game-description {
    color: #888888;
    font-family: GameFont, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    font-weight: normal;
    max-width: 45vw;
    margin: 14px auto 0;
    letter-spacing: 0.2px;
    opacity: 0.85;
}

@media (max-width: 600px) {
    .game-description {
        font-size: 12px;
        line-height: 1.6;
        max-width: 90vw;
        margin-top: 10px;
    }
}

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

#credits {
    position: fixed;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10000 !important;
}

/* Mobile controls */
#touch-controls-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 8000;
}

#editOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    z-index: 8100;
}

/* Edit buttons */
#btnEdit {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    opacity: 0.3;
    cursor: pointer;
    pointer-events: auto;
    z-index: 8500;
}

/* D-Pad */
.touch-btn {
    position: absolute;
    touch-action: none;
    user-select: none;
    pointer-events: auto;
    width: 70px;
    height: auto;
    object-fit: contain;
    z-index: 8200;
    transition: filter 0.1s ease, opacity 0.1s ease;
}

.touch-btn:hover {
    filter: brightness(1.3);
    cursor: pointer;
}

.touch-btn:active,
.touch-btn.btn-pressed {
    filter: brightness(1.6);
    transform: scale(0.95) !important;
}

#dpad_up    { bottom: 130px; left: 80px; }
#dpad_down  { bottom: 30px;  left: 80px; }
#dpad_left  { bottom: 80px;  left: 30px; }
#dpad_right { bottom: 80px;  left: 130px; }

#btnZ       { bottom: 48px;  right: 50px; width: 80px; }
#btnX       { bottom: 24px;  right: 140px; width: 80px; }

.edit-panel {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: white;
    font-family: sans-serif;
    font-size: 12px;
    pointer-events: auto;
    z-index: 8500;
}

.slider-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.btn-group button {
    background: #061021;
    color: #fff;
    border: 1px solid #444;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.edit-mode-active .touch-btn {
    outline: 2px dashed #00ff00;
    cursor: move !important;
    z-index: 8300;
}

.touch-btn.selected-target {
    outline: 2px solid #ffff00 !important;
}

/* Note button */
#note-access-container {
    position: fixed;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    z-index: 9999;
    pointer-events: auto;
}

.note-wrapper {
    position: relative;
    height: 100vh;
    width: 177.78vh;
    max-width: 100vw;
    max-height: 56.25vw;
    display: flex;
    justify-content: center;
    align-items: center;
    container-type: inline-size;
}

#btnNote {
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

#btnNote:hover {
    transform: scale(0.85);
    filter: brightness(1.2);
}

/* Overlay */
.note-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 12000;
    color: white;
    font-family: sans-serif;
}

.note-modal-content {
    background: #111;
    border: 2px solid #444;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#pinInput {
    font-size: 24px;
    text-align: center;
    letter-spacing: 8px;
    width: 120px;
    margin: 0 auto;
    padding: 5px;
}

/* More note-related stuff */
#noteViewerModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 12000;
}

.note-paper-container {
    position: relative;
    width: 95vw;
    max-width: 1400px;
    height: 85vh;
    background: #000000;
    border: none;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    box-sizing: border-box;
    padding: 30px;
    overflow: visible;
    color: #000000;
}

#noteScrollProgress {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background: #ffffff;
    width: 0%;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    transition: width 0.1s ease-out;
    z-index: 12003;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

#btnCloseNote {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: #888888;
    font-size: 64px;
    cursor: pointer;
    z-index: 12002;
    transition: color 0.2s;
}

#btnCloseNote:hover {
    color: #ffffff;
}

#noteScrollArea {
    flex: 0 0 45%;
    max-width: 45%;
    height: 100%;
    overflow-y: auto;
    padding-right: 20px;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#noteScrollArea::-webkit-scrollbar {
    display: none;
}

#noteScrollArea::-webkit-scrollbar-thumb {
    background-color: #444444;
    border-radius: 3px;
}

#noteTextContent {
    font-family: GameFont, sans-serif;
    font-size: 1.35rem;
    line-height: 2.2;
    white-space: pre-wrap;
    word-break: break-word;
    color: #f0f0f0;
}

.note-image-panel {
    flex: 0 0 55%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    pointer-events: none;
    position: relative;
    overflow: visible;
}

#noteImage {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    
    transform: translateX(5%) translateY(25%) scale(1.65); 
    transform-origin: center center;

    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    filter: drop-shadow(0px 15px 25px rgba(0, 0, 0, 0.95));
}

.note-img-trigger {
    display: block;
    height: 1px;
    width: 100%;
}
