@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Special+Elite&family=Playfair+Display:wght@400;700;900&display=swap');

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

:root {
  --sepia: #d4a76a;
  --dark-brown: #2a1a0e;
  --mid-brown: #5c3a1e;
  --cream: #f0e0c0;
  --gold: #c9a84c;
  --crimson: #8b1a1a;
  --dark-bg: #1a0f07;
  --smoke: #4a4a4a;
  --green-bribe: #2a6b3a;
  --panel-bg: rgba(26, 15, 7, 0.95);
}

body {
  background: var(--dark-bg);
  color: var(--cream);
  font-family: 'Special Elite', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px),
    radial-gradient(ellipse at center, #2a1a0e 0%, #1a0f07 100%);
}

/* HUD */
#hud {
  background: linear-gradient(180deg, #3d2412 0%, #2a1a0e 100%);
  border-bottom: 3px solid var(--gold);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  z-index: 100;
  position: relative;
}

#hud::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

#hud-title {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.2em;
  color: var(--gold);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  white-space: nowrap;
  letter-spacing: 2px;
}

#hud-title .year {
  color: var(--crimson);
  font-size: 0.8em;
}

#hud-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.4);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  font-size: 0.8em;
}

.stat-icon { font-size: 1em; }
.stat-label { 
  color: rgba(240,224,192,0.6); 
  font-size: 0.7em;
  text-transform: uppercase;
}
.stat-value { 
  color: var(--gold); 
  font-weight: bold;
  font-family: 'Cinzel', serif;
}

.threat-stat {
  min-width: 120px;
}

.threat-bar {
  width: 60px;
  height: 10px;
  background: rgba(0,0,0,0.6);
  border-radius: 5px;
  border: 1px solid rgba(139, 26, 26, 0.5);
  overflow: hidden;
}

.threat-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b1a1a, #ff3333);
  border-radius: 5px;
  transition: width 0.5s ease;
}

#hud-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

#day-counter {
  font-size: 0.75em;
  color: var(--sepia);
  white-space: nowrap;
}

#rank-badge {
  background: linear-gradient(135deg, var(--gold), #8b6914);
  color: var(--dark-brown);
  padding: 2px 10px;
  border-radius: 3px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Main Area */
#main-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas {
  display: block;
  cursor: pointer;
}

/* Sidebar */
#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 260px;
  height: 100%;
  background: var(--panel-bg);
  border-left: 2px solid var(--gold);
  transition: transform 0.3s ease;
  z-index: 50;
  overflow-y: auto;
}

#sidebar.collapsed {
  transform: translateX(220px);
}

#sidebar-toggle {
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%) translateX(-100%);
  background: var(--panel-bg);
  border: 2px solid var(--gold);
  border-right: none;
  color: var(--gold);
  padding: 10px 6px;
  font-family: 'Cinzel', serif;
  font-size: 0.65em;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border-radius: 4px 0 0 4px;
  letter-spacing: 2px;
}

#sidebar-content {
  padding: 12px;
}

#sidebar-content h3 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 0.9em;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
  padding-bottom: 6px;
}

.sidebar-item {
  background: rgba(0,0,0,0.3);
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 3px;
  border-left: 3px solid var(--gold);
  font-size: 0.75em;
  color: var(--cream);
}

.sidebar-item .item-name {
  color: var(--gold);
  font-family: 'Cinzel', serif;
}

/* Tooltip */
#tooltip {
  position: absolute;
  background: var(--panel-bg);
  border: 2px solid var(--gold);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.75em;
  color: var(--cream);
  pointer-events: none;
  z-index: 200;
  max-width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.8);
}

#tooltip.hidden { display: none; }

#tooltip .tip-title {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 4px;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal.hidden { display: none; }

.modal-content {
  background: linear-gradient(180deg, #3d2412 0%, #2a1a0e 100%);
  border: 3px solid var(--gold);
  border-radius: 8px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(201, 168, 76, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
}

.modal-header h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.2em;
  letter-spacing: 2px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--crimson);
  font-size: 1.5em;
  cursor: pointer;
}

