/* style.css — Wolf Pack Defense */
:root {
  --bg: #1a1f2e;
  --panel: #232a3f;
  --panel-light: #2d3550;
  --text: #e8e8e8;
  --text-dim: #8892a8;
  --accent: #e94560;
  --accent2: #4ecdc4;
  --gold: #ffd700;
  --green: #5cb85c;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #e8eef2;
    --panel: #ffffff;
    --panel-light: #f0f4f8;
    --text: #1a1f2e;
    --text-dim: #5a6378;
    --border: rgba(0,0,0,0.1);
    --shadow: 0 4px 20px rgba(0,0,0,0.12);
  }
}

html[data-theme="dark"] {
  --bg: #1a1f2e;
  --panel: #232a3f;
  --panel-light: #2d3550;
  --text: #e8e8e8;
  --text-dim: #8892a8;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

html[data-theme="light"] {
  --bg: #e8eef2;
  --panel: #ffffff;
  --panel-light: #f0f4f8;
  --text: #1a1f2e;
  --text-dim: #5a6378;
  --border: rgba(0,0,0,0.1);
  --shadow: 0 4px 20px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
}

/* ─── Top Bar ─── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
  flex-shrink: 0;
  gap: 8px;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-size: 15px;
  background: var(--panel-light);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stat-svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.stat-sub {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-btn, .speed-btn {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover, .speed-btn:hover {
  background: var(--accent);
  color: #fff;
}

.btn-svg {
  width: 18px;
  height: 18px;
}

.icon-btn.muted .btn-svg {
  opacity: 0.4;
}

.speed-btn {
  min-width: 38px;
}

/* ─── Game Area ─── */
#gameArea {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* ─── Tower Panel ─── */
.tower-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
  min-width: 180px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.tp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 900;
  font-size: 15px;
}

.tp-level {
  color: var(--gold);
  font-size: 12px;
  background: rgba(255,215,0,0.15);
  padding: 2px 8px;
  border-radius: 6px;
}

.tp-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tp-stat {
  flex: 1;
  text-align: center;
  background: var(--panel-light);
  border-radius: 6px;
  padding: 4px 2px;
}

.tp-stat label {
  display: block;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.tp-stat span {
  font-weight: 800;
  font-size: 13px;
}

.tp-actions {
  display: flex;
  gap: 6px;
}

.tp-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 7px 4px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.tp-btn.upgrade {
  background: linear-gradient(135deg, #4ecdc4, #2a9d8f);
  color: #fff;
}

.tp-btn.upgrade:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.tp-btn.upgrade:disabled {
  background: var(--panel-light);
  color: var(--text-dim);
  cursor: not-allowed;
}

.tp-btn.sell {
  background: linear-gradient(135deg, #e94560, #b03050);
  color: #fff;
}

.tp-btn.sell:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* ─── Overlays ─── */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,15,25,0.85);
  backdrop-filter: blur(6px);
  z-index: 20;
  padding: 20px;
}

.overlay-screen.hidden {
  display: none;
}

.overlay-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.overlay-content h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #e94560, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}

.tagline {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 18px;
  font-weight: 600;
}

.how-to {
  text-align: left;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.how-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

.how-num {
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}

.tower-preview {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
}

.tp-card small {
  color: var(--gold);
  font-weight: 800;
}

.tp-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--border);
}

.big-btn {
  background: linear-gradient(135deg, #e94560, #c73650);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(233,69,96,0.4);
  width: 100%;
}

.big-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233,69,96,0.5);
}

.big-btn:active {
  transform: translateY(0);
}

.end-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 16px 0 22px;
  flex-wrap: wrap;
}

.end-stat {
  text-align: center;
}

.end-stat label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 2px;
}

.end-stat span {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
}

/* ─── Bottom Bar ─── */
#bottombar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
  z-index: 10;
  flex-shrink: 0;
}

.tower-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.tower-buttons::-webkit-scrollbar {
  display: none;
}

.tower-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-light);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--text);
  flex-shrink: 0;
}

.tower-btn:hover:not(.disabled) {
  border-color: var(--accent2);
  background: var(--panel);
}

