:root {
  --bg0: #140e0a;
  --bg1: #24180f;
  --bg2: #3a2616;
  --card: rgba(36, 24, 15, 0.92);
  --line: rgba(255, 196, 120, 0.22);
  --text: #fff3e4;
  --muted: #c9a888;
  --accent: #ff7a18;
  --accent2: #ffd166;
  --ok: #3ecf8e;
  --danger: #ff5a5a;
  --info: #5ec8ff;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 122, 24, 0.22), transparent 55%),
    radial-gradient(900px 500px at 0% 100%, rgba(94, 200, 255, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, #0f0b08);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 28px 28px;
}

#app { min-height: 100vh; position: relative; z-index: 1; }

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 12px;
  padding: 24px;
}
.boot-badge {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent2);
  text-shadow: 0 0 24px rgba(255, 122, 24, 0.45);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes tick {
  from { transform: scale(1.15); }
  to { transform: scale(1); }
}

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 12px calc(var(--nav-h) + var(--safe-bottom) + 16px);
  animation: slideUp 0.35s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent2);
}
.resources {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chip {
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.hero-welcome {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 28px 18px 22px;
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(255,122,24,.35), rgba(20,14,10,.2)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath fill='%23ff7a18' fill-opacity='.12' d='M0 120 L40 80 L80 110 L120 60 L160 100 V160 H0Z'/%3E%3C/svg%3E") bottom/cover;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-welcome h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1.2;
}
.hero-welcome p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.muted { color: var(--muted); font-size: 0.88rem; line-height: 1.6; }
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.space { justify-content: space-between; }
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

label { display: block; margin: 8px 0 4px; font-size: 0.86rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--text);
  padding: 12px;
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #ff9f1c);
  color: #1a0f08;
  box-shadow: 0 8px 18px rgba(255, 122, 24, 0.28);
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.danger { background: linear-gradient(135deg, #ff5a5a, #ff8a5a); color: #2a0b0b; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 10px; font-size: 0.82rem; border-radius: 10px; }

.avatar-pick {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.avatar-pick button {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.3);
  font-size: 1.4rem;
  cursor: pointer;
}
.avatar-pick button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,122,24,.35);
}

.list { display: grid; gap: 8px; }
.item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.28);
  border: 1px solid transparent;
}
.item.active { border-color: var(--accent); }
.item .av {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,122,24,.15);
  font-size: 1.4rem;
  flex-shrink: 0;
}
.item .meta { flex: 1; min-width: 0; }
.item .meta strong { display: block; font-size: 0.92rem; }
.item .meta span { color: var(--muted); font-size: 0.78rem; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(255,255,255,.08);
}
.badge.common { color: #cfcfcf; }
.badge.uncommon { color: #7dffb3; }
.badge.professional { color: #7db7ff; }
.badge.elite { color: #d27dff; }
.badge.legendary { color: #ffd166; }

.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(16, 11, 8, 0.94);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 20;
  backdrop-filter: blur(10px);
  max-width: 480px;
  margin: 0 auto;
}
.nav button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  display: grid;
  place-items: center;
  gap: 2px;
  cursor: pointer;
}
.nav button .ico { font-size: 1.15rem; }
.nav button.active { color: var(--accent2); }

.toast {
  position: fixed;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: #2a1a10;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 50;
  max-width: 90vw;
  box-shadow: var(--shadow);
  animation: slideUp .25s ease;
}

.progress {
  height: 10px;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .3s linear;
}

.battle-arena {
  text-align: center;
}
.battle-arena .timer {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent2);
  animation: tick .8s ease;
}
.vs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}
.vs .side {
  padding: 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.28);
}
.log {
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 6px;
  text-align: right;
}
.log div {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,.25);
  font-size: 0.84rem;
  color: #ffe7c8;
}

.map-grid {
  display: grid;
  gap: 8px;
}
.map-tile {
  padding: 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--line);
}
.map-tile.mine { border-color: var(--ok); }
.map-tile.enemy { border-color: rgba(255,90,90,.45); }

.tabs {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}
.tabs button.active {
  color: #1a0f08;
  background: var(--accent2);
  border-color: transparent;
  font-weight: 700;
}

.range-wrap { margin: 10px 0; }
.range-wrap input[type=range] { width: 100%; accent-color: var(--accent); }

.empty {
  text-align: center;
  padding: 24px 10px;
  color: var(--muted);
}

.admin-box textarea { min-height: 80px; }

@media (min-width: 480px) {
  .shell { padding-top: 18px; }
}