/* Build Cards */
.build-card {
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(201, 168, 76, 0.3);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.build-card:hover {
  border-color: var(--gold);
}

.build-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.build-card-name {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1em;
}

.build-card-cost {
  color: var(--sepia);
  font-weight: bold;
}

.build-card-desc {
  color: rgba(240,224,192,0.7);
  font-size: 0.8em;
  font-style: italic;
  margin-bottom: 8px;
}

.build-card-stats {
  color: var(--cream);
  font-size: 0.8em;
  margin-bottom: 8px;
}

.build-btn {
  background: linear-gradient(180deg, #c9a84c, #8b6914);
  color: var(--dark-brown);
  border: none;
  padding: 6px 20px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.85em;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.2s;
}

.build-btn:hover {
  background: linear-gradient(180deg, #dbb85c, #a07a1a);
  transform: scale(1.02);
}

.build-btn:disabled {
  background: #555;
  color: #888;
  cursor: not-allowed;
  transform: none;
}

/* Tile selector in build picker */
.tile-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.tile-select {
  background: rgba(0,0,0,0.6);
  color: var(--gold);
  border: 2px solid rgba(201, 168, 76, 0.4);
  padding: 4px 10px;
  font-family: 'Special Elite', monospace;
  font-size: 0.85em;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
}

.tile-select:focus {
  outline: none;
  border-color: var(--gold);
}

/* Bribe modal */
.bribe-officer-name {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.2em;
  text-align: center;
  margin-bottom: 10px;
}

.bribe-info {
  text-align: center;
  margin-bottom: 12px;
  font-size: 0.9em;
}

.bribe-btn {
  display: block;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--green-bribe), #1a4a2a);
  color: var(--cream);
  border: 2px solid #4a9a5a;
  padding: 10px 30px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1em;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.bribe-btn:hover {
  background: linear-gradient(180deg, #3a8b4a, #2a6b3a);
}

.bribe-btn:disabled {
  background: #444;
  border-color: #666;
  cursor: not-allowed;
}

/* Newspaper */
.newspaper-content {
  background: #f5e6c8;
  color: #1a0f07;
  border: 3px solid #2a1a0e;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  font-family: 'Special Elite', monospace;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.newspaper-header {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 1.8em;
  border-bottom: 3px double #2a1a0e;
  padding-bottom: 6px;
  margin-bottom: 6px;
  letter-spacing: 3px;
}

.newspaper-date {
  font-size: 0.75em;
  color: #5c3a1e;
  margin-bottom: 12px;
}

.newspaper-headline {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.3em;
  margin-bottom: 12px;
  line-height: 1.3;
}

.newspaper-body {
  font-size: 0.85em;
  line-height: 1.5;
  margin-bottom: 16px;
  color: #3d2412;
}

.newspaper-btn {
  background: #2a1a0e;
  color: #f5e6c8;
  border: none;
  padding: 8px 24px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
  letter-spacing: 2px;
}

/* Ticker */
#ticker-bar {
  background: linear-gradient(180deg, #2a1a0e, #1a0f07);
  border-top: 2px solid var(--gold);
  padding: 4px 0;
  overflow: hidden;
  height: 28px;
  position: relative;
}

#ticker-content {
  white-space: nowrap;
  position: absolute;
  animation: ticker 30s linear infinite;
  font-size: 0.75em;
  color: var(--sepia);
  line-height: 20px;
}

@keyframes ticker {
  0% { transform: translateX(100vw); }
  100% { transform: translateX(-200%); }
}

/* End Day */
#end-day-container {
  padding: 6px;
  text-align: center;
  background: var(--dark-bg);
}

#build-quick-btn {
  background: linear-gradient(180deg, #c9a84c, #8b6914);
  color: var(--dark-brown);
  border: 3px solid #dbb85c;
  padding: 8px 30px;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.1em;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  margin-right: 12px;
}

#build-quick-btn:hover {
  background: linear-gradient(180deg, #dbb85c, #a07a1a);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.6);
}

#build-quick-btn:active {
  transform: translateY(1px);
}

#hire-thugs-btn {
  background: linear-gradient(180deg, #6a3a6a, #3d1a3d);
  color: #e8c8e8;
  border: 3px solid #8a5a8a;
  padding: 8px 24px;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.1em;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  margin-right: 12px;
}

#hire-thugs-btn:hover {
  background: linear-gradient(180deg, #8a4a8a, #5a2a5a);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(61,26,61,0.6);
}

#hire-thugs-btn:active {
  transform: translateY(1px);
}

