@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Tajawal:wght@400;700;900&family=MedievalSharp&display=swap");

:root {
  --bg: #1e1710;
  --bg2: #2a1f15;
  --bg3: #372517;
  --brd: #8b5a2b;
  --brd2: #c27e3a;
  --green: #b87c4a;
  --dgreen: #7a572f;
  --gold: #e0b060;
  --red: #b84c3c;
  --text: #dacaa0;
  --dim: #8b7a5a;
  --panel: rgba(30, 23, 16, 0.96);
  --scroll-track: #2a241e;
  --scroll-thumb: #6a4a2a;
  --wood-light: #4f3a28;
  --wood-dark: #2c211a;
  --metal: #6f6f5a;
  --rune: #c8944a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 30%, rgba(80, 55, 35, 0.2) 2%, transparent 2.5%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.02) 0px, rgba(0, 0, 0, 0.02) 2px, transparent 2px, transparent 6px);
  background-size: 40px 40px, auto;
  color: var(--text);
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
}

/* ===========================
   START SCREEN - ANCIENT SCROLL
   =========================== */
#scr-start {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 30%, #2f241b, #14100c 85%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 20px 10px 30px;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
}

#scr-start::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cpath fill='%23ab8e5c' fill-opacity='0.04' d='M0 0 L200 200 M200 0 L0 200' stroke='%23dbb87c' stroke-width='0.6'/%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: 0.3;
  pointer-events: none;
}

.start-title {
  font-family: "Cinzel", "MedievalSharp", serif;
  font-size: clamp(32px, 6vw, 62px);
  color: var(--gold);
  letter-spacing: 6px;
  text-shadow: 0 0 12px rgba(224, 176, 96, 0.6), 0 2px 0 #3a2a1a;
  margin-bottom: 4px;
  text-align: center;
  background: linear-gradient(135deg, #f5e2b0, #c8a86c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  font-weight: 900;
}

.start-sub {
  color: #b69b6c;
  font-size: clamp(12px, 2vw, 16px);
  margin-bottom: 24px;
  text-align: center;
  direction: rtl;
  font-style: italic;
  letter-spacing: 1px;
}

.start-section-label {
  color: #b5936a;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 10px;
  direction: rtl;
  text-align: center;
  border-bottom: 1px solid rgba(200, 168, 64, 0.3);
  display: inline-block;
  padding: 0 12px;
}

/* Map cards - Parchment style */
.maps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 1100px;
  margin-bottom: 28px;
}

.map-card {
  background: #231f1a;
  border: 2px solid #5a4028;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.map-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c8944a, #e0b060, #c8944a);
  opacity: 0;
  transition: opacity 0.2s;
}

.map-card:hover {
  border-color: #c8944a;
  transform: translateY(-4px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.5);
}

.map-card.selected {
  border-color: #e8bc6c;
  box-shadow: 0 0 0 2px #3a2a1a, 0 0 0 4px #e0b060;
}

.map-card.selected::after {
  opacity: 1;
}

.map-card canvas {
  width: 100%;
  height: 100px;
  display: block;
  image-rendering: crisp-edges;
  background: #3c2c1c;
  border-bottom: 1px solid #5a4028;
}

.map-card-info {
  padding: 10px 12px;
  direction: rtl;
  background: linear-gradient(135deg, #2a231c, #1f1a14);
}

.map-card-name {
  font-size: 14px;
  color: #e0bc7c;
  font-weight: 800;
  font-family: "Cinzel", serif;
  letter-spacing: 0.5px;
}

.map-card-en {
  font-size: 10px;
  color: #9b7e5a;
  margin-bottom: 5px;
  font-style: italic;
}

.map-card-desc {
  font-size: 11px;
  color: #a98f66;
  line-height: 1.5;
}

.map-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  color: #e7bc6e;
  border: 1px solid #e0b060;
  font-family: monospace;
  font-weight: bold;
  backdrop-filter: blur(2px);
}

/* Difficulty buttons - weathered */
.diff-row {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  justify-content: center;
  flex-wrap: wrap;
  direction: rtl;
}

.diff-btn {
  padding: 10px 32px;
  border-radius: 30px;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  font-family: "Tajawal", sans-serif;
  font-weight: 800;
  transition: all 0.2s;
  background: #1f1913;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 3px 0 #0a0704;
}

