* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body {
    width: 100%; height: 100%;
    background: #1a1a1a;
    font-family: 'Oswald', sans-serif;
    overflow: hidden;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  body {
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at top, #2a1a0a 0%, #0a0a0a 60%, #000 100%);
  }
  #stage {
    position: relative;
    width: 420px; height: 750px;
    max-width: 100vw; max-height: 100vh;
    aspect-ratio: 420/750;
    background: #0a0a0a;
    box-shadow: 0 0 0 2px #ff6b1a44, 0 0 60px #ff6b1a33, 0 30px 80px rgba(0,0,0,0.7);
    overflow: hidden;
    border-radius: 8px;
  }
  @media (max-width: 460px) {
    #stage { width: 100vw; height: 100vh; border-radius: 0; box-shadow: none; }
  }
  canvas {
    display: block;
    width: 100%; height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }

  /* HUD overlay */
  #hud {
    position: absolute; top: 0; left: 0; right: 0;
    padding: 10px 12px 0;
    display: none;
    z-index: 5;
    pointer-events: none;
  }
  #hud.show { display: block; }
  .hud-row {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
  }
  .hud-pill {
    background: rgba(0,0,0,0.6);
    border: 1.5px solid #ff6b1a;
    padding: 4px 10px;
    border-radius: 18px;
    font-family: 'Russo One', sans-serif;
    font-size: 13px;
    color: #ffd86e;
    letter-spacing: 1px;
    display: flex; align-items: center; gap: 5px;
    backdrop-filter: blur(6px);
  }
  .hud-pill .icon { font-size: 14px; }
  .combo-pill {
    background: linear-gradient(135deg, #ff2a8a, #ff6b1a);
    border-color: #ffd86e;
    color: #fff;
    text-shadow: 1px 1px 0 #5a0000;
    font-size: 14px;
    animation: comboBeat 0.3s ease-out;
    transform-origin: center;
  }
  @keyframes comboBeat {
    0% { transform: scale(1.5); }
    100% { transform: scale(1); }
  }

  /* Bars container */
  .bars { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
  .bar-wrap {
    background: rgba(0,0,0,0.6);
    border: 1.5px solid;
    border-radius: 12px;
    padding: 3px 5px;
    backdrop-filter: blur(6px);
  }
  .bar-wrap.hp { border-color: #ff6b1a; }
  .bar-wrap.nitro { border-color: #1aafff; }
  .bar-track {
    height: 9px;
    background: #2a1a1a;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
  }
  .bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.15s ease;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.3);
  }
  .bar-fill.hp { background: linear-gradient(90deg, #ff2222, #ff8a3a, #ffd86e); }
  .bar-fill.nitro { background: linear-gradient(90deg, #1a6aff, #1aafff, #6ee0ff); width: 0%; }
  .bar-label {
    font-family: 'Russo One', sans-serif;
    font-size: 9px;
    letter-spacing: 1.5px;
    margin-bottom: 1px;
    display: flex; justify-content: space-between;
    text-shadow: 0 1px 2px #000;
  }
  .bar-label.hp { color: #ffd86e; }
  .bar-label.nitro { color: #6ee0ff; }
  .bar-label .ready {
    background: #1aafff;
    color: #001020;
    padding: 0 5px;
    border-radius: 4px;
    font-size: 8px;
    animation: blink 0.6s steps(2) infinite;
  }
  @keyframes blink { 50% { opacity: 0.3; } }

  /* Action buttons (touch) */
  .action-btns {
    position: absolute;
    bottom: 16px;
    left: 0; right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 6;
    pointer-events: none;
  }
  .action-btns.show { display: flex; }
  .act-btn {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: 2.5px solid #ff6b1a;
    color: #ffd86e;
    font-family: 'Bungee', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(255,255,255,0.1);
    transition: transform 0.08s, background 0.15s;
    position: relative;
  }
  .act-btn:active {
    transform: scale(0.92);
    background: rgba(255,107,26,0.4);
  }
  .act-btn .icon { font-size: 22px; line-height: 1; }
  .act-btn .ammo {
    position: absolute;
    top: -4px; right: -4px;
    background: #ff2a2a;
    color: #fff;
    font-family: 'Russo One', sans-serif;
    font-size: 11px;
    border-radius: 50%;
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #000;
  }
  .act-btn.nitro { border-color: #1aafff; color: #6ee0ff; }
  .act-btn.nitro.ready {
    box-shadow: 0 4px 12px rgba(26,175,255,0.6), inset 0 0 0 2px rgba(255,255,255,0.15), 0 0 20px #1aafff;
    animation: pulseGlow 1s ease-in-out infinite;
  }
  @keyframes pulseGlow {
    0%, 100% { box-shadow: 0 4px 12px rgba(26,175,255,0.6), inset 0 0 0 2px rgba(255,255,255,0.15), 0 0 20px #1aafff; }
    50% { box-shadow: 0 4px 12px rgba(26,175,255,0.9), inset 0 0 0 2px rgba(255,255,255,0.3), 0 0 35px #6ee0ff; }
  }
  .act-btn.disabled {
    opacity: 0.4;
    border-color: #555;
    color: #888;
  }

  .pause-btn {
    position: absolute;
    top: 96px;
    right: 12px;
    width: 34px; height: 34px;
    background: rgba(0,0,0,0.7);
    border: 1.5px solid #ff6b1a;
    border-radius: 50%;
    color: #ffd86e;
    font-size: 12px;
    z-index: 6;
    display: none;
    align-items: center; justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    pointer-events: auto;
  }
  .pause-btn.show { display: flex; }

  /* Mission banner */
  .mission-banner {
    position: absolute;
    top: 142px;
    left: 12px;
    right: 12px;
    background: rgba(0,0,0,0.7);
    border: 1.5px solid #ffd86e;
    border-radius: 8px;
    padding: 5px 10px;
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    color: #ffd86e;
    letter-spacing: 1px;
    display: none;
    z-index: 5;
    pointer-events: none;
    backdrop-filter: blur(6px);
    text-align: center;
  }
  .mission-banner.show { display: block; }
  .mission-banner .obj { color: #fff; font-weight: 700; }
  .mission-banner.done {
    border-color: #6effa0;
    color: #6effa0;
    animation: missionDone 0.5s ease-out;
  }
  @keyframes missionDone {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
  }

  /* SCREENS */
  .screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 30px 26px;
    z-index: 10;
    background:
      radial-gradient(ellipse at top, rgba(255,107,26,0.15) 0%, transparent 60%),
      linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.92));
  }
  .screen.hide { display: none; }
  .scroll-screen { overflow-y: auto; justify-content: flex-start; padding-top: 30px; }

  /* TITLE */
  #title-screen {
    background:
      radial-gradient(ellipse at center, rgba(255,107,26,0.25) 0%, rgba(0,0,0,0.85) 70%),
      linear-gradient(180deg, #1a0a05 0%, #000 100%);
    justify-content: flex-start;
    padding-top: 30px;
  }
  .title-bg {
    position: absolute; inset: 0;
    background-image:
      repeating-linear-gradient(0deg, transparent, transparent 22px, rgba(255,107,26,0.04) 22px, rgba(255,107,26,0.04) 23px),
      repeating-linear-gradient(90deg, transparent, transparent 22px, rgba(255,107,26,0.04) 22px, rgba(255,107,26,0.04) 23px);
    pointer-events: none;
  }
  /* Logo image at top of title screen */
  .title-logo {
    display: block;
    width: 220px;
    height: auto;
    margin: -10px auto 0;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 8px 24px rgba(255,107,26,0.4));
    image-rendering: -webkit-optimize-contrast;
  }
  /* Small accent tag still used on the How-To and Game-Over screens */
  .small-tag {
    font-family: 'Russo One', sans-serif;
    color: #ffd86e;
    font-size: 12px;
    letter-spacing: 5px;
    margin-bottom: 6px;
    text-transform: uppercase;
  }

  /* Bike select */
  .bike-select-label {
    font-family: 'Russo One', sans-serif;
    font-size: 12px;
    letter-spacing: 4px;
    color: #ffd86e;
    margin-top: 22px;
    text-transform: uppercase;
  }
  .bike-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 360px;
  }
  .bike-card {
    aspect-ratio: 1;
    background: rgba(0,0,0,0.6);
    border: 2px solid #444;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 6px;
    backdrop-filter: blur(4px);
  }
  .bike-card img {
    width: 56px; height: 56px;
    object-fit: contain;
    image-rendering: pixelated;
    transition: transform 0.2s;
  }
  .bike-card .name {
    font-family: 'Russo One', sans-serif;
    font-size: 9px;
    color: #aaa;
    letter-spacing: 1px;
    margin-top: 2px;
  }
  .bike-card:hover img { transform: scale(1.1); }
  .bike-card.selected {
    border-color: #ff6b1a;
    background: rgba(255,107,26,0.2);
    box-shadow: 0 0 20px rgba(255,107,26,0.4);
  }
  .bike-card.selected .name { color: #ffd86e; }

  /* Buttons */
  .btn {
    font-family: 'Russo One', sans-serif;
    font-size: 20px;
    letter-spacing: 4px;
    text-transform: uppercase;
    padding: 14px 36px;
    background: linear-gradient(180deg, #ff8a3a 0%, #ff6b1a 50%, #c84500 100%);
    color: #fff;
    border: 3px solid #ffd86e;
    border-radius: 50px;
    cursor: pointer;
    box-shadow:
      0 5px 0 #5a1a00,
      0 8px 25px rgba(255,107,26,0.5),
      inset 0 2px 0 rgba(255,255,255,0.3);
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 2px 2px 0 #5a1a00;
    position: relative;
    margin-top: 22px;
    animation: pulse 1.6s ease-in-out infinite;
  }
  .btn:active {
    transform: translateY(4px);
    box-shadow:
      0 1px 0 #5a1a00,
      0 3px 12px rgba(255,107,26,0.5),
      inset 0 2px 0 rgba(255,255,255,0.3);
  }
  .btn.secondary {
    background: linear-gradient(180deg, #444 0%, #222 50%, #000 100%);
    border-color: #666;
    color: #ffd86e;
    font-size: 14px;
    padding: 10px 24px;
    box-shadow: 0 3px 0 #000, 0 6px 15px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 1px 1px 0 #000;
    margin-top: 12px;
    animation: none;
    letter-spacing: 3px;
  }
  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
  }

  /* GAME OVER */
  .go-title {
    font-family: 'Bungee', sans-serif;
    font-size: 50px;
    color: #ff2a2a;
    text-shadow: 3px 3px 0 #5a0000, 0 0 30px rgba(255,42,42,0.7);
    letter-spacing: 2px;
    transform: rotate(-2deg);
    text-align: center;
    line-height: 0.95;
  }
  .stats-card {
    margin-top: 22px;
    background: rgba(0,0,0,0.6);
    border: 2px solid #ff6b1a;
    padding: 14px 24px;
    border-radius: 12px;
    backdrop-filter: blur(6px);
    min-width: 240px;
  }
  .stat-row {
    display: flex; justify-content: space-between;
    font-family: 'Russo One', sans-serif;
    color: #fff;
    font-size: 14px;
    letter-spacing: 1px;
    padding: 5px 0;
    border-bottom: 1px dashed rgba(255,107,26,0.3);
  }
  .stat-row:last-child { border-bottom: none; }
  .stat-row .v { color: #ffd86e; }
  .new-best {
    color: #ffd86e;
    font-family: 'Bungee', sans-serif;
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
    letter-spacing: 2px;
    animation: blink 0.6s steps(2) infinite;
    text-shadow: 0 0 10px #ffd86e;
  }

  .toast {
    position: absolute;
    top: 35%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bungee', sans-serif;
    font-size: 44px;
    color: #ffd86e;
    text-shadow: 3px 3px 0 #c84500, 0 0 30px #ff6b1a;
    pointer-events: none;
    opacity: 0;
    z-index: 7;
    letter-spacing: 4px;
    text-align: center;
  }
  .toast.show { animation: toastPop 1.2s ease-out; }
  @keyframes toastPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
  }

  /* Sound icon toggle */
  .sound-btn {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.5);
    border: 1.5px solid #ffd86e;
    border-radius: 50%;
    color: #ffd86e;
    font-size: 12px;
    z-index: 11;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
  }
  .sound-btn.in-game {
    top: auto;
    bottom: 92px;
    right: 12px;
    width: 28px; height: 28px;
    font-size: 11px;
    border-color: #ff6b1a;
  }

  /* rotate suggestion */
  #rotate {
    display: none;
    position: fixed; inset: 0;
    background: #000;
    z-index: 100;
    align-items: center; justify-content: center;
    flex-direction: column;
    color: #ffd86e;
    font-family: 'Russo One', sans-serif;
    text-align: center;
    padding: 30px;
  }
  #rotate .icon { font-size: 60px; animation: rot 2s ease-in-out infinite; margin-bottom: 20px; }
  @keyframes rot { 0%,100%{ transform: rotate(-90deg); } 50%{ transform: rotate(0deg); } }
  @media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    #rotate { display: flex; }
  }