/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #060911;
  color: #E2E8F0;
  overflow: hidden;
  height: 100vh;
}

h1, h2, h3, h4, .font-cinzel {
  font-family: 'Cinzel', serif;
}

/* Main Container Layout */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header Styling */
#game-header {
  height: 60px;
  background: linear-gradient(180deg, #111726 0%, #0B0F1A 100%);
  border-bottom: 2px solid #D4AF37;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.game-title {
  color: #FFD700;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.4);
}

.game-subtitle {
  color: #94A3B8;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 15px;
}

.player-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid #D4AF37;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.player-name {
  font-weight: 700;
  font-family: 'Cinzel', serif;
}

.phase-tag {
  background: rgba(212, 175, 55, 0.15);
  color: #FFD700;
  border: 1px solid #D4AF37;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.reinforcements-badge {
  background: #D32F2F;
  color: #FFFFFF;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem;
  animation: pulse-badge 1.5s infinite alternate;
}

@keyframes pulse-badge {
  from { transform: scale(1); box-shadow: 0 0 5px rgba(211, 47, 47, 0.5); }
  to { transform: scale(1.05); box-shadow: 0 0 15px rgba(211, 47, 47, 0.9); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-comedy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
  color: #FFFFFF;
  border: 1px solid #A78BFA;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
}

.btn-comedy:hover {
  background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
  border-color: #DDD6FE;
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.8);
  transform: translateY(-1px);
}

/* Main Workspace */
#game-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Sidebars */
#sidebar-left, #sidebar-right {
  width: 280px;
  background: rgba(11, 15, 26, 0.95);
  border-right: 1px solid rgba(212, 175, 55, 0.3);
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 10px;
  z-index: 5;
}

#sidebar-right {
  border-right: none;
  border-left: 1px solid rgba(212, 175, 55, 0.3);
}

.panel-header h2 {
  font-size: 0.95rem;
  color: #D4AF37;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 5px;
  text-transform: uppercase;
}

.scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-card {
  background: rgba(15, 23, 42, 0.7);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.score-card.active-player {
  background: rgba(212, 175, 55, 0.15);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.score-card.eliminated {
  opacity: 0.4;
  filter: grayscale(100%);
}

.score-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-family: 'Cinzel', serif;
  margin-bottom: 4px;
}

.score-details {
  display: flex;
  justify-content: space-between;
  color: #94A3B8;
  font-size: 0.75rem;
}

.provinces-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.prov-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

/* Map Viewport & Canvas */
#map-viewport {
  flex: 1;
  position: relative;
  background: #060911;
  overflow: hidden;
}

#game-map {
  width: 100%;
  height: 100%;
  display: block;
}

#map-action-bar {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 15, 26, 0.9);
  border: 1px solid #D4AF37;
  padding: 8px 24px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.selection-info {
  font-size: 0.9rem;
  color: #CBD5E1;
}

/* Activity Log */
.log-feed {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 5px;
}

.log-item {
  font-size: 0.78rem;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid #64748B;
  line-height: 1.3;
}

.log-time {
  color: #64748B;
  font-size: 0.7rem;
  margin-right: 5px;
}

