:root {
  --bg: #07100d;
  --bg-soft: rgba(11, 22, 18, 0.86);
  --panel: rgba(13, 27, 22, 0.82);
  --panel-strong: rgba(19, 40, 33, 0.94);
  --line: rgba(130, 202, 170, 0.28);
  --line-hot: rgba(118, 241, 196, 0.76);
  --text: #e6fff4;
  --muted: #a7c7b8;
  --accent: #62f1bf;
  --accent-2: #ffd866;
  --danger: #ff6b5f;
  --enemy: #ff856d;
  --shadow: rgba(0, 0, 0, 0.42);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(28, 58, 47, 0.92), rgba(13, 31, 25, 0.96));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 34px;
  padding: 7px 10px;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

button:hover,
button:focus-visible {
  border-color: var(--line-hot);
  outline: none;
}

button:active {
  transform: translateY(1px);
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

button.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(255, 216, 102, 0.26) inset;
}

kbd {
  border: 1px solid rgba(230, 255, 244, 0.22);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--accent);
  font-size: 0.72rem;
  padding: 2px 5px;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #091511;
  touch-action: none;
}

#hud {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

#hud button {
  pointer-events: auto;
}

.top-strip,
.left-panel,
.objective-panel,
.command-bar,
.log-panel,
.center-banner,
#crashPanel {
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 42px var(--shadow);
}

.top-strip {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border-radius: 8px;
  padding: 10px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand strong {
  display: block;
  line-height: 1.05;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(98, 241, 191, 0.6);
  border-radius: 7px;
  background:
    linear-gradient(135deg, transparent 43%, rgba(98, 241, 191, 0.9) 44%, transparent 57%),
    radial-gradient(circle at 50% 50%, rgba(255, 216, 102, 0.88) 0 18%, transparent 19%),
    rgba(9, 31, 24, 0.9);
}

.resource-row,
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.resource-row span {
  border: 1px solid rgba(130, 202, 170, 0.2);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 0.9rem;
  padding: 7px 9px;
}

.left-panel {
  position: absolute;
  top: 86px;
  left: 12px;
  width: min(268px, calc(100vw - 24px));
  border-radius: 8px;
  padding: 12px;
}

.objective-panel {
  position: absolute;
  top: 86px;
  right: 12px;
  width: min(320px, calc(100vw - 24px));
  border-radius: 8px;
  padding: 12px;
}

.left-panel h2,
.objective-panel h2 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.left-panel p,
.objective-panel p,
#selectionSummary {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

#selectionStats {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--text);
  font-size: 0.88rem;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.command-bar {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: repeat(8, minmax(104px, 1fr));
  gap: 8px;
  border-radius: 8px;
  padding: 10px;
}

.command-bar button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  text-align: left;
}

.command-bar small {
  color: var(--accent-2);
}

.log-panel {
  position: absolute;
  bottom: 76px;
  left: 12px;
  display: grid;
  gap: 4px;
  width: min(380px, calc(100vw - 24px));
  max-height: 130px;
  overflow: hidden;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.log-panel div:first-child {
  color: var(--text);
}

.center-banner {
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  min-width: 260px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  padding: 18px 22px;
  text-align: center;
}

.center-banner strong {
  color: var(--accent-2);
  font-size: 1.35rem;
}

.center-banner span {
  color: var(--muted);
}

#crashPanel {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 5;
  width: min(460px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  border-color: rgba(255, 107, 95, 0.55);
  border-radius: 8px;
  padding: 20px;
}

#crashPanel h1 {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 1.3rem;
}

#crashPanel p {
  color: var(--muted);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .top-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .resource-row,
  .status-row {
    flex-wrap: wrap;
  }

  .left-panel,
  .objective-panel {
    top: auto;
    bottom: 118px;
    width: calc(50vw - 18px);
  }

  .command-bar {
    grid-template-columns: repeat(4, minmax(80px, 1fr));
  }

  .log-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .brand small,
  .objective-panel,
  .left-panel {
    display: none;
  }

  .top-strip {
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 8px;
  }

  .resource-row span {
    font-size: 0.78rem;
    padding: 6px 7px;
  }

  .command-bar {
    right: 8px;
    bottom: 8px;
    left: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 40vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
