* { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; line-height: 1.6; margin: 0; color: #1e293b; background: #f8fafc; }
header { 
  padding: 32px 24px; 
  background: #1d4ed8; 
  color: #ffffff; 
  text-align: center;
  border-bottom: 4px solid #1e40af;
}
header h1 { margin: 0 0 8px; font-size: 28px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
header p { margin: 0; font-size: 16px; font-weight: 600; color: #dbeafe; }
main { padding: 24px 16px; max-width: 1100px; margin: 0 auto; }

.controls { background: #ffffff; border: 2px solid #e2e8f0; border-radius: 12px; padding: 24px; margin-bottom: 24px; box-shadow: 0 4px 0 #e2e8f0; }
.controls label { display: block; font-weight: 700; margin-bottom: 10px; color: #1e293b; font-size: 14px; text-transform: uppercase; }
.controls .row { display: flex; gap: 12px; }
.controls input { flex: 1; padding: 12px 16px; border: 2px solid #cbd5e1; border-radius: 8px; font-size: 16px; color: #0f172a; font-weight: 500; }
.controls input:focus { border-color: #2563eb; outline: none; }
.controls button { 
  padding: 12px 28px; 
  background: #2563eb; 
  color: #ffffff; 
  border: none; 
  border-radius: 8px; 
  cursor: pointer; 
  font-weight: 700;
  text-transform: uppercase;
  transition: background 0.2s;
  box-shadow: 0 4px 0 #1d4ed8;
}
.controls button:hover { 
  background: #1d4ed8;
}
.controls button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1d4ed8;
}
.controls small { display: block; margin-top: 8px; color: #6b7280; }

#status { margin-bottom: 12px; color: #374151; }
.hidden { display: none !important; }

/* Modal Styles */
.modal {
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: #fefefe;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  font-weight: bold;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 5px;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.close-btn:hover {
  color: #1e293b;
}

.close-btn {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: #64748b;
}

.close-btn:hover {
  color: #1e293b;
}

.summary { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.summary .score { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 16px; width: 180px; text-align: center; }
.summary .value { font-size: 36px; font-weight: 700; }
.summary .badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { 
  display: inline-block;
  padding: 4px 10px; 
  border-radius: 999px; 
  font-size: 12px;
  font-weight: 600;
  margin-right: 5px;
  background: #eef2ff; 
  color: #1e40af; 
  border: 1px solid #c7d2fe; 
}

.badge.priority {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge.basic {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

button.primary {
  background: #2563eb;
  color: white;
  border: none;
  font-weight: bold;
}

button.primary:hover {
  background: #1d4ed8;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.panel { 
  background: rgba(255, 255, 255, 0.8); 
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(229, 231, 235, 0.5); 
  border-radius: 12px; 
  padding: 16px; 
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  overflow: hidden;
}

#comparison-grid .panel:first-child { border-top: 4px solid #2563eb; }
#comparison-grid .panel:last-child { border-top: 4px solid #7c3aed; }

#battle-header {
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.kv .key { color: #374151; overflow: hidden; text-overflow: ellipsis; }
.kv .value { font-weight: 600; word-break: break-all; }

.history-row {
  cursor: pointer;
  transition: background 0.2s;
}

.history-row:hover {
  background: #f8fafc;
}

.pricing-card {
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
  padding: 20px;
  border: 2px solid #2563eb;
  border-radius: 12px;
  background: #f0f7ff;
}

.pricing-card .price {
  font-size: 32px;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 16px;
  text-align: center;
}

.pricing-card .price span {
  font-size: 14px;
  font-weight: 400;
  color: #6b7280;
}

.pricing-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}

.pricing-card li {
  margin-bottom: 10px;
  font-size: 14px;
}

.scrollable-content {
  height: 320px;
  overflow-y: auto;
  padding-right: 8px;
}

#rationale .item {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f3f4f6;
  overflow-wrap: break-word;
  word-break: break-word;
}

#rationale .item:last-child {
  border-bottom: none;
}

pre, code { 
  white-space: pre-wrap; 
  word-break: break-all; 
  overflow-wrap: break-word; 
  max-height: 400px; 
  overflow: auto; 
  background: #0b1020; 
  color: #d1e7ff; 
  padding: 12px; 
  border-radius: 6px;
  max-width: 100%;
  display: block;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 12px; margin-bottom: 8px; width: 100%; }
.skeleton-title { height: 24px; margin-bottom: 16px; width: 60%; }
.skeleton-rect { height: 100px; width: 100%; margin-bottom: 16px; }

/* Focus & Accessibility */
:focus-visible {
  outline: 3px solid #3b82f6 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2) !important;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

.modal-content button, 
.modal-content input, 
.modal-content a {
  transition: all 0.2s ease;
}

.action-btn:active, button:active {
  transform: scale(0.98);
}

/* Status Modal Enhancements */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fade-in-up 0.4s ease forwards;
  opacity: 0;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.stat-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse-green 2s infinite;
}

@keyframes fade-in-up {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease-out;
}

.toast.error { border-left: 4px solid #ef4444; }
.toast.success { border-left: 4px solid #10b981; }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