.diff-btn.easy {
  color: #b8a87c;
  border-color: #6f5a3a;
  background: #2c241c;
}

.diff-btn.med {
  color: #e0b470;
  border-color: #9e6e3a;
  background: #2f241a;
}

.diff-btn.hard {
  color: #c97a5a;
  border-color: #ac4a2a;
  background: #2e1e16;
}

.diff-btn.sel {
  filter: brightness(1.2);
  box-shadow: 0 0 10px currentColor, inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: scale(0.98);
  border-color: #e0b060;
}

/* Start button - heavy iron */
.start-btn {
  padding: 14px 56px;
  background: linear-gradient(135deg, #4f3a28, #2c211a);
  border: 2px solid #aa7a42;
  border-radius: 60px;
  color: #ecdbaa;
  font-size: 18px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-weight: 900;
  letter-spacing: 3px;
  box-shadow: 0 6px 0 #1f140e;
  transition: 0.07s linear;
  direction: rtl;
  text-shadow: 0 1px 0 #000;
}

.start-btn:hover {
  background: linear-gradient(135deg, #6a4a2a, #3e2a1c);
  box-shadow: 0 3px 0 #1f140e;
  transform: translateY(2px);
}

/* ===========================
   GAME SCREEN - WAR ROOM
   =========================== */
#scr-game {
  display: none;
  flex-direction: column;
  height: 100dvh;
  background: #1c1510;
}

/* HUD TOP - Iron band */
#hud-top {
  background: linear-gradient(90deg, #1e1610, #2c221c, #1e1610);
  border-bottom: 3px solid #6a4a2a;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  direction: rtl;
  flex-wrap: wrap;
  min-height: 48px;
  box-shadow: inset 0 1px 0 rgba(255, 215, 140, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-title {
  font-family: "Cinzel", serif;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 0 4px #6a3e1a;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 2px;
}

.res-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.ri {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #5e482c;
  font-size: 12px;
  min-width: 90px;
  backdrop-filter: blur(4px);
  font-weight: bold;
}

.ri .ic {
  font-size: 14px;
  filter: drop-shadow(0 1px 1px black);
}

.ri .vl {
  color: #f5da9a;
  font-weight: 800;
  min-width: 34px;
  text-align: center;
}

.ri .rt {
  color: #a98754;
  font-size: 9px;
  min-width: 32px;
}

.ri .lb {
  color: #bc9a6a;
  font-size: 10px;
  font-weight: 600;
}

.map-info-badge {
  background: #1f1711;
  border: 1px solid #7e623e;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  color: #cbb27a;
  flex-shrink: 0;
  white-space: nowrap;
  direction: rtl;
  font-weight: bold;
  box-shadow: inset 0 1px 0 rgba(255, 235, 180, 0.1);
}

/* MAIN AREA */
#main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* TOOLBAR - wood + rivets */
#toolbar {
  width: 52px;
  flex-shrink: 0;
  background: #241e18;
  border-left: 3px solid #684e30;
  border-right: 1px solid #3a2a1c;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  gap: 5px;
  overflow-y: auto;
  box-shadow: inset -2px 0 0 #4a3420;
}

#toolbar::-webkit-scrollbar {
  width: 4px;
  background: #34281e;
}

#toolbar::-webkit-scrollbar-thumb {
  background: #8b623c;
  border-radius: 2px;
}

.tb-btn {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2f271f;
  border: 1px solid #6c5438;
  color: #e5ca9a;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.08s linear;
  flex-shrink: 0;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 235, 160, 0.1), 0 2px 3px rgba(0, 0, 0, 0.3);
}

.tb-btn:hover {
  background: #4f3a28;
  border-color: #b48a48;
  transform: scale(0.96);
}

.tb-btn.active {
  background: #6a4a2a;
  border-color: #e0b060;
  box-shadow: inset 0 0 6px #ffcc88, 0 0 8px rgba(224, 176, 96, 0.5);
}

.tb-btn small {
  font-size: 7px;
  position: absolute;
  bottom: 2px;
  color: #c2a06a;
  font-family: monospace;
  font-weight: bold;
}

.tb-sep {
  width: 28px;
  height: 2px;
  background: #5e482e;
  margin: 4px 0;
  flex-shrink: 0;
  border-radius: 2px;
}

