/* ========================================================================================
   MEDIEVAL KINGDOM SIMULATOR - MOBILE OPTIMIZED STYLESHEET
   Version 2.1.1 - Enhanced Mobile Support
   ======================================================================================== */

/* Eredhar Studios Theme Variables */
:root {
  --bg-dark: #0e0e14;
  --bg-card: rgba(22, 22, 33, 0.95);
  --bg-header: rgba(26, 26, 37, 0.95);
  --bg-overlay: rgba(22, 22, 33, 0.92);
  --gold: #ffe082;
  --gold-hover: #ffcc33;
  --blue-link: #81d4fa;
  --purple: #ba68c8;
  --purple-hover: #ab47bc;
  --text-light: #f5f5f5;
  --text-gray: #ccc;
  --border-gold: 2px solid #ffe082;
  --shadow-gold: 0 0 20px rgba(255, 224, 130, 0.4);
  --shadow-gold-hover: 0 0 30px rgba(255, 224, 130, 0.6);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Improve touch scrolling */
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: 'Playfair Display', serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  /* Prevent text selection on mobile */
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection for specific elements */
.event-description,
.about-intro,
.changelog-content,
p {
  -webkit-user-select: text;
  user-select: text;
}

/* ============================================
   GAME FRAME - Main Container
   ============================================ */

.game-frame {
  width: 100%;
  max-width: 1800px;
  height: 96vh;
  max-height: 1100px;
  display: flex;
  flex-direction: column;
  border: 4px solid var(--gold);
  border-radius: 16px;
  background-color: var(--bg-dark);
  box-shadow: 
    0 0 40px rgba(255, 224, 130, 0.6),
    inset 0 0 60px rgba(255, 224, 130, 0.1);
  position: relative;
  overflow: hidden;
}

/* Ornate corner decorations */
.game-frame::before,
.game-frame::after {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border: 3px solid rgba(255, 224, 130, 0.6);
  z-index: 10;
  pointer-events: none;
}

.game-frame::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
  border-radius: 8px 0 0 0;
}

.game-frame::after {
  top: 8px;
  right: 8px;
  border-left: none;
  border-bottom: none;
  border-radius: 0 8px 0 0;
}

/* ============================================
   TOP BAR - Title and Always-Visible Stats
   ============================================ */

.top-bar {
  background: linear-gradient(180deg, var(--bg-header) 0%, rgba(26, 26, 37, 0.98) 100%);
  border-bottom: 3px solid var(--gold);
  padding: 15px 30px;
  flex-shrink: 0;
  z-index: 5;
}

.top-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.game-title {
  color: var(--gold);
  font-size: 1.8rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.8),
    0 0 20px rgba(255, 224, 130, 0.5);
  margin: 0;
}

.top-bar-right {
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
}

.stat-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(255, 224, 130, 0.1);
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid rgba(255, 224, 130, 0.3);
  transition: all 0.3s ease;
  /* Better tap targets on mobile */
  min-height: 44px;
}

.stat-display:hover {
  background-color: rgba(255, 224, 130, 0.2);
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(255, 224, 130, 0.3);
}

.stat-display .stat-icon {
  font-size: 1.3rem;
}

.stat-display .stat-value {
  color: var(--gold);
  font-weight: bold;
  font-size: 1.1rem;
  min-width: 40px;
  text-align: right;
}

/* ============================================
   GAME VIEWPORT - Kingdom Background Area
   ============================================ */

.game-viewport {
  flex: 1;
  background-image: url('../images/kingdom-background.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
}

/* Subtle vignette effect */
.game-viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
}

/* ============================================
   OVERLAY PANELS - Content Overlays
   ============================================ */

.overlay-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 20px));
  width: 85%;
  max-width: 900px;
  max-height: 85%;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(15px);
  border: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(255, 224, 130, 0.3),
    inset 0 0 40px rgba(255, 224, 130, 0.05);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.overlay-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%);
}

