:root {
  color-scheme: dark;
  --bg: #080d0d;
  --surface: #101919;
  --surface-2: #172424;
  --surface-3: #203131;
  --border: #385151;
  --border-bright: #577575;
  --text: #f2f5f2;
  --muted: #aebdbc;
  --accent: #f0b84b;
  --accent-strong: #ffd36f;
  --link: #72d8dd;
  --danger: #ff7979;
  --success: #82d49a;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(75, 112, 95, 0.18), transparent 34rem),
    linear-gradient(145deg, #070b0b 0%, #0b1212 48%, #070909 100%);
  font-family: Verdana, Geneva, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

a {
  color: var(--link);
  text-decoration-color: rgba(114, 216, 221, 0.45);
  text-underline-offset: 2px;
}

a:hover {
  color: #b9f4f5;
}

.game-app {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
}

.game-header {
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(120deg, rgba(240, 184, 75, 0.13), transparent 35%),
    linear-gradient(135deg, #203430, #101919 58%, #182424);
  box-shadow: var(--shadow);
}

.game-header::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.035), transparent);
  content: "";
  pointer-events: none;
}

.game-header-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.game-header-row > div {
  min-width: 0;
}

.game-title {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 4vw, 38px);
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow: 0 2px 12px #000;
}

.game-subtitle {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  color: #d6dfdc;
  font-size: 12px;
}

.fullscreen-button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}

.empire-stats {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 22, 22, 0.96);
  box-shadow: var(--shadow);
}

.empire-stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #d8e5eb, #f5f8fa 50%, #d8e5eb);
}

.empire-stats-summary > div {
  padding: 6px 12px;
  color: #071111;
  font-size: 15px;
  text-align: center;
}

.empire-stats-summary strong {
  color: #071111;
}

.empire-stats h2 {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--accent-strong);
  background: linear-gradient(90deg, var(--surface), var(--surface-3), var(--surface));
  font-family: Verdana, Geneva, sans-serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.empire-stats-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr);
}

.land-statistics,
.resource-statistics {
  padding: 10px 14px;
}

.land-statistics {
  border-right: 1px solid var(--border);
}

.land-statistics-row {
  display: grid;
  grid-template-columns: 64px repeat(3, minmax(54px, 1fr));
  gap: 10px;
  align-items: center;
}

.land-statistics-row + .land-statistics-row {
  margin-top: 8px;
}

.land-statistics-row > span {
  color: var(--text);
  font-weight: bold;
}

.resource-statistics {
  display: grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  gap: 8px 14px;
}

.empire-stat-item {
  display: flex;
  min-width: 0;
  gap: 3px;
  align-items: center;
  color: var(--text);
  flex-direction: column;
}

.empire-stat-item img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border-bright);
  object-fit: cover;
}

.empire-stat-item strong {
  overflow: hidden;
  max-width: 100%;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.game-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.game-sidebar,
.game-main {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 22, 22, 0.94);
  box-shadow: var(--shadow);
}

.game-sidebar {
  position: sticky;
  top: 12px;
  overflow: hidden;
}

.turn-panel {
  padding: 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.turn-panel form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: end;
  margin: 0;
}

.turn-panel label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.turn-count {
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: 11px;
}

.game-nav {
  margin: 0;
  padding: 8px;
  list-style: none;
}

.game-nav li {
  margin: 2px 0;
  list-style: none;
}

.game-nav a,
.market-links {
  display: block;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #d7eeee;
  text-decoration: none;
}

.game-nav a:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.game-nav a.active {
  border-color: #6d633f;
  color: var(--accent-strong);
  background: linear-gradient(90deg, rgba(240, 184, 75, 0.16), rgba(240, 184, 75, 0.03));
  font-weight: bold;
}

.market-links {
  color: var(--muted);
  font-size: 11px;
}

.market-links a {
  display: inline;
  padding: 0;
}

.game-main {
  overflow: hidden;
}

.flash-message {
  margin: 12px 12px 0;
  padding: 10px 12px;
  border: 1px solid #7a6731;
  border-radius: 8px;
  color: #ffe9a9;
  background: rgba(111, 82, 22, 0.3);
}

.game-content {
  min-height: 420px;
  padding: 14px;
  overflow-x: auto;
}

.page-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: -14px -14px 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface-3), var(--surface));
}

