:root {
  --window-bg: #1f1f1e;
  --sidebar-bg: #272725;
  --main-bg: #212120;
  --panel-border: #363633;
  --panel-border-soft: #2d2d2a;
  --text: #e2e2df;
  --text-soft: #8e8e87;
  --text-dim: #73736e;
  --accent: #f26822;
  --accent-deep: #d45a1d;
  --track: #111110;
  --canvas-bg: #212422;
  --surface-raised: #2b2b29;
  --surface-panel-top: #262624;
  --surface-panel-bottom: #222220;
  --surface-accent-hover: #332720;
  --border-strong: #4a4a47;
  --text-panel: #ecece7;
  --text-panel-strong: #f1f1eb;
  --text-panel-soft: #b0b0aa;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #151514;
  color: var(--text);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button {
  font: inherit;
}

.window-shell {
  position: relative;
  height: 100vh;
  background: var(--window-bg);
  border-top: 1px solid #88211a;
  border-bottom: 1px solid #7a1948;
}

.titlebar {
  display: grid;
  grid-template-columns: 120px 1fr 90px;
  align-items: center;
  height: 29px;
  padding: 0 10px;
  border-bottom: 1px solid var(--panel-border-soft);
  background: #252523;
  color: #d4d4d1;
  user-select: none;
}

.titlebar__tools,
.titlebar__controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.titlebar__tool {
  display: inline-flex;
  width: 13px;
  height: 13px;
  color: #d2d2cf;
  opacity: 0.85;
}

.titlebar__tool svg {
  width: 100%;
  height: 100%;
}

.titlebar__title {
  text-align: center;
  font-size: 13px;
  color: #f0f0ec;
}

.titlebar__controls {
  justify-content: flex-end;
  gap: 10px;
}

.titlebar__control {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 12px;
  color: #d1d1cc;
}

.titlebar__control--min::before,
.titlebar__control--max::before,
.titlebar__control--close::before,
.titlebar__control--close::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.titlebar__control--min::before {
  left: 1px;
  right: 1px;
  bottom: 1px;
  height: 1px;
}

.titlebar__control--max::before {
  inset: 1px;
  border: 1px solid currentColor;
  background: transparent;
}

.titlebar__control--close::before,
.titlebar__control--close::after {
  top: 5px;
  left: 0;
  width: 12px;
  height: 1px;
}

.titlebar__control--close::before {
  transform: rotate(45deg);
}

.titlebar__control--close::after {
  transform: rotate(-45deg);
}

.workspace {
  display: grid;
  grid-template-columns: 214px 1fr;
  height: calc(100vh - 29px);
}

.wallet-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--panel-border-soft);
  overflow: hidden;
}

.account-card {
  position: relative;
  margin: 12px 11px 16px;
  padding: 12px 11px 42px;
  border: 1px solid #4b4b48;
  border-radius: 6px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03) 58%, rgba(255, 255, 255, 0.18) 58%, rgba(255, 255, 255, 0.08) 100%),
    linear-gradient(180deg, #7a705f 0%, #56534d 100%);
  overflow: hidden;
}

.account-card::after {
  content: "";
  position: absolute;
  inset: auto -28px -22px auto;
  width: 90px;
  height: 90px;
  transform: rotate(45deg);
  background: rgba(255, 255, 255, 0.08);
}

.account-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-card__mark {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
}

.account-card__mark-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.account-card__meta {
  margin: 0 0 1px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
}

.account-card__name {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: #f3f3ee;
}

.account-card__balance {
  margin-top: 18px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  color: #efefeb;
  flex-wrap: wrap;
}

.account-card__currency {
  text-transform: lowercase;
  letter-spacing: 0.03em;
  opacity: 0.88;
}

.balance-value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.account-card__trend {
  position: absolute;
  right: 10px;
  bottom: 10px;
  margin: 0;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
}

.tower-market {
  padding-top: 2px;
  overflow: auto;
}

.tower-market__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 6px;
}

.sidebar-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  color: #e9e9e3;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.clear-selection {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  cursor: pointer;
}

.tower-list {
  display: block;
}

.tower-card {
  width: 100%;
  padding: 11px 14px 11px 16px;
  border: 0;
  border-top: 1px solid #31312f;
  border-left: 2px solid transparent;
  background: transparent;
  color: #d0d0cb;
  text-align: left;
  cursor: pointer;
}

.tower-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tower-card.is-selected {
  background: #30302e;
  border-left-color: var(--accent);
  color: #f2f2ed;
}

.tower-card.is-disabled {
  color: #8c8c86;
}

.tower-card__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
}

.tower-card__meta,
.tower-card__description {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: inherit;
}

.tower-card__description {
  color: #9a9a95;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 8px 10px;
}

.sync-block + .sync-block {
  margin-top: 10px;
}

.sync-block__label {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 600;
  color: #f1f1eb;
}

.sync-block__bar {
  height: 4px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.sync-block__bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 140ms linear;
}

.network-status {
  display: grid;
  grid-template-columns: 22px 1fr 18px;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 8px;
  border-top: 1px solid #343431;
  color: #ecece7;
}

.network-status__icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.network-status__icon svg {
  width: 12px;
  height: 12px;
  display: block;
}

.network-status__label {
  margin: 0;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.network-status strong {
  display: block;
  font-size: 11px;
  font-weight: 600;
}

.main-panel {
  display: flex;
  flex-direction: column;
  padding: 12px 18px 10px;
  background: var(--main-bg);
  overflow: hidden;
}

.main-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2d2d2a;
}

.primary-button,
.speed-button {
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(180deg, #fb7a29 0%, var(--accent-deep) 100%);
  color: #fff;
}

.primary-button:disabled,
.speed-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.speed-button {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: #d7d7d2;
}

.speed-button.is-active {
  background: #3a2a20;
  border-color: var(--accent);
  color: #fff;
}

.game-stage-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding: 10px 0 8px;
  position: relative;
  z-index: 0;
}

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 20px;
  box-sizing: border-box;
  overflow: hidden;
}

canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  aspect-ratio: 12 / 7;
  border-radius: 2px;
}

.overlay-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 2px;
  background: rgba(20, 20, 19, 0.82);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
}

.overlay-message[hidden] {
  display: none;
}

.game-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid #2d2d2a;
  padding-top: 6px;
  position: relative;
  z-index: 2;
}

.status-message {
  margin: 0;
  font-size: 11px;
  flex: 1;
  min-width: 0;
  color: var(--text-panel);
}

.tower-inspector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 360px;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid #363633;
  background: linear-gradient(180deg, var(--surface-panel-top) 0%, var(--surface-panel-bottom) 100%);
  position: relative;
  z-index: 3;
}

.tower-inspector[hidden] {
  display: none;
}

.tower-inspector__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tower-inspector__label {
  margin: 0 0 2px;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.tower-inspector__name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-panel-strong);
}

.tower-inspector__level {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: #dfdfd9;
  font-size: 10px;
  font-weight: 700;
}

.tower-inspector__stats {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: #b9b9b2;
}

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

.inspector-button {
  min-height: 56px;
  padding: 9px 10px 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text-panel);
  text-align: left;
  cursor: pointer;
}

.inspector-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-accent-hover);
}

.inspector-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.inspector-button__title {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
}

.inspector-button__meta {
  display: block;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-panel-soft);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 190px 1fr;
  }

  .tower-inspector {
    min-width: 100%;
    max-width: none;
  }
}
