.app {
  display: grid;
  grid-template-rows: 54px 1fr 104px;
  width: 100vw;
  height: 100vh;
  min-width: 1100px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #151714;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand strong {
  color: #efe3c5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  letter-spacing: 0.015em;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.resource-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.resource-pill {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #20211d;
  font-size: 12px;
  white-space: nowrap;
}

.resource-pill.online-gold {
  border-color: #806a39;
  background: #2d281c;
  color: #ead69e;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger {
  color: #ffd8d2;
  border-color: #77453e;
  background: #38211f;
}

.game-shell {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr) 318px;
  min-height: 0;
}

.panel {
  overflow: auto;
  padding: 14px 12px 22px;
  background: var(--panel);
}

.left-panel {
  border-right: 1px solid var(--line);
}

.right-panel {
  border-left: 1px solid var(--line);
}

.panel section + section {
  margin-top: 18px;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #102b36;
}

#worldCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  cursor: grab;
}

#worldCanvas:active {
  cursor: grabbing;
}

.zoom-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 4;
  display: grid;
  grid-template-columns: 34px minmax(220px, auto) 34px;
  align-items: stretch;
  transform: translateX(-50%);
  border: 1px solid #796846;
  border-radius: 6px;
  background: rgba(20, 21, 19, 0.94);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.42), inset 0 0 0 2px rgba(224, 190, 105, 0.08);
  color: #d4bd82;
  overflow: hidden;
}

.zoom-step {
  min-width: 34px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #282923;
  color: #d4bd82;
  font-size: 21px;
  line-height: 1;
}

.zoom-step:first-child {
  border-right: 1px solid rgba(177, 148, 78, 0.38);
}

.zoom-step:last-child {
  border-left: 1px solid rgba(177, 148, 78, 0.38);
}

.zoom-step:hover {
  background: #36362f;
}

.zoom-readout {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 5px 13px 4px;
  text-align: center;
}

.zoom-readout strong {
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.zoom-levels {
  display: flex;
  gap: 5px;
}

.zoom-levels button {
  width: 17px;
  height: 17px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(222, 195, 119, 0.34);
  border-radius: 50%;
  background: #20211d;
  color: #aeb8a6;
  font-size: 9px;
  line-height: 15px;
}

.zoom-levels button:hover,
.zoom-levels button.active {
  border-color: #efd57c;
  background: #75633c;
  color: #fff4c7;
}

.map-debug {
  display: none;
}

.map-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  color: #dce8d5;
  text-shadow: 0 1px 2px #000;
  font-size: 12px;
}

.feedback-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: min(640px, calc(100% - 48px));
  padding: 10px 14px;
  border: 1px solid rgba(232, 213, 142, 0.42);
  border-radius: 8px;
  background: rgba(18, 24, 18, 0.9);
  color: #fff2bc;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 13px;
  z-index: 4;
}

.feedback-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.feedback-toast.bad {
  color: #ffd8d2;
  border-color: rgba(216, 109, 92, 0.56);
}

.boot-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #fff2bc;
  background:
    radial-gradient(circle at 50% 44%, rgba(53, 52, 45, 0.72), rgba(16, 35, 42, 0.94) 62%),
    #102b36;
}

.boot-overlay strong {
  font-size: 18px;
}

.boot-overlay span {
  max-width: 420px;
  color: #cbd8c2;
  font-size: 13px;
  line-height: 1.35;
}

.boot-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.account-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 10, 8, 0.88);
}

.account-gate.hidden {
  display: none;
}

.account-card {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px 18px;
  padding: 22px;
  border: 1px solid #806d43;
  border-radius: 6px;
  background: #171916;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.64), inset 0 0 0 2px rgba(206, 173, 92, 0.06);
}

.account-crest {
  grid-row: 1 / span 4;
  display: grid;
  place-items: center;
  align-self: start;
  width: 72px;
  height: 92px;
  border: 1px solid #9b7e43;
  border-radius: 4px 4px 22px 22px;
  background: #263e57;
  color: #e3c36f;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
}

.account-card > header {
  display: grid;
  gap: 6px;
}

.account-card > header > span {
  color: #c4a760;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.account-card h1 {
  margin: 0;
  color: #ede0bf;
  font-family: Georgia, serif;
  font-size: 25px;
  letter-spacing: 0;
}

.account-card p,
.account-card > small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

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

.account-tabs button {
  min-height: 34px;
}

.account-tabs button.active {
  border-color: #b89b58;
  background: #383326;
  color: #f0dfb6;
}

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

.account-form.hidden {
  display: none;
}

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

.account-form label {
  display: grid;
  gap: 4px;
  color: #bdb8aa;
  font-size: 10px;
}

.account-form input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #44453c;
  border-radius: 4px;
  background: #0d110e;
  color: var(--text);
}

.account-form > button {
  min-height: 39px;
  border-color: #7e6b42;
  background: #302d24;
  color: #f0dfb6;
  font-weight: 700;
}

.account-status {
  min-height: 16px;
  color: #d8c587;
}

.account-status.bad {
  color: #df8e7d;
}

@media (max-width: 560px) {
  .account-card {
    grid-template-columns: 1fr;
  }

  .account-crest {
    display: none;
  }

  .account-form-grid {
    grid-template-columns: 1fr;
  }
}

.event-log {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #151714;
  min-height: 0;
}

.log-title {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 12px;
}

.log-lines {
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .app {
    min-width: 0;
  }

  .game-shell {
    grid-template-columns: 242px minmax(0, 1fr) 286px;
  }

  .topbar {
    grid-template-columns: minmax(220px, 290px) 1fr auto;
    gap: 10px;
  }

  .resource-pill {
    padding-inline: 6px;
    font-size: 11px;
  }
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .app {
    grid-template-rows: auto auto auto;
    width: 100%;
    height: auto;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .resource-bar,
  .top-actions {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .game-shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "left"
      "right";
  }

  .map-wrap {
    grid-area: map;
    height: 66vh;
    min-height: 480px;
  }

  .left-panel {
    grid-area: left;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .right-panel {
    grid-area: right;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .panel {
    overflow: visible;
  }

  .event-log {
    min-height: 150px;
  }
}

@media (max-width: 560px) {
  .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zoom-hud {
    top: 8px;
    grid-template-columns: 32px minmax(190px, auto) 32px;
  }

  .zoom-readout {
    padding-inline: 6px;
  }

  .map-overlay span:last-child {
    display: none;
  }

  .event-log {
    grid-template-columns: 1fr;
  }
}
