.game-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.game-shell {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 10px;
  max-width: 100%;
  overflow: hidden;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 8px 10px;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}
.hud-top > div { color: var(--text-dim); white-space: nowrap; }
.hud-top span { color: #fff; margin-left: 6px; }
.hud-top .hud-score span { color: var(--gold); }
.hud-icon-group { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 1.1rem;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }
.icon-btn[aria-pressed="true"] { color: var(--accent-2); border-color: var(--accent-2); }

/* Fullscreen mode: let the whole game shell fill the screen. */
.game-shell:fullscreen,
.game-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep, #0a0714);
  padding: 8px;
}
.game-shell:fullscreen .stage,
.game-shell:-webkit-full-screen .stage {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.tower-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 8px;
}
.tower-name { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px; }
.integrity-bar {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.integrity-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3ddc84, #ffd93d);
  transition: width 0.25s ease;
}
.integrity-fill.low {
  background: linear-gradient(90deg, #ff5d7a, #ff2e6c);
  animation: pulse-red 0.6s infinite alternate;
}
@keyframes pulse-red { from { opacity: 1; } to { opacity: 0.55; } }

.stage {
  position: relative;
  width: 100%;
  height: min(72vh, 640px);
  min-height: 380px;
  border-radius: 12px;
  overflow: hidden;
  background: #06040f;
}
#game-canvas { width: 100%; height: 100%; }

.combo-toast {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -10px);
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 217, 61, 0.8);
  opacity: 0;
  pointer-events: none;
  letter-spacing: 1px;
}
.combo-toast.show { animation: combo-pop 0.9s ease forwards; }
@keyframes combo-pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); }
  35% { transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1); }
}

.tier-toast {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: 2px;
  color: #fff59d;
  text-shadow: 0 0 18px rgba(255, 217, 61, 0.7), 0 2px 4px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.tier-toast.show { animation: tier-pop 0.7s cubic-bezier(.2,1.4,.4,1) forwards; }
.tier-toast.big { font-size: 2.3rem; color: #fff; text-shadow: 0 0 26px rgba(51, 230, 255, 0.85), 0 2px 6px rgba(0,0,0,0.5); }
@keyframes tier-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  45% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

#score-popups {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.score-popup {
  position: absolute;
  top: 40%;
  color: #fff59d;
  font-weight: 800;
  font-size: 1rem;
  text-shadow: 0 0 8px rgba(0,0,0,0.6);
  animation: popup-float 1.4s ease forwards;
}
@keyframes popup-float {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-40px); }
}

.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px 4px;
}
.next-piece {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#next-canvas {
  width: 56px; height: 56px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
}

.mobile-controls { display: none; gap: 8px; }
.mobile-controls button {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 1.3rem;
  color: #fff;
}
.mobile-controls button:active { background: rgba(255,255,255,0.2); }

@media (pointer: coarse), (max-width: 760px) {
  .mobile-controls { display: flex; }
}

@media (max-width: 760px) {
  .game-wrap { padding: 0 8px; }
  .stage { height: min(78vh, 720px); }
  .hud-top { font-size: 0.8rem; gap: 8px; }
}
