:root {
  --bg: #0b0f14; --panel: #131a22; --panel2: #1a2430; --line: #26323f;
  --text: #e8eef4; --muted: #8a9aab; --accent: #ffb020; --red: #ff4d4d; --green: #35d07f;
  --blue: #4da3ff; --purple: #b07cff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: contain; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .warn { color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; }
.gap { gap: 6px; } .right { text-align: right; }
code { background: #0006; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
b, strong { color: #fff; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { max-width: 360px; text-align: center; }
.logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 0 40px #ffb02033; }
h1 { margin: 12px 0 4px; letter-spacing: 2px; }

header#top { position: sticky; top: 0; z-index: 5; padding: calc(10px + var(--safe-t)) 14px 8px;
  background: linear-gradient(#0b0f14, #0b0f14ee); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.title { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.stats { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 9px;
  white-space: nowrap; font-size: 13px; }
.stat b { color: var(--accent); }
.icon-btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 9px;
  width: 34px; height: 30px; font-size: 15px; }
.icon-btn.off { opacity: .4; }

main { padding: 12px 12px calc(84px + var(--safe-b)); max-width: 820px; margin: 0 auto; }
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 6;
  background: #0d131aee; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); backdrop-filter: blur(8px); }
nav#tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 9px; font-size: 11px; }
nav#tabs button span { display: block; font-size: 20px; margin-bottom: 1px; }
nav#tabs button.on { color: var(--accent); }

h2 { font-size: 15px; margin: 18px 4px 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.country { position: relative; cursor: pointer; transition: transform .08s; }
.country:active { transform: scale(.97); }
.country.me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.country.dead { opacity: .45; filter: grayscale(1); }
.country .name { font-weight: 700; font-size: 14px; line-height: 1.2; padding-right: 26px; }
.country .who { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.num { position: absolute; top: 8px; right: 10px; font-weight: 800; color: var(--muted); }
.hp { letter-spacing: 2px; color: var(--red); }
.bld { margin: 5px 0; font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.tag.red { color: var(--red); } .tag.gold { color: var(--accent); } .tag.blue { color: var(--blue); }
.tag.green { color: var(--green); } .tag.purple { color: var(--purple); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--purple); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 11px;
  font-size: 14px; text-decoration: none; cursor: pointer; }
.btn:active { filter: brightness(1.3); }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.btn.danger { background: #3a1416; border-color: #6b2125; color: #ffb3b3; }
.btn.ok { background: #123a26; border-color: #1f6b44; color: #b6ffd6; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; margin: 14px 0 6px; }
.btn.sel { border-color: var(--accent); color: var(--accent); }
.btn[disabled] { opacity: .4; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns .btn { flex: 1 1 auto; }
.cost { font-size: 11px; color: var(--muted); }

.sheet { position: fixed; inset: 0; z-index: 20; background: #0008; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--panel); width: 100%; max-width: 620px; max-height: 86vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(18px + var(--safe-b)); border-top: 1px solid var(--line);
  animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 16px; }
.reply { background: var(--panel2); border-radius: 11px; padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; word-wrap: break-word; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  background: #000d; border: 1px solid var(--line); padding: 9px 14px; border-radius: 12px; max-width: 90vw; }

input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font-size: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.stepper { display: flex; gap: 6px; align-items: center; }
.stepper input { text-align: center; }
.stepper .btn { width: 46px; }
.report p { margin: 0 0 8px; }
.chat { display: flex; flex-direction: column; gap: 6px; }
.msg { padding: 8px 11px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: #3a2a08; }
.msg.ai { align-self: flex-start; background: var(--panel2); }
.mapimg { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.pulse { animation: pulse 1s ease-in-out 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--red); } }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, 1fr); } }
