/*
 * TURCLON - 16-Bit Neo-Geo Arcade Stylesheet
 * Responsive canvas, arcade bezel, overlays, touch controls, language selector & security gate.
 */

:root {
    --cyber-blue: #00e5ff;
    --neon-green: #39ff14;
    --neo-yellow: #ffe600;
    --hot-pink: #ff007f;
    --danger-red: #ff1744;
    --dark-bg: #070913;
    --bezel-color: #121624;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--dark-bg);
    font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Container principale del gioco */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #171d33 0%, #060810 100%);
}

/* Canvas con pixel art senza sfocature */
#game-canvas {
    display: block;
    background-color: #000;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.25), 0 0 10px rgba(0, 0, 0, 0.8);
    border: 2px solid #232b42;
    border-radius: 4px;
}

/* Effetto Scanlines CRT */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 5;
    opacity: 0.6;
}

/* -------------------------------------------------------------
   SELETTORE LINGUA (EN / IT / JA)
   ------------------------------------------------------------- */
.lang-selector {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    gap: 6px;
    z-index: 50;
    background: rgba(10, 15, 28, 0.85);
    border: 1px solid var(--cyber-blue);
    padding: 4px 8px;
    border-radius: 20px;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
    backdrop-filter: blur(4px);
}

.lang-btn {
    background: transparent;
    border: none;
    color: #8da4d0;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: #ffffff;
    text-shadow: 0 0 6px var(--cyber-blue);
}

.lang-btn.active {
    background: var(--cyber-blue);
    color: #000;
    box-shadow: 0 0 10px var(--cyber-blue);
}

/* -------------------------------------------------------------
   PASSWORD / SECURITY CLEARANCE GATE
   ------------------------------------------------------------- */
#security-gate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #04060f;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    color: #fff;
    padding: 20px;
    text-align: center;
    transition: opacity 0.4s ease;
}

#security-gate.fade-out {
    opacity: 0;
    pointer-events: none;
}

#security-gate.hidden {
    display: none !important;
}

.terminal-box {
    background: rgba(14, 20, 36, 0.95);
    border: 2px solid var(--cyber-blue);
    border-radius: 8px;
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 0 35px rgba(0, 229, 255, 0.3), inset 0 0 20px rgba(0, 229, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.terminal-title {
    color: var(--cyber-blue);
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--cyber-blue);
}

.terminal-sub {
    color: var(--neo-yellow);
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.gate-input {
    background: #060914;
    border: 2px solid var(--cyber-blue);
    color: var(--neon-green);
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 10px 14px;
    border-radius: 4px;
    text-align: center;
    letter-spacing: 3px;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gate-input:focus {
    border-color: var(--neo-yellow);
    box-shadow: 0 0 16px rgba(255, 230, 0, 0.4);
}

.gate-input.error {
    border-color: var(--danger-red);
    color: var(--danger-red);
    box-shadow: 0 0 20px var(--danger-red);
    animation: shake 0.35s ease-in-out;
}

.gate-input.success {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.gate-error-msg {
    font-size: 0.8rem;
    min-height: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--danger-red);
}

/* -------------------------------------------------------------
   OVERLAYS: START, GAME OVER, LEVEL CLEAR
   ------------------------------------------------------------- */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 15, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    z-index: 20;
    text-align: center;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    padding: 16px;
}

.overlay.hidden {
    display: none !important;
}

/* LOGO IMMAGINE UFFICIALE TURCLON CON EFFETTO SHIMMER */
.title-logo-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
    margin-bottom: 6px;
}

.title-logo {
    max-width: min(420px, 82vw);
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 0 14px rgba(255, 113, 206, 0.7)) drop-shadow(0 0 28px rgba(0, 229, 255, 0.45));
    user-select: none;
    pointer-events: none;
    display: block;
    animation: logoFloat 3s ease-in-out infinite alternate;
}

/* Riflesso di luce cromata periodico che attraversa il logo TURCLON */
.title-logo-wrapper::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -80%;
    width: 35%;
    height: 200%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(25deg);
    pointer-events: none;
    animation: chromeSweep 4s ease-in-out infinite;
}

@keyframes chromeSweep {
    0%, 65% { left: -80%; }
    100% { left: 150%; }
}

@keyframes logoFloat {
    0% { transform: translateY(0px) scale(1); }
    100% { transform: translateY(-3px) scale(1.015); }
}

.title-glow {
    font-size: clamp(1.4rem, 4vw, 2.8rem);
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--cyber-blue);
    text-shadow: 0 0 10px var(--cyber-blue), 0 0 20px var(--cyber-blue);
    margin-bottom: 8px;
}

.subtitle {
    font-size: clamp(0.55rem, 1.3vw, 0.75rem);
    color: var(--neo-yellow);
    letter-spacing: 2px;
    margin-bottom: 16px;
    text-shadow: 0 0 8px rgba(255, 230, 0, 0.5);
}

/* ARCADE MENU SYSTEM */
.arcade-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 8px 0 14px 0;
    width: 100%;
    max-width: 440px;
}

