:root {
    --background-color: #0a0a0a;
    --text-color: #ffffff;
    --accent-color: #4a9eff;
    --border-color: #333333;
    --canvas-width: 455px;
    --canvas-height: 256px;
    --text-box-color: #fff8e7;
    
    /* Configurable asset paths - cursores desde /ui/ en la raíz de public */
    --cursor-pointer: url(/ui/pointer.png) 16 16, auto;
    --cursor-look: url(/ui/look.png) 16 16, auto;
    --cursor-grab: url(/ui/grab.png) 16 16, auto;
    --cursor-talk: url(/ui/talk.png) 16 16, auto;
    --cursor-walk: url(/ui/walk.png) 16 16, auto;
    --cursor-wait: url(/ui/wait.png) 16 16, auto;
    --cursor-skip: url(/ui/skip.png) 16 16, auto;
    --player-background: url(../assets/background-player.png);
}

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

@font-face {
    font-family: 'FFFlauta';
    src: url('../assets/FFFlauta-100.otf') format('opentype');
}

body {
    background: var(--player-background);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-size: cover;
    background-position-y: center;    
    font-family: 'Geist Mono', monospace;
    cursor: var(--cursor-pointer);

    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: optimizeQuality;
    -ms-interpolation-mode: nearest-neighbor;
}

.game-container {
    position: relative;
    width: calc(var(--canvas-width) * 3);
    height: calc(var(--canvas-height) * 3);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Estilo para pantalla completa - manejado por JavaScript */
.game-container.fullscreen {
    /* Los estilos se aplican dinámicamente desde JavaScript */
}

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    cursor: pointer;
}

.splash-screen.hidden {
    display: none;
}

.splash-content {
    text-align: center;
    animation: fadeIn 1s ease-in-out;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.logo {
    width: 500px;
    height: 200px;
    margin-bottom: 1rem;
}

.splash-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.version {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 2rem;
}

.click-hint {
    font-size: 1rem;
    color: var(--text-color);
    opacity: 0.6;
    animation: pulse 2s infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #3d3d3d;
    overflow: hidden;
}

#canvas-container {
    width: var(--canvas-width);
    height: var(--canvas-height);
    position: relative;
   /*ackground-color: var(--background-color);*/
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    zoom: 3;
    transform-origin: center center;
    overflow: hidden;
    /* Curvatura CRT realista usando border-radius elíptico */
    border-radius: 1px;
}

/* Estilo para pantalla completa - manejado por JavaScript */
#canvas-container.fullscreen {
    /* Los estilos se aplican dinámicamente desde JavaScript */
}

/* Textura RGB overlay para simular TV viejo */
#canvas-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/rgb.png');
    background-size: 30px 3px; /* Más grande para debug */
    background-repeat: repeat;
    opacity: 0.12;
    mix-blend-mode:overlay;
    pointer-events: none;
    z-index: 99999;
    zoom: 0.333333333333333;
    /* Quitar antialiasing */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    
}

.game-element {
    position: absolute;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}

.game-element img {
    position: absolute;
    width: auto;
    height: auto;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#dialog-box {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: none;
    z-index: 10000;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

/* Estilo para diálogos en pantalla completa */
.game-container.fullscreen #dialog-box {
    bottom: 2rem; /* Posicionar desde abajo para mantener posición consistente */
    top: auto; /* Quitar posicionamiento desde arriba */
    font-size: 25px; /* Tamaño de fuente más grande */
}

.game-container.fullscreen #dialog-speaker {
    font-size: 25px; /* Tamaño de fuente más grande */
}

.game-container.fullscreen #dialog-text {
    font-size: 25px; /* Tamaño de fuente más grande */
}

#dialog-box.active {
    display: block;
}

#dialog-speaker {
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

#dialog-text {
    line-height: 1.5;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

.text-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-family: 'FFFlauta';
    color: var(--text-box-color);
    z-index: 99999 !important;
    text-transform: uppercase;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

