/* World Military Power — mobile-first styles */
:root {
  --bg: #0e120d;
  --bg2: #141a12;
  --card: #182016;
  --card2: #1f2a1c;
  --line: #2c3a28;
  --text: #e8ecdf;
  --muted: #9aa58f;
  --accent: #e3b341;
  --accent2: #8fbf5a;
  --a: #e3b341;
  --b: #5ab0e6;
  --p-finance: #e3b341;
  --p-air: #5ab0e6;
  --p-manpower: #c98bd9;
  --p-land: #8fbf5a;
  --p-sea: #3f8fd1;
  --p-nuclear: #e5603f;
  --radius: 14px;
  --font: "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, sans-serif;
  --head: "Oswald", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.55;
  background-image: radial-gradient(circle at 20% -10%, #24311f 0, transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(143,191,90,.035) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(143,191,90,.035) 39px 40px);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--head); line-height: 1.25; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.lang-si h1, .lang-si h2, .lang-ta h1, .lang-ta h2 { letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(14,18,13,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-family: var(--head); font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav a { color: var(--muted); padding: 8px 12px; border-radius: 10px; }
.topnav a.on, .topnav a:hover { color: var(--text); background: var(--card2); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; color: var(--text); width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { background: var(--card2); }
.langsw { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.langsw a { padding: 8px 9px; color: var(--muted); font-size: .8rem; font-weight: 600; min-height: 36px; display: grid; place-items: center; }
.langsw a.on { background: var(--accent); color: #1a1405; }
.langsw a:hover { text-decoration: none; }

/* layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.page-title { margin-top: 4px; }
.sec-title { margin: 22px 0 10px; font-size: 1.1rem; color: var(--accent2); text-transform: uppercase; letter-spacing: .06em; }
.lang-si .sec-title, .lang-ta .sec-title { text-transform: none; letter-spacing: 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec-head h2 { margin: 0 0 10px; }
.notice { background: #2e2a14; border: 1px solid #5b4f1d; color: #f1e3a4; padding: 10px 14px; border-radius: 10px; font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: #1a1405; font-weight: 700; font-family: var(--font); font-size: .95rem; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.back { display: inline-block; margin-bottom: 10px; min-height: 44px; line-height: 44px; }

/* hero */
.hero { padding: 22px 4px 8px; }
.hero h1 { font-size: 2rem; color: var(--accent); margin-bottom: 6px; }
.hero p { color: var(--muted); margin: 0 0 14px; max-width: 640px; }
.fake-search { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; cursor: pointer; text-align: left; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: linear-gradient(160deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile b { display: block; font-family: var(--head); font-size: 1.35rem; color: var(--accent); line-height: 1.2; }
.tile span { color: var(--muted); font-size: .82rem; }

/* flags */
.flag { width: 28px; height: auto; aspect-ratio: 3/2; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); flex: none; }
.flag-none { display: inline-block; width: 28px; height: 19px; background: var(--card2); border-radius: 3px; }

/* rank list */
.ranklist { list-style: none; margin: 0; padding: 0; }
.ranklist li { display: grid; grid-template-columns: 34px 1fr auto; grid-template-areas: "rk name val" "rk bar bar"; column-gap: 10px; row-gap: 4px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ranklist li:last-child { border-bottom: 0; }
.ranklist .rk { grid-area: rk; font-family: var(--head); font-size: 1.05rem; color: var(--muted); text-align: center; }
.ranklist li:nth-child(-n+3) .rk { color: var(--accent); }
.ranklist .clink { grid-area: name; }
.ranklist .rv { grid-area: val; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.ranklist .bar { grid-area: bar; }
.ranklist .badge, .ranklist .mini-btn { grid-area: bar; justify-self: start; }
.clink { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; min-width: 0; min-height: 32px; }
.clink .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: .7rem; background: #2e2a14; color: #f1e3a4; border: 1px solid #5b4f1d; padding: 1px 8px; border-radius: 99px; }
.mini-btn { font-size: .75rem; padding: 4px 10px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); color: var(--text); }

.bar { display: block; height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; width: 100%; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 99px; }
.bar.p-finance i { background: var(--p-finance); }
.bar.p-air i { background: var(--p-air); }
.bar.p-manpower i { background: var(--p-manpower); }
.bar.p-land i { background: var(--p-land); }
.bar.p-sea i { background: var(--p-sea); }
.bar.p-nuclear i { background: var(--p-nuclear); }

/* Sri Lanka card */
.lk-card { background: linear-gradient(135deg, #2a1f0c, var(--card) 60%); border-color: #5b4f1d; }
.lk-link { display: flex; align-items: center; gap: 14px; color: var(--text); }
.lk-link:hover { text-decoration: none; }
.lk-link .flag { width: 64px; }
.lk-link h2 { margin: 0; }
.lk-link p { margin: 0; font-size: .85rem; }
.big-score { margin-left: auto; font-family: var(--head); font-size: 2rem; color: var(--accent); }
.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.mini-stats div { background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 10px; }
.mini-stats span { display: block; font-size: .75rem; color: var(--muted); }
.mini-stats b { font-variant-numeric: tabular-nums; }

/* quick lists */
.quick-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.quick { color: var(--text); margin: 0; }
.quick:hover { text-decoration: none; border-color: var(--accent2); }
.quick h3 { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.qi { width: 28px; height: 28px; display: grid; place-items: center; background: var(--card2); border-radius: 8px; font-size: .9rem; }
.quick ol { margin: 0; padding: 0; list-style: none; }
.quick li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: .9rem; }
.quick li .flag { width: 20px; }
.quick li b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); color: var(--text); white-space: nowrap; font-size: .9rem; }
.chip.on { background: var(--accent); color: #1a1405; border-color: var(--accent); font-weight: 700; }
.chip:hover { text-decoration: none; border-color: var(--accent2); }
.chip.static { cursor: default; }

/* filters */
.filters, .cmp-form, .compare-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label, .compare-inline label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; font-size: .8rem; color: var(--muted); }
.filters label.check { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; font-size: .9rem; color: var(--text); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
select, input[type=text], input[type=search], input[type=number], input[type=password], input[type=url], textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; font-size: 16px;
}
textarea { min-height: 120px; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* charts */
.chart-box { position: relative; width: 100%; min-height: 220px; }
.chart-box.radar { height: 300px; }

/* country page */
.country-head { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.country-head > .flag { grid-column: 1 / -1; width: 100%; max-width: 220px; border-radius: 8px; }
.country-head h1 { margin: 0 0 2px; }
.country-head p { margin: 0 0 6px; }
.rank-pill { display: inline-block; background: var(--card2); border: 1px solid var(--line); padding: 3px 12px; border-radius: 99px; font-size: .85rem; }
.score-ring { --p: 0; width: 104px; height: 104px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--card) 79%, transparent 80% 100%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bg2) 0); }
.score-ring b { font-family: var(--head); font-size: 1.6rem; color: var(--accent); line-height: 1; }
.score-ring span { font-size: .62rem; color: var(--muted); max-width: 80px; }
.two-col { display: grid; gap: 16px; }
.pillars, .weights { list-style: none; margin: 0; padding: 0; }
.pillars li, .weights li { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; padding: 7px 0; font-size: .9rem; }
.pillars b, .weights b { text-align: right; font-variant-numeric: tabular-nums; }
.stat-groups { display: grid; gap: 16px; }
.stat-groups .card { margin: 0; }
.stat-group h2 { padding-left: 10px; border-left: 4px solid var(--accent); }
.g-finance h2 { border-color: var(--p-finance); } .g-air h2 { border-color: var(--p-air); }
.g-manpower h2 { border-color: var(--p-manpower); } .g-land h2 { border-color: var(--p-land); }
.g-sea h2 { border-color: var(--p-sea); } .g-nuclear h2 { border-color: var(--p-nuclear); }
.stat-group dl { margin: 0; }
.stat-group dl div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.stat-group dl div:last-child { border-bottom: 0; }
.stat-group dt { color: var(--muted); font-size: .9rem; }
.stat-group dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.wr { display: inline-block; margin-left: 6px; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--card2); color: var(--accent2); }
.sources p { font-size: .88rem; color: var(--muted); }
.stat-groups { margin-bottom: 16px; }

/* compare */
.cmp-form label { flex: 1 1 140px; }
.swap-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card2); color: var(--text); font-size: 1.2rem; cursor: pointer; flex: none; }
.vs-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); }
.vs-side:hover { text-decoration: none; }
.vs-side .flag { width: 100%; max-width: 120px; border-radius: 6px; }
.vs-side b { font-size: 1rem; }
.vs-side .big-score { margin: 0; font-size: 1.6rem; }
.vs-side:first-child .big-score { color: var(--a); }
.vs-side:last-child .big-score { color: var(--b); }
.vs-side small { color: var(--muted); font-size: .75rem; }
.vs-mark { font-family: var(--head); font-weight: 700; color: var(--muted); font-size: 1.1rem; }
.cmp-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cmp-row:last-child { border-bottom: 0; }
.cmp-label { text-align: center; color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.cmp-vals { display: grid; grid-template-columns: minmax(70px, auto) 1fr minmax(70px, auto); gap: 8px; align-items: center; }
.cv { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }
.cv.a { text-align: left; } .cv.b { text-align: right; }
.cv.win.a { color: var(--a); } .cv.win.b { color: var(--b); }
.cv.win::after { content: " ▲"; font-size: .65rem; }
.cmp-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.bar.rev { transform: scaleX(-1); }
.bar.a i { background: var(--a); }
.bar.b i { background: var(--b); }

/* map */
.map-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; justify-content: space-between; }
.map-bar h1 { margin: 0; font-size: 1.3rem; }
.map-bar label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); flex: 1 1 220px; max-width: 360px; }
.world-map { height: 62vh; min-height: 360px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #0b1520; }
.map-hint { margin: 8px 4px 16px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font); }
.pop h3 { display: flex; gap: 8px; align-items: center; margin: 0 0 6px; }
.pop .flag { width: 26px; }
.pop p { margin: 2px 0; }
.pop a.btn { min-height: 36px; margin-top: 8px; color: #1a1405; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* weapons */
.weapon-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.weapon-card { margin: 0; color: var(--text); display: grid; grid-template-columns: 48px 1fr; column-gap: 12px; }
.weapon-card:hover { text-decoration: none; border-color: var(--accent2); }
.weapon-card .w-icon { grid-row: span 2; }
.weapon-card h3 { margin: 2px 0 4px; }
.weapon-card p { margin: 0; color: var(--muted); font-size: .87rem; }
.w-icon { width: 48px; height: 48px; display: grid; place-items: center; font-size: 1.6rem; background: var(--card2); border-radius: 12px; }
.w-icon.big { width: 64px; height: 64px; font-size: 2.2rem; flex: none; }
.wd-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.wd-head h1 { margin: 0; }
.wd-head p { margin: 0; }
.prose { line-height: 1.75; }
.prose p { margin: 0 0 1em; }

/* search overlay */
.search-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(8,10,7,.96); padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); display: flex; flex-direction: column; }
.search-overlay[hidden] { display: none; }
.search-box { display: flex; gap: 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.search-box input { min-height: 50px; font-size: 17px; }
.search-results { list-style: none; margin: 12px auto 0; padding: 0; max-width: 640px; width: 100%; overflow-y: auto; }
.search-results li a { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); color: var(--text); min-height: 52px; }
.search-results li a:hover, .search-results li a.sel { background: var(--card); text-decoration: none; }
.search-results .sr-score { margin-left: auto; color: var(--accent); font-weight: 700; }
.search-results .sr-en { color: var(--muted); font-size: .8rem; }

