* {
            box-sizing: border-box;
        }

        html, body{
            margin: 0;
            padding: 0;
            width: 100vw;
            height: 100vh;
            max-width: 100vw;
            max-height: 100vh;
            overflow: hidden;
        }

        body {
            font-family: 'Courier New', monospace;
            background: #000;
            color: #0f0;
            overflow: hidden;
            text-transform: uppercase;
        }

        .screen {
            display: none;
            width: 100vw;
            height: 100vh;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .screen.active {
            display: flex;
        }

        /* BENVENUTO */
        #welcome {
            background: linear-gradient(180deg, #1a0033 0%, #000 100%);
            text-align: center;
        }

        .title {
            font-size: 4rem;
            text-shadow: 0 0 20px #ff00ff, 0 0 40px #ff00ff;
            margin-bottom: 2rem;
            animation: glow 1.5s ease-in-out infinite alternate;
        }
        .text-center{
            text-align: center;
        }

        .font-bold{
            font-weight: bold;
        }

        div.madeby{
            position: absolute;
            width: 100vw;
            bottom: 0;
            left: 0;
            z-index: 1;
            font-size: 1rem;
        }

        @keyframes glow {
            from { text-shadow: 0 0 20px #ff00ff, 0 0 40px #ff00ff; }
            to { text-shadow: 0 0 30px #00ffff, 0 0 60px #00ffff; }
        }

        .btn-start {
            padding: 20px 60px;
            font-size: 2rem;
            background: #ff00ff;
            border: 4px solid #fff;
            color: #fff;
            cursor: pointer;
            text-transform: uppercase;
            font-weight: bold;
            animation: pulse 1s infinite;
        }

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

        .div-navigation{
            display: flex;
            justify-content: space-around;
        }

        /* SELEZIONE KART */
        #kart-select {
            background: linear-gradient(180deg, #003366 0%, #000 100%);
        }

        .kart-grid {
             display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 30px;
            padding: 2rem;
            overflow: auto;
        }

        .kart-option {
            width: 180px;
            height: 180px;
            border: 4px solid #666;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            transition: all 0.3s;
        }

        .kart-option:hover {
            border-color: #ffff00;
            transform: scale(1.1);
        }

        .kart-option.selected {
            border-color: #00ff00;
            box-shadow: 0 0 30px #00ff00;
        }

        .kart-preview {
            width: 80px;
            height: 60px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3rem;
        }

        /* SELEZIONE PILOTA */
        #driver-select {
            background: linear-gradient(180deg, #330033 0%, #000 100%);
        }

        .driver-list {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 20px;
            padding: 2rem;
            overflow: auto;
        }

        .driver-option {
            padding: 1rem;
            border: 3px solid #666;
            cursor: pointer;
            font-size: 1.5rem;
            transition: all 0.3s;
            width: 180px;
            text-align: center;
        }

        .driver-option:hover {
            border-color: #ffff00;
            transform: translateX(10px);
        }

        .driver-option.selected {
            border-color: #00ff00;
            background: rgba(0, 255, 0, 0.2);
        }

        /* GIOCO */
        #game {
            background: #222;
            position: relative;
            overflow: hidden;
        }

        #game-canvas {
            width: 100%;
            height: 100%;
            display: block;
        }

        .game-ui {
            position: absolute;
            top: 20px;
            left: 20px;
            right: 20px;
            font-size: 2rem;
            color: #fff;
            font-weight: bold;
            text-shadow: 3px 3px 6px #000, -1px -1px 2px #000;
            z-index: 10;
        }

        .player-info{
            text-align: center;
            margin-bottom: 1rem;
        }

        .game-stats {
            display: flex;
            justify-content: space-between;
            margin-bottom: 15px;
        }

        .fuel-container {
            margin-top: 15px;
            background: rgba(0, 0, 0, 0.7);
            padding: 15px;
            border: 3px solid #fff;
            border-radius: 8px;
            max-width: 40%;
            width: 40%;
            display: inline-block;
        }

        .fuel-label {
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 1.8rem;
        }

        .fuel-progress {
            width: 100%;
            height: 35px;
            background: #222;
            border: 3px solid #fff;
            border-radius: 8px;
            overflow: hidden;
            position: relative;
            box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
        }

        .fuel-bar {
            height: 100%;
            /*background: linear-gradient(90deg, #ff0000 0%, #ffff00 50%, #00ff00 100%);*/
            background-color: #00ff00;
            transition: width 0.3s ease;
            position: relative;
            box-shadow: 0 0 10px rgba(255,255,255,0.5);
        }

        .fuel-bar::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
            animation: shine 2s infinite;
        }

        @keyframes shine {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }

        .fuel-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-weight: bold;
            color: #fff;
            text-shadow: 2px 2px 4px #000;
            font-size: 1.4rem;
            z-index: 1;
        }

        .controls {
            position: absolute;
            bottom: 40px;
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            padding: 0 20px;
            z-index: 10;
        }

        .control-btn {
            width: 100px;
            height: 100px;
            font-size: 3rem;
            background: rgba(255, 255, 255, 0.2);
            border: 4px solid #fff;
            color: #fff;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            user-select: none;
            touch-action: manipulation;
        }

        .control-btn:active {
            background: rgba(255, 255, 255, 0.4);
            transform: scale(0.95);
        }

        #turbo-btn {
            background: rgba(255, 0, 0, 0.3);
            border-color: #ff0000;
            animation: turbo-pulse 1s infinite;
        }

        #pause-btn {
            background: rgba(255, 255, 0, 0.8);
            border-color: #7e6b00;
        }

        @keyframes turbo-pulse {
            0%, 100% { box-shadow: 0 0 10px #ff0000; }
            50% { box-shadow: 0 0 30px #ff0000; }
        }

        .btn-next {
            padding: 15px 40px;
            font-size: 1.5rem;
            background: #00ff00;
            border: 3px solid #fff;
            color: #000;
            cursor: pointer;
            font-weight: bold;
            margin-top: 2rem;
        }

        .btn-next:disabled {
            background: #666;
            cursor: not-allowed;
            opacity: 0.5;
        }

        .btn-back {
            padding: 15px 40px;
            font-size: 1.5rem;
            background: #ff6600;
            border: 3px solid #fff;
            color: #fff;
            cursor: pointer;
            font-weight: bold;
            margin-top: 2rem;
            margin-right: 1rem;
        }

        

        .btn-pause:hover {
            background: rgba(255, 255, 0, 1);
        }

        .pause-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.95);
            z-index: 100;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .pause-modal.active {
            display: flex;
        }

        .pause-modal h2 {
            color: #ffff00;
            font-size: 4rem;
            margin-bottom: 2rem;
        }

        .record-display {
            color: #00ff00;
            font-size: 2rem;
            margin-bottom: 3rem;
            text-shadow: 0 0 10px #00ff00;
        }

        .pause-buttons {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .pause-btn {
            padding: 20px 60px;
            font-size: 2rem;
            border: 3px solid #fff;
            cursor: pointer;
            font-weight: bold;
            text-transform: uppercase;
            min-width: 300px;
            transition: all 0.3s;
        }

        .pause-btn-resume {
            background: #00ff00;
            color: #000;
        }

        .pause-btn-exit {
            background: #ff0000;
            color: #fff;
        }

        .pause-btn:hover {
            transform: scale(1.05);
        }

        h2 {
            font-size: 3rem;
            margin-bottom: 2rem;
            text-shadow: 0 0 10px currentColor;
        }

        .img-kart{
            max-width: max-content;
            width: 100%;
        }

        .img-helmet{
            max-width: max-content;
            width: 100%;
        }

        
        .audio-controls{
            font-size: 2rem;
            display: inline-block;
        }

        .music-btn{
            border: solid 3px #fff;
            border-radius: 8px;
            background: rgba(0,0,0,0.6);
            color: white;
            cursor: pointer;
            font-size: 1.5rem;
            padding: 1rem 1rem;
        }

        .music-btn.active {
            background: #00c000;
        }

        .audio-btn {
            border: solid 3px #fff;
            border-radius: 8px;
            background: rgba(0,0,0,0.6);
            color: white;
            cursor: pointer;
            font-size: 1.5rem;
            padding: 1rem 1rem;
        }

        .audio-btn.active {
            background: #00c000;
        }

        #smallScreenModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    z-index: 9999;
    text-align: center;
    padding: 20px;
  }

  #smallScreenModal .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border-radius: 12px;
    padding: 30px;
    max-width: 90%;
  }

  #smallScreenModal button {
    margin-top: 20px;
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    background-color: #ff0000;
    color: #fff;
    cursor: pointer;
  }

  i.icon {
    text-decoration: none;
    font-style: normal;
  }
  