.text-box p {
    margin: 0;
    font-size: 20px;
    line-height: 1.4;
    text-shadow: 
        -2px -2px 1px #000,
        2px -2px 1px #000,
        -2px 2px 1px #000,
        2px 2px 1px #000;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

/* Clases para diferentes posiciones de diálogo */
.text-box.centered {
    bottom: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.text-box.top {
    bottom: auto !important;
    top: 10px !important;
    transform: translateX(-50%) !important;
}

.text-box.bottom {
    bottom: 10px !important;
    top: auto !important;
    transform: translateX(-50%) !important;
}

.text-box p {
    margin: 0;
    font-size: 20px;
    line-height: 1.4;
    text-shadow: 
        -2px -2px 1px #000,
        2px -2px 1px #000,
        -2px 2px 1px #000,
        2px 2px 1px #000;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
}

/* Estilo para tooltips en pantalla completa */
.game-container.fullscreen .text-box {
    bottom: 10px;
}

.game-container.fullscreen .text-box p {
    font-size: 25px; /* Tamaño de fuente más grande */
}

/* Estilos para diferentes posiciones de diálogo en pantalla completa */
.game-container.fullscreen .text-box.centered {
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.game-container.fullscreen .text-box.top {
    top: 10px !important;
    transform: translateX(-50%) !important;
}

.game-container.fullscreen .text-box.bottom {
    bottom: 10px !important;
    top: auto !important;
    transform: translateX(-50%) !important;
}

.fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: black;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.5s ease-in-out;
}

.fade-overlay.active {
    opacity: 1;
}



/*-------------DEBUG---------------*/

.debugButton {
    z-index: 1000;
    cursor: var(--cursor-pointer);
    color: #fff;
    font-size: 14px;
    background-color: transparent;
    padding: 1px;
    border-radius: 3px;
    border: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    display: inline-block;
}

.debugButton:hover {
    opacity: 1;
}

.fullscreenButton {display: inline-block;
    z-index: 1000;
    cursor: var(--cursor-pointer);
    color: #fff;
    font-size: 14px;
    background-color: transparent;
    padding: 1px;
    border-radius: 3px;
    border: none;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.fullscreenButton:hover {
    opacity: 1;
}

.fullscreenButton.fullscreen {
    color: #FFF;
    opacity: 1;
}

/* Información de versión y controles */
.game-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 99999;
    color: #fff;
    font-size: 10px;
    opacity: 0.6;
    font-family: 'Courier New', monospace;
    line-height: 1.2;
    cursor: var(--cursor-pointer);
    display: inline-block;
}

.game-info .version {
    margin-bottom: 2px;
}

.game-info .controls {
    font-size: 9px;
    opacity: 0.8;
}



/*-------------INVENTORY---------------*/

.game-inventory {
    position: absolute;
    bottom: 20px;
    right: 20px;
    cursor: var(--cursor-pointer);
    z-index: 1000;
}


.game-inventory-item {
    width: 16px;
    height: 16px;
    zoom: 3;
    cursor: var(--cursor-look);
}

/* Zoom específico para inventario en fullscreen */
.game-container.fullscreen .game-inventory-item {
    zoom: 4.219780219780224;
}

/*-------------LOADING SCREEN---------------*/

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    color: #FFA500;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.2;
    display: none;
    z-index: 9999;
    overflow: hidden;
}

.loading-screen.active {
    display: block;
}

.loading-content {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.loading-header {
    text-align: center;
    margin-bottom: 20px;
}

.loading-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
    text-shadow: 0 0 10px #FFA500;
}

.loading-header p {
    font-size: 12px;
    opacity: 0.8;
}

.loading-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.loading-status {
    flex: 1;
}

.status-line {
    margin-bottom: 8px;
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

.status-line.active {
    opacity: 1;
    transform: translateX(0);
}

.status-line.completed {
    color: #00FF00;
}

.loading-progress {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #333;
    border: 1px solid #FFA500;
    margin-bottom: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #FFA500;
    width: 0%;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px #FFA500;
}

.progress-text {
    text-align: center;
    font-size: 12px;
}

.loading-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.stat-line {
    font-size: 12px;
    opacity: 0.8;
}

.stat-value {
    color: #00FF00;
    font-weight: bold;
}

.loading-footer {
    text-align: center;
    margin-top: 20px;
    animation: blink 1s infinite;
}

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

/* Efecto de scanlines para más nostalgia */
.loading-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 165, 0, 0.03) 2px,
        rgba(255, 165, 0, 0.03) 4px
    );
    pointer-events: none;
}

#ascii-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 4px;
    padding: 20px;
    
    line-height: 0.6px;
    font-weight: bold;
    letter-spacing: 0.6px;

    z-index: 9999;
    display: none;
    white-space: pre;
    overflow: hidden;
}

/* Textura RGB overlay para el loader MS-DOS */
.ascii-rgb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../assets/rgb.png');
    background-size: 30px 3px;
    background-repeat: repeat;
    opacity: 0.3; /* Aumentado de 0.12 a 0.3 para ser más visible */
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 100000;
    /* Quitar antialiasing */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    /* Debug: agregar un borde temporal para ver si se está creando */
    border: 2px solid red;
}

.ascii-title {
    font-family: 'Courier New', monospace;
    font-size: 4px;
    margin-bottom: 20px;
    text-transform: none;
}