/* CANVAS WRAP - map frame */
#cv-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#cv-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #130e0a;
  border: 2px solid #3e2e1e;
  border-radius: 6px;
  margin: 4px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6), 0 0 0 2px #4f3a26;
}

#cv {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
}

#minimap-cv {
  position: absolute;
  bottom: 12px;
  right: 12px;
  border: 2px solid #9e794a;
  border-radius: 4px;
  opacity: 0.95;
  cursor: pointer;
  image-rendering: pixelated;
  box-shadow: 0 0 0 2px #2a1c10;
  transition: 0.1s;
}

#minimap-cv:hover {
  border-color: #e0b070;
  transform: scale(1.02);
}

/* TOOLTIP - worn scroll */
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: #241f18e6;
  border: 1px solid #b8925c;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: #f5e2bc;
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  direction: rtl;
  text-align: right;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5);
  display: none;
  backdrop-filter: blur(4px);
  font-weight: 500;
  letter-spacing: 0.3px;
  border-left: 3px solid #dbaa5a;
}

/* NOTIFICATIONS - battle log */
#notif {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f1a14e6;
  border: 1px solid #c8944a;
  border-radius: 30px;
  padding: 6px 24px;
  font-size: 13px;
  color: #ffdfa5;
  pointer-events: none;
  transition: opacity 0.5s;
  opacity: 0;
  white-space: nowrap;
  max-width: 90%;
  text-align: center;
  direction: rtl;
  font-family: monospace;
  font-weight: bold;
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 8px black;
}

/* SIDEBAR - ancient codex */
#sidebar {
  width: 210px;
  flex-shrink: 0;
  background: #1e1913;
  border-right: 3px solid #7a5a36;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  direction: rtl;
  background-image: repeating-linear-gradient(45deg, #2a221c 0px, #2a221c 1px, #1f1913 1px, #1f1913 8px);
}

#sidebar::-webkit-scrollbar {
  width: 6px;
  background: #2c241e;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #8b6a3e;
  border-radius: 3px;
}

.sb-sec {
  border-bottom: 1px solid #5a4028;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
}

.sb-sec h3 {
  font-size: 10px;
  color: #e0bc78;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: "Cinzel", serif;
  border-right: 3px solid #c8944a;
  padding-right: 6px;
}

.sb-btn {
  width: 100%;
  margin-bottom: 4px;
  padding: 6px 8px;
  background: #2b241e;
  border: 1px solid #624a30;
  border-radius: 6px;
  color: #cbb87a;
  font-size: 11px;
  cursor: pointer;
  text-align: right;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.1s;
  font-family: "Tajawal", sans-serif;
  font-weight: 600;
}

.sb-btn:hover {
  background: #4f3a28;
  color: #ffe2b0;
  border-color: #b47a3e;
  box-shadow: inset 0 1px 0 rgba(255, 215, 140, 0.3);
}

.sb-btn.sel-on {
  background: #6a4a2a;
  border-color: #e8bc6c;
  color: #fff0d0;
  box-shadow: 0 0 6px rgba(224, 176, 96, 0.4);
}

.sb-btn .cost {
  font-size: 9px;
  color: #bb9a64;
  line-height: 1.3;
  text-align: left;
}

.act-btn {
  width: 100%;
  margin-bottom: 5px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: "Tajawal", sans-serif;
  font-weight: 800;
  transition: all 0.1s;
  text-align: center;
}

.act-btn.mv {
  background: #23281e;
  border: 1px solid #6a7842;
  color: #d4e08c;
}

.act-btn.mv:hover,
.act-btn.mv.on {
  background: #4f6830;
  color: #faf7d0;
  border-color: #c8d86c;
}

.act-btn.atk {
  background: #361f1a;
  border: 1px solid #aa523a;
  color: #ed9a7a;
}

.act-btn.atk:hover {
  background: #873e2a;
  color: #ffcdb0;
}

.act-btn.sa {
  background: #24242e;
  border: 1px solid #6e6eaa;
  color: #b0b0e8;
}

.act-btn.sa:hover {
  background: #46468a;
  color: #e8e8ff;
}

#info-box {
  padding: 12px;
  font-size: 11px;
  color: #b8a074;
  line-height: 1.7;
  direction: rtl;
  background: #16120e;
  border-top: 1px solid #4a3a28;
}

