* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #102028;
  color: #f4fffb;
  font-family: system-ui, "Segoe UI", sans-serif;
}

#app {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#topbar {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#btn-home {
  pointer-events: auto;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(8, 20, 24, 0.55);
  color: #f4fffb;
  font: 700 0.85rem/1 system-ui, "Segoe UI", sans-serif;
  text-decoration: none;
}

#level-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 #102028;
}

#btn-mute {
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(8, 20, 24, 0.55);
  color: #f4fffb;
  font: 700 0.9rem/1 system-ui, "Segoe UI", sans-serif;
}

#boss-wrap {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, 78vw);
  text-align: center;
}

#boss-name {
  font-weight: 700;
  margin-bottom: 4px;
  text-shadow: 0 2px 0 #102028;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

#boss-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(#ff8b78, #d14332);
}

#dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}

#squad-stat, #hint {
  margin: 0;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 2px 0 #102028, 0 0 8px rgba(0, 0, 0, 0.45);
}

#hint {
  font-weight: 600;
  font-size: 0.95rem;
}

#controls {
  pointer-events: auto;
  display: flex;
  gap: 10px;
}

#controls button {
  flex: 1;
  height: 78px;
  border: 0;
  border-radius: 18px;
  background: #123f3d;
  color: #f3fffc;
  font: 700 1.25rem/1 system-ui, "Segoe UI", sans-serif;
  box-shadow: inset 0 -4px 0 #0a2827;
}

#controls button.held,
#controls button:active {
  background: #1b8f86;
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 #0a2827;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(6, 12, 16, 0.38);
}

#hud[hidden],
#dock[hidden],
#boss-wrap[hidden],
#hint[hidden],
#overlay[hidden] {
  display: none !important;
}

.card {
  width: min(460px, 100%);
  max-height: min(92dvh, 760px);
  overflow: auto;
  background: rgba(14, 24, 30, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 16px 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.card h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.card p {
  margin: 0 0 10px;
  line-height: 1.45;
  color: #d5e6e1;
}

.levels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.card button {
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #1b8f86;
  color: #f4fffb;
  font: 700 0.95rem/1.2 system-ui, "Segoe UI", sans-serif;
  cursor: pointer;
}

.card button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.card button:disabled {
  opacity: 0.4;
  cursor: default;
}

.levels button {
  flex: 1 1 30%;
  background: #16343a;
}

#btn-play, .wide {
  width: 100%;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.actions button { flex: 1; }

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-row p {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.shop-row button { min-width: 96px; }

button:focus-visible {
  outline: 3px solid #f2d48a;
  outline-offset: 2px;
}

@media (pointer: coarse), (max-width: 700px) {
  .kb { display: none; }
}

@media (max-height: 520px) {
  #controls button { height: 56px; }
  .card h1 { font-size: 1.4rem; }
}
