@font-face {
    font-family: 'Press Start 2P';
    src: url('2P/PressStart2P-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ===============================
   RESET & BASE
=============================== */
body {
    margin: 0;
    overflow: hidden;
    background: #000;
    font-family: Arial, sans-serif;
}

#game {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* ===============================
   MODAL POI
=============================== */
#modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9000;
}

#modal-content {
    background: white;
    padding: clamp(12px, 3vw, 24px);
    width: fit-content;
    max-width: 90vw;
    max-height: 85vh;
    overflow: auto;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255,255,255,0.3);
    font-size: clamp(14px, 1.8vw, 18px);
    box-sizing: border-box;
}

#modal-content h2 {
    font-size: clamp(16px, 2.6vw, 26px);
    line-height: 1.4;
    margin-top: 0;
}

#modal-content img,
#modal-content video {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-top: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#modal-content audio {
    max-width: 100%;
    margin-top: 10px;
}

/* ===============================
   START SCREEN
=============================== */
#start-screen {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#start-content {
    text-align: center;
    color: white;
    font-size: 22px;
    animation: fadeIn 0.8s ease-out;
}

/* Pulsante START che pulsa */
#start-button {
    width: 240px;
    cursor: pointer;
    margin-bottom: 20px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}


/* Freccia accanto al pulsante START */
#start-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

#start-arrow {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

/* ===============================
   FRECCE (D‑Pad stile videogame)
=============================== */
#arrows {
    display: inline-block;
    margin-top: 10px;
}

#arrows .row {
    display: flex;
    justify-content: center;
}

.arrow {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    margin: 4px;
}

/* Animazione fade-in */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===============================
   CONTROLLI TOUCH (mobile)
=============================== */
#touch-controls {
    display: none;
    position: fixed;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: clamp(130px, 34vw, 190px);
    height: clamp(130px, 34vw, 190px);
    z-index: 9500;
    touch-action: none;
}

#touch-controls.visible {
    display: block;
}

.touch-btn {
    position: absolute;
    width: 32%;
    height: 32%;
    border-radius: 12px;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.5);
    color: #fff;
    font-size: clamp(18px, 4vw, 26px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.touch-btn:active {
    background: rgba(255,255,255,0.4);
}

.touch-up    { top: 0;    left: 34%; }
.touch-left  { top: 34%;  left: 0; }
.touch-down  { top: 68%;  left: 34%; }
.touch-right { top: 34%;  right: 0; }

/* ===============================
   PULSANTE ESC (esce dal fullscreen, mobile)
=============================== */
#btn-esc {
    display: none;
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 9500;
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2.5vw, 16px);
    border-radius: 8px;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.5);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: clamp(11px, 2.5vw, 14px);
    font-weight: bold;
    letter-spacing: 1px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#btn-esc.visible {
    display: block;
}

#btn-esc:active {
    background: rgba(255,255,255,0.3);
}
