/* style.css — Sandcastle Siege */
:root {
  --bg: #1a2230;
  --panel: #2a3548;
  --ink: #f4e8c8;
  --accent: #ffe66d;
  --red: #e05a3a;
  --green: #7be08a;
  --blue: #7bd4e8;
  --shadow: rgba(0,0,0,0.4);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #d8c9a0;
  --panel: #f0e4c8;
  --ink: #3a2a18;
  --shadow: rgba(0,0,0,0.2);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  font-family: 'Press Start 2P', 'Courier New', monospace;
}
body { color: var(--ink); }

#game {
  position: fixed; inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 10;
  font-size: 9px;
  text-shadow: 2px 2px 0 var(--shadow);
}
.hud-left, .hud-center, .hud-right {
  background: rgba(26,34,48,0.55);
  border: 2px solid rgba(244,232,200,0.25);
  border-radius: 4px;
  padding: 6px 10px;
  backdrop-filter: blur(2px);
}
.hud-center { text-align: center; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.hud-label {
  font-size: 7px; letter-spacing: 1px;
  opacity: 0.7; margin-bottom: 4px;
}
.hud-val { font-size: 12px; color: var(--ink); }
.hud-val.big { font-size: 16px; color: var(--accent); }

.hp-wrap { display: flex; flex-direction: column; gap: 4px; }
.hp-bar {
  width: 110px; height: 12px;
  background: #3a1a1a;
  border: 2px solid #1a0a0a;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.hp-fill {
  height: 100%; width: 100%;
  background: var(--green);
  transition: width 0.2s ease, background 0.3s;
}
.hp-fill.mid { background: var(--accent); }
.hp-fill.low { background: var(--red); animation: pulse 0.6s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.icon-btn {
  pointer-events: auto;
  width: 28px; height: 28px;
  background: rgba(26,34,48,0.7);
  border: 2px solid rgba(244,232,200,0.3);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}
.icon-btn::before {
  content: ''; position: absolute; inset: 6px;
  background: var(--ink);
  clip-path: polygon(0% 30%, 50% 30%, 50% 15%, 100% 50%, 50% 85%, 50% 70%, 0% 70%);
}
.icon-btn.off::before { opacity: 0.3; }
.icon-btn.off::after {
  content: ''; position: absolute;
  top: 4px; left: 22px; width: 18px; height: 2px;
  background: var(--red); transform: rotate(45deg);
}

/* ---------- Power status ---------- */
#powerStatus {
  position: fixed; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px;
  z-index: 10;
  pointer-events: none;
}
.pwr {
  background: rgba(26,34,48,0.7);
  border: 2px solid rgba(244,232,200,0.3);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 7px;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 64px;
}
.pwr-bar {
  height: 4px; background: #1a1a2a; border-radius: 2px; overflow: hidden;
}
.pwr-bar > div { height: 100%; transition: width 0.1s linear; }

/* ---------- Announce ---------- */
#announce {
  position: fixed; top: 38%; left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 22px;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--shadow), 0 0 20px rgba(255,230,109,0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  letter-spacing: 2px;
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
}
#announce.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,14,22,0.78);
  z-index: 20;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.panel {
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 28px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 0 var(--shadow), 0 0 40px rgba(0,0,0,0.5);
  position: relative;
}
.panel::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(244,232,200,0.2);
  border-radius: 3px;
  pointer-events: none;
}
.panel h1 {
  font-size: 26px;
  line-height: 1.3;
  margin: 0 0 14px;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--shadow);
  letter-spacing: 1px;
}
.panel h1.dead { color: var(--red); }
.tag {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  color: var(--ink);
  opacity: 0.8;
  margin: 0 0 22px;
  letter-spacing: 1px;
}
.how {
  font-family: 'Courier New', monospace;
  font-size: 17px;
  text-align: left;
  margin: 0 auto 22px;
  display: inline-block;
  line-height: 1.8;
}
.how .key {
  display: inline-block;
  background: rgba(244,232,200,0.15);
  border: 1px solid rgba(244,232,200,0.3);
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--accent);
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 8px;
  margin-right: 8px;
  min-width: 44px;
  text-align: center;
}
.btn {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  background: var(--accent);
  color: #2a1a08;
  border: none;
  border-bottom: 4px solid #b89020;
  padding: 14px 22px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.08s, border-bottom-width 0.08s;
  text-shadow: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}
.best {
  margin-top: 16px;
  font-size: 8px;
  opacity: 0.7;
  color: var(--ink);
}
.result {
  margin: 0 0 22px;
  font-family: 'Courier New', monospace;
  font-size: 20px;
}
.result .row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(244,232,200,0.2);
}
.result .row b { color: var(--accent); }
.result .row.best b { color: var(--green); }

@media (max-width: 380px) {
  .panel h1 { font-size: 20px; }
  .btn { font-size: 10px; padding: 12px 16px; }
  .hud-val.big { font-size: 13px; }
  .hp-bar { width: 80px; }
  #announce { font-size: 16px; }
}
