:root{
  --bg:#f0f2f5; --card:#fff; --muted:#f9f9f9; --text:#333; --sub:#555;
  --army:#ff4d4d; --marines:#4da6ff; --airforce:#33cc33;
  --accent:#007bff; --accentHover:#0056b3; --ok:#10b981; --warn:#ef4444;
}
*{box-sizing:border-box}
body{font-family:Arial, sans-serif;background:var(--bg);margin:0;padding:15px;color:var(--text);}
h1{text-align:center;color:var(--text);margin:0 0 10px;font-size:1.6em;}
h2{margin:0 0 10px;font-size:1.05em;color:var(--sub);}
.section{background:var(--card);padding:15px;margin-bottom:15px;border-radius:10px;box-shadow:0 2px 6px rgba(0,0,0,.08);}
.flex-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;}
label{font-size:.88em;margin-right:4px;}
input[type="number"]{width:70px;padding:8px;border-radius:6px;border:1px solid #ccc;text-align:center;min-height:44px;font-size:16px;}
input.name-input{width:160px;min-height:44px;padding:8px;}
button{padding:12px 16px;border:none;border-radius:8px;background:var(--accent);color:#fff;cursor:pointer;min-width:120px;min-height:44px;font-size:14px;touch-action:manipulation;}
button:hover{background:var(--accentHover);}
button.secondary{background:#6b7280;}
button.secondary:hover{background:#4b5563;}
button:disabled{opacity:.6;cursor:not-allowed;}
.player{margin-bottom:10px;background:var(--muted);padding:10px;border-radius:8px;}
.troop-label{padding:3px 8px;border-radius:999px;color:#fff;font-size:.76em;}
.army{background:var(--army);}
.marines{background:var(--marines);}
.airforce{background:var(--airforce);}
.troop-count{font-size:.85em;margin-top:4px;color:#111;}
.bar-row{margin:10px 0;}
.bar-container{display:flex; height:26px; border-radius:6px; overflow:hidden; background:#e5e7eb; border:1px solid #e5e7eb;}
.bar{height:100%; text-align:center; color:#fff; font-weight:bold; line-height:26px; font-size:.85em; white-space:nowrap; overflow:hidden;}
.orig{opacity:.5; outline:2px dashed rgba(0,0,0,.2); outline-offset:-3px;}
.legend{display:flex; gap:12px; font-size:.85em; color:#444; align-items:center; flex-wrap:wrap;}
.legend-swatch{width:14px; height:14px; border-radius:3px; display:inline-block; margin-right:6px;}
.legend .orig-swatch{border:2px dashed rgba(0,0,0,.35); background:#0000;}
#result p{margin:.25rem 0 .5rem; font-weight:bold;}
.small{font-size:.8em;color:#666;}
.pill{display:inline-block; padding:2px 6px; border-radius:999px; font-size:.75em; margin-left:6px;}
.ok{background:#ecfdf5;color:#065f46;}
.warn{background:#fef2f2;color:#7f1d1d;}
/* tooltip */
.tooltip{position:absolute; top:-26px; left:0; background:#333; color:#fff; padding:2px 6px; border-radius:4px; font-size:.75em; display:none;}

/* Enemy Force Distribution Styles */
.troop-grid{display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:15px; margin:15px 0;}
.troop-card{background:var(--muted); padding:15px; border-radius:10px; border:1px solid #e5e7eb;}
.troop-header{margin-bottom:10px;}
.troop-input-row{display:flex; align-items:center; gap:8px; margin-bottom:8px;}
.troop-input-row label{font-size:.85em; min-width:80px;}
.troop-input-row input{width:100px; text-align:right;}
.percentage-row{font-size:.85em; color:#666; text-align:center; padding:5px; background:#fff; border-radius:5px; border:1px solid #e5e7eb;}
.enemy-summary{margin-top:20px; padding:15px; background:#f8f9fa; border-radius:8px; border:1px solid #e5e7eb;}
.enemy-summary h3{margin:0 0 10px; font-size:1em; color:var(--text);}
.summary-grid{display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:10px;}
.summary-item{display:flex; justify-content:space-between; align-items:center; padding:8px; background:#fff; border-radius:5px; border:1px solid #e5e7eb;}
.summary-label{font-size:.85em; color:#666;}
.summary-value{font-weight:bold; color:var(--text);}
.counter-attack-section{margin-top:20px; text-align:center;}
.counter-attack-button{background:var(--warn); color:#fff; padding:12px 20px; border:none; border-radius:8px; font-size:16px; font-weight:bold; cursor:pointer; min-width:200px;}
.counter-attack-button:hover{background:#dc2626;}
.counter-results{margin-top:15px; padding:15px; background:#f0f9ff; border:1px solid #0ea5e9; border-radius:8px; display:none;}
.counter-results h4{margin:0 0 10px; color:#0c4a6e;}
.counter-strategy{background:#fff; padding:10px; margin:8px 0; border-radius:5px; border-left:4px solid #0ea5e9;}
.counter-strategy strong{color:#0c4a6e;}
/* Navigation styles */
.nav-bar {
  background: var(--card);
  padding: 10px 15px;
  margin-bottom: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-link:hover {
  color: var(--accentHover);
}

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

.tool-card {
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.tool-icon {
  font-size: 2.5em;
  margin-bottom: 12px;
  text-align: center;
}

.tool-card h3 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 1.2em;
}

.tool-card p {
  margin: 0;
  color: var(--sub);
  font-size: 0.9em;
  line-height: 1.4;
}

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

.stat-card {
  background: var(--muted);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
}

.stat-number {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85em;
  color: var(--sub);
}

/* Install section styles */
.install-section {
  text-align: center;
}

.install-benefits {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.install-benefits li {
  padding: 8px 0;
  color: var(--text);
  font-size: 0.95em;
}

.install-button {
  background: linear-gradient(135deg, var(--accent), var(--accentHover));
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
  margin: 20px 0;
}

.install-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.install-button:active {
  transform: translateY(0);
}

.install-status {
  margin-top: 15px;
  min-height: 24px;
}

.install-status .success {
  color: var(--ok);
  font-weight: bold;
  background: #ecfdf5;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #d1fae5;
}

.install-status .info {
  color: #6b7280;
  font-style: italic;
  background: #f9fafb;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

/* responsive */
@media (max-width:768px){
  body{padding:10px;}
  .section{padding:12px;margin-bottom:12px;}
  h1{font-size:1.4em;}
  .flex-row{gap:6px;}
  input[type="number"]{width:60px;font-size:16px;}
  input.name-input{width:140px;}
  button{min-width:100px;padding:10px 12px;font-size:13px;}
  .legend{gap:8px;font-size:.8em;}
  .player{padding:8px;}
  .tool-grid{grid-template-columns: 1fr; gap: 15px;}
  .stats-grid{grid-template-columns: repeat(3, 1fr); gap: 10px;}
}

@media (max-width:480px){
  body{padding:8px;}
  .section{padding:10px;margin-bottom:10px;}
  h1{font-size:1.2em;}
  .flex-row{flex-direction:column;align-items:stretch;gap:8px;}
  input[type="number"]{width:100%;max-width:80px;}
  input.name-input{width:100%;max-width:200px;}
  button{width:100%;min-width:auto;}
  .legend{justify-content:center;}
  .tool-card{padding: 15px;}
  .stats-grid{grid-template-columns: 1fr; gap: 8px;}
}

/* Accessibility Styles */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: bold;
}

.skip-link:focus {
  top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000000;
    --secondary-color: #ffffff;
    --accent-color: #0066cc;
    --text-color: #000000;
    --background-color: #ffffff;
  }
  
  .tool-card {
    border: 2px solid #000000;
  }
  
  .tool-card:hover {
    border-color: #0066cc;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .tool-card:hover {
    transform: none;
  }
}

/* Focus styles for keyboard navigation */
.tool-card:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ensure minimum touch target size */
.tool-card,
button,
input,
select,
textarea {
  min-height: 44px;
  min-width: 44px;
}

/* Color contrast improvements */
.tool-card h3 {
  color: #1a1a2e;
}

.tool-card p {
  color: #333;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #4fc3f7;
    --secondary-color: #1a1a2e;
    --accent-color: #0f3460;
    --text-color: #ffffff;
    --background-color: #1a1a2e;
  }
  
  body {
    background-color: var(--background-color);
    color: var(--text-color);
  }
  
  .tool-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }
  
  .tool-card:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  
  .tool-card h3 {
    color: #ffffff;
  }
  
  .tool-card p {
    color: rgba(255, 255, 255, 0.8);
  }
}

