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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
  min-height: 100vh;
  padding: 10px;
  background-attachment: fixed;
}

.app-container {
  max-width: 500px;
  margin: 0 auto;
  background: #1a1a2e;
  color: #fff;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Resources Header */
.resources-header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.resource-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px;
  background: rgba(76, 111, 166, 0.15);
  border-radius: 12px;
  border: 1px solid rgba(76, 111, 166, 0.4);
}

.resource-icon {
  font-size: 20px;
}

.resource-value {
  font-size: 12px;
  font-weight: bold;
  color: #d4af37;
  text-align: center;
  word-break: break-word;
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
  animation: gentle-glow 3s ease-in-out infinite;
}

@keyframes gentle-glow {
  0%, 100% {
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
  }
  50% {
    text-shadow: 0 0 16px rgba(212, 175, 55, 0.6);
  }
}

/* Player Card */
.player-card {
  margin: 20px 15px;
  padding: 15px;
  background: linear-gradient(135deg, rgba(76, 111, 166, 0.25) 0%, rgba(55, 74, 107, 0.25) 100%);
  border: 2px solid rgba(212, 175, 55, 0.4);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(76, 111, 166, 0.15), inset 0 0 20px rgba(212, 175, 55, 0.03);
  animation: card-float 4s ease-in-out infinite;
}

@keyframes card-float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

.player-header {
  text-align: center;
  margin-bottom: 15px;
}

.player-header h2 {
  font-size: 24px;
  color: #fff;
  margin: 0;
}

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

.player-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.avatar-placeholder {
  width: 60px;
  height: 60px;
  background: rgba(212, 175, 55, 0.15);
  border: 2px solid #d4af37;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

#player-username {
  font-size: 14px;
  color: #d4af37;
}

.player-id {
  flex: 1;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 10px;
  padding: 0 15px 10px;
}

.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: left 0.3s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn-storage,
.btn-exchange {
  background: linear-gradient(135deg, #4c6fa6 0%, #374a6b 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(76, 111, 166, 0.3);
}

.btn-storage:hover,
.btn-exchange:hover {
  box-shadow: 0 6px 16px rgba(76, 111, 166, 0.5);
  transform: translateY(-2px);
}

.btn-storage:active,
.btn-exchange:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(76, 111, 166, 0.3);
}