.gameover-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.95);
            z-index: 100;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .gameover-modal.active {
            display: flex;
        }

        .gameover-modal h2 {
            color: #ff0000;
            font-size: 3rem;
            margin-bottom: 2rem;
            text-shadow: 0 0 20px #ff0000;
        }

        .gameover-content{
            padding: 2rem;
            border: solid 5px;
            border-radius: 1rem;
            text-align: center;
        }

        .btn-restart{
            background-color: #00ff00;
            border-radius: 0;
            color: #000;
            padding: 1rem;
            font-size: 2rem;
            font-weight: bold;
            border: solid 5px #ffffff;
            cursor: pointer;
        }

        .gameover-stats {
            color: #fff;
            font-size: 2rem;
            margin-bottom: 1rem;
            text-align: center;
        }

        .gameover-stats div {
            margin: 15px 0;
        }

        .new-record-badge {
            color: #00ff00;
            font-size: 3rem;
            margin: 20px 0;
            text-shadow: 0 0 20px #00ff00;
            animation: glow 1s ease-in-out infinite alternate;
        }

        .btn-play-again {
            padding: 25px 70px;
            font-size: 2.5rem;
            background: #00ff00;
            border: 4px solid #fff;
            color: #000;
            cursor: pointer;
            font-weight: bold;
            text-transform: uppercase;
            margin-top: 2rem;
            transition: all 0.3s;
        }

        .btn-play-again:hover {
            transform: scale(1.1);
            box-shadow: 0 0 30px #00ff00;
        }

        .gameover-stats > h2 {
            font-size: 3rem;
            margin-bottom: 2rem;
            text-shadow: 0 0 10px currentColor;
        }