/* footer + bottom nav */
.foot { max-width: 1100px; margin: 10px auto 0; padding: 16px; color: var(--muted); font-size: .8rem; text-align: center; }
.foot p { margin: 4px 0; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(14,18,13,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; color: var(--muted); font-size: .66rem; text-align: center; line-height: 1.15; padding: 4px 2px; }
.bottomnav a.on { color: var(--accent); }
.bottomnav a:hover { text-decoration: none; }

@media (min-width: 600px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .weapon-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-stats { grid-template-columns: repeat(4, 1fr); }
  .country-head { grid-template-columns: auto 1fr auto; }
  .country-head > .flag { grid-column: auto; width: 140px; }
  .ranklist li { grid-template-columns: 40px minmax(160px, 260px) 1fr auto; grid-template-areas: "rk name bar val"; }
  .ranklist .badge, .ranklist .mini-btn { grid-area: auto; }
  .ranklist.full li:has(.badge) { grid-template-columns: 40px minmax(160px, 260px) auto 1fr auto; grid-template-areas: "rk name badge bar val"; }
  .ranklist .badge { grid-area: badge; }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .topnav { display: flex; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .weapon-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; align-items: center; }
  .stat-groups { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2.6rem; }
}

/* admin */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-nav a { padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--text); min-height: 44px; }
.admin-nav a.on { background: var(--accent); color: #1a1405; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.form-grid label, .form-row label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.form-row { margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; }
.ok { color: var(--accent2); } .err { color: #ff7d6b; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; background: #1d2d17; border: 1px solid #3c5a2c; }
.flash.bad { background: #3a1915; border-color: #7a3027; }
