* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 1280px;
    /* Maximum size limits */
    aspect-ratio: 16 / 9;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* Mira personalizada. Usa un archivo aparte de 32x32: el cursor CSS no
       se reescala, así que la imagen de 128x128 usada en el HUD del canvas
       se vería como un icono gigante si se reutilizara aquí tal cual. */
    cursor: url('../Image/crosshair-cursor.png') 16 16, crosshair;
}

#game-container.vertical-mode {
    /* JavaScript controlará dinámicamente el aspect ratio y el escalado
       para evitar desbordamiento vertical. Se quitan limitaciones fuertes nativas. */
    width: auto;
    height: 100%;
}

#game-canvas {
    background-color: #000000;
    width: 100%;
    height: 100%;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-family: sans-serif;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
    z-index: 10;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #00ffaa rgba(0,0,0,0.5);
}

/* Level Editor Palette */
#editor-palette {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 80px;
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid #00ffaa;
    padding: 10px;
    border-radius: 10px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.2);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Hide scrollbar for palette unless needed */
}

#editor-palette::-webkit-scrollbar {
    width: 0; /* No visible scrollbar for small palette but scrollable */
}

.palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: grab;
    transition: transform 0.2s;
}

.palette-item:hover {
    transform: scale(1.1);
}

.palette-item.active-tool {
    border: 2px solid #00ffaa;
    background: rgba(0, 255, 170, 0.1);
    border-radius: 8px;
    padding: 5px;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.5);
}

.palette-item span {
    font-size: 10px;
    color: #eee;
    font-weight: bold;
}

.icon {
    width: 40px;
    height: 40px;
    border: 2px solid #fff;
    background: #555;
}

.rect-icon {
    /* Standard rectangle with Rock image */
    background-image: url('../Image/Rock.png');
    background-size: cover;
    background-position: center;
}

.arc-icon {
    border-top-left-radius: 100%;
    background: radial-gradient(circle at 100% 100%, #666 0%, #666 70%, #fff 71%, #fff 100%);
}

.hexagon-icon {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.health-icon {
    background-color: #fff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.health-icon::after {
    content: '+';
    color: red;
    font-size: 30px;
    font-weight: bold;
}

.goal-icon {
    background-color: #ffd700;
    clip-path: polygon(10% 10%, 90% 10%, 90% 40%, 50% 70%, 10% 40%);
}

.spawn-icon {
    width: 24px;
    height: 24px;
    background: #00ffaa;
    border-radius: 50%;
    border: 2px solid white;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    color: #000;
}

.spawn-icon::after {
    content: '⚡';
}

.enemy-icon {
    background-color: #666; /* Shoulders */
    border: 2px solid #000;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.enemy-icon::before {
    content: '';
    width: 50%;
    height: 50%;
    background-color: #999; /* Head */
    border: 1px solid #000;
    border-radius: 4px; /* Rounded corners */
    z-index: 2;
}

.enemy-icon::after {
    content: '';
    width: 4px;
    height: 100%;
    background-color: #222; /* Rifle */
    border: 1px solid #000;
    position: absolute;
    top: -10px; /* Extends beyond the shoulders */
    z-index: 1;
}

.eraser-icon {
    background: linear-gradient(135deg, #ff44aa 0%, #ff44aa 50%, #ffffff 51%, #ffffff 100%);
    border-radius: 4px;
    border: 2px solid #fff;
}

/* Canvas Cursor override */
#game-canvas.eraser-active {
    cursor: none;
}

#ui-layer label {
    margin-right: 10px;
}

#ui-layer input[type="number"] {
    width: 60px;
    padding: 5px;
    background: #222;
    color: #0f0;
    border: 1px solid #0f0;
    border-radius: 3px;
    font-weight: bold;
}

#ui-layer input[type="checkbox"] {
    transform: scale(1.5);
    cursor: pointer;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

#replay-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px #00ffaa;
}

/* Custom Neon Scrollbar for UI Layer */
#ui-layer::-webkit-scrollbar {
    width: 6px;
}

#ui-layer::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

#ui-layer::-webkit-scrollbar-thumb {
    background: #00ffaa;
    border-radius: 10px;
    box-shadow: 0 0 5px #00ffaa;
}

#ui-layer::-webkit-scrollbar-thumb:hover {
    background: #00cc88;
}