#info-box b {
  color: #f5cf95;
  font-weight: 800;
}

/* HUD BOT - command bar */
#hud-bot {
  background: #1e1610;
  border-top: 3px solid #684e2e;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-size: 12px;
  direction: rtl;
}

#status-txt {
  flex: 1;
  color: #e2c894;
  font-size: 12px;
  font-weight: 500;
  text-shadow: 0 1px 0 #000;
}

.hb-btn {
  padding: 4px 14px;
  background: #2b221b;
  border: 1px solid #aa7a48;
  border-radius: 6px;
  color: #ecd6a8;
  font-size: 11px;
  cursor: pointer;
  font-family: "Tajawal", sans-serif;
  font-weight: bold;
  transition: 0.1s;
}

.hb-btn:hover {
  background: #5a3e28;
  border-color: #e0b070;
  color: #fff2dd;
}

/* ===========================
   GUIDE MODAL - old tome
   =========================== */
#guide-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
}

.guide-box {
  background: #1e1912;
  border: 2px solid #c8944a;
  border-radius: 18px;
  width: min(720px, 95vw);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  direction: rtl;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 215, 140, 0.2);
}

.guide-header {
  padding: 14px 20px;
  border-bottom: 2px solid #7a623e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #2f261e;
}

.guide-header h2 {
  font-family: "Cinzel", serif;
  color: #f5cf95;
  font-size: 20px;
  text-shadow: 0 2px 2px black;
}

.guide-close {
  background: none;
  border: none;
  color: #c2945a;
  font-size: 26px;
  cursor: pointer;
  padding: 0 8px;
  transition: 0.1s;
}

.guide-close:hover {
  color: #e07050;
  transform: scale(1.1);
}

.guide-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid #5a402a;
  flex-shrink: 0;
  flex-wrap: wrap;
  background: #231f18;
}

.gtab {
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #735a38;
  background: #2f261e;
  color: #d0b67c;
  font-family: "Tajawal", sans-serif;
  font-weight: bold;
  transition: 0.1s;
}

.gtab:hover {
  background: #4f3a28;
  color: #fff0ca;
}

.gtab.on {
  background: #6a4a2a;
  border-color: #e8bc6c;
  color: #fff2df;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
}

.guide-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: #1c1712;
}

.guide-body::-webkit-scrollbar {
  width: 6px;
}

.guide-body::-webkit-scrollbar-thumb {
  background: #856c44;
  border-radius: 3px;
}

.guide-body h3 {
  font-size: 15px;
  color: #eac882;
  margin-bottom: 12px;
  border-bottom: 1px solid #5e4a30;
  padding-bottom: 4px;
}

.guide-body p {
  font-size: 13px;
  color: #cfbc8c;
  line-height: 1.8;
  margin-bottom: 12px;
}

.guide-body ul {
  font-size: 12px;
  color: #bbaa80;
  line-height: 2;
  list-style: none;
  margin-bottom: 14px;
}

.guide-body ul li::before {
  content: "⚔ ";
  color: #d8aa6a;
}

.g-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 12px;
  background: #251f18;
  border-radius: 8px;
  overflow: hidden;
}

.g-table th {
  background: #352c22;
  color: #f0cf96;
  padding: 6px 8px;
  border-bottom: 1px solid #7a623e;
  text-align: right;
  font-weight: 800;
}

.g-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #4a3926;
  color: #cfbc94;
  vertical-align: top;
}

.g-table tr:hover td {
  background: #2f261e;
}

.tc-icon {
  text-align: center !important;
}

.tc-name {
  color: #f3daa0 !important;
  font-weight: 800;
}

.tile-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.tile-item {
  background: #2a231c;
  border: 1px solid #6e5438;
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tile-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid #ab8a58;
}

.tile-item span {
  font-size: 11px;
  color: #e2c894;
}

.kbd {
  display: inline-block;
  background: #1c1712;
  border: 1px solid #ad884e;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 10px;
  color: #f5daaa;
  font-family: monospace;
  font-weight: bold;
  box-shadow: inset 0 1px 0 #68502e;
}

/* ===========================
   OVERLAYS - victory/defeat
   =========================== */