/* Hire Modal Styles */
.hire-card {
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(138, 90, 138, 0.3);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.hire-card:hover {
  border-color: #8a5a8a;
}

.hire-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.hire-card-name {
  font-family: 'Cinzel', serif;
  color: #e8c8e8;
  font-size: 1em;
}

.hire-card-cost {
  color: var(--gold);
  font-weight: bold;
}

.hire-card-desc {
  color: rgba(240,224,192,0.7);
  font-size: 0.8em;
  font-style: italic;
  margin-bottom: 8px;
}

.hire-card-stats {
  color: var(--cream);
  font-size: 0.8em;
  margin-bottom: 8px;
}

.hire-btn {
  background: linear-gradient(180deg, #6a3a6a, #3d1a3d);
  color: #e8c8e8;
  border: 2px solid #8a5a8a;
  padding: 6px 20px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.85em;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.2s;
}

.hire-btn:hover {
  background: linear-gradient(180deg, #8a4a8a, #5a2a5a);
  transform: scale(1.02);
}

.hire-btn:disabled {
  background: #555;
  color: #888;
  border-color: #666;
  cursor: not-allowed;
  transform: none;
}

.roster-title {
  color: #8a5a8a;
  font-family: 'Cinzel', serif;
  font-size: 0.85em;
  margin: 12px 0 6px;
  border-top: 1px solid rgba(138, 90, 138, 0.3);
  padding-top: 8px;
}

.roster-item {
  background: rgba(0,0,0,0.3);
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: 3px;
  border-left: 3px solid #8a5a8a;
  font-size: 0.78em;
  color: var(--cream);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.roster-item .thug-name {
  color: #e8c8e8;
  font-family: 'Cinzel', serif;
}

.fire-btn {
  background: linear-gradient(180deg, #6a2a2a, #4a1a1a);
  color: var(--cream);
  border: 1px solid #8a3a3a;
  padding: 2px 10px;
  font-family: 'Cinzel', serif;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.8em;
}

.fire-btn:hover {
  background: #8a3a3a;
}

#end-day-btn {
  background: linear-gradient(180deg, #8b1a1a, #5c1010);
  color: var(--gold);
  border: 3px solid var(--gold);
  padding: 8px 40px;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.1em;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#end-day-btn:hover {
  background: linear-gradient(180deg, #a52a2a, #7c2020);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.6);
}

#end-day-btn:active {
  transform: translateY(1px);
}

/* Footer */
#game-footer {
  background: #1a0f07;
  border-top: 1px solid rgba(201, 168, 76, 0.2);
  padding: 4px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.6em;
}

#game-footer a {
  color: var(--gold);
  text-decoration: none;
}

#game-footer span {
  color: rgba(240,224,192,0.4);
  font-style: italic;
}

/* Info modal */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.15);
  font-size: 0.9em;
}

.info-label { color: rgba(240,224,192,0.6); }
.info-value { color: var(--gold); font-family: 'Cinzel', serif; }

.upgrade-btn {
  margin-top: 12px;
  background: linear-gradient(180deg, #4a6a9a, #2a4a6a);
  color: var(--cream);
  border: 2px solid #6a8aba;
  padding: 8px 20px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
  font-size: 0.9em;
}

.upgrade-btn:disabled {
  background: #444;
  border-color: #666;
  cursor: not-allowed;
}

.demolish-btn {
  margin-top: 6px;
  background: linear-gradient(180deg, #6a2a2a, #4a1a1a);
  color: var(--cream);
  border: 2px solid #8a3a3a;
  padding: 6px 20px;
  font-family: 'Cinzel', serif;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
  font-size: 0.8em;
}

/* Animations */
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(201, 168, 76, 0.3); }
  50% { box-shadow: 0 0 15px rgba(201, 168, 76, 0.6); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.screen-shake {
  animation: shake 0.3s ease;
}

.income-flash {
  animation: goldPulse 0.5s ease;
}

/* Mobile */
@media (max-width: 768px) {
  #hud {
    padding: 4px 8px;
    gap: 6px;
  }
  
  #hud-title {
    font-size: 0.85em;
    width: 100%;
    text-align: center;
  }
  
  #hud-stats {
    gap: 4px;
    justify-content: center;
  }
  
  .stat {
    padding: 2px 5px;
    font-size: 0.65em;
  }
  
  .stat-label { display: none; }
  
  .threat-bar { width: 40px; }
  
  #hud-meta {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  
  #sidebar { width: 220px; }
  #sidebar.collapsed { transform: translateX(180px); }
  
  #build-quick-btn {
    padding: 6px 14px;
    font-size: 0.85em;
    margin-right: 6px;
  }
  
  #hire-thugs-btn {
    padding: 6px 14px;
    font-size: 0.85em;
    margin-right: 6px;
  }
  
  #end-day-btn {
    padding: 6px 20px;
    font-size: 0.85em;
  }
  
  .modal-content, .newspaper-content {
    max-width: 95%;
    padding: 14px;
  }
}