* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #1a3c36; }
body { font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #f6e8c8; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; top: 10px; left: 10px; right: 10px; pointer-events: none; z-index: 5; }
#hud-top { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: rgba(16, 34, 30, 0.72); border: 1px solid rgba(232, 176, 76, 0.5);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; letter-spacing: 1px;
  text-transform: uppercase;
}
.chip b { color: #ffd97a; font-size: 15px; }
.bar-chip { display: flex; align-items: center; gap: 8px; }
.bar { width: 90px; height: 10px; background: rgba(255,255,255,0.12); border-radius: 5px; overflow: hidden; }
.bar div { height: 100%; width: 100%; background: linear-gradient(90deg, #d9642e, #ffd97a); border-radius: 5px; }
.bar.reload div { background: linear-gradient(90deg, #2e8f7c, #9ff7c6); }
#msg {
  margin: 18px auto 0; width: fit-content; text-align: center;
  font-size: clamp(20px, 4vw, 34px); font-weight: 700; letter-spacing: 3px;
  color: #ffd97a; text-shadow: 0 2px 12px rgba(0,0,0,0.7);
  opacity: 0; transition: opacity 0.35s;
}
#msg.show { opacity: 1; }

.overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(37,96,102,0.55), rgba(11,36,50,0.88) 70%);
}
.overlay.hidden { display: none; }
.panel {
  max-width: 560px; width: calc(100% - 32px); text-align: center;
  background: rgba(16, 34, 30, 0.88); border: 1px solid rgba(232,176,76,0.45);
  border-radius: 16px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.panel h1 { font-size: clamp(30px, 7vw, 44px); letter-spacing: 6px; color: #ffd97a; text-shadow: 0 3px 18px rgba(217,100,46,0.6); }
#end-title.win { color: #9ff7c6; } #end-title.lose { color: #ff8a5c; }
.tag { margin-top: 6px; color: #cfe3d8; font-style: italic; }
.howto { list-style: none; margin: 18px 0; text-align: left; font-size: 14px; line-height: 1.8; }
.howto li::before { content: "▸ "; color: #e8b04c; }
#end-stats { margin: 14px 0 18px; line-height: 1.7; }
.big-btn {
  pointer-events: auto; cursor: pointer; font: inherit; font-weight: 700; letter-spacing: 2px;
  color: #14201d; background: linear-gradient(180deg, #ffd97a, #e8964c);
  border: none; border-radius: 10px; padding: 14px 26px; font-size: 16px;
  box-shadow: 0 6px 20px rgba(232,150,76,0.45); transition: transform 0.15s;
}
.big-btn:hover { transform: translateY(-2px) scale(1.03); }

/* touch controls: shown on coarse pointers / narrow screens */
#touch { display: none; position: fixed; inset: auto 0 0 0; z-index: 10; pointer-events: none; }
@media (pointer: coarse), (max-width: 820px) { #touch { display: block; } }
#dpad { position: absolute; left: 14px; bottom: 16px; display: grid;
  grid-template-columns: 56px 56px 56px; grid-template-rows: 56px 56px; gap: 6px; pointer-events: auto; }
#t-fwd { grid-column: 2; grid-row: 1; } #t-left { grid-column: 1; grid-row: 2; }
#t-back { grid-column: 2; grid-row: 2; } #t-right { grid-column: 3; grid-row: 2; }
.tbtn {
  width: 56px; height: 56px; border-radius: 12px; border: 1px solid rgba(232,176,76,0.55);
  background: rgba(16,34,30,0.65); color: #ffd97a; font-size: 20px; touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.tbtn:active { background: rgba(232,150,76,0.5); }
#aim-pad {
  position: absolute; right: 110px; bottom: 20px; width: 96px; height: 96px; border-radius: 50%;
  border: 1px solid rgba(232,176,76,0.55); background: rgba(16,34,30,0.55); pointer-events: auto;
  touch-action: none; display: flex; align-items: center; justify-content: center;
}
#aim-knob { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,217,122,0.75); }
#t-fire {
  position: absolute; right: 16px; bottom: 24px; width: 84px; height: 84px; border-radius: 50%;
  border: 1px solid rgba(255,138,92,0.8); background: rgba(120,42,24,0.7); color: #ffe9b0;
  font-weight: 800; letter-spacing: 1px; font-size: 16px; pointer-events: auto;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
#t-fire:active { background: rgba(217,100,46,0.85); }