/* Reset Zoom Button Styling */
#reset-zoom {
    width: 100%;
    margin-top: 5px;
    padding: 8px;
    background: transparent;
    border: 1px solid #00aaff;
    color: #00aaff;
    font-weight: bold;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#reset-zoom:hover {
    background: rgba(0, 170, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.4);
    border-color: #00eeff;
    color: #00eeff;
}

/* --- Notification Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #111 100%);
    border: 1px solid #00ffaa;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    padding: 30px;
    box-shadow: 0 0 30px rgba(0, 255, 170, 0.15);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.modal-header {
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

.modal-header h2 {
    color: #00ffaa;
    margin: 0;
    font-size: 1.8em;
    letter-spacing: 1px;
}

.version-tag {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.9em;
    color: #888;
    background: #222;
    padding: 2px 8px;
    border-radius: 4px;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #00ffaa #222;
}

.modal-body section {
    margin-bottom: 20px;
}

.modal-body h3 {
    color: #ffaa00;
    font-size: 1.1em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body ul {
    list-style: none;
    padding-left: 5px;
}

.modal-body li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 20px;
    color: #ccc;
    line-height: 1.4;
}

.modal-body li::before {
    content: '▹';
    position: absolute;
    left: 0;
    color: #00ffaa;
}

.modal-footer {
    margin-top: 25px;
    display: flex;
    justify-content: center;
}

.primary-btn {
    background: #00ffaa;
    color: black;
    border: none;
    padding: 12px 40px;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.3);
}

.primary-btn:hover {
    background: #00dd99;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 255, 170, 0.5);
}

.modal-overlay.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Scrollbar for modal */
.modal-body::-webkit-scrollbar {
    width: 5px;
}

.modal-body::-webkit-scrollbar-track {
    background: #222;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #00ffaa;
    border-radius: 10px;
}

/* ==============================
   Game Over & Victory Overlays
   ============================== */
#game-over-overlay,
#victory-overlay,
#pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: overlayFadeIn 0.4s ease-out;
}

#pause-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

#game-over-overlay {
    background: rgba(80, 0, 0, 0.85);
}

#victory-overlay {
    background: rgba(0, 50, 0, 0.85);
}

.overlay-content {
    text-align: center;
    animation: overlayContentPop 0.5s ease-out;
}

.overlay-title {
    font-family: sans-serif;
    font-size: 4em;
    margin-bottom: 20px;
    letter-spacing: 4px;
}

.game-over-title {
    color: #ff4444;
    text-shadow: 0 0 30px rgba(255, 0, 0, 0.6), 0 0 60px rgba(255, 0, 0, 0.3);
}

.victory-title {
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
}

.pause-title {
    color: #ffffff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.6), 0 0 60px rgba(255, 255, 255, 0.3);
}

.overlay-subtitle {
    color: #ccc;
    font-family: sans-serif;
    font-size: 1.2em;
    margin-bottom: 30px;
}

.overlay-btn {
    border: none;
    padding: 15px 50px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.5em;
    transition: transform 0.2s, box-shadow 0.2s;
}

.overlay-btn:hover {
    transform: scale(1.08);
}

.game-over-btn {
    background: #ff4444;
    color: white;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.game-over-btn:hover {
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.8);
}

.victory-btn {
    background: #ffd700;
    color: black;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.victory-btn:hover {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
}

.pause-btn {
    background: #00ffaa;
    color: black;
    box-shadow: 0 0 20px rgba(0, 255, 170, 0.5);
}

.pause-btn:hover {
    box-shadow: 0 0 30px rgba(0, 255, 170, 0.8);
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes overlayContentPop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}


/* ==================================================================
   Añadidos: paleta ampliada, botonera unificada y panel de resultados
   ================================================================== */

/* -- Paleta -- */
.palette-hint {
    font-size: 9px;
    color: #888;
    text-align: center;
    line-height: 1.3;
    margin: -8px 0 0 0;
}

.palette-item {
    position: relative;
}

.palette-item kbd {
    position: absolute;
    top: -4px;
    right: -6px;
    background: #00ffaa;
    color: #000;
    font-size: 9px;
    font-weight: bold;
    font-family: monospace;
    border-radius: 3px;
    padding: 0 3px;
    line-height: 12px;
    pointer-events: none;
}

.ammo-icon {
    background: #3a3a2a;
    border: 2px solid #ffcc00;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ammo-icon::after {
    content: '';
    width: 70%;
    height: 30%;
    background: #ffcc00;
}

/* El panel de la paleta se atenúa mientras se juega */
#editor-palette.disabled-panel {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.6);
}