.tower-btn.selected {
  border-color: var(--accent2);
  background: rgba(78,205,196,0.15);
  box-shadow: 0 0 0 2px rgba(78,205,196,0.3);
}

.tower-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tb-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.tb-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.tb-name {
  font-weight: 800;
  font-size: 13px;
}

.tb-cost {
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
}

.wave-btn {
  background: linear-gradient(135deg, #e94560, #c73650);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(233,69,96,0.3);
}

.wave-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(233,69,96,0.4);
}

.wave-btn:disabled {
  background: var(--panel-light);
  color: var(--text-dim);
  cursor: default;
  box-shadow: none;
}

.wave-btn:not(:disabled) {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 3px 10px rgba(233,69,96,0.3); }
  50% { box-shadow: 0 3px 18px rgba(233,69,96,0.6); }
}

/* ─── Tower Icon Backgrounds ─── */
.wolf-bg {
  background: radial-gradient(circle at 40% 35%, #7a7a8a, #4a4a5a);
  position: relative;
}
.wolf-bg::before, .wolf-bg::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-bottom-color: #3a3a4a;
  top: 2px;
}
.wolf-bg::before { left: 4px; transform: rotate(-15deg); }
.wolf-bg::after { right: 4px; transform: rotate(15deg); }

.alpha-bg {
  background: radial-gradient(circle at 40% 35%, #4a4a5e, #1a1a2a);
  position: relative;
}
.alpha-bg::before, .alpha-bg::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-bottom-color: #0a0a1a;
  top: 2px;
}
.alpha-bg::before { left: 4px; transform: rotate(-15deg); }
.alpha-bg::after { right: 4px; transform: rotate(15deg); }

.pup-bg {
  background: radial-gradient(circle at 40% 35%, #aaaabb, #7a7a8a);
  position: relative;
}
.pup-bg::before, .pup-bg::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 4px solid transparent;
  border-bottom-color: #6a6a7a;
  top: 4px;
}
.pup-bg::before { left: 6px; transform: rotate(-20deg); }
.pup-bg::after { right: 6px; transform: rotate(20deg); }

.frost-bg {
  background: radial-gradient(circle at 40% 35%, #7ab0e0, #3a6a9a);
  position: relative;
}
.frost-bg::before, .frost-bg::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-bottom-color: #2a5a8a;
  top: 2px;
}
.frost-bg::before { left: 4px; transform: rotate(-15deg); }
.frost-bg::after { right: 4px; transform: rotate(15deg); }

.shadow-bg {
  background: radial-gradient(circle at 40% 35%, #3a2a4a, #1a0a2a);
  position: relative;
}
.shadow-bg::before, .shadow-bg::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-bottom-color: #0a0010;
  top: 0px;
}
.shadow-bg::before { left: 4px; transform: rotate(-10deg); }
.shadow-bg::after { right: 4px; transform: rotate(10deg); }

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .stat-item {
    font-size: 13px;
    padding: 3px 7px;
    gap: 3px;
  }
  .stat-svg { width: 16px; height: 16px; }
  .stat-sub { display: none; }
  .score-item { display: none; }
  #topbar { padding: 6px 8px; gap: 4px; }
  .topbar-right { gap: 4px; }
  .icon-btn, .speed-btn { padding: 5px 8px; font-size: 12px; }
  .tower-btn { padding: 5px 8px; }
  .tb-icon { width: 28px; height: 28px; }
  .tb-name { font-size: 12px; }
  .tb-cost { font-size: 10px; }
  .wave-btn { padding: 8px 12px; font-size: 12px; }
  #bottombar { padding: 6px 8px; gap: 6px; }
  .overlay-content { padding: 22px 18px; }
  .overlay-content h1 { font-size: 24px; }
  .tower-panel { min-width: 150px; padding: 10px; right: 6px; top: 6px; }
  .tp-stat span { font-size: 11px; }
  .tp-stat label { font-size: 8px; }
  .tp-icon { width: 36px; height: 36px; }
  .tp-card { font-size: 10px; }
}

@media (max-width: 360px) {
  .tower-btn .tb-info { display: none; }
  .tower-btn { padding: 6px; }
  .tb-icon { width: 32px; height: 32px; }
}

