:root {
  --panel-bg: #1b3f7a;
  --panel-dark: #14325e;
  --panel-light: #2c5aa3;
  --line: #8fb6ff;
  --text: #e7f0ff;
  --accent: #7de3ff;
  --accent-2: #7dff9f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Courier New", monospace;
  background: #0b1b3b;
  color: var(--text);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: radial-gradient(circle at 30% 20%, rgba(125, 227, 255, 0.08), transparent 45%),
    radial-gradient(circle at 70% 70%, rgba(125, 255, 159, 0.08), transparent 50%),
    #0b1b3b;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--panel-light), var(--panel-dark));
  border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
}

.top-bar .title {
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(125, 227, 255, 0.6);
}

.top-bar .meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text);
}

.top-time {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-2);
}

.top-turn {
  padding: 6px 10px;
  font-size: 11px;
}

.main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-height: 0;
}

.company-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-dark));
  border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
}

.company-actions {
  display: flex;
  gap: 8px;
}

/* constrain company info text width so lines don't run excessively long */
.company-info {
  flex: 1 1 auto;
  min-width: 0; /* allow flex children to shrink */
  max-width: 820px; /* limit line length on wide screens */
}
.company-subtitle {
  max-width: 68ch;
  overflow-wrap: break-word;
  word-break: break-word;
}

.turn-action {
  display: flex;
}

.company-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.company-subtitle {
  font-size: 12px;
  color: var(--text);
  opacity: 0.8;
}

.company-action {
  background: #0b1b3b;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.company-action:hover {
  background: var(--accent);
  color: #0b1b3b;
  box-shadow: 0 0 10px rgba(125, 227, 255, 0.8);
}

/* Make the primary "next year" button large and prominent (only interactive button) */
#next-year {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(90deg, #06b6d4, #0ea5a4);
  color: #001;
  border: none;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(6, 182, 180, 0.14), inset 0 -2px 0 rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  transform-origin: center;
}
#next-year:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(6, 182, 180, 0.18);
}
#next-year:active {
  transform: translateY(0);
  box-shadow: 0 8px 20px rgba(6, 182, 180, 0.12);
}

.tech-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(90deg, #4b8bff, #46c0ff);
  color: #001;
  border: none;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(70, 192, 255, 0.16), inset 0 -2px 0 rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.tech-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(70, 192, 255, 0.2);
}

.tech-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(70, 192, 255, 0.14);
}

@media (max-width: 768px) {
  #next-year {
    width: 100%;
    font-size: 15px;
    padding: 12px 14px;
  }

  .tech-btn {
    width: 100%;
    font-size: 14px;
    padding: 10px 14px;
  }
}


.reward-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 26, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}

.reward-modal.active {
  display: flex;
}

.tech-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 26, 0.74);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 12;
  padding: 20px;
}

.tech-modal.active {
  display: flex;
}

.tech-dialog {
  position: relative;
  background: linear-gradient(180deg, rgba(12, 32, 64, 0.98), rgba(8, 20, 40, 0.98));
  border: 2px solid rgba(70, 192, 255, 0.6);
  padding: 16px 18px 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
  width: min(720px, 92vw);
  display: grid;
  gap: 12px;
  border-radius: 12px;
}

.tech-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.tech-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: #7de3ff;
  letter-spacing: 1px;
}

.tech-subtitle {
  font-size: 12px;
  text-align: center;
  color: #cfe7ff;
  opacity: 0.9;
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.tech-card {
  border: 1px solid rgba(125, 227, 255, 0.4);
  background: radial-gradient(circle at 20% 20%, rgba(70, 192, 255, 0.18), transparent 60%),
    rgba(8, 16, 30, 0.8);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.tech-card:hover {
  transform: translateY(-3px);
  border-color: rgba(125, 255, 159, 0.6);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.tech-name {
  font-size: 14px;
  font-weight: 700;
  color: #7dff9f;
}

.tech-desc {
  font-size: 12px;
  color: #dfefff;
  opacity: 0.92;
  margin-top: 6px;
}

.reward-dialog {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 50, 94, 0.98), rgba(12, 32, 64, 0.98));
  border: 2px solid #29b6ff;
  padding: 16px 18px 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
  width: min(760px, 92vw);
  display: grid;
  gap: 12px;
  border-radius: 12px;
}

.reward-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.stage-visual {
  width: 100%;
  height: 360px;
  border-radius: 10px;
  border: 2px solid rgba(143, 182, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.reward-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: #7de3ff;
  letter-spacing: 1px;
}

.reward-tag {
  font-size: 12px;
  color: #f2d17d;
  text-align: center;
}

.reward-text {
  font-size: 13px;
  color: var(--text);
  text-align: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(143, 182, 255, 0.25);
}

.reward-action {
  background: linear-gradient(90deg, #0a6cff, #22c2ff);
  border: none;
  color: #ffffff;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
}

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
  }

  .top-bar .meta {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-time {
    position: static;
    transform: none;
    font-size: 13px;
  }

  .top-turn {
    margin-left: auto;
  }

  .map-area {
    height: 66vh;
    padding: 10px 12px;
    box-sizing: border-box;
  }

  .company-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .company-info {
    max-width: 100%;
  }

  .company-actions {
    width: 100%;
  }

  .company-action {
    width: 100%;
  }

  .fleet-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .finance-row {
    font-size: 11px;
  }
}

.map-area {
  position: relative;
  background: #0a1b32 url("1.jpg") center / cover no-repeat;
  border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
  height: 66vh;
}

#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Ensure the main canvas fills its container and doesn't overflow on mobile */
#space-canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
  box-sizing: border-box;
}

.hover-tip {
  position: absolute;
  pointer-events: none;
  padding: 6px 8px;
  background: rgba(11, 27, 59, 0.85);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--accent);
  transform: translate(10px, -10px);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.side-panel {
  display: grid;
  grid-template-rows: 210px 1fr 130px;
  gap: 8px;
}

.panel {
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-dark));
  border: 2px solid var(--line);
  padding: 10px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
}

.panel h3 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#miniCanvas {
  width: 100%;
  height: 160px;
  border: 1px solid rgba(143, 182, 255, 0.4);
  background: #0b1b3b;
  display: block;
}

.stats {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(143, 182, 255, 0.3);
}

.stat-row span {
  color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.actions button {
  background: #0b1b3b;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  padding: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.actions button:hover {
  background: var(--accent);
  color: #0b1b3b;
  box-shadow: 0 0 10px rgba(125, 227, 255, 0.8);
}

.bottom {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.fleet {
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-dark));
  border: 2px solid var(--line);
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.fleet h3 {
  font-size: 13px;
  color: var(--accent-2);
  text-transform: uppercase;
}

.fleet-table {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.fleet-row {
  display: grid;
  grid-template-columns: 140px 80px 80px 1fr;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(143, 182, 255, 0.3);
  align-items: center;
}

.finance {
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-dark));
  border: 2px solid var(--line);
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.finance h3 {
  font-size: 13px;
  color: var(--accent-2);
  text-transform: uppercase;
}

.finance-table {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.finance-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(143, 182, 255, 0.3);
}

.finance-row.total {
  color: var(--accent);
  font-weight: 700;
}

.icon-grid {
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-dark));
  border: 2px solid var(--line);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
}

.icon {
  background: #0b1b3b;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--accent);
}

@media (max-width: 1024px) {
  .main {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-rows: auto auto auto;
  }

  .bottom {
    grid-template-columns: 1fr;
  }
}
