* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, sans-serif;
  background: #0f1c24;
  color: #f4f7f9;
}

.initialinfo {
  border: 1px solid #2c4854;
  padding: 0.25rem 0.5rem;
  background: #13232c;
  color: #fff;
  max-width: fit-content;
  margin: 0.5rem auto 1rem;
  text-align: center;
  border-radius: 8px;
}

.initialinfo a {
  color: #fff;
  text-decoration: underline;
}

#app {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  flex-direction: column;
  justify-content: flex-start;
  margin: auto;
  max-width: 1900px;
  gap: 20px;
  padding: 30px 15px 100px;
}

.top {
  display: flex;
  flex-direction: row;
  gap: 15px;
  width: 100%;
  align-items: flex-start;
}

.leftview {
  display: flex;
  flex-direction: column;
  width: 320px;
  gap: 1rem;
}

#canvas-wrapper {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  max-width: 1280px;
  width: 100%;
  overflow: hidden;

}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #1b2f3a;
}

#hud {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  width: 320px;
  background: rgba(8, 14, 17, 0.9);
}

#hud section {
  border: 1px solid #203945;
  padding: 0.75rem;
  min-height: 80px;
}

#hud section h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a8c2d0;
}

#build-panel {
  flex: 1;
  overflow-y: auto;
}

#controls-panel,
section#recipe-panel,
#upgrade-panel {
  margin-top: 1rem;
  overflow-y: auto;
  margin-bottom: 3rem;
}

.bottom {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.controls-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: row;
  gap: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.controls-list li {
  display: flex;
  gap: 0.5rem;
  border: 1px solid #355061;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.key-cap {
  padding: 0.15rem 0.45rem;
  border: 1px solid #355061;
  border-radius: 4px;
  font-family: "Fira Mono", monospace;
  font-size: 0.8rem;
  background: #16232b;
}

#status-panel {
  min-height: auto;
}

#tutorial-panel {
  min-height: inherit;
  border: 1px solid #2c4854;
  padding: 2rem 1rem;
  background: #13232c;
  margin-top: 1rem;
}

.tutorial-body {
  margin: 0.5rem 0 1rem;
}

.tutorial-nav {
  display: flex;
  gap: 0.5rem;
}

.tutorial-nav button {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid #2c4854;
  background: #13232c;
  color: inherit;
  cursor: pointer;
}

.recipe-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
}

.recipe-item {
  padding: 0.5rem;
  border: 1px solid #1e3842;
  background: #0f1c1f;
}

.recipe-item h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.recipe-item-body {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.upgrade-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upgrade-list li {
  border: 1px solid #1e3842;
  padding: 0.35rem 0.5rem;
  background: #102028;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.upgrade-name {
  font-weight: 600;
}

.recipe-side {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 120px;
  font-size: 0.85rem;
}

.recipe-side li {
  margin-bottom: 0.2rem;
}

.recipe-side-title {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: #8ca0ad;
}

.recipe-arrow {
  font-size: 1.2rem;
  color: #9bd3ff;
}

@media (max-width: 1400px) {

  #hud,
  .leftview {
    width: 280px;
  }
}

@media (max-width: 1100px) {
  .top {
    flex-direction: column;
  }

  .leftview,
  #hud {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  #build-panel,
  #controls-panel {
    flex: 1 1 320px;
  }

  #hud {
    flex-direction: row;
    flex-wrap: wrap;
  }

  #hud section {
    flex: 1 1 300px;
  }

  .recipe-list {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  #app {
    padding: 15px;
  }

  #hud section {
    min-height: auto;
  }

  .controls-list {
    font-size: 0.8rem;
  }

  .build-list button {
    padding: 0.4rem 0.6rem;
  }

  .bottom {
    order: 3;
  }

  #hud {
    flex-direction: column;
  }

  #hud section {
    flex: 1 1 auto;
  }
}

.build-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.build-list button {
  padding: 0.5rem 0.75rem;
  border: 1px solid #22404d;
  background: #13232c;
  color: inherit;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.build-list button:hover {
  background: #1c3541;
}

.build-list button.is-active {
  background: #2f576a;
  border-color: #51a5d6;
}

.build-list button.is-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.build-name {
  font-weight: 600;
}

.build-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: contain;
  font-size: 1.2rem;
}

.build-cost {
  font-size: 0.8rem;
  color: #a7c4d5;
}

.resource-legend {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.75rem;
}

.resource-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.resource-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.orientation-label {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #9dc1d3;
}

.resource-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 0.5rem;
  margin: 0;
}

.resource-list dt {
  font-weight: 600;
}

.resource-list dd {
  margin: 0;
  text-align: right;
}

#status-panel{
  position: fixed;
  left: 0px;
  top: 0px;
  max-width: 300px;
  width: 100%;
  background: #ddd;
}

.status-title {
  margin: 0;
  font-weight: 600;
  color: #000;
}

.status-message {
  margin: 0;
  font-weight: 600;
  min-height: 1.5rem;
  color: #000;
}

.status-message.is-error {
  color: #ff9a8f;
}

.status-message.is-success {
  color: #000;
}

.status-message.is-remove {
  color: #9ddcff;
}

.status-time {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #8ca0ad;
}

.debug-lines {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: "Fira Mono", "Consolas", monospace;
  font-size: 0.85rem;
}

.debug-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.debug-actions button {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #2f4a52;
  background: #122028;
  color: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.debug-actions button:hover {
  background: #1f3641;
}

#resource-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 16, 22, 0.9);
  color: #f4f7f9;
  padding: 0.3rem 0.5rem;
  border: 1px solid #1f3a46;
  font-size: 0.8rem;
  transform: translate(12px, 12px);
  transition: opacity 0.15s;
  white-space: nowrap;
}

#resource-tooltip.hidden {
  opacity: 0;
}
.resource-table { width:100%; border-collapse: collapse; }
.resource-table th, .resource-table td { padding: 4px 6px; border-bottom: 1px solid #1e3842; text-align: left; }
.resource-table td:nth-child(2), .resource-table td:nth-child(3) { text-align: right; }
.rate-positive { color:#4ade80; }
.rate-negative { color:#ff6b6b; }
.rate-neutral { color:#a7c4d5; }

