:root {
  --ui-gold-line: rgba(214, 157, 69, .74);
  --ui-gold-bright: #f1d28a;
  --ui-panel-dark: rgba(9, 27, 29, .91);
  --ui-panel-soft: rgba(17, 34, 34, .86);
  --ui-text-warm: #f6e6bd;
}

body {
  background: #050d0f url("../assets/ui/ui-page-bg.png?v=20260619c") center top / cover fixed no-repeat;
}

.game-shell {
  position: relative;
  max-width: 480px;
  background:
    linear-gradient(180deg, rgba(4, 9, 13, .18), rgba(5, 13, 14, .86) 64%),
    url("../assets/ui/ui-page-bg.png?v=20260619c") center top / 100% auto repeat-y;
}

.game-shell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 72px;
  height: 112px;
  background: url("../assets/ui/top-ornament.png?v=20260619c") left top / contain no-repeat;
  pointer-events: none;
}

.topbar {
  position: relative;
  min-height: 122px;
  align-items: flex-start;
  padding: 6px 0 0 50px;
  margin-bottom: 10px;
}

.topbar h1 {
  color: var(--ui-text-warm);
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-size: 42px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(71, 45, 12, .72), 0 0 18px rgba(230, 186, 93, .24);
}

.eyebrow {
  color: #d8a84d;
  font-size: 14px;
  letter-spacing: .04em;
}

.policy-line,
.level-progress-line {
  color: #d8ceb5;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
}

.level-progress-line i {
  display: block;
  width: min(218px, 72vw);
  height: 7px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(237, 226, 184, .12);
  box-shadow: inset 0 0 0 1px rgba(246, 224, 156, .1);
}

.level-progress-line b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e4b85e, #ffe096);
}

.topbar-actions {
  align-self: flex-start;
}

.icon-button#leaderboardButton {
  width: 54px;
  min-width: 54px;
  height: 54px;
  min-height: 54px;
  margin-top: -2px;
  border: 0;
  background: url("../assets/ui/leaderboard-badge.png?v=20260619c") center / contain no-repeat;
  box-shadow: none;
  color: transparent;
}

.resource-strip {
  gap: 6px;
  margin-bottom: 10px;
}

.resource-strip article {
  position: relative;
  min-height: 58px;
  padding: 8px 6px 7px 46px;
  border-color: var(--ui-gold-line);
  border-radius: 4px;
  background:
    linear-gradient(135deg, transparent 0 8px, var(--ui-panel-dark) 8px) padding-box,
    linear-gradient(135deg, rgba(247, 201, 103, .75), rgba(105, 75, 34, .5)) border-box;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .34);
}

.resource-strip article::before,
.status-grid article::before,
.policy-card::before,
.auto-card::before {
  content: "";
  position: absolute;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45));
}

.resource-strip article:nth-child(1)::before { background-image: url("../assets/ui/resource-faith.png?v=20260619c"); }
.resource-strip article:nth-child(2)::before { background-image: url("../assets/ui/resource-grain.png?v=20260619c"); }
.resource-strip article:nth-child(3)::before { background-image: url("../assets/ui/resource-ore.png?v=20260619c"); }
.resource-strip article:nth-child(4)::before { background-image: url("../assets/ui/resource-crystal.png?v=20260619c"); }

.resource-strip article::before {
  left: 5px;
  top: 9px;
  width: 38px;
  height: 42px;
}

.resource-strip span {
  color: #d9cdb3;
  font-size: 12px;
  font-weight: 900;
}

.resource-strip strong {
  color: #f8ead0;
  font-size: 25px;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .52);
}

.resource-strip em {
  color: #69d982;
  font-size: 11px;
}

.world-panel,
.kingdom-panel,
.status-grid,
.panel.active {
  border: 1px solid var(--ui-gold-line);
  border-radius: 10px;
  background: rgba(8, 22, 24, .78);
  box-shadow: inset 0 0 0 1px rgba(255, 222, 128, .08), 0 14px 28px rgba(0, 0, 0, .28);
}

.world-panel {
  position: relative;
}

.world-map {
  border: 0;
  border-radius: 9px;
  background-color: #071319;
}

.world-panel::before,
.world-panel::after {
  content: "";
  position: absolute;
  z-index: 18;
  width: 34px;
  height: 34px;
  border-top: 2px solid rgba(225, 179, 90, .8);
  pointer-events: none;
}

