/* Tower Blast — helles, modernes UI. Keine dunklen Flächen. */

:root {
  --sand:      #f7f1e4;
  --paper:     #ffffff;
  --ink:       #26303a;
  --ink-soft:  #5d6b78;
  --line:      #e3dccd;
  --petrol:    #1f8a9c;
  --petrol-dk: #16697a;
  --gold:      #e8a33d;
  --coral:     #e2664f;
  --violet:    #7b6bd6;
  --mint:      #3fb08a;
  --shadow:    0 10px 30px rgba(38, 48, 58, .16);
  --shadow-sm: 0 3px 10px rgba(38, 48, 58, .12);
  --radius:    18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sand);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  touch-action: none;
  user-select: none;
}

/* Der Himmel kommt als Verlauf hinter dem transparenten WebGL-Bild —
   das spart eine zusätzliche Kuppel in der 3D-Szene. */
#scene {
  display: block;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(180deg, #c9e6fa 0%, #dcedf6 30%, #e9f1ed 44%, #f4efe3 56%, #f7f1e4 100%);
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b));
  display: flex;
  flex-direction: column;
}
.hud[hidden] { display: none; }

.hud-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}

.chip {
  background: rgba(255, 255, 255, .92);
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 6px 12px;
  min-width: 78px;
  text-align: center;
  line-height: 1.1;
}
.chip-label {
  display: block;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.chip-value {
  display: block;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.chip--balls .chip-value { color: var(--petrol); }
.chip--level .chip-value { color: var(--violet); }
.chip--score .chip-value { color: var(--gold); }
.chip--balls.is-low .chip-value { color: var(--coral); }

.chip.pulse { animation: pop .28s ease; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* Fortschritt */
.targets {
  margin: 10px auto 0;
  width: min(320px, 76%);
  text-align: center;
}
.targets-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  overflow: hidden;
}
.targets-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mint), var(--petrol));
  transition: width .35s ease;
}
.targets-text {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-shadow: 0 1px 2px rgba(255, 255, 255, .9);
}

.icon-btn {
  position: absolute;
  top: calc(74px + var(--safe-t));
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-sm);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
}
.icon-btn.is-off { opacity: .5; }

/* Power-Ups */
.powerbar {
  margin-top: auto;
  display: flex;
  gap: 10px;
  justify-content: center;
  pointer-events: auto;
}
.power {
  position: relative;
  width: 84px;
  padding: 8px 4px 7px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
  font-family: inherit;
}
.power:active { transform: scale(.95); }
.power-icon { display: block; font-size: 20px; line-height: 1; }
.power-name {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.power-count {
  position: absolute;
  top: -8px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--petrol);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
  border: 2px solid #fff;
}
.power.is-armed { border-color: var(--coral); background: #fff3ef; }
.power.is-armed .power-count { background: var(--coral); }
.power.is-empty { opacity: .42; }

.hint {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-shadow: 0 1px 2px rgba(255, 255, 255, .9);
  transition: opacity .4s ease;
}
.hint.is-hidden { opacity: 0; }

/* Fliegende Punkte-Anzeige */
.floater {
  position: fixed;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(255, 255, 255, .95), 0 0 2px rgba(255, 255, 255, 1);
  pointer-events: none;
  animation: floatup .85s ease-out forwards;
  z-index: 20;
}
@keyframes floatup {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  20%  { opacity: 1; transform: translate(-50%, -70%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(18px + var(--safe-t)) 18px calc(18px + var(--safe-b));
  background: linear-gradient(180deg, rgba(247, 241, 228, .82), rgba(255, 255, 255, .92));
  backdrop-filter: blur(6px);
  z-index: 30;
  animation: fade .25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.card {
  width: min(430px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 26px 22px 22px;
  text-align: center;
}

.logo { margin-bottom: 6px; }
.logo-mark {
  display: block;
  width: 62px;
  height: 62px;
  margin: 0 auto 10px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 74%, var(--gold) 0 22%, transparent 23%),
    linear-gradient(160deg, var(--petrol), var(--petrol-dk));
  box-shadow: var(--shadow-sm);
}
h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.02em;
}
h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.lead { margin: 10px 0 18px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

.stats {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.stat {
  flex: 1;
  background: #fbf8f1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 4px;
}
.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--petrol);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft);
  font-weight: 700;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  margin-top: 10px;
  border: none;
  border-radius: 15px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary {
  background: linear-gradient(180deg, var(--petrol), var(--petrol-dk));
  color: #fff;
  box-shadow: 0 5px 0 rgba(22, 105, 122, .45);
}
.btn--ghost {
  background: #fbf8f1;
  color: var(--ink-soft);
  border: 2px solid var(--line);
}

.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 99px;
  background: #e7f5f2;
  color: var(--petrol-dk);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.badge--warn { background: #fdefe9; color: var(--coral); }

.scorelist { margin: 16px 0 6px; text-align: left; }
.scoreline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  color: var(--ink-soft);
}
.scoreline b { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.scoreline--total { border-bottom: none; }
.scoreline--total b { font-size: 22px; color: var(--gold); }

.reward {
  margin: 8px 0 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: #fdf6e7;
  color: #a8721a;
  font-size: 13px;
  font-weight: 700;
}

.howto {
  text-align: left;
  margin: 14px 0 18px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.howto li { margin-bottom: 9px; }
.howto b { color: var(--ink); }

/* ---------- Ladeanzeige ---------- */
.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sand);
  z-index: 40;
}
.loader[hidden] { display: none; }
.loader-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--petrol);
  animation: bounce .9s infinite ease-in-out;
}
.loader-dot:nth-child(2) { animation-delay: .15s; background: var(--gold); }
.loader-dot:nth-child(3) { animation-delay: .3s; background: var(--coral); }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-11px); opacity: 1; }
}

/* ---------- Querformat / kleine Höhen ---------- */
@media (max-height: 560px) {
  .chip-value { font-size: 19px; }
  .power { width: 72px; padding: 6px 4px 5px; }
  .power-icon { font-size: 17px; }
  .hint { display: none; }
  .targets { margin-top: 6px; }
  .card { padding: 18px 18px 16px; }
  h1 { font-size: 26px; }
  .logo-mark { width: 44px; height: 44px; margin-bottom: 6px; }
  .lead { margin: 6px 0 12px; }
}
