:root{
  --bg:#f3f4f6;
  --panel:#ffffff;
  --accent:#1f6feb;
  --muted:#6b7280;
  --danger:#ef4444;
  --card-shadow: 0 6px 18px rgba(15,23,42,0.08);
}

html,body,#app{height:100%;margin:0;background:var(--bg);font-family:Inter,system-ui,Arial;}
#app{position:relative;overflow:hidden;display:flex;align-items:stretch;flex-direction:row;}

/* Left sidebar: upgrade panel */
#addonSidebar{
  width:200px;
  min-width:200px;
  background:var(--panel);
  box-shadow:var(--card-shadow);
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:10px;
  box-sizing:border-box;
  height:calc(100% - 56px);
  overflow-y:auto;
  order:-1;
}
.addonSidebarHeader{
  font-size:13px;font-weight:700;color:#6b7280;
  text-transform:uppercase;letter-spacing:.07em;
  border-bottom:2px solid #f0f3f7;
  padding-bottom:6px;margin-bottom:4px;
}
#addonEmptyHint{
  font-size:12px;color:#9ca3af;
  text-align:center;padding:20px 6px;
  line-height:1.6;
}

#gameCanvas{
  flex:1;
  background:linear-gradient(180deg,#e9eef6 0%, #f7fafc 100%);
  display:block;
  margin:0;
  touch-action: manipulation;
}

/* Right sidebar: vertical stacked tower cards and editor */
#sideBar{
  width:200px;
  background:var(--panel);
  box-shadow: var(--card-shadow);
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:10px;
  padding-bottom:16px;
  box-sizing:border-box;
  height:calc(100% - 56px);
  overflow-y:auto;
}