.world-panel::before {
  left: 5px;
  top: 5px;
  border-left: 2px solid rgba(225, 179, 90, .8);
  border-radius: 8px 0 0;
}

.world-panel::after {
  right: 5px;
  top: 5px;
  border-right: 2px solid rgba(225, 179, 90, .8);
  border-radius: 0 8px 0 0;
}

.target-card {
  position: absolute;
  left: 18px;
  top: 16px;
  z-index: 58;
  display: block;
  width: 202px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.target-card.protected-only {
  width: 178px;
}

.target-card.active {
  width: auto;
  min-width: 0;
  pointer-events: none;
}

.target-card h2 {
  color: var(--ui-text-warm);
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-size: 21px;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .72);
}

.target-card p {
  color: #dacfb3;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.38;
  text-shadow: 0 1px 2px #000;
}

.target-card.protected-only h2,
.target-card.protected-only #targetMeta {
  display: none;
}

.target-card.active h2,
.target-card.active p {
  display: none;
}

.target-card.protected-only #worldStatus {
  max-width: 170px;
  color: #d8cfb9;
  font-size: 10px;
  line-height: 1.45;
}

.target-card button {
  display: none;
}

.target-card.active button {
  display: none;
  min-width: 92px;
  height: 42px;
  padding: 0 14px;
  pointer-events: none;
  touch-action: manipulation;
}

.target-card.active button:disabled {
  filter: grayscale(.6);
  opacity: .58;
}

.target-card button::before {
  content: none;
}

.kingdom-panel {
  padding: 4px;
}

.kingdom-strip {
  border-radius: 8px;
}

.status-grid {
  gap: 6px;
  padding: 6px;
}

.status-grid article {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  align-content: start;
  column-gap: 8px;
  min-height: 72px;
  padding: 10px 8px;
  border-color: rgba(189, 137, 58, .72);
  border-radius: 4px;
  background: var(--ui-panel-soft);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, .28);
}

.status-grid article::before {
  position: relative;
  grid-column: 1;
  grid-row: 1 / 4;
  left: auto;
  top: auto;
  width: 34px;
  height: 34px;
  align-self: start;
}

.status-grid article:nth-child(1)::before { background-image: url("../assets/ui/status-level.png?v=20260619c"); }
.status-grid article:nth-child(2)::before { background-image: url("../assets/ui/status-area.png?v=20260619c"); }
.status-grid article:nth-child(3)::before { background-image: url("../assets/ui/status-tribe.png?v=20260619c"); }
.status-grid article:nth-child(4)::before { background-image: url("../assets/ui/status-power.png?v=20260619c"); }
.status-grid article:nth-child(5)::before { background-image: url("../assets/ui/status-skill.png?v=20260619c"); }
.status-grid article:nth-child(6)::before { background-image: url("../assets/ui/status-raid.png?v=20260619c"); }

.status-grid article > span {
  grid-column: 2;
  color: #cbbf9f;
  font-size: 12px;
  font-weight: 900;
}

.status-grid article > strong {
  grid-column: 2;
  color: #f7e8c7;
  font-size: 18px;
  line-height: 1.08;
  word-break: keep-all;
}

.status-grid article > em {
  grid-column: 2;
}

.status-action.skill-ready {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon value"
    "icon hint";
  column-gap: 8px;
  align-items: start;
}

.status-grid .status-action.skill-ready::before {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.status-grid article:nth-child(5) {
  padding-left: 8px;
  padding-right: 8px;
}

.status-grid article:nth-child(5)::before {
  width: 34px;
  height: 34px;
}

.status-grid article:nth-child(5) > span {
  font-size: 11px;
  line-height: 1.15;
}

.status-grid article:nth-child(5) > strong {
  font-size: 15px;
  line-height: 1.1;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.status-grid article:nth-child(5) > em {
  font-size: 9px;
}

.tabbar {
  gap: 6px;
  padding: 8px 0;
  background: rgba(6, 15, 17, .96);
}

.tab {
  min-height: 40px;
  border: 1px solid rgba(132, 102, 60, .7);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(35, 41, 37, .9), rgba(21, 28, 27, .94));
  color: #b8ac91;
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 241, 188, .04);
}