.page-heading h2 {
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  letter-spacing: 0.03em;
}

.turn-log {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.turn-log summary {
  padding: 10px 12px;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: bold;
}

.turn-log-body {
  padding: 0 12px 12px;
}

.status-panel {
  padding: 0 14px 14px;
}

.status-title {
  margin: 0 -14px 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--accent-strong);
  background: var(--surface-2);
  font-weight: bold;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  gap: 8px;
}

.status-card {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
}

.status-card-title {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-card strong {
  color: var(--accent-strong);
}

.HEADER {
  padding: 7px 8px;
  color: white;
  background: var(--surface-3);
  font-family: Verdana, sans-serif;
  font-size: 11px;
  font-weight: bold;
}

table {
  max-width: 100%;
  border-collapse: collapse;
  background: rgba(9, 16, 16, 0.68);
}

.game-content > table,
.game-content > form > table {
  margin-bottom: 14px;
  border-color: var(--border) !important;
  border-radius: 8px;
}

td,
th {
  border-color: var(--border) !important;
  padding: 6px 8px;
  vertical-align: middle;
}

tr:nth-child(even) > td:not(.HEADER) {
  background: rgba(255, 255, 255, 0.018);
}

input,
select,
button,
textarea {
  max-width: 100%;
  border: 1px solid var(--border-bright);
  border-radius: 5px;
  color: var(--text);
  background: #0a1111;
  font-family: Verdana, sans-serif;
  font-size: 11px;
}

input,
select,
button {
  min-height: 29px;
  padding: 5px 7px;
}

textarea {
  padding: 8px;
  resize: vertical;
}

input[type="submit"],
input[type="button"],
button {
  border-color: #806a32;
  color: #fff1bf;
  background: linear-gradient(#3a3524, #242419);
  cursor: pointer;
  font-weight: bold;
}

input[type="submit"]:hover,
input[type="button"]:hover,
button:hover {
  border-color: var(--accent);
  background: linear-gradient(#4c4228, #2b281c);
}

input:focus,
select:focus,
button:focus,
textarea:focus {
  outline: 2px solid rgba(114, 216, 221, 0.4);
  outline-offset: 1px;
}

input[type="checkbox"],
input[type="radio"] {
  min-height: auto;
}

form {
  max-width: 100%;
}

.coming-soon {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #a64d4d;
  border-radius: 8px;
  color: #ffd5d5;
  background: rgba(113, 25, 25, 0.35);
  text-align: center;
}

.military-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.military-stat,
.military-section,
.attack-card,
.attack-intro,
.protection-notice {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(24, 38, 38, 0.94), rgba(12, 20, 20, 0.96));
}

.military-stat {
  display: flex;
  min-height: 116px;
  padding: 13px;
  flex-direction: column;
}

.military-stat > span,
.equipment-grid span {
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.military-stat > strong {
  margin: 7px 0 4px;
  color: var(--accent-strong);
  font-size: 19px;
}

.military-stat small,
.attack-card small {
  color: var(--muted);
  font-size: 10px;
}

.military-stat progress {
  width: 100%;
  height: 8px;
  margin: 2px 0 7px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  color: var(--accent);
  background: #071010;
}

.military-stat progress::-webkit-progress-bar {
  background: #071010;
}

.military-stat progress::-webkit-progress-value {
  background: linear-gradient(90deg, #8f6b25, var(--accent));
}

.military-stat progress::-moz-progress-bar {
  background: linear-gradient(90deg, #8f6b25, var(--accent));
}

.military-section {
  margin-bottom: 14px;
  padding: 12px;
}

.military-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.military-section-heading,
.attack-card-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.military-section-heading h3,
.attack-card-heading h3 {
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.military-section-heading p,
.attack-card-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 7px;
}

.equipment-grid > div {
  display: flex;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(5, 12, 12, 0.45);
  flex-direction: column;
}

.equipment-grid strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 15px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.military-table {
  width: 100%;
  margin: 0;
}

.unit-quantity {
  display: flex;
  gap: 5px;
  min-width: 125px;
}

.unit-quantity input:first-child {
  width: 76px;
}

.military-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button.danger-button {
  border-color: #844646;
  color: #ffd2d2;
  background: linear-gradient(#482626, #2b1717);
}

button.danger-button:hover {
  border-color: var(--danger);
  background: linear-gradient(#5a2929, #331919);
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.attack-intro {
  margin: 0 0 12px;
  padding: 11px 13px;
}

.attack-intro div {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.attack-intro span {
  color: var(--muted);
  font-size: 10px;
}

.attack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.attack-card {
  display: flex;
  gap: 11px;
  padding: 14px;
  flex-direction: column;
}

.attack-card-army {
  grid-row: span 2;
}

.attack-card-heading {
  justify-content: flex-start;
}

.attack-card-icon {
  display: grid;
  width: 34px;
  height: 34px;
  border: 1px solid #79642f;
  border-radius: 50%;
  color: var(--accent-strong);
  background: rgba(240, 184, 75, 0.1);
  font-size: 18px;
  place-items: center;
  flex: 0 0 auto;
}

.field-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
}

.field-label select,
.field-label > input {
  width: 100%;
  color: var(--text);
}

.attack-unit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.attack-unit-grid label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 7px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(5, 12, 12, 0.45);
}

.attack-unit-grid label > span,
.attack-unit-grid small {
  display: block;
}

.attack-unit-grid input {
  width: 100%;
}

.attack-options {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  flex-wrap: wrap;
}

.check-option {
  color: var(--muted);
  font-size: 10px;
}

.attack-submit {
  width: 100%;
}

.status-pill {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid #496f60;
  border-radius: 20px;
  color: var(--success);
  background: rgba(52, 105, 78, 0.2);
  white-space: nowrap;
}

.operation-army {
  min-width: 130px;
  color: #d6dfdc;
  font-size: 10px;
}

.attack-warning {
  max-width: 220px;
  margin-top: 5px;
  color: var(--danger);
  font-size: 9px;
}

.protection-notice {
  margin-top: 12px;
  padding: 16px;
  border-color: #7a6731;
  color: #ffe9a9;
  background: rgba(111, 82, 22, 0.22);
  text-align: center;
}

.ui-section,
.summary-card,
.wall-hero,
.message-card,
.info-banner {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(24, 38, 38, 0.94), rgba(12, 20, 20, 0.96));
}

.ui-section {
  margin-bottom: 14px;
  padding: 12px;
}

.ui-section-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.ui-section-heading h3 {
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.ui-section-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card {
  display: flex;
  min-height: 98px;
  padding: 12px;
  flex-direction: column;
}

.summary-card > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-card > strong {
  margin: 6px 0 3px;
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.2;
}

.summary-card small,
.detail-list small,
.conversion-grid small,
.trade-input-grid small {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.compact-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0 0;
}

.wall-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wall-allocation-controls {
  display: grid;
  width: 100%;
  gap: 6px;
  grid-template-columns: 1fr;
  margin: 6px 0 3px;
}

.wall-allocation-controls select {
  width: 100%;
  min-width: 0;
}

.wall-allocation-controls input[type="submit"] {
  width: 100%;
}

.ui-columns,
.trade-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.quick-input {
  display: flex;
  min-width: 0;
  gap: 4px;
  align-items: center;
}

.quick-input > input {
  width: 76px;
  min-width: 48px;
  flex: 1 1 76px;
}

.quick-input-buttons {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.quick-input-buttons button {
  min-height: 29px;
  padding: 4px 5px;
  font-size: 9px;
}

.inline-form label,
.stack-form label,
.build-order-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
}

.form-grow {
  min-width: 180px;
  flex: 1;
}

.stack-form {
  display: grid;
  gap: 9px;
}

.full-button {
  width: 100%;
  margin-top: 10px;
}

.section-actions {
  display: flex;
  margin-top: 10px;
  justify-content: flex-end;
}

.data-table {
  width: 100%;
  margin: 0;
}

.weapon-production-table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
}

.weapon-production-table th,
.weapon-production-table td {
  border: 1px solid var(--border);
  text-align: center;
}

.weapon-production-table thead th {
  padding: 10px 6px 8px;
  color: var(--text);
  background: rgba(5, 12, 12, 0.7);
}

.weapon-production-table thead th:first-child,
.weapon-production-table tbody th {
  width: 150px;
}

.weapon-production-table thead img {
  display: block;
  width: 49px;
  height: 35px;
  margin: 0 auto 4px;
  object-fit: contain;
}

.weapon-production-table thead span {
  display: block;
  color: var(--accent-strong);
  font-size: 11px;
}

.weapon-production-table tbody th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  text-align: left;
}

.weapon-production-table td {
  height: 46px;
}

.weapon-production-table input {
  width: min(96px, 100%);
  text-align: center;
}

.weapon-production-table .quick-input {
  justify-content: center;
}

.weapon-production-table td strong {
  color: var(--text);
  font-size: 14px;
}

.buildings-table {
  width: 100%;
  min-width: 820px;
  table-layout: fixed;
  border: 1px solid var(--border);
}

.buildings-table th,
.buildings-table td {
  border: 1px solid var(--border);
}

.buildings-table thead th {
  padding: 8px 6px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 11px;
  text-align: center;
}

.buildings-table thead th:first-child {
  width: 30px;
}

.buildings-table thead th:nth-child(2) {
  width: 170px;
}

.buildings-table thead th:nth-child(3),
.buildings-table thead th:nth-child(4),
.buildings-table thead th:nth-child(6) {
  width: 86px;
}

.buildings-table thead th:nth-child(5) {
  width: 112px;
}

.buildings-table tbody td {
  padding: 6px;
  background: rgba(4, 10, 19, 0.58);
}

.buildings-table tbody td:nth-child(3),
.buildings-table tbody td:nth-child(6),
.buildings-total td {
  text-align: right;
}

.building-help-cell {
  padding: 6px 2px !important;
  text-align: center;
  vertical-align: top;
}

.building-help {
  display: inline-grid;
  width: 18px;
  height: 18px;
  cursor: default;
  font-weight: bold;
  place-items: center;
}

.building-name {
  font-weight: bold;
}

.building-gold {
  color: #ffcc00;
}

.building-iron {
  color: #ffcc00;
}

.building-wood {
  color: #00ff00;
}

.building-food {
  color: #ff6600;
}

.building-farm {
  color: #ff6600;
}

.building-craft {
  color: #00ccff;
}

.building-structure {
  color: #fff;
}

.building-land {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.building-land img {
  width: 46px;
  height: 25px;
  object-fit: contain;
}

.buildings-table select {
  width: 100%;
}

.building-production,
.building-usage {
  display: grid;
  gap: 4px;
  font-size: 10px;
}

.building-resource-line {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  min-height: 28px;
}

.building-resource-line img {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.building-resource-line span {
  color: var(--text);
}

.building-resource-line strong {
  font-size: 11px;
}

.building-resource-line.production strong {
  color: var(--success);
}

.building-resource-line.consumption strong {
  color: var(--danger);
}

.building-usage {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

.buildings-total th,
.buildings-total td {
  padding: 8px;
  color: var(--text);
  background: var(--surface-3) !important;
  font-size: 12px;
  font-weight: bold;
}

.buildings-total th {
  text-align: left;
}

.buildings-total input {
  width: 100%;
}

.empire-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.status-summary-table {
  width: 100%;
  table-layout: fixed;
  border: 1px solid var(--border);
}

.status-summary-table th,
.status-summary-table td {
  border: 1px solid var(--border);
}

.status-summary-table thead th {
  padding: 9px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 14px;
  text-align: center;
}

.status-summary-table tbody th {
  width: 65%;
  color: var(--muted);
  font-size: 10px;
  font-weight: normal;
  text-align: left;
}

.status-summary-table tbody td {
  color: var(--text);
  font-weight: bold;
  text-align: right;
}

.status-summary-table .summary-total th,
.status-summary-table .summary-total td,
.status-summary-table .summary-capacity th {
  color: var(--text);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: bold;
}

.status-summary-table .summary-capacity th {
  padding: 9px;
  text-align: center;
}

.status-summary-table .population-details td {
  padding: 12px 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.status-summary-table .population-details strong {
  color: var(--accent-strong);
}

.monthly-summary-table {
  width: 100%;
  min-width: 850px;
  table-layout: fixed;
  border: 1px solid var(--border);
}

.monthly-summary-table th,
.monthly-summary-table td {
  border: 1px solid var(--border);
  text-align: right;
}

.monthly-summary-table thead th {
  padding: 9px 6px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 10px;
  text-align: center;
}

.monthly-summary-table thead th:first-child {
  width: 170px;
}

.monthly-summary-table tbody th {
  display: flex;
  min-height: 60px;
  gap: 9px;
  align-items: center;
  color: var(--text);
  font-size: 11px;
  font-weight: normal;
  text-align: left;
}

.monthly-summary-table tbody th img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border-bright);
  object-fit: cover;
  flex: 0 0 auto;
}

.monthly-summary-table tbody th span,
.monthly-summary-table tbody th small {
  display: block;
}

.monthly-summary-table tbody th small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.monthly-summary-table td {
  color: var(--text);
  font-size: 11px;
}

.season-values {
  display: flex;
  gap: 3px;
  flex-direction: column;
}

.economy-positive {
  color: #eff45c;
}

.economy-negative {
  color: var(--danger);
}

.economy-neutral {
  color: var(--text);
}

.data-table small {
  color: var(--muted);
}

.detail-list {
  display: grid;
  gap: 6px;
}

.detail-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(5, 12, 12, 0.42);
}

.detail-list small {
  grid-column: 1 / -1;
}

.warning-banner,
.info-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
}

.warning-banner {
  margin-top: 9px;
  border: 1px solid #844646;
  border-radius: 7px;
  color: #ffd2d2;
  background: rgba(112, 35, 35, 0.22);
}

.info-banner {
  color: #dbe8e5;
  background: linear-gradient(90deg, rgba(60, 101, 91, 0.32), rgba(16, 27, 27, 0.96));
}

.event-log {
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #dbe5e2;
  background: rgba(4, 10, 10, 0.5);
  white-space: normal;
}

.news-card,
.message-card {
  margin-top: 8px;
  overflow: hidden;
}

.news-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 12, 12, 0.42);
}

.news-card-body,
.message-body {
  padding: 11px;
}

.news-card form {
  padding: 0 11px 11px;
}

.current-row > td {
  background: rgba(240, 184, 75, 0.08) !important;
}

.wall-hero {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px;
}

.wall-hero h3 {
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
}

.wall-hero p {
  color: var(--muted);
}

.wall-progress {
  display: grid;
  place-items: center;
}

.wall-progress-ring {
  display: grid;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--surface-3) 0);
  place-content: center;
  position: relative;
}

.wall-progress-ring::before {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.wall-progress-ring strong,
.wall-progress-ring span {
  position: relative;
  z-index: 1;
  text-align: center;
}

.wall-progress-ring strong {
  color: var(--accent-strong);
  font-size: 24px;
}

.wall-progress-ring span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.ration-grid,
.conversion-grid,
.trade-input-grid {
  display: grid;
  gap: 6px;
}

.ration-option,
.conversion-grid label,
.trade-input-grid label {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(5, 12, 12, 0.42);
}

.ration-option {
  grid-template-columns: auto minmax(0, 1fr);
  cursor: pointer;
}

.ration-option small,
.ration-option strong,
.conversion-grid small,
.conversion-grid strong,
.trade-input-grid small {
  display: block;
}

.conversion-grid label,
.trade-input-grid label {
  grid-template-columns: minmax(0, 1fr) auto;
}

.page-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  flex-wrap: wrap;
}

.page-tabs a {
  min-width: 90px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  text-transform: capitalize;
  flex: 1;
}

.page-tabs a:hover,
.page-tabs a.active {
  border-color: #6d633f;
  color: var(--accent-strong);
  background: rgba(240, 184, 75, 0.1);
}

.message-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
}