.btn-attack {
  background: linear-gradient(135deg, #d32f2f 0%, #8b0000 100%);
  color: #fff;
  flex: 1;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.btn-attack:hover {
  box-shadow: 0 6px 16px rgba(211, 47, 47, 0.5);
  transform: translateY(-2px);
}

.btn-attack:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.nav-item {
  flex: 1;
  padding: 10px;
  border: none;
  background: rgba(76, 111, 166, 0.15);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.nav-item.active {
  background: linear-gradient(135deg, #4c6fa6 0%, #2a3f57 100%);
  border-color: #d4af37;
  box-shadow: 0 4px 12px rgba(76, 111, 166, 0.4), 0 0 20px rgba(212, 175, 55, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(76, 111, 166, 0.4), 0 0 20px rgba(212, 175, 55, 0.3);
  }
  50% {
    box-shadow: 0 4px 16px rgba(76, 111, 166, 0.5), 0 0 30px rgba(212, 175, 55, 0.5);
  }
}

.nav-item:active {
  transform: scale(0.95);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: flex-end;
}

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

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-content {
  background: #1a1a2e;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(76, 111, 166, 0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 20px;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #d4af37 0%, #a8860e 100%);
  color: #000;
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:active {
  transform: scale(0.95);
}

/* Storage Specific */
.resource-input-group {
  margin-bottom: 15px;
  padding: 12px;
  background: rgba(76, 111, 166, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(76, 111, 166, 0.3);
}

.resource-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.resource-row > span:first-child {
  flex: 1;
}

.input-controls {
  display: flex;
  gap: 8px;
  flex: 0.7;
}

.resource-row input {
  flex: 1;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  min-width: 0;
}

.resource-row input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.max-btn {
  padding: 8px 12px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid #d4af37;
  color: #d4af37;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.max-btn:active {
  transform: scale(0.95);
  background: rgba(212, 175, 55, 0.3);
}

.storage-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  margin-top: 15px;
}

/* Exchange Specific */
.exchange-section {
  padding: 15px;
  background: rgba(76, 111, 166, 0.1);
  border-radius: 10px;
  margin-bottom: 15px;
  font-size: 16px;
}

.exchange-input {
  margin-bottom: 15px;
}

.exchange-input input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(76, 111, 166, 0.3);
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
}

.exchange-input input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.exchange-result {
  padding: 15px;
  background: rgba(212, 175, 55, 0.1);
  border: 2px solid #d4af37;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: bold;
}

.exchange-rate {
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  text-align: center;
}

.exchange-rate p {
  margin: 5px 0;
  font-size: 14px;
}

.exchange-rate .minimum {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin-top: 10px;
}

/* Page Management */
.page {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.page:not(#main-page) {
  display: none;
}

/* Building Tabs */
.building-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  padding: 10px;
  border: 2px solid rgba(76, 111, 166, 0.4);
  background: rgba(76, 111, 166, 0.1);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
}

.tab-btn.active {
  background: linear-gradient(135deg, #4c6fa6 0%, #2a3f57 100%);
  border-color: #d4af37;
  box-shadow: 0 4px 12px rgba(76, 111, 166, 0.4), 0 0 15px rgba(212, 175, 55, 0.2);
  animation: tab-highlight 0.4s ease;
}

@keyframes tab-highlight {
  0% {
    transform: scaleX(0.8);
  }
  100% {
    transform: scaleX(1);
  }
}

.tab-btn:hover:not(.active) {
  background: rgba(76, 111, 166, 0.2);
  border-color: rgba(76, 111, 166, 0.6);
}

.tab-btn:active {
  transform: scale(0.95);
}

/* Buildings Container */
.buildings-container {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Building Card */
.building-card {
  background: linear-gradient(135deg, rgba(76, 111, 166, 0.15) 0%, rgba(55, 74, 107, 0.15) 100%);
  border: 2px solid rgba(76, 111, 166, 0.4);
  border-radius: 15px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 15px rgba(212, 175, 55, 0.02);
  transition: all 0.3s ease;
  animation: card-entrance 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes card-entrance {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.building-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(76, 111, 166, 0.3), inset 0 0 15px rgba(212, 175, 55, 0.05);
  border-color: rgba(212, 175, 55, 0.5);
}

.building-card:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.building-card.locked {
  opacity: 0.6;
  border-color: rgba(255, 255, 255, 0.2);
}

.locked-card {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(160, 130, 30, 0.1) 100%);
  border: 2px dashed rgba(212, 175, 55, 0.4);
}

.building-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.building-title {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.building-level {
  font-size: 12px;
  color: #d4af37;
  background: rgba(212, 175, 55, 0.15);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(212, 175, 55, 0.5);
}

.building-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border-left: 3px solid rgba(212, 175, 55, 0.5);
}

.info-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 14px;
  font-weight: bold;
  color: #d4af37;
}

.production-bar {
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1.5px solid rgba(212, 175, 55, 0.3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.production-fill {
  height: 100%;
  background: linear-gradient(90deg, #4c6fa6 0%, #d4af37 100%);
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
  position: relative;
}

.production-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.building-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.building-btn {
  padding: 10px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.building-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: left 0.3s ease;
}

.building-btn:hover::before {
  left: 100%;
}

.collect-btn {
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.collect-btn:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
  transform: translateY(-2px);
}

.collect-btn:active {
  transform: scale(0.95);
}

.collect-btn:disabled {
  background: linear-gradient(135deg, #616161 0%, #424242 100%);
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: #fff;
}

.upgrade-btn {
  background: linear-gradient(135deg, #4c6fa6 0%, #2a3f57 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(76, 111, 166, 0.3);
}

.upgrade-btn:hover {
  box-shadow: 0 6px 16px rgba(76, 111, 166, 0.5);
  transform: translateY(-2px);
}

.upgrade-btn:active {
  transform: scale(0.95);
}

.buy-btn {
  background: linear-gradient(135deg, #d4af37 0%, #a8860e 100%);
  color: #000;
  grid-column: 1 / -1;
}

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

.locked-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: rgba(212, 175, 55, 0.1);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255, 255, 255, 0.8);
}

.cost-item strong {
  color: #d4af37;
}

/* Responsive */
@media (max-width: 480px) {
  .app-container {
    border-radius: 0;
  }

  .resource-item {
    font-size: 12px;
  }

  .btn {
    font-size: 14px;
    padding: 10px;
  }

  .modal-content {
    border-radius: 0;
  }

  .building-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .building-info {
    grid-template-columns: 1fr 1fr;
  }
}