.status-line {
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.loader-status {
    font-family: 'FFFlauta', monospace;
    font-size: 14px;
}

.status-line.active {
    opacity: 1;
}

.status-line.loading::after {
    content: '';
    animation: loadingDots 1.5s forwards;
}

.status-line.processing::after {
    content: '';
    animation: processingBar 2s forwards;
}

.status-line.complete::after {
    content: ' [OK]';
    color: #00ff00;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: '....'; }
}

@keyframes processingBar {
    0% { content: ' [==..................] 0%'; }
    10% { content: ' [====................] 10%'; }
    20% { content: ' [======..............] 20%'; }
    30% { content: ' [========............] 30%'; }
    40% { content: ' [==========..........] 40%'; }
    50% { content: ' [============........] 50%'; }
    60% { content: ' [==============......] 60%'; }
    70% { content: ' [================....] 70%'; }
    80% { content: ' [==================..] 80%'; }
    90% { content: ' [====================] 90%'; }
    100% { content: ' [====================] 100%'; }
}

.dialog-topic-selector {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 0 0;
}
.dialog-topic-btn {
  background: #222;
  color: #fff;
  border: 2px solid #ffeb3b;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 16px;
  cursor: var(--cursor-pointer);
  transition: background 0.2s, color 0.2s;
}
.dialog-topic-btn:hover {
  background: #ffeb3b;
  color: #222;
}

/* Footer para debug log */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 16px;
    font-size: 12px;
    font-family: 'Geist Mono', monospace;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10000;
    border-top: 1px solid #333;
    height: 40px;
}

/* Cuando el footer está visible, empujar todo el contenido hacia arriba */
body.footer-visible {
    padding-bottom: 40px;
}

body.footer-visible .game-container {
    margin-bottom: 40px;
}

body.footer-visible .game-info {
    margin-bottom: 40px;
}

body.footer-visible .text-box {
    margin-bottom: 40px;
}

body.footer-visible .dialog-topic-selector {
    margin-bottom: 40px;
}

.footer span {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 11px;
}

.footer span:last-child {
    margin-right: 0;
}

/* AI Chat Input Styles - Matching dialog styles */
.ai-chat-input-container {
    position: absolute;
    top: 130px;
    height: 55px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 9998 !important;
    width: 512px;
    background-color: rgba(0, 0, 0, 0.9);
    border: 0px solid var(--text-box-color);
    border-radius: 15px;
    padding: 0;
    backdrop-filter: blur(4px);
    text-align: center;
    cursor: default;
}

.ai-chat-drag-handle {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    cursor: grab;
    cursor: -webkit-grab;
    color: rgba(255, 248, 231, 0.5);
    opacity: 0.6;
    transition: opacity 0.2s;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.ai-chat-drag-handle:hover {
    opacity: 1;
    color: rgba(255, 248, 231, 0.8);
}

.ai-chat-drag-handle:active {
    cursor: grabbing;
    cursor: -webkit-grabbing;
    opacity: 1;
}

.ai-chat-input-container.dragging {
    cursor: grabbing;
    cursor: -webkit-grabbing;
}

#ai-chat-input {
    flex: 1;
    padding: 0;
    margin: 4px 10px 4px 40px;
    font-family: 'FFFlauta', monospace;
    font-size: 20px;
    background-color: rgba(255, 248, 231, 0.1);
    border: 3px solid rgba(255, 248, 231, 0.3);
    border-radius: 6px;
    color: var(--text-box-color);
    text-transform: uppercase;
    outline: none;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: none;
    font-smooth: never;
    text-rendering: optimizeSpeed;
    text-shadow: 
        -2px -2px 1px #000,
        2px -2px 1px #000,
        -2px 2px 1px #000,
        2px 2px 1px #000;
    text-align: center;
    height: calc(100% - 8px);
    box-sizing: border-box;
}

#ai-chat-input::placeholder {
    color: rgba(255, 248, 231, 0.5);
    text-transform: none;
    text-shadow: 
        -2px -2px 1px #000,
        2px -2px 1px #000,
        -2px 2px 1px #000,
        2px 2px 1px #000;
}

#ai-chat-input:focus {
    outline: none;
}

.ai-chat-send-btn {
    padding: 8px 12px;
    background-color: transparent;
    border: none;
    color: var(--text-box-color);
    cursor: var(--cursor-pointer);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ai-chat-send-btn:hover {
    opacity: 1;
}

.ai-chat-send-btn:active {
    opacity: 0.6;
}

.game-container.fullscreen .ai-chat-input-container {
    bottom: 20px;
}

.game-container.fullscreen #ai-chat-input {
    font-size: 25px;
}