.overlay-header {
  background: linear-gradient(180deg, rgba(255, 224, 130, 0.15) 0%, rgba(255, 224, 130, 0.05) 100%);
  border-bottom: 2px solid rgba(255, 224, 130, 0.3);
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.overlay-header h2 {
  color: var(--gold);
  font-size: 1.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0;
}

.close-overlay-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 2rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  border-radius: 50%;
  /* Better tap target */
  min-width: 44px;
  min-height: 44px;
}

.close-overlay-btn:hover,
.close-overlay-btn:active {
  background-color: rgba(255, 224, 130, 0.2);
  transform: rotate(90deg);
  color: var(--gold-hover);
}

.overlay-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px;
  /* Better mobile scrolling */
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for overlay content */
.overlay-content::-webkit-scrollbar {
  width: 10px;
}

.overlay-content::-webkit-scrollbar-track {
  background: rgba(255, 224, 130, 0.1);
  border-radius: 5px;
}

.overlay-content::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 5px;
}

.overlay-content::-webkit-scrollbar-thumb:hover {
  background: var(--gold-hover);
}

/* ============================================
   BOTTOM NAVIGATION - Action Buttons
   ============================================ */

.bottom-nav {
  background: linear-gradient(0deg, var(--bg-header) 0%, rgba(26, 26, 37, 0.98) 100%);
  border-top: 3px solid var(--gold);
  padding: 15px 20px;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  flex-shrink: 0;
  z-index: 5;
}

.nav-btn {
  background: linear-gradient(180deg, rgba(255, 224, 130, 0.15) 0%, rgba(255, 224, 130, 0.05) 100%);
  color: var(--gold);
  border: 2px solid rgba(255, 224, 130, 0.4);
  padding: 12px 25px;
  border-radius: 8px;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
  /* Better tap targets */
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 224, 130, 0.3) 0%, rgba(255, 224, 130, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-btn:hover,
.nav-btn:active {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 224, 130, 0.4);
  transform: translateY(-2px);
}

.nav-btn:hover::before,
.nav-btn:active::before {
  opacity: 1;
}

.nav-btn.active {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-hover) 100%);
  color: var(--bg-dark);
  border-color: var(--gold-hover);
  box-shadow: 
    0 0 25px rgba(255, 224, 130, 0.6),
    inset 0 -3px 10px rgba(0, 0, 0, 0.3);
}

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

/* ============================================
   BUILDING CARDS
   ============================================ */

.building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.building-card {
  background-color: rgba(26, 26, 37, 0.9);
  border-radius: 12px;
  border: 3px solid rgba(255, 224, 130, 0.3);
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.building-card:hover,
.building-card:active {
  transform: translateY(-5px);
  border-color: var(--gold);
  box-shadow: 0 8px 25px rgba(255, 224, 130, 0.4);
}

.building-image {
  width: 100%;
  height: 160px;
  overflow: hidden;
  border-bottom: 2px solid rgba(255, 224, 130, 0.3);
}

.building-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.building-card:hover .building-image img,
.building-card:active .building-image img {
  transform: scale(1.05);
}

.building-content {
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.building-info h3 {
  color: var(--gold);
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.building-info p {
  color: var(--text-gray);
  font-size: 0.85rem;
  margin: 3px 0;
}

.building-cost {
  color: var(--gold) !important;
  font-size: 0.9rem !important;
  font-weight: bold;
}

.building-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.building-count {
  color: var(--gold);
  font-size: 1.3rem;
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

.buy-btn {
  background-color: var(--gold);
  color: var(--bg-dark);
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  /* Better tap target */
  min-height: 44px;
  min-width: 80px;
}

.buy-btn:hover,
.buy-btn:active {
  background-color: var(--gold-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 224, 130, 0.5);
}

.buy-btn:active {
  transform: scale(0.98);
}

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

/* ============================================
   STATS SECTIONS
   ============================================ */

.stats-section {
  margin-bottom: 30px;
}

.stats-section-title {
  color: var(--gold);
  font-size: 1.3rem;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid rgba(255, 224, 130, 0.3);
  padding-bottom: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
}

.summary-item {
  background-color: rgba(26, 26, 37, 0.8);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 224, 130, 0.3);
}

.summary-item h4 {
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 8px;
}

.summary-item p {
  color: var(--text-gray);
  font-size: 0.9rem;
  margin: 3px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.stat-card-small {
  background-color: rgba(26, 26, 37, 0.9);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 224, 130, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.stat-card-small:hover,
.stat-card-small:active {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(255, 224, 130, 0.3);
}

.stat-card-small .stat-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-label-small {
  color: var(--text-gray);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value-small {
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: bold;
}

.stat-rate-small {
  color: var(--text-gray);
  font-size: 0.8rem;
  font-style: italic;
}

/* ============================================
   EVENT LOG
   ============================================ */

.event-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
  background-color: rgba(26, 26, 37, 0.8);
  border-radius: 8px;
}

.event-log::-webkit-scrollbar {
  width: 8px;
}

.event-log::-webkit-scrollbar-track {
  background: rgba(255, 224, 130, 0.1);
  border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 4px;
}

.event-log-empty {
  color: var(--text-gray);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.event-log-entry {
  background-color: rgba(22, 22, 33, 0.9);
  padding: 12px 15px;
  border-radius: 6px;
  border-left: 4px solid var(--gold);
  animation: slideInLog 0.3s ease;
}

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

.event-log-entry.positive {
  border-left-color: #4caf50;
}

.event-log-entry.negative {
  border-left-color: #f44336;
}

.event-log-entry.neutral {
  border-left-color: #2196f3;
}

.event-log-title {
  color: var(--gold);
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 5px;
}

.event-log-desc {
  color: var(--text-gray);
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.event-log-time {
  color: #888;
  font-size: 0.75rem;
  font-style: italic;
}

/* ============================================
   TRADE CONTROLS
   ============================================ */

.trade-controls {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.trade-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.trade-input {
  flex: 1;
  background-color: rgba(26, 26, 37, 0.9);
  border: 2px solid var(--gold);
  color: var(--text-light);
  padding: 12px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  /* Better mobile input */
  min-height: 44px;
}

.trade-input:focus {
  outline: none;
  border-color: var(--gold-hover);
  box-shadow: 0 0 15px rgba(255, 224, 130, 0.4);
}

.trade-btn {
  background-color: var(--blue-link);
  color: var(--bg-dark);
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  /* Better tap target */
  min-height: 44px;
}

.trade-btn:hover,
.trade-btn:active {
  background-color: #4fc3f7;
  box-shadow: 0 4px 12px rgba(129, 212, 250, 0.5);
}

.trade-btn:disabled {
  background-color: #555;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
}

.quick-sell-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.quick-sell-btn {
  background-color: rgba(26, 26, 37, 0.9);
  color: var(--gold);
  border: 2px solid var(--gold);
  padding: 10px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Better tap target */
  min-height: 44px;
}

.quick-sell-btn:hover,
.quick-sell-btn:active {
  background-color: var(--gold);
  color: var(--bg-dark);
  box-shadow: 0 2px 8px rgba(255, 224, 130, 0.4);
}

/* ============================================
   TECHNOLOGY TREE
   ============================================ */

.tech-tier {
  margin-bottom: 30px;
}

.tech-tier-title {
  color: var(--purple);
  font-size: 1.2rem;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tech-tier-title::before,
.tech-tier-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--purple));
}

.tech-tier-title::after {
  background: linear-gradient(to left, transparent, var(--purple));
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.tech-card {
  background-color: rgba(26, 26, 37, 0.9);
  padding: 15px;
  border-radius: 8px;
  border: 2px solid rgba(186, 104, 200, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  /* Better tap target */
  min-height: 150px;
}

.tech-card:hover:not(.tech-locked):not(.tech-purchased),
.tech-card:active:not(.tech-locked):not(.tech-purchased) {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(186, 104, 200, 0.4);
  border-color: var(--purple);
}

.tech-card.tech-locked {
  opacity: 0.5;
  filter: grayscale(100%);
  cursor: not-allowed;
}

.tech-card.tech-purchased {
  border-color: #4caf50;
  background-color: rgba(76, 175, 80, 0.1);
}

.tech-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 10px;
}

.tech-name {
  color: var(--purple);
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
}

.tech-card.tech-purchased .tech-name {
  color: #4caf50;
}

.tech-desc {
  color: var(--text-gray);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 10px;
  line-height: 1.4;
}

.tech-cost {
  color: var(--purple);
  font-size: 0.9rem;
  font-weight: bold;
  text-align: center;
  padding: 6px;
  background-color: rgba(186, 104, 200, 0.1);
  border-radius: 4px;
}

.tech-card.tech-purchased .tech-cost {
  color: #4caf50;
}

.tech-requirement {
  color: #f44336;
  font-size: 0.75rem;
  text-align: center;
  margin-top: 5px;
  font-style: italic;
}

/* ============================================
   ACHIEVEMENTS
   ============================================ */

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.achievement-card {
  background-color: rgba(26, 26, 37, 0.9);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 224, 130, 0.3);
  text-align: center;
  transition: all 0.2s ease;
}

.achievement-card.unlocked {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 224, 130, 0.3);
}

.achievement-card.locked {
  opacity: 0.4;
  filter: grayscale(100%);
}

.achievement-card:hover,
.achievement-card:active {
  transform: translateY(-2px);
}

.achievement-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.achievement-name {
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.achievement-desc {
  color: var(--text-gray);
  font-size: 0.75rem;
}

.achievement-progress {
  color: var(--blue-link);
  font-size: 0.7rem;
  margin-top: 4px;
  font-style: italic;
}

/* ============================================
   CHANGELOG SECTION - Main Collapsible
   ============================================ */

.about-section {
  margin-bottom: 30px;
}

.changelog-main-section {
  cursor: pointer;
  padding: 15px 20px;
  background-color: rgba(26, 26, 37, 0.8);
  border: 2px solid rgba(255, 224, 130, 0.3);
  border-radius: 8px;
  transition: all 0.3s ease;
  margin-bottom: 15px;
  /* Better tap target */
  min-height: 60px;
}

.changelog-main-section:hover,
.changelog-main-section:active {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(255, 224, 130, 0.3);
  background-color: rgba(26, 26, 37, 0.95);
}

.changelog-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.changelog-main-arrow {
  color: var(--gold);
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.changelog-main-section.expanded .changelog-main-arrow {
  transform: rotate(180deg);
}

.changelog-main-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.changelog-main-section.expanded + .changelog-main-content {
  max-height: 3000px;
  margin-top: 15px;
}

/* ============================================
   CHANGELOG SECTION - Version Entries
   ============================================ */

.changelog-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.changelog-entry {
  background-color: rgba(26, 26, 37, 0.9);
  border: 2px solid rgba(255, 224, 130, 0.3);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.changelog-entry:hover,
.changelog-entry:active {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(255, 224, 130, 0.3);
}

.changelog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(90deg, rgba(255, 224, 130, 0.1) 0%, transparent 100%);
  /* Better tap target */
  min-height: 60px;
}

.changelog-version {
  color: var(--gold);
  font-weight: bold;
  font-size: 1.1rem;
}

.changelog-arrow {
  color: var(--gold);
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.changelog-entry.expanded .changelog-arrow {
  transform: rotate(180deg);
}

.changelog-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 20px;
}

.changelog-entry.expanded .changelog-content {
  max-height: 2000px;
  padding: 0 20px 20px 20px;
}

.changelog-category {
  color: var(--blue-link);
  font-weight: bold;
  font-size: 1rem;
  margin: 15px 0 8px 0;
}

.changelog-category:first-child {
  margin-top: 5px;
}

.changelog-content ul {
  margin: 0 0 10px 20px;
  padding: 0;
  color: var(--text-gray);
  line-height: 1.8;
}

.changelog-content li {
  margin-bottom: 6px;
}

.changelog-content li strong {
  color: var(--gold);
}

/* ============================================
   ABOUT SECTION
   ============================================ */

.about-intro {
  color: var(--text-gray);
  font-size: 1.05rem;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 20px;
}

.credits-box {
  background: linear-gradient(135deg, rgba(26, 26, 37, 0.9), rgba(22, 22, 33, 0.9));
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  border: 2px solid rgba(129, 212, 250, 0.3);
}

.credits-text {
  color: var(--text-light);
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.credits-author {
  color: var(--gold);
  font-size: 1.3rem;
  font-weight: bold;
}

/* ============================================
   EVENT POPUP (for random events)
   ============================================ */

.event-popup {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
  backdrop-filter: blur(10px);
  padding: 20px;
}

.event-popup.active {
  display: flex;
}

.event-popup-content {
  background-color: var(--bg-card);
  padding: 40px;
  border-radius: 12px;
  border: var(--border-gold);
  text-align: center;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-gold-hover);
  animation: slideIn 0.3s ease;
  backdrop-filter: blur(20px);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.event-title {
  color: var(--gold);
  font-size: 2rem;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.event-description {
  color: var(--text-light);
  font-size: 1.1rem;
  margin-bottom: 30px;
  line-height: 1.6;
  white-space: pre-line;
}

.event-choices {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.event-choice-btn {
  background-color: var(--gold);
  color: var(--bg-dark);
  border: none;
  padding: 15px 30px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  /* Better tap target */
  min-height: 50px;
}

.event-choice-btn:hover:not(:disabled),
.event-choice-btn:active:not(:disabled) {
  background-color: var(--gold-hover);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 224, 130, 0.5);
}

.event-choice-btn:disabled {
  background-color: #555;
  color: #888;
  cursor: not-allowed;
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */

.game-over {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
  padding: 20px;
}

.game-over.active {
  display: flex;
}

.game-over-content {
  background-color: var(--bg-card);
  padding: 40px;
  border-radius: 12px;
  border: var(--border-gold);
  text-align: center;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-gold-hover);
  backdrop-filter: blur(20px);
}

.game-over-content h2 {
  color: var(--gold);
  font-size: 2.5rem;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.game-over-content p {
  color: var(--text-gray);
  font-size: 1.2rem;
  margin-bottom: 30px;
}

.restart-btn {
  background-color: var(--gold);
  color: var(--bg-dark);
  border: none;
  padding: 15px 40px;
  border-radius: 6px;
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  /* Better tap target */
  min-height: 50px;
}

.restart-btn:hover,
.restart-btn:active {
  background-color: var(--gold-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(255, 224, 130, 0.6);
}

/* ============================================
   RESPONSIVE DESIGN - TABLET
   ============================================ */

@media (max-width: 1200px) {
  .game-frame {
    height: 85vh;
  }
  
  .overlay-panel {
    width: 90%;
    max-height: 80%;
  }
  
  .game-title {
    font-size: 1.5rem;
    letter-spacing: 2px;
  }
  
  .top-bar-right {
    gap: 15px;
  }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE (LANDSCAPE)
   ============================================ */

@media (max-width: 900px) and (orientation: landscape) {
  .game-frame {
    height: 95vh;
  }
  
  .top-bar {
    padding: 10px 15px;
  }
  
  .game-title {
    font-size: 1.2rem;
    letter-spacing: 1px;
  }
  
  .stat-display {
    padding: 6px 10px;
    gap: 6px;
  }
  
  .stat-display .stat-icon {
    font-size: 1rem;
  }
  
  .stat-display .stat-value {
    font-size: 0.9rem;
    min-width: 30px;
  }
  
  .bottom-nav {
    padding: 10px 15px;
    gap: 10px;
  }
  
  .nav-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
  }
  
  .overlay-panel {
    width: 95%;
    max-height: 85%;
  }
  
  .overlay-header {
    padding: 12px 15px;
  }
  
  .overlay-header h2 {
    font-size: 1.3rem;
  }
  
  .overlay-content {
    padding: 15px;
  }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE (PORTRAIT)
   ============================================ */

@media (max-width: 768px) {
  body {
    padding: 5px;
  }
  
  .game-frame {
    height: 98vh;
    border-width: 2px;
    border-radius: 12px;
  }
  
  .game-frame::before,
  .game-frame::after {
    width: 40px;
    height: 40px;
    border-width: 2px;
  }
  
  /* TOP BAR MOBILE */
  .top-bar {
    padding: 10px 15px;
  }
  
  .game-title {
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-align: center;
  }
  
  .top-bar-content {
    flex-direction: column;
    gap: 10px;
  }
  
  .top-bar-right {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    justify-items: center;
  }
  
  .stat-display {
    padding: 6px 10px;
    gap: 6px;
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }
  
  .stat-display .stat-icon {
    font-size: 1.1rem;
  }
  
  .stat-display .stat-value {
    font-size: 0.95rem;
    min-width: 35px;
  }
  
  /* BOTTOM NAV MOBILE */
  .bottom-nav {
    padding: 10px;
    gap: 8px;
  }
  
  .nav-btn {
    padding: 10px 15px;
    font-size: 0.85rem;
    min-height: 40px;
    flex: 1 1 calc(50% - 4px);
  }
  
  /* OVERLAY MOBILE */
  .overlay-panel {
    width: 98%;
    max-height: 90%;
    border-width: 2px;
  }
  
  .overlay-header {
    padding: 12px 15px;
  }
  
  .overlay-header h2 {
    font-size: 1.3rem;
    letter-spacing: 1px;
  }
  
  .close-overlay-btn {
    font-size: 1.8rem;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
  
  .overlay-content {
    padding: 15px;
  }
  
  /* BUILDING CARDS MOBILE */
  .building-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .building-card {
    border-width: 2px;
  }
  
  .building-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .building-actions {
    justify-content: space-between;
    width: 100%;
  }
  
  .buy-btn {
    flex: 1;
    min-width: 100px;
  }
  
  /* STATS MOBILE */
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  /* TRADE MOBILE */
  .quick-sell-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* TECH TREE MOBILE */
  .tech-grid {
    grid-template-columns: 1fr;
  }
  
  .tech-card {
    min-height: 140px;
  }
  
  /* ACHIEVEMENTS MOBILE */
  .achievements-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  /* CHANGELOG MOBILE */
  .changelog-header {
    padding: 12px 15px;
    min-height: 50px;
  }
  
  .changelog-version {
    font-size: 0.95rem;
  }
  
  .changelog-content ul {
    margin: 0 0 10px 15px;
  }
  
  /* EVENT POPUP MOBILE */
  .event-popup-content {
    padding: 25px;
    max-height: 85vh;
  }
  
  .event-title {
    font-size: 1.6rem;
  }
  
  .event-description {
    font-size: 1rem;
  }
  
  .event-choice-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    min-height: 48px;
  }
  
  /* GAME OVER MOBILE */
  .game-over-content {
    padding: 30px 20px;
  }
  
  .game-over-content h2 {
    font-size: 2rem;
  }
  
  .game-over-content p {
    font-size: 1rem;
  }
  
  .restart-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    min-height: 48px;
  }
}

/* ============================================
   RESPONSIVE DESIGN - SMALL MOBILE
   ============================================ */

@media (max-width: 480px) {
  .game-title {
    font-size: 1rem;
  }
  
  .top-bar-right {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-display .stat-icon {
    font-size: 1rem;
  }
  
  .stat-display .stat-value {
    font-size: 0.85rem;
    min-width: 30px;
  }
  
  .nav-btn {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
  
  .overlay-header h2 {
    font-size: 1.1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .achievements-grid {
    grid-template-columns: 1fr;
  }
  
  .event-title {
    font-size: 1.4rem;
  }
  
  .event-description {
    font-size: 0.9rem;
  }
}

/* ============================================
   PREVENT ZOOM ON INPUT FOCUS (iOS)
   ============================================ */

@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============================================
   TOUCH-SPECIFIC IMPROVEMENTS
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .nav-btn:hover::before,
  .buy-btn:hover,
  .trade-btn:hover,
  .quick-sell-btn:hover,
  .event-choice-btn:hover:not(:disabled),
  .restart-btn:hover {
    transform: none;
  }
  
  /* Add active (pressed) states for better feedback */
  .nav-btn:active {
    opacity: 0.8;
  }
  
  .buy-btn:active:not(:disabled),
  .trade-btn:active:not(:disabled),
  .quick-sell-btn:active,
  .event-choice-btn:active:not(:disabled),
  .restart-btn:active {
    opacity: 0.9;
    transform: scale(0.98);
  }
  
  /* Larger tap targets for critical buttons */
  .close-overlay-btn {
    min-width: 48px;
    min-height: 48px;
  }
}
