@import url('https://fonts.googleapis.com/css2?family=Russo+One&display=swap');

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a1628;
  font-family: 'Russo One', sans-serif;
}

#game-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* ── Sidebar ───────────────────────────────────────── */
#sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#sidebar.visible {
  opacity: 1;
  pointer-events: all;
}

.sidebar-section {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ── Sidebar Buttons ───────────────────────────────── */
.sidebar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 62px;
  padding: 14px 6px;
  background: #2a2e1e;
  border: 2px solid #4a5230;
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: #a8b86a;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  outline: none;
  position: relative;
  z-index: 2;
}

.sidebar-btn:hover,
.sidebar-btn.active {
  background: #3a4228;
  border-color: #7a9040;
  color: #c8d880;
}

.btn-icon { font-size: 20px; line-height: 1; }
.btn-label {
  font-size: 9px;
  font-family: 'Russo One', sans-serif;
  letter-spacing: 0.08em;
}

/* ── Side Panel ────────────────────────────────────── */
.side-panel {
  position: absolute;
  right: 62px;
  top: 50%;
  transform: translateY(-50%) translateX(20px);
  width: 280px;
  background: #1e2214;
  border: 2px solid #4a5230;
  border-radius: 8px 0 0 8px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  box-shadow: -6px 0 24px rgba(0,0,0,0.6);
}

.side-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(-50%) translateX(0);
}

.panel-header {
  background: #2a3018;
  border-bottom: 2px solid #4a5230;
  padding: 10px 14px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: #a8b86a;
}

/* ── Tabs ──────────────────────────────────────────── */
.panel-tabs {
  display: flex;
  border-bottom: 2px solid #4a5230;
  background: #23281a;
}

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-right: 1px solid #4a5230;
  color: #6b7840;
  font-family: 'Russo One', sans-serif;
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  outline: none;
}

.tab-btn:last-child { border-right: none; }
.tab-btn:hover { background: #2e3520; color: #a8b86a; }
.tab-btn.active {
  background: #3a4228;
  color: #c8d880;
  border-bottom: 2px solid #7a9040;
}

/* ── Tab Content ───────────────────────────────────── */
.tab-content {
  padding: 10px;
  min-height: 100px;
  max-height: 340px;
  overflow-y: auto;
}

.tab-content.hidden { display: none; }

.placeholder {
  color: #4a5a28;
  font-size: 11px;
  font-family: 'Russo One', sans-serif;
  text-align: center;
  margin-top: 20px;
  letter-spacing: 0.06em;
}

/* ── Building Cards ────────────────────────────────── */
#buildings-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.building-card {
  background: #1c2412;
  border: 1px solid #3a4a22;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s, background 0.2s;
}

.building-card:hover:not(.unaffordable) {
  border-color: #6a8030;
  background: #232e16;
}

.building-card.unaffordable {
  opacity: 0.38;
}

/* Icon box */
.building-icon {
  width: 44px;
  height: 44px;
  background: #2a3418;
  border: 1px solid #3e5020;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

/* Text block */
.building-info {
  flex: 1;
  min-width: 0;
}

.building-name {
  font-family: 'Russo One', sans-serif;
  font-size: 11px;
  color: #c8d880;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.building-income {
  font-family: 'Russo One', sans-serif;
  font-size: 10px;
  color: #6a9040;
  margin-top: 3px;
}

.building-owned {
  font-family: 'Russo One', sans-serif;
  font-size: 10px;
  color: #8aaa50;
  background: #2a3818;
  border: 1px solid #3e5020;
  border-radius: 4px;
  padding: 2px 5px;
  min-width: 26px;
  text-align: center;
}

/* Buy button */
.building-buy {
  background: linear-gradient(180deg, #4a6a20 0%, #344c16 100%);
  border: 1px solid #6a9030;
  border-radius: 6px;
  color: #c8e060;
  font-family: 'Russo One', sans-serif;
  font-size: 11px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.building-buy:hover:not(:disabled) {
  background: linear-gradient(180deg, #5a7e28 0%, #3e5e1a 100%);
  border-color: #8ab040;
  transform: translateY(-1px);
}

.building-buy:active:not(:disabled) {
  transform: translateY(0);
}

.building-buy:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: #2a3414;
  border-color: #3a4820;
  color: #6a7840;
}

/* ── Placement Banner ──────────────────────────────── */
#placement-banner {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2414;
  border: 2px solid #7a9040;
  border-radius: 8px;
  padding: 10px 24px;
  font-family: 'Russo One', sans-serif;
  font-size: 13px;
  color: #c8e060;
  letter-spacing: 0.08em;
  display: none;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

#placement-banner.visible {
  display: block;
}

.building-hp {
  font-family: 'Russo One', sans-serif;
  font-size: 9px;
  color: #60a840;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

/* ── Admin Panel ───────────────────────────────────────── */
.admin-btn {
  border-color: #5a3a20 !important;
  color: #c8a060 !important;
}
.admin-btn:hover, .admin-btn.active {
  background: #3a2810 !important;
  border-color: #c8a060 !important;
  color: #ffd080 !important;
}

.admin-action-btn {
  width: 100%;
  background: linear-gradient(180deg, #3a2810 0%, #281a08 100%);
  border: 1px solid #7a5020;
  border-radius: 6px;
  color: #e0a050;
  font-family: 'Russo One', sans-serif;
  font-size: 11px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
}
.admin-action-btn:hover {
  background: linear-gradient(180deg, #503820 0%, #382510 100%);
  border-color: #c8a060;
  color: #ffd080;
}
.admin-action-btn.active {
  background: linear-gradient(180deg, #305030 0%, #1e3020 100%);
  border-color: #60c060;
  color: #90e090;
}

.admin-input {
  flex: 1;
  background: #1a1208;
  border: 1px solid #5a3a20;
  border-radius: 5px;
  color: #e0c080;
  font-family: 'Russo One', sans-serif;
  font-size: 11px;
  padding: 6px 8px;
  outline: none;
  width: 100%;
}
.admin-input:focus { border-color: #c8a060; }