:root {
  --ink: #e8eef2;
  --dim: #9fb0bc;
  --panel: rgba(13, 20, 27, 0.92);
  --edge: #2b3b48;
  --amber: #ffb340;
  --cyan: #46e0c8;
  --red: #ff5d5d;
  --green: #7ddf6a;
  --outline: #0a0e12;
  --radius: 8px;
  --display: "Chakra Petch", "Arial Narrow", sans-serif;
  --body: "IBM Plex Sans", Verdana, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0d141b;
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
}

#app { position: fixed; inset: 0; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

#topbar {
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 14px;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-mark {
  width: 14px;
  height: 14px;
  background: var(--amber);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  display: inline-block;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--dim);
  font-weight: 500;
}

.stats { display: flex; gap: 18px; margin-left: 8px; flex-wrap: wrap; }

.stat { display: flex; align-items: baseline; gap: 6px; font-size: 14px; }

.stat b { font-family: var(--display); font-size: 17px; }

.stat-label { color: var(--dim); font-size: 11px; }

.income { color: var(--cyan); font-size: 11px; }

.dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.dot-crystal { background: var(--cyan); }
.dot-supply { background: var(--amber); }
.dot-enemy { background: var(--red); }

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

.btn {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 1px;
  background: #1b2833;
  color: var(--ink);
  border: 1px solid #3b5266;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.btn:hover { background: #243646; border-color: var(--amber); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.big { font-size: 17px; padding: 12px 34px; margin-top: 10px; background: var(--amber); color: #1a1206; border-color: var(--amber); }
.btn.big:hover { background: #ffc35e; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.train { display: flex; flex-direction: column; gap: 2px; min-width: 132px; text-align: left; }

@media (max-width: 1400px) {
  #hints { display: none; }
}
.btn.train .cost { color: var(--cyan); font-size: 12px; }
.btn.train .sub { color: var(--dim); font-size: 11px; font-family: var(--body); font-weight: 400; letter-spacing: 0; }

.keycap {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  margin: 0 2px;
  background: #22303c;
  border: 1px solid #46586a;
  border-bottom-width: 3px;
  border-radius: 5px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
}

#objective {
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
}

#toast {
  position: absolute;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  z-index: 6;
  pointer-events: none;
}

.toast-msg {
  background: rgba(13, 20, 27, 0.95);
  border: 1px solid var(--amber);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .toast-msg { animation: none; }
}

#minimap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 220px;
  height: 140px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: #0a1016;
  z-index: 5;
  cursor: pointer;
}

#bottombar {
  position: absolute;
  left: 242px;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 10px;
  z-index: 5;
  pointer-events: none;
}

#bottombar .panel { position: static; pointer-events: auto; }

#selection {
  flex: 1 1 160px;
  min-width: 140px;
  min-height: 76px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#selection .empty { color: var(--dim); }

.unit-chip {
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  background: #16222d;
  display: flex;
  gap: 6px;
  align-items: center;
}

.unit-chip .hp { width: 56px; height: 6px; background: #05080b; border-radius: 3px; overflow: hidden; }
.unit-chip .hp i { display: block; height: 100%; background: var(--green); }

#build { padding: 8px 12px; display: flex; gap: 8px; align-items: stretch; }
#build.hidden { display: none; }
#build .queue { font-size: 12px; color: var(--dim); align-self: center; max-width: 150px; }

#hints {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--dim);
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 11, 0.72);
}

.overlay.hidden { display: none; }

.card {
  max-width: 560px;
  width: calc(100% - 40px);
  max-height: calc(100% - 60px);
  overflow-y: auto;
  background: #101820;
  border: 1px solid #3b5266;
  border-top: 4px solid var(--amber);
  border-radius: 10px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

.kicker {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--amber);
  margin: 0 0 6px;
}

.card h1 {
  font-family: var(--display);
  font-size: 52px;
  letter-spacing: 8px;
  margin: 0 0 8px;
  color: var(--ink);
}

.card h1.small-h { font-size: 30px; letter-spacing: 4px; }

.lede { color: var(--dim); font-size: 15px; margin: 0 0 12px; }

.how { text-align: left; font-size: 14px; line-height: 1.65; padding-left: 20px; margin: 0 0 8px; }
.how .nw { white-space: nowrap; }
.how b { color: var(--amber); }

.fine { font-size: 12px; color: var(--dim); margin: 12px 0 0; }

#end-stats { margin: 6px auto 4px; border-collapse: collapse; font-size: 14px; }
#end-stats td { padding: 4px 14px; text-align: left; }
#end-stats td:last-child { font-family: var(--display); text-align: right; }
#end-stats tr td:first-child { color: var(--dim); }

.diff-row { display: flex; gap: 8px; justify-content: center; margin: 14px 0 4px; }
.btn.diff { min-width: 92px; opacity: 0.6; }
.btn.diff.sel { opacity: 1; outline: 2px solid var(--player, #ffb340); }
.btn.train.disabled { opacity: 0.45; }
