:root {
  --bg: #f4f1ea;
  --card-bg: #ffffff;
  --primary: #7a4b23;
  --primary-dark: #5c3717;
  --accent: #c98a3c;
  --text: #2b2117;
  --muted: #7a7268;
  --border: #e3ddd0;
  --error-bg: #fdecea;
  --error-text: #a33a2f;
  --success-bg: #eaf6ea;
  --success-text: #2f7a3a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Tahoma", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===================== تأثيرات بصرية حسب الطقس الحالي ===================== */
/* طبقة ثابتة فوق الصفحة كلها (زخرفية بحتة: pointer-events:none حتى ما تعيق أي ضغطة) */
.weather-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

/* مطر: خطوط قطرات مائلة متحركة لأسفل */
body.weather-rain .weather-fx {
  background-image: repeating-linear-gradient(
    115deg,
    rgba(174, 210, 255, .35) 0px, rgba(174, 210, 255, .35) 1px,
    transparent 1px, transparent 14px
  );
  background-size: 140% 140%;
  opacity: .5;
  animation: weather-rain-fall .45s linear infinite;
}
@keyframes weather-rain-fall {
  from { background-position: 0 0; }
  to   { background-position: -60px 120px; }
}

/* ضباب: تراكب أبيض شفاف ناعم يتحرك ببطء + تمويه خفيف */
body.weather-fog .weather-fx {
  background:
    radial-gradient(ellipse at 50% 25%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(rgba(255,255,255,.22), rgba(255,255,255,.22));
  backdrop-filter: blur(1.5px);
  animation: weather-fog-drift 9s ease-in-out infinite alternate;
}
@keyframes weather-fog-drift {
  from { opacity: .55; transform: translateX(-2%); }
  to   { opacity: .85; transform: translateX(2%); }
}

/* عاصفة: مطر أقوى + ومضات برق دورية + اهتزاز خفيف جدًا للمحتوى */
body.weather-storm .weather-fx {
  background-image: repeating-linear-gradient(
    115deg,
    rgba(180, 200, 255, .5) 0px, rgba(180, 200, 255, .5) 2px,
    transparent 2px, transparent 10px
  );
  background-size: 140% 140%;
  animation: weather-rain-fall .25s linear infinite, weather-lightning 7s ease-in-out infinite;
}
@keyframes weather-lightning {
  0%, 93%, 100% { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
  94%           { box-shadow: inset 0 0 200px 80px rgba(255,255,255,.55); }
  95%           { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
  96%           { box-shadow: inset 0 0 160px 60px rgba(255,255,255,.35); }
  97%, 100%     { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
}
body.weather-storm .container {
  animation: weather-storm-shake 6s ease-in-out infinite;
}
@keyframes weather-storm-shake {
  0%, 95%, 100% { transform: translate(0, 0); }
  96%           { transform: translate(1px, -1px); }
  97%           { transform: translate(-1px, 1px); }
  98%           { transform: translate(1px, 1px); }
  99%           { transform: translate(-1px, -1px); }
}

/* شريط خفيف أعلى الصفحة يوضّح حالة الطقس الحالية وأثرها (يظهر فقط لو غير صحو) */
.weather-strip {
  text-align: center;
  font-size: .78em;
  padding: 5px 14px;
  color: #fff;
  line-height: 1.4;
}
.weather-strip-rain  { background: #5a8fc2; }
.weather-strip-fog   { background: #8a8f94; }
.weather-strip-storm { background: #4a4458; }

/* احترام تفضيل تقليل الحركة: نطفي كل أنيميشن الطقس */
@media (prefers-reduced-motion: reduce) {
  .weather-fx, body.weather-storm .container {
    animation: none !important;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  position: relative;
}
.topbar .brand { font-weight: bold; font-size: 1.15em; display: flex; align-items: center; gap: 8px; }
.weather-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .68em;
  font-weight: normal;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* شريط علوي بنمط "كبسولة مُقسّمة" (segmented pill) — بديل أنيق للقائمة المنسدلة التقليدية */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0,0,0,.16);
  border-radius: 999px;
  padding: 4px;
}
.primary-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  opacity: .82;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: .85em;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.primary-nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
.primary-nav a.active {
  opacity: 1;
  background: #fff;
  color: var(--primary-dark);
  font-weight: bold;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.primary-nav a .nav-badge-urgent { position: absolute; top: -4px; inset-inline-end: -4px; }

/* مجموعة أيقونات الزاوية: الرسائل / التقارير / الشرح / خروج — بلا نص، دائرية ومدمجة */
.corner-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
  font-size: 1.05em;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }
.icon-btn.active { background: #fff; color: var(--primary-dark); }
.icon-btn .nav-badge,
.icon-btn .nav-badge-urgent {
  position: absolute;
  top: -3px;
  inset-inline-end: -3px;
  min-width: 16px;
  text-align: center;
}

/* شريط التبويب السفلي الثابت — يظهر على الهاتف فقط (أسلوب تطبيقات الجوال)،
   كل الخيارات الثمانية ظاهرة دفعة واحدة بدون طي خلف "المزيد" */
.bottom-tabbar { display: none; }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .brand-text { display: none; }
  .weather-text { display: none; }
  .primary-nav { display: none; }

  body { padding-bottom: 60px; }

  .bottom-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    background: var(--primary);
    border-top: 1px solid rgba(255,255,255,.15);
    box-shadow: 0 -4px 16px rgba(0,0,0,.18);
    z-index: 60;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bottom-tabbar a {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 6px 1px 7px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
    font-size: .52em;
    line-height: 1.1;
    cursor: pointer;
    white-space: nowrap;
  }
  .bottom-tabbar a span:first-child { font-size: 1.25em; line-height: 1; }
  .bottom-tabbar a.active { color: #fff; }
  .bottom-tabbar a .nav-badge,
  .bottom-tabbar a .nav-badge-urgent {
    position: absolute;
    top: 0;
    inset-inline-end: 12%;
    font-size: 9px;
    line-height: 1.3;
    padding: 0 4px;
  }
}

@media (max-width: 420px) {
  .bottom-tabbar a { font-size: .46em; padding: 6px 0 7px; }
  .bottom-tabbar a span:first-child { font-size: 1.1em; }
}
.nav-badge {
  background: #e0453a;
  color: #fff;
  border-radius: 999px;
  font-size: .7em;
  padding: 1px 6px;
  margin-inline-start: 3px;
}
.nav-badge-urgent {
  animation: pulse-urgent 1.5s infinite;
}
@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
.unread-link { font-weight: bold; }
.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: .7em;
  padding: 1px 8px;
  margin-inline-start: 6px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

h1 { font-size: 1.5em; margin-bottom: 8px; }
h2 { font-size: 1.2em; margin: 0 0 8px; }
h3 { font-size: 1.05em; margin: 0 0 8px; color: var(--primary-dark); }

.muted { color: var(--muted); font-size: .9em; }

.card, .village-info {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: bold;
}
.resources span {
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.building-list { list-style: none; padding: 0; margin: 0; }
.building-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.building-list li:last-child { border-bottom: none; }

.card-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 400px;
}
.card-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .9em;
  color: var(--muted);
}
.card-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
}
.card-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.card-form select,
.card-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
  resize: vertical;
}
.card-form select:focus,
.card-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.card-form button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition: background .15s;
}
.card-form button:hover { background: var(--primary-dark); }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.alert ul { margin: 0; padding-inline-start: 20px; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-link {
  font-size: .85em;
  color: var(--primary);
  text-decoration: none;
}
.btn-link:hover { text-decoration: underline; }

.build-active {
  border-color: var(--accent);
  background: #fdf6ea;
}

.build-list { display: flex; flex-direction: column; gap: 10px; }
.build-row {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 10px;
}
.build-row:last-child { border-bottom: none; padding-bottom: 0; }
.build-row-main { display: flex; justify-content: space-between; align-items: baseline; }
.build-row-cost { margin: 4px 0; }

.inline-form { display: inline; }
.btn-small {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .85em;
  cursor: pointer;
}
.btn-small:hover { background: var(--primary-dark); }
.btn-small:disabled {
  background: #cfc7ba;
  cursor: not-allowed;
}

.small { font-size: .85em; }

.qty-input {
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  margin-inline-end: 6px;
}
.train-form { display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.map-wrap { overflow-x: auto; margin-bottom: 16px; }
.map-table { border-collapse: collapse; margin: 0 auto; }
.map-table td {
  width: 26px;
  height: 26px;
  min-width: 26px;
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #eee;
}
.tile-empty { background: #f2efe8; }
.tile-oasis { background: #cfe9c3; }
.tile-npc { background: #ecc9c2; }
.tile-player { background: #f0d9a0; }
.tile-me { outline: 2px solid var(--accent); outline-offset: -2px; background: #f7e2ae; }
.tile-link { display: block; width: 100%; height: 100%; text-decoration: none; color: inherit; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: .85em;
  color: var(--muted);
  align-items: center;
}
.legend-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-inline-end: 4px;
}

.table-wrap { overflow-x: auto; }
.players-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
}
.players-table th, .players-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.players-table th {
  color: var(--muted);
  font-weight: normal;
  font-size: .85em;
}
.players-table td:first-child, .players-table th:first-child { white-space: normal; }
.players-table tr.row-me { background: var(--bg); }
.players-table .nowrap { white-space: nowrap; font-size: .85em; }

.note {
  font-size: .85em;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: .8em;
  padding: 20px;
}

@media (max-width: 480px) {
  .resources { justify-content: center; }
  .card-form { max-width: 100%; }
}

.game-end-banner {
  background: linear-gradient(90deg, #c98a3c, #e0453a);
  color: #fff;
  text-align: center;
  font-weight: bold;
  padding: 12px 16px;
  font-size: 1.05em;
}