.btn-arcade {
    padding: 10px 24px;
    font-size: 0.8rem;
    font-weight: bold;
    font-family: inherit;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #ff007f 0%, #b30059 100%);
    border: 2px solid #ff71ce;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.5);
    transition: transform 0.1s, box-shadow 0.1s;
    user-select: none;
}

.btn-arcade:hover, .btn-arcade:active {
    transform: scale(1.04);
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.8);
}

.btn-menu-start {
    width: 100%;
    padding: 12px 20px;
    font-size: 0.85rem;
    letter-spacing: 2px;
    background: linear-gradient(180deg, #ff007f 0%, #99004d 100%);
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.btn-menu-start:hover {
    box-shadow: 0 0 30px rgba(255, 0, 127, 0.9), inset 0 0 12px rgba(255, 255, 255, 0.6);
}

.menu-sub-row {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.btn-menu-sub {
    flex: 1;
    padding: 9px 6px;
    font-size: 0.55rem;
    letter-spacing: 1px;
    background: linear-gradient(180deg, #18253f 0%, #0d1524 100%);
    border: 1.5px solid #2d426d;
    color: #a3bde8;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-menu-sub:hover {
    border-color: var(--cyber-blue);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(180deg, #1c2b48 0%, #0e1728 100%);
    border-color: var(--cyber-blue);
    margin-top: 10px;
}

/* ARCADE FOOTER */
.arcade-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.arcade-coin-prompt {
    font-size: 0.58rem;
    color: var(--neo-yellow);
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(255, 230, 0, 0.7);
    animation: blinkAnim 1.2s infinite;
}

.credits-small {
    font-size: 0.5rem;
    color: #61759b;
    letter-spacing: 1px;
}

/* MANUAL / HOW TO PLAY MODAL */
.manual-box {
    max-width: 480px;
    border-color: var(--cyber-blue);
    background: rgba(8, 12, 24, 0.96);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.35);
}

.manual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #1e2c4a;
    padding-bottom: 8px;
    width: 100%;
}

.manual-body {
    text-align: left;
    max-height: 52vh;
    overflow-y: auto;
    font-size: 0.58rem;
    line-height: 1.8;
    background: rgba(14, 20, 36, 0.85);
    margin: 8px 0;
    padding: 12px 16px;
    width: 100%;
    box-sizing: border-box;
}

.manual-section-header {
    color: var(--neo-yellow);
    margin: 4px 0;
    font-size: 0.62rem;
}

.manual-divider {
    border-top: 1px dashed #283a60;
    margin: 8px 0;
}

.instructions {
    background: rgba(26, 34, 56, 0.7);
    border: 1px solid var(--cyber-blue);
    border-radius: 6px;
    padding: 12px 18px;
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    line-height: 1.6;
    max-width: 520px;
    color: #d1dcfa;
    box-shadow: inset 0 0 15px rgba(0, 229, 255, 0.1);
}

.blink {
    animation: blinkAnim 1s infinite;
}

@keyframes blinkAnim {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.2; }
}

/* -------------------------------------------------------------
   CONTROLLI TOUCH (MOBILE D-PAD & PULSANTI A/B)
   ------------------------------------------------------------- */
#touch-controls {
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 30;
}

#touch-controls.hidden {
    display: none;
}

.touch-cluster {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.touch-dpad {
    display: flex;
    align-items: center;
    gap: 8px;
}

.touch-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(22, 28, 48, 0.7);
    border: 2px solid var(--cyber-blue);
    color: #fff;
    font-family: inherit;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
    touch-action: manipulation;
    cursor: pointer;
}

.touch-btn:active, .touch-btn.active {
    background: var(--cyber-blue);
    color: #000;
    box-shadow: 0 0 20px var(--cyber-blue);
    transform: scale(0.92);
}

.touch-btn.btn-action-a {
    border-color: var(--neo-yellow);
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.3);
}

.touch-btn.btn-action-a:active, .touch-btn.btn-action-a.active {
    background: var(--neo-yellow);
    color: #000;
    box-shadow: 0 0 20px var(--neo-yellow);
}

.touch-btn.btn-action-b {
    border-color: var(--hot-pink);
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
}

.touch-btn.btn-action-b:active, .touch-btn.btn-action-b.active {
    background: var(--hot-pink);
    color: #fff;
    box-shadow: 0 0 20px var(--hot-pink);
}

/* Avviso per dispositivi mobili tenuti in Portrait */
#portrait-warning {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #060810;
    z-index: 999;
    color: var(--neo-yellow);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#portrait-warning span {
    font-size: 3rem;
    margin-bottom: 12px;
}

@media screen and (orientation: portrait) and (max-width: 768px) {
    #portrait-warning {
        display: flex;
    }
}

/* Crediti a pié di pagina */
.credits-small {
    font-size: 0.75rem;
    color: #8da4d0;
    letter-spacing: 1.5px;
    margin-top: 18px;
    opacity: 0.85;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.35);
    font-weight: bold;
}