.ovl-bg {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ovl-box {
  background: #1e1812;
  border: 3px solid #c8944a;
  border-radius: 24px;
  padding: 32px 40px;
  text-align: center;
  max-width: 460px;
  width: 90%;
  direction: rtl;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

.ovl-box h2 {
  font-size: 32px;
  color: #f5cf8c;
  margin-bottom: 12px;
  font-family: "Cinzel", serif;
  text-shadow: 0 2px 4px black;
}

.ovl-box p {
  color: #c8aa74;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 20px;
}

.ovl-btn {
  padding: 10px 28px;
  background: #342a20;
  border: 1px solid #c8944a;
  border-radius: 40px;
  color: #fae6bc;
  font-size: 14px;
  cursor: pointer;
  margin: 4px;
  font-family: "Tajawal", sans-serif;
  font-weight: bold;
  transition: 0.1s;
}

.ovl-btn:hover {
  background: #5a462e;
  border-color: #f5cf8c;
  transform: scale(1.02);
}

/* ===========================
   ACHIEVEMENTS MODAL - honor hall
   =========================== */
#ach-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
}

.ach-box {
  background: #1e1812;
  border: 2px solid #b8884e;
  border-radius: 20px;
  width: min(720px, 95vw);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  direction: rtl;
}

.ach-header {
  padding: 14px 20px;
  border-bottom: 2px solid #7a623e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #2c241c;
}

.ach-header h2 {
  font-family: "Cinzel", serif;
  color: var(--gold);
  font-size: 20px;
  text-shadow: 0 1px 2px black;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
  background: #17130e;
}

.ach-grid::-webkit-scrollbar {
  width: 5px;
}

.ach-grid::-webkit-scrollbar-thumb {
  background: #876e42;
  border-radius: 4px;
}

.ach-card {
  background: #28221a;
  border: 1px solid #6a5238;
  border-radius: 12px;
  padding: 12px 12px;
  transition: 0.15s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.ach-card.unlocked {
  border-color: #e0b060;
  background: #30281e;
  box-shadow: 0 0 8px rgba(224, 176, 96, 0.3);
}

.ach-card.unlocked .ach-icon {
  opacity: 1;
  filter: drop-shadow(0 0 2px #e0b060);
}

.ach-icon {
  font-size: 28px;
  margin-bottom: 6px;
  opacity: 0.5;
  filter: grayscale(0.6);
}

.ach-name {
  font-size: 13px;
  color: #f0cf92;
  font-weight: 800;
  margin-bottom: 3px;
}

.ach-desc {
  font-size: 10px;
  color: #b49562;
  line-height: 1.5;
}

.ach-prog {
  margin-top: 8px;
  height: 4px;
  background: #352c22;
  border-radius: 3px;
  overflow: hidden;
}

.ach-prog-bar {
  height: 100%;
  background: #e0b060;
  border-radius: 3px;
  transition: width 0.3s;
  box-shadow: inset 0 1px 0 #ffdf9a;
}

.ach-stats {
  padding: 12px 18px;
  border-top: 1px solid #5e462e;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #241e16;
}

.ach-stat {
  font-size: 12px;
  color: #b89a68;
  font-weight: 500;
}

.ach-stat b {
  color: #f5cf92;
  font-weight: 800;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #sidebar {
    width: 160px;
  }

  #toolbar {
    width: 44px;
  }

  .tb-btn {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  .ri {
    min-width: 70px;
    padding: 2px 8px;
  }
}

@media (max-width: 450px) {
  #sidebar {
    display: none;
  }

  .maps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Add some finishing touches: rivets, grain */
#toolbar .tb-btn::before {
  content: "⚔";
  font-size: 0px;
}

.tb-btn[title]:hover::after {
  display: none;
}

/* ===========================
   ADD MAP MODAL
   =========================== */
#add-map-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#add-map-modal .guide-box {
  background: var(--panel);
  border: 2px solid var(--brd);
  border-radius: 12px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  direction: rtl;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

#add-map-modal .guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

#add-map-modal .guide-header h2 {
  font-size: 24px;
  color: #f5cf8c;
  font-family: "Cinzel", serif;
}

#add-map-modal .guide-close {
  background: none;
  border: none;
  color: #c8aa74;
  font-size: 24px;
  cursor: pointer;
  padding: 0 8px;
}

#add-map-modal textarea {
  background: #1a1a1a;
  color: #0f0;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}