.message-meta time {
  margin-left: auto;
}

.new-badge,
.you-badge {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 10px;
  color: #161207;
  background: var(--accent);
  font-size: 8px;
  font-weight: bold;
  text-transform: uppercase;
}

.message-actions {
  display: flex;
  gap: 5px;
  padding: 0 11px 11px;
}

.blocked-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.blocked-list > div {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.trade-input-grid {
  margin-bottom: 10px;
}

.trade-input-grid label > span,
.capitalized {
  text-transform: capitalize;
}

.table-form {
  display: flex;
  gap: 5px;
}

.scores-intro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-filter-grid {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.score-filter-grid > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-filter-grid > div + div {
  border-top: 1px solid var(--border);
}

.score-filter {
  min-width: 0;
  padding: 8px 9px;
  color: #d89a45;
  background: rgba(5, 12, 12, 0.45);
  font-size: 10px;
  text-align: center;
}

.score-filter + .score-filter {
  border-left: 1px solid var(--border);
}

.scores-legend {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.scores-legend span {
  display: block;
}

.scores-legend .legend-current {
  color: var(--link);
  font-weight: bold;
}

.scores-legend .legend-protected {
  color: #eff45c;
  font-weight: bold;
}

.scores-player-count {
  margin: 12px -12px -12px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
}

.scores-player-count strong {
  color: var(--text);
}

.scores-table {
  min-width: 820px;
}

.scores-table .HEADER {
  text-align: center;
}

.scores-table .alliance-cell {
  text-align: center;
}

.scores-table .current-player > td {
  color: var(--link);
  background: rgba(114, 216, 221, 0.07);
}

.scores-table .scores-gap td {
  text-align: center;
  letter-spacing: 0.4em;
  font-weight: 700;
  opacity: 0.55;
  padding: 8px 0;
}

.scores-table .protected-player > td {
  color: #eff45c;
}

.scores-table .protected-player a {
  color: inherit;
}

.rank-badge {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  place-items: center;
}

.player-menu {
  position: absolute;
  z-index: 1000;
  max-width: 360px;
  padding: 10px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: white;
  background: #071111;
  box-shadow: var(--shadow);
  font-size: 11px;
}

.boot-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.boot-card {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.boot-card h1 {
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
}

@media (max-width: 960px) {
  .game-app {
    padding: 8px;
  }

  .game-shell {
    grid-template-columns: 1fr;
  }

  .game-sidebar {
    position: static;
  }

  .game-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .market-links {
    text-align: center;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .empire-stats-body {
    grid-template-columns: 1fr;
  }

  .land-statistics {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .military-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .equipment-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .empire-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scores-intro-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 12px;
  }

  .game-header {
    padding: 15px;
  }

  .game-header-row {
    align-items: stretch;
    flex-direction: column;
  }

  .empire-stats-summary > div {
    padding: 6px 3px;
    font-size: 11px;
  }

  .land-statistics,
  .resource-statistics {
    padding: 8px;
  }

  .land-statistics-row {
    grid-template-columns: 56px repeat(3, minmax(48px, 1fr));
    gap: 4px;
  }

  .empire-stat-item img {
    width: 42px;
    height: 42px;
  }

  .fullscreen-button {
    width: 100%;
  }

  .game-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-nav a {
    padding: 7px;
    font-size: 11px;
  }

  .game-content {
    padding: 10px;
  }

  .page-heading {
    margin: -10px -10px 12px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .military-summary,
  .military-columns,
  .attack-grid,
  .attack-unit-grid,
  .summary-grid,
  .ui-columns,
  .trade-columns,
  .wall-hero {
    grid-template-columns: 1fr;
  }

  .equipment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .empire-summary-grid {
    grid-template-columns: 1fr;
  }

  .military-section-heading,
  .ui-section-heading,
  .attack-intro div {
    align-items: stretch;
    flex-direction: column;
  }

  .wall-hero {
    text-align: center;
  }

  .compact-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    text-align: left;
  }

  .wall-summary {
    grid-template-columns: 1fr;
  }

  .conversion-grid label,
  .trade-input-grid label {
    grid-template-columns: 1fr;
  }

  .military-actions {
    justify-content: stretch;
  }

  .military-actions button {
    flex: 1;
  }

  td,
  th {
    padding: 5px;
  }
}

/* Portrait monthly summary is a MOST-theme layout; other themes use the wide table. */
.monthly-portrait {
  display: none;
}

/* Android shell: sign-in choice on the boot page (see pages/layout.ts). */
.lr-auth {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.lr-auth[hidden] {
  display: none;
}

.lr-google-btn {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.lr-auth-button {
  padding: 13px 24px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.lr-auth-button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #12100e;
}

.lr-auth-button:active {
  opacity: 0.75;
}

.lr-auth-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.lr-guest-back {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lr-guest-back[hidden] {
  display: none;
}

/* Standalone sign-in and devices page (see pages/link.ts). */
.lr-link-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.lr-link-page h1 {
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  margin: 0 0 8px;
}

.lr-link-block {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.lr-link-block h2 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--text);
}

.lr-link-block .lr-auth-button {
  width: 100%;
  margin-top: 10px;
}

.lr-link-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
}

.lr-code {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  user-select: all;
}

.lr-empire-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  background: var(--surface-2);
}

.lr-empire-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.lr-empire-card p {
  margin: 2px 0;
  color: var(--text);
  font-size: 14px;
}

.lr-link-status {
  min-height: 20px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.lr-link-status--error {
  color: var(--danger);
}

.lr-link-back {
  color: var(--link);
}

/* Anchor styled as a button on the account pages. */
.lr-link-button {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* Nation picker, shown once per empire (see pages/civ.ts). */
.civ-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.civ-page h1 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  color: var(--accent-strong);
}

.civ-page__lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.civ-page__error {
  margin: 0 0 12px;
  color: var(--danger);
  font-weight: 700;
}

.civ-grid {
  display: grid;
  gap: 10px;
}

@media (min-width: 520px) {
  .civ-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.civ-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.civ-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--surface-2);
}

.civ-card input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.civ-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.civ-card__name {
  font-weight: 700;
  color: var(--text);
}

.civ-card__unit,
.civ-card__traits {
  font-size: 12px;
  color: var(--muted);
}

.civ-card__traits--plus {
  color: #1a7a3c;
}

.civ-card__traits--minus {
  color: #b33a2b;
}

.civ-submit {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #12100e;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

/* World administration (see pages/admin.ts). */
.admin-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.admin-page h1 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--accent-strong);
}

.admin-flash {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.admin-card {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.admin-card--danger {
  border-color: var(--danger);
}

.admin-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.admin-facts {
  margin: 0;
  display: grid;
  gap: 6px;
}

.admin-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-facts dt {
  color: var(--muted);
}

.admin-facts dd {
  margin: 0;
  color: var(--text);
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-form input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.admin-form button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.admin-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.admin-table .num {
  text-align: right;
}

/* Hall of fame (see pages/archive.ts). */
.arc-entry {
  display: block;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.epoch-timer {
  margin: -4px 0 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted, #666);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.arc-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.arc-page h1 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--accent-strong);
}

.arc-lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.arc-round {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.arc-round__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.arc-round__head::-webkit-details-marker {
  display: none;
}

.arc-round__head::marker {
  content: "";
}

.arc-round__no {
  font-weight: 800;
  color: var(--text);
}

.arc-round__meta {
  color: var(--muted);
  font-size: 12px;
}

.arc-round__winner {
  margin-left: auto;
  color: var(--accent-strong);
  font-weight: 700;
}

.arc-round__body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

.arc-mine {
  margin: 10px 0;
  color: var(--link);
}

.arc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.arc-table th,
.arc-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.arc-table .num {
  text-align: right;
}

.arc-me {
  background: var(--surface-2);
  font-weight: 700;
}

.arc-empty {
  color: var(--muted);
}

.arc-back {
  color: var(--link);
}

/* Previous round summary on the nation picker. */
.civ-prev {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.civ-prev__head {
  font-weight: 800;
  color: var(--accent-strong);
  margin-bottom: 6px;
}

.civ-prev__list {
  margin: 0 0 4px;
  padding-left: 22px;
  color: var(--text);
}

.civ-prev__gap {
  margin: 0 0 2px;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.28em;
  line-height: 1;
}

.civ-prev__self {
  margin: 0 0 8px;
}

.civ-prev__place {
  display: inline-block;
  min-width: 1.8em;
  font-variant-numeric: tabular-nums;
}

.civ-prev__self > span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.civ-prev__list li {
  padding: 2px 0;
}

.civ-prev__list span {
  color: var(--muted);
}

.civ-prev__me {
  font-weight: 800;
  color: var(--link);
}

.civ-prev__link {
  color: var(--link);
  font-weight: 700;
}


/* Alliance / protection row colors on classic scores */
.scores-table .rel-clan > td { color: #e070ff; }
.scores-table .rel-ally > td { color: #f0c090; }
.scores-table .rel-war > td { color: #ff6b6b; }
.scores-table .rel-prot > td,
.scores-table .protected-player > td { color: #e6c35c; }
.scores-legend .legend-clan { color: #e070ff; }
.scores-legend .legend-ally { color: #f0c090; }
.scores-legend .legend-war { color: #ff6b6b; }
.prot-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border: 1px solid #e6c35c;
  border-radius: 3px;
  font-size: 9px;
  color: #e6c35c;
}