.towerCard{
  background:linear-gradient(180deg,#fff,#fbfdff);
  border-radius:8px;
  padding:8px;
  box-shadow:0 4px 10px rgba(15,23,42,0.04);
  touch-action:none;
  user-select:none;
  cursor:pointer;
}
.towerCard:active{transform:scale(.995);}

.towerTitle{font-weight:600;color:#111;margin-bottom:4px;}
.towerDesc{font-size:12px;color:var(--muted);margin-bottom:6px;}
.towerCost{font-size:13px;color:var(--accent);font-weight:600;}

.divider{height:1px;background:#f0f3f7;margin:6px 0;border-radius:2px;}

#characterEditor{display:flex;flex-direction:column;gap:6px;}
.editorHeader{font-size:13px;font-weight:600;color:#111}
#charList{display:flex;flex-direction:column;gap:6px;max-height:240px;overflow:auto;padding-right:6px;}
.charItem{
  display:flex;gap:6px;align-items:center;background:#fafafa;padding:6px;border-radius:6px;border:1px solid #f0f3f7;
}
.charItem input{flex:1;border:0;background:transparent;font-size:13px;padding:6px;outline:none}
.charItem .drag{width:22px;height:22px;background:#eee;border-radius:4px;display:flex;align-items:center;justify-content:center;font-size:12px;color:#777}

/* Bottom bar */
#bottomBar{
  position:absolute;
  bottom:0;
  left:0;
  right:0;
  height:56px;
  background:var(--panel);
  box-shadow: 0 -6px 18px rgba(15,23,42,0.04);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:8px 12px;
  box-sizing:border-box;
  gap:8px;
}

#stats{display:flex;gap:12px;align-items:center;font-weight:600;color:#111;}
#stats div{font-size:14px}
#controls{display:flex;gap:8px}
#controls button{background:var(--accent);color:white;border:0;padding:8px 10px;border-radius:6px;font-weight:600}
#controls button.secondary{background:#e6e9ef;color:#111;border:0}

/* Gold display in bottom bar */
.goldDisplay{
  display:flex;align-items:center;gap:8px;margin:0 8px;
  background:linear-gradient(180deg,#fff8e6,#fff4d8);
  padding:6px 8px;border-radius:8px;border:1px solid rgba(0,0,0,0.04);box-shadow:0 6px 10px rgba(15,23,42,0.04);
  min-width:92px;justify-content:flex-start;
}
/* make the coin icon more prominent while keeping a tighter frame */
.goldDisplay img#goldIcon{width:48px;height:48px;display:block;object-fit:contain}

/* help */
#help{position:absolute;left:212px;top:12px;background:rgba(255,255,255,0.9);padding:6px 10px;border-radius:8px;font-size:12px;color:var(--muted);box-shadow:var(--card-shadow)}

/* ─────────────── Main Menu ─────────────────────────────────────────── */
#mainMenu{
  display:flex;position:fixed;inset:0;
  background:linear-gradient(145deg,#0f172a 0%,#1e3a5f 60%,#0f172a 100%);
  align-items:center;justify-content:center;flex-direction:column;
  gap:18px;z-index:600;
}
#menuLogo{
  max-width:420px;width:80%;height:auto;
  filter:drop-shadow(0 0 28px rgba(251,191,36,0.45)) drop-shadow(0 4px 12px #000);
}
#menuTitle{
  font-size:52px;font-weight:900;color:#fef08a;
  margin:0;letter-spacing:2px;
  text-shadow:0 0 30px rgba(251,191,36,0.5),0 2px 8px #000;
}
#menuSub{color:#94a3b8;font-size:18px;margin:0;}
#menuButtons{display:flex;gap:20px;}
.menuBtn{
  background:var(--accent);color:#fff;border:0;
  padding:16px 48px;border-radius:12px;font-size:20px;font-weight:700;
  cursor:pointer;box-shadow:0 6px 24px rgba(31,111,235,0.4);
  transition:filter .15s,transform .1s;
}
.menuBtn:hover{filter:brightness(1.15);transform:translateY(-2px);}
.menuBtn.circle{background:#7c3aed;box-shadow:0 6px 24px rgba(124,58,237,0.4);}
#menuHint{color:#64748b;font-size:13px;margin:0;}

/* ───────── Addon Panel ────────────────────────────────────────────── */
.addonPanelTitle{font-size:14px;font-weight:700;color:#111;padding:4px 0 6px;border-bottom:2px solid #e8edf3;margin-bottom:4px;}
.addonSection{display:flex;flex-direction:column;gap:4px;margin-bottom:8px;}
.addonSectionLabel{
  font-size:10px;font-weight:700;letter-spacing:.07em;
  color:var(--muted);text-transform:uppercase;
  border-bottom:1px solid #f0f3f7;padding-bottom:3px;margin-bottom:2px;
}
.addonStat{font-size:12px;color:#333;padding:1px 0;}
.addonStatGrid{
  display:grid;grid-template-columns:1fr 1fr;
  gap:3px 6px;font-size:12px;padding:2px 0;
}
.statLabel{color:var(--muted);font-weight:500;}
.statVal{color:#111;font-weight:700;text-align:right;}
.statBonus{color:#7c3aed;font-size:10px;font-weight:700;}
.addonEffects{
  font-size:11px;color:#059669;font-weight:600;
  background:#f0fdf4;border-radius:5px;padding:4px 6px;
  margin-top:4px;line-height:1.6;
}
.addonRow{
  display:flex;align-items:center;gap:5px;
  background:#fafbfd;border-radius:7px;
  padding:6px 7px;border:1px solid #edf0f5;
}
.addonInfo{display:flex;flex-direction:column;flex:1;gap:2px;min-width:0;}
.addonName{font-size:12px;font-weight:600;color:#111;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.addonLv{font-size:11px;color:var(--accent);font-weight:700;margin-left:4px;}
.addonDesc{font-size:10px;color:var(--muted);line-height:1.35;}
.addonBuyBtn{
  background:var(--accent);color:#fff;border:0;border-radius:5px;
  padding:5px 8px;font-size:11px;font-weight:700;cursor:pointer;
  white-space:nowrap;flex-shrink:0;
}
.addonBuyBtn:hover{filter:brightness(1.12);}
.addonBuyBtn.locked{background:#4b5563;cursor:not-allowed;opacity:0.55;filter:none;}

/* responsive tweaks for smaller screens */
@media (max-width:760px){
  #sideBar{width:160px;padding:8px;height:calc(100% - 60px)}
  #gameCanvas{height:100vh}
  #bottomBar{height:60px;padding:10px}
}

/* Game Over overlay */
#gameOverScreen{
  display:none;
  position:absolute;
  top:0;left:200px; /* exclude left addon sidebar */
  right:200px; /* exclude right tower sidebar */
  bottom:56px; /* exclude bottom bar */
  background:rgba(0,0,0,0.6);
  align-items:center;
  justify-content:center;
  z-index:200;
}
#gameOverBox{
  background:#fff;
  border-radius:16px;
  padding:36px 56px;
  text-align:center;
  box-shadow:0 12px 40px rgba(0,0,0,0.3);
}
#gameOverTitle{
  font-size:44px;
  font-weight:800;
  color:#ef4444;
  margin-bottom:12px;
  letter-spacing:1px;
}
#gameOverScore{
  font-size:20px;
  font-weight:600;
  color:#111;
  margin-bottom:28px;
}
#gameOverBox button{
  background:var(--accent);
  color:#fff;
  border:0;
  padding:12px 36px;
  border-radius:8px;
  font-size:16px;
  font-weight:700;
  cursor:pointer;
}
#gameOverBox button:hover{filter:brightness(1.1)}