/* Icetower — Shell, HUD, Overlays. Kein externes Asset, keine Web-Fonts. */
:root {
  --bg: #070b18;
  --bg-2: #0d1730;
  --ink: #eaf2ff;
  --ink-dim: #93a6c9;
  --accent: #56d3ff;
  --accent-2: #ffd166;
  --line: rgba(120, 170, 255, .22);
  --panel: rgba(8, 14, 30, .88);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  height: 100dvh;              /* dynamische Browserleisten auf dem Handy */
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 0%, var(--bg-2), var(--bg) 70%);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* App-Gerüst: Spielfeld nimmt den ganzen Rest, Bedienung + Fuß bleiben fest. */
#app {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 6px;
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}

#stage {
  position: relative;
  min-width: 0;          /* Grid-Item darf schrumpfen — sonst zwingt der Canvas die Spur auf */
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  line-height: 0;
}

canvas#game {
  display: block;
  max-width: 100%;       /* Canvas nie größer als sein Fach */
  max-height: 100%;
  background: #050813;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(86, 211, 255, .08) inset;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  inset: 10px 12px auto 12px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  line-height: 1.1;
}

.hud-block { display: flex; flex-direction: column; gap: 2px; }
.hud-combo { align-items: center; }
.hud-right { align-items: flex-end; }
.hud-combo .hud-value { color: var(--accent-2); }
.hud-label {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #c3d5f2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
}
.hud-value {
  font-size: clamp(16px, 3.2vh, 22px);
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
  font-variant-numeric: tabular-nums;
}

#hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .04em;
  pointer-events: none;
}

/* Overlays (Menü, Pause, Game Over) */
.screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 8, 19, .72);
  backdrop-filter: blur(2px);
  border-radius: 10px;
  line-height: 1.4;
}
.screen.is-on { display: flex; }

.panel {
  width: min(320px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  text-align: center;
}
.panel-title {
  margin: 0;
  font-size: 24px;
  letter-spacing: .18em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(86, 211, 255, .35);
}
.panel-title--bad { color: #ff5d73; text-shadow: 0 0 18px rgba(255, 93, 115, .3); }
.panel-sub { margin: 0 0 4px; font-size: 12px; color: var(--ink-dim); }
.panel-best { margin: 2px 0 0; font-size: 11.5px; color: var(--accent-2); letter-spacing: .03em; }
.panel-record { margin: 0; min-height: 15px; font-size: 12px; font-weight: 700; color: var(--accent-2); }
.panel-keys { margin: 6px 0 0; font-size: 11px; color: var(--ink-dim); }

.btn {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: rgba(86, 211, 255, .12); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: rgba(86, 211, 255, .16);
  border-color: rgba(86, 211, 255, .55);
  color: #d9f6ff;
  font-weight: 700;
}
kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--ink);
  background: rgba(255, 255, 255, .05);
}

.hud-btn {
  position: absolute;
  z-index: 6;
  top: 42px;
  right: 10px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 14, 30, .8);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.hud-btn:hover { border-color: var(--accent); background: rgba(86, 211, 255, .14); }
.hud-btn.is-muted { opacity: .55; }
.hud-btn--full { top: 88px; }
.hud-btn.is-active { border-color: var(--accent); color: var(--accent); }
@media (pointer: coarse), (max-width: 860px) { .hud-btn--full { top: 80px; } }

#pagefoot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  align-items: center;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .05em;
  padding-bottom: 2px;
}
#pagefoot a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px dotted var(--line); }
#pagefoot a:hover { color: var(--accent); }
.foot-links { display: flex; gap: 10px; }

/* Rechtstexte */
.legal {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  line-height: 1.65;
  font-size: 14px;
  overflow-y: auto;
}
.legal h1 { font-size: 22px; color: var(--accent); }
.legal h2 { font-size: 16px; margin-top: 28px; color: var(--ink); }
.legal a { color: var(--accent); }
body.legal-page { display: block; overflow: auto; }

/* Touch-Steuerung (F09): nur auf groben Zeigern / schmalen Screens sichtbar */
#touchpad {
  display: none;                 /* nur grobe Zeiger / schmale Screens */
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
  pointer-events: none;
}
.tbtn {
  pointer-events: auto;
  width: 72px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 14, 30, .62);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:active { background: rgba(86, 211, 255, .22); border-color: var(--accent); }
.tbtn-jump { margin-left: auto; width: 96px; }

@media (pointer: coarse), (max-width: 860px) {
  #touchpad { display: flex; }
  #hint { display: none; }
  #stage { touch-action: none; }   /* Gesten statt Browser-Scroll/Zoom */
  .tbtn { height: clamp(64px, 10vh, 84px); width: clamp(72px, 23vw, 96px); font-size: 22px; }
  .tbtn-jump { width: clamp(88px, 30vw, 120px); }
  #pagefoot { font-size: 10px; gap: 3px 10px; }
  .hud-btn { top: 42px; right: 8px; width: 42px; height: 42px; font-size: 19px; }
  .hud-btn--full { top: 90px; }
}

@media (max-height: 560px) {
  #pagefoot { display: none; }
  #touchpad { padding: 0; }
  .tbtn { height: 48px; }
}