.tab.active {
  border-color: #d59e43;
  background: linear-gradient(180deg, #7e5a24, #3e280e);
  color: #ffe4a1;
  box-shadow: inset 0 0 0 1px rgba(255, 231, 162, .28), 0 0 13px rgba(209, 147, 50, .28);
}

.panel.active {
  padding: 6px;
}

.policy-grid,
.build-list,
.tribe-list {
  gap: 6px;
}

.policy-card,
.auto-card,
.action-row,
.build-item,
.raid-card,
.tribe-card {
  position: relative;
  min-height: 70px;
  margin-bottom: 6px;
  padding: 10px 38px 10px 70px;
  border-color: rgba(142, 101, 47, .78);
  border-radius: 4px;
  background: rgba(10, 29, 31, .84);
  color: var(--ui-text-warm);
  box-shadow: inset 0 0 0 1px rgba(255, 222, 128, .04);
}

.action-row {
  padding-left: 14px;
}

.tribe-list .tribe-card {
  display: block;
  padding: 12px 14px;
}

.tribe-list .tribe-card > div {
  min-width: 0;
}

.tribe-list .skill-detail-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  overflow: visible;
}

.tribe-list .skill-detail-card .skill-heading {
  min-width: 0;
}

.policy-card::before,
.auto-card::before {
  left: 13px;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translateY(-50%);
}

.policy-card[data-policy="economy"]::before { background-image: url("../assets/ui/policy-economy.png?v=20260619c"); }
.policy-card[data-policy="military"]::before { background-image: url("../assets/ui/policy-military.png?v=20260619c"); }
.policy-card[data-policy="faith"]::before { background-image: url("../assets/ui/policy-faith.png?v=20260619c"); }
.auto-card::before { background-image: url("../assets/ui/policy-auto.png?v=20260619c"); }

.world-chat:not(.expanded) .chat-input-button {
  background: url("../assets/ui/chat-bubble.png?v=20260619c") center / 46px 46px no-repeat;
}

.world-chat:not(.expanded) .chat-input-button::before,
.world-chat:not(.expanded) .chat-input-button::after {
  display: none;
}

.policy-card::after,
.auto-card::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: #d9a95d;
  font-size: 32px;
  font-weight: 300;
}

.policy-card.active {
  border-color: #f1c56c;
  background: linear-gradient(90deg, rgba(71, 51, 18, .86), rgba(26, 30, 25, .84));
  box-shadow: inset 0 0 0 1px rgba(255, 225, 132, .34), 0 0 15px rgba(229, 169, 70, .22);
}

.policy-card.active::after {
  content: "✓";
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #ffd978;
  border-radius: 50%;
  color: #ffe29a;
  font-size: 22px;
  font-weight: 900;
}

.policy-card strong {
  color: #ffe6aa;
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-size: 19px;
}

.policy-card span,
.auto-card p {
  color: #d6c9aa;
  font-size: 12px;
  font-weight: 800;
}

.country-strip {
  border-color: rgba(207, 153, 65, .72);
  background: rgba(8, 24, 25, .86);
}

.world-chat {
  top: max(100px, calc(env(safe-area-inset-top) + 92px));
  right: max(28px, calc((100vw - 480px) / 2 + 28px));
  bottom: auto;
}

@media (max-width: 390px) {
  .topbar {
    padding-left: 42px;
  }

  .topbar h1 {
    font-size: 36px;
  }

  .resource-strip {
    gap: 4px;
  }

  .resource-strip article {
    min-height: 48px;
    padding: 6px 4px 5px 31px;
  }

  .resource-strip article::before {
    left: 3px;
    top: 8px;
    width: 27px;
    height: 31px;
  }

  .resource-strip span {
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
  }

  .resource-strip strong {
    margin-top: 2px;
    font-size: 16px;
    line-height: 1;
    white-space: nowrap;
  }

  .resource-strip em {
    margin-top: 3px;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
  }

  .world-map {
    aspect-ratio: 4 / 3;
  }

  .target-card {
    width: 174px;
  }
}

@media (min-width: 391px) and (max-width: 520px) {
  .resource-strip {
    gap: 5px;
  }

  .resource-strip article {
    min-height: 52px;
    padding: 7px 5px 6px 36px;
  }

  .resource-strip article::before {
    left: 4px;
    top: 8px;
    width: 31px;
    height: 35px;
  }

  .resource-strip span {
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
  }

  .resource-strip strong {
    margin-top: 2px;
    font-size: 18px;
    line-height: 1;
    white-space: nowrap;
  }

  .resource-strip em {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
  }

  .world-map {
    aspect-ratio: 4 / 3;
  }
}
