* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background: #0d1424;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

main { width: 100%; max-width: 800px; padding: 12px; position: relative; }

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  background: #1b2a4a;
}

/* ===== Handy-Steuerung: nur auf Touch-Geräten ===== */
#touch, #drehen { display: none; }

#touch button {
  width: 70px; height: 70px; margin: 4px;
  font-size: 30px; line-height: 1; color: #fff;
  background: rgba(255, 255, 255, .18);
  border: 2px solid rgba(255, 255, 255, .45);
  border-radius: 18px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(2px);
}
#touch button:active, #touch button.an { background: rgba(255, 255, 255, .5); transform: scale(.94); }
#touch .rund { border-radius: 50%; width: 62px; height: 62px; font-size: 28px; background: rgba(255, 180, 40, .28); }
#touch .gross { width: 96px; height: 96px; border-radius: 50%; font-size: 40px; background: rgba(90, 200, 255, .28); }
#touch .links, #touch .rechts { display: flex; align-items: flex-end; }

@media (pointer: coarse) {
  body { overflow: hidden; position: fixed; inset: 0; }
  #touch { display: flex; justify-content: space-between; align-items: flex-end; }

  /* Hochformat: Spiel oben, Knöpfe darunter */
  @media (orientation: portrait) {
    body { align-items: flex-start; }
    main { padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); }
    #touch { margin-top: 22px; }
    #touch button { width: min(74px, 19vw); height: min(74px, 19vw); margin: min(4px, 1vw); }
    #touch .rechts { display: grid; grid-template-columns: auto auto; align-items: center; }
    #touch .rund { width: min(58px, 15vw); height: min(58px, 15vw); font-size: 26px; grid-column: 1; }
    #touch .gross { width: min(100px, 25vw); height: min(100px, 25vw); grid-column: 2; grid-row: 1 / span 2; }
    #drehen { display: block; color: #ffd54f; text-align: center; margin-top: 18px; font-size: 15px; }
  }

  /* Querformat: Spiel füllt den Bildschirm, Knöpfe liegen darüber */
  @media (orientation: landscape) {
    main { max-width: none; padding: 0; width: 100vw; height: 100dvh; display: flex; align-items: center; justify-content: center; }
    canvas { width: auto; height: auto; max-width: 100vw; max-height: 100dvh; aspect-ratio: 8 / 5; border-radius: 0; box-shadow: none; }
    canvas { width: min(100vw, 160dvh); }
    #touch {
      position: absolute; inset: auto 0 0 0; pointer-events: none;
      padding: 0 max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    }
    #touch button { pointer-events: auto; opacity: .85; }
  }
}

/* ===== Eure gezeichneten Knöpfe ===== */
#touch button {
  background: center / contain no-repeat transparent;
  border: none; border-radius: 50%; backdrop-filter: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
}
#touch .rund, #touch .gross { background-color: transparent; }
#touch button:active, #touch button.an { background-color: transparent; transform: scale(.9); filter: brightness(1.3) drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
#touch .k-links     { background-image: url("assets/knoepfe/links.png"); }
#touch .k-rechts    { background-image: url("assets/knoepfe/rechts.png"); }
#touch .k-schiessen { background-image: url("assets/knoepfe/schiessen.png"); }
#touch .k-blitz     { background-image: url("assets/knoepfe/blitz.png"); }
#touch .k-sprung    { background-image: url("assets/knoepfe/sprung.png"); }

/* ===== App installieren ===== */
#installieren {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 10px 18px; font: 600 16px system-ui, sans-serif; color: #fff;
  background: linear-gradient(135deg, #1e88e5, #ff7a1a); border: none; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
#ios-hinweis {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 10;
  padding: 14px 16px; color: #fff; font: 15px/1.45 system-ui, sans-serif; text-align: center;
  background: rgba(13, 20, 36, .95); border: 2px solid #ffd54f; border-radius: 16px;
}
#ios-hinweis button { display: block; margin: 10px auto 0; padding: 6px 22px; border: none; border-radius: 999px; background: #ffd54f; font-weight: 700; }
[hidden] { display: none !important; }
#touch button[class*="k-"] { background-size: contain; background-position: center; background-repeat: no-repeat; background-color: transparent; }

/* ===== Ton an/aus ===== */
#tonknopf {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 11;
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4);
  background: rgba(13,20,36,.6); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