.log-type-phase { border-left-color: #388E3C; background: rgba(56, 142, 60, 0.08); }
.log-type-combat { border-left-color: #E65100; background: rgba(230, 81, 0, 0.08); }
.log-type-conquest { border-left-color: #FFD700; background: rgba(255, 215, 0, 0.1); }
.log-type-ability { border-left-color: #9C27B0; background: rgba(156, 39, 176, 0.08); }
.log-type-elimination { border-left-color: #D32F2F; background: rgba(211, 47, 47, 0.15); }

/* Buttons & Styling */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: 'Cinzel', serif;
  transition: all 0.2s ease;
}

.btn-gold, .btn-action-gold {
  background: linear-gradient(135deg, #D4AF37 0%, #AA7C11 100%);
  color: #060911;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-gold:hover, .btn-action-gold:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.btn-dark {
  background: rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-dark:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

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

.modal-card {
  background: #0B0F1A;
  border: 2px solid #D4AF37;
  border-radius: 12px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.9);
}

.modal-large { width: 1000px; }
.modal-medium { width: 500px; }

.modal-title {
  color: #FFD700;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 6px;
}

.modal-subtitle {
  color: #94A3B8;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 20px;
}

/* Scenario Selector Panel */
.scenario-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 27, 75, 0.6));
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.scenario-selector label {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  color: #c4b5fd;
  letter-spacing: 0.5px;
}

.scenario-buttons-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-scenario-opt {
  background: rgba(255, 255, 255, 0.06);
  color: #CBD5E1;
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-scenario-opt:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: #a78bfa;
  color: #f1f5f9;
}

.btn-scenario-opt.active {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #ffffff;
  font-weight: 700;
  border-color: #c4b5fd;
  box-shadow: 0 0 14px rgba(124, 58, 237, 0.6);
}

.scenario-desc-text {
  font-size: 0.82rem;
  color: #94a3b8;
  text-align: center;
  font-style: italic;
  margin-top: 4px;
  line-height: 1.4;
  max-width: 800px;
}

.scenario-badge {
  background: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.5);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.btn-team-toggle {
  background: rgba(255, 255, 255, 0.08);
  color: #CBD5E1;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-team-toggle:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #FFD700;
}

.btn-team-toggle.active {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #FFFFFF;
  border-color: #34D399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.5);
}

.faction-team-tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: center;
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Faction & Setup Grid */
.player-count-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  background: rgba(15, 23, 42, 0.8);
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.player-count-selector label {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: #FFD700;
}

.count-buttons-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-count-opt {
  background: rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-count-opt:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #FFD700;
}

.btn-count-opt.active {
  background: linear-gradient(135deg, #D4AF37 0%, #AA7C11 100%);
  color: #060911;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

.setup-instruction {
  text-align: center;
  font-size: 1.05rem;
  color: #E2E8F0;
  margin-bottom: 15px;
  font-family: 'Cinzel', serif;
}

.start-sim-box {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.faction-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.faction-card:hover {
  transform: translateY(-4px);
  border-color: #FFD700;
}

.faction-icon {
  font-size: 2.2rem;
  text-align: center;
}

.faction-name {
  font-size: 1.2rem;
  text-align: center;
}

.faction-title {
  color: #94A3B8;
  font-size: 0.8rem;
  text-align: center;
  font-style: italic;
}

.faction-motto {
  color: #D4AF37;
  font-size: 0.75rem;
  text-align: center;
  font-family: 'Cinzel', serif;
}

.faction-desc {
  font-size: 0.8rem;
  color: #CBD5E1;
  line-height: 1.3;
}

.faction-ability {
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.btn-select-faction {
  margin-top: auto;
  color: #FFFFFF;
  font-weight: 700;
  padding: 10px;
  border-radius: 6px;
}

/* Conquest Slider Modal */
.conquest-slider-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  background: rgba(15, 23, 42, 0.8);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.conquest-slider-container label {
  font-size: 1.1rem;
  font-family: 'Cinzel', serif;
  color: #FFD700;
  text-align: center;
}

.conquest-slider-container input[type=range] {
  width: 100%;
  accent-color: #D4AF37;
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #94A3B8;
}

/* Victory Epilogue Modal */
.victory-card {
  text-align: center;
  border: 3px solid #FFD700;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
  background: linear-gradient(180deg, #111726 0%, #060911 100%);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: rgba(15, 23, 42, 0.7);
  color: #D4AF37;
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  color: #FFFFFF;
  border-color: #EF4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  transform: scale(1.1);
}

.victory-title {
  font-size: 2.2rem;
  color: #FFD700;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  letter-spacing: 2px;
}

.victory-faction {
  font-size: 1.3rem;
  color: #E2E8F0;
  margin-bottom: 15px;
}

.victory-art-container {
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid #D4AF37;
  margin-bottom: 20px;
}

.victory-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.victory-story-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 20px;
  text-align: left;
}

.story-heading {
  font-size: 1rem;
  color: #D4AF37;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.story-text {
  font-size: 0.95rem;
  color: #E2E8F0;
  line-height: 1.6;
  font-style: italic;
}

/* ============================
   EVENT CARD SYSTEM
   ============================ */

/* Event button in header */
.btn-event {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #fff;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.45);
  border: 1px solid rgba(167, 139, 250, 0.5);
  transition: all 0.2s ease;
}

.btn-event:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.7);
}

@keyframes event-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.8); }
  50%  { box-shadow: 0 0 0 10px rgba(124, 58, 237, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.btn-event-pulse {
  animation: event-pulse 0.8s ease-out 2;
}

/* Targeting bar shown on map when awaiting diocese click */
.event-targeting-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #3b0764cc, #1e1b4bcc);
  border: 2px solid #a78bfa;
  border-radius: 40px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 200;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.5);
  font-family: 'Cinzel', serif;
  color: #e9d5ff;
  font-size: 0.9rem;
  white-space: nowrap;
}

.event-targeting-bar.hidden {
  display: none;
}

/* Event card visual style (extends .relic-card) */
.event-card {
  border-color: rgba(124, 58, 237, 0.5) !important;
  background: rgba(124, 58, 237, 0.06) !important;
  position: relative;
  overflow: hidden;
}

.event-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.08), transparent 60%);
  pointer-events: none;
}

.event-card:hover {
  border-color: #a78bfa !important;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.35) !important;
}

/* Log colours for new event/warning/bonus types */
.log-type-event    { border-left-color: #7c3aed; background: rgba(124, 58, 237, 0.12); color: #e9d5ff; }
.log-type-warning  { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); color: #fde68a; }
.log-type-bonus    { border-left-color: #0891b2; background: rgba(8, 145, 178, 0.08); }
.log-type-info     { border-left-color: #475569; }