/* -- Controles del panel lateral -- */
#ui-layer hr {
    border: 0;
    border-top: 1px solid #444;
    margin: 15px 0;
}

.full-input {
    width: 100%;
    padding: 5px;
    background: #222;
    color: #0f0;
    border: 1px solid #0f0;
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
}

select.full-input {
    background: #333;
    color: #fff;
    border-color: #555;
}

#ui-layer input[type="text"].full-input {
    color: #eee;
    border-color: #555;
}

.panel-hint {
    font-size: 0.8em;
    color: #888;
    margin-top: 5px;
}

/* Botones del panel: una sola base con variantes de color */
#ui-layer button {
    width: 100%;
    border: none;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    font-family: inherit;
    transition: filter 0.15s, transform 0.15s;
}

#ui-layer button:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

#ui-layer button:active {
    transform: translateY(0);
}

.main-btn    { background: #00ffaa; color: #000; padding: 10px !important; font-size: 1.1em !important; }
.accent-btn  { background: #00ffaa; color: #000; }
.info-btn    { background: #00aaff; color: #000; }
.magenta-btn { background: #ff00ff; color: #fff; }
.warn-btn    { background: #ffaa00; color: #000; }
.danger-btn  { background: #ff4444; color: #fff; }

.outline-btn {
    background: #333;
    color: #00ffaa;
    border: 1px solid #00ffaa !important;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

/* -- Panel de resultados de fin de partida -- */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 16px 24px;
    margin: 0 auto 24px auto;
    max-width: 320px;
    font-family: monospace;
    font-size: 1.05em;
    color: #ddd;
    text-align: left;
}

.results-panel b {
    color: #fff;
    float: right;
    margin-left: 20px;
}

.overlay-content {
    max-width: 90vw;
}

/* Los botones de overlay son grandes; en pantallas bajas conviene reducirlos */
@media (max-height: 700px) {
    .overlay-title { font-size: 2.6em; margin-bottom: 12px; }
    .overlay-subtitle { margin-bottom: 16px; }
    .overlay-btn { padding: 10px 30px; font-size: 1.15em; }
    .results-panel { padding: 10px 18px; font-size: 0.95em; margin-bottom: 16px; }
}

/* -- Cursor -- */
/* En modo juego la mira se dibuja en el propio lienzo, así que se oculta
   el cursor del sistema para no ver dos miras a la vez. */
#game-canvas.hide-cursor {
    cursor: none;
}

/* ==================================================================
   Versión móvil (jugar.html): pantalla completa, sin editor
   ================================================================== */
body.mobile-play {
    background: #000;
    /* Evita el rebote/pull-to-refresh del navegador al arrastrar los sticks */
    overscroll-behavior: none;
    touch-action: none;
}

body.mobile-play #game-container {
    /* En vertical (fijado desde JS) el propio motor centra el lienzo */
    cursor: default;
}

/* Evita que un toque largo dispare el menú contextual o la selección de
   texto de iOS/Android mientras se manejan los sticks */
#touch-controls,
#touch-controls * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#touch-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    pointer-events: none; /* el lienzo de abajo sigue recibiendo los toques */
}

/* Pista visual fija: dónde apoyar el pulgar antes de tocar */
.touch-hint {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 170, 0.35);
    background: rgba(0, 255, 170, 0.08);
    bottom: 8%;
    transition: opacity 0.15s;
}

#touch-hint-move { left: 6%; }
#touch-hint-aim  { right: 6%; }

/* Stick "en vivo": aparece centrado donde se apoya el dedo */
.touch-stick-base {
    position: absolute;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(0, 255, 170, 0.12);
    border: 2px solid rgba(0, 255, 170, 0.5);
    pointer-events: none;
}

.touch-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: rgba(0, 255, 170, 0.55);
    border: 2px solid #00ffaa;
    box-shadow: 0 0 12px rgba(0, 255, 170, 0.6);
    /* transform la actualiza JS en cada movimiento del dedo */
}

#touch-dash-btn,
#touch-pause-btn {
    position: absolute;
    border-radius: 50%;
    border: 2px solid #00ffaa;
    background: rgba(0, 0, 0, 0.5);
    color: #00ffaa;
    font-size: 1.6em;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

#touch-dash-btn {
    width: 64px;
    height: 64px;
    right: 8%;
    bottom: 28%;
}

#touch-pause-btn {
    width: 46px;
    height: 46px;
    font-size: 1.1em;
    top: 12px;
    right: 12px;
}
