:root {
  color-scheme: dark;
  --bg: #02090a;
  --surface: rgba(2, 18, 20, 0.92);
  --surface-2: rgba(3, 30, 32, 0.9);
  --ink: #f6f0df;
  --muted: #b7c8c3;
  --line: rgba(56, 242, 223, 0.24);
  --teal: #38f2df;
  --amber: #f0ba54;
  --green: #89cf76;
  --danger: #7b3038;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at top, #07272a, #02090a 62%);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.landscape-shell {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: 16px;
}

.device-frame {
  width: min(1220px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  min-width: 320px;
  border: 1px solid rgba(56, 242, 223, 0.28);
  border-radius: 18px;
  padding: 10px;
  background: rgba(1, 11, 13, 0.96);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.stage {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 14px;
  background: #030c0e;
}

.game-hud {
  display: grid;
  grid-template-columns: minmax(310px, 1fr) repeat(3, minmax(92px, 0.24fr)) minmax(164px, 0.38fr);
  gap: 8px;
  align-items: stretch;
  min-height: 58px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.brand-button,
.hud-stat,
.hud-action,
.nav-toggle {
  border: 1px solid rgba(56, 242, 223, 0.32);
  color: var(--ink);
  background: linear-gradient(180deg, rgba(7, 36, 39, 0.92), rgba(2, 12, 14, 0.96));
  box-shadow: inset 0 0 18px rgba(56, 242, 223, 0.08), 0 0 20px rgba(56, 242, 223, 0.05);
}

.nav-toggle {
  color: var(--teal);
  font-size: 1.3rem;
}

.brand-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 12px;
  text-align: left;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 3px solid var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(56, 242, 223, 0.38);
  clip-path: polygon(50% 0, 100% 84%, 70% 100%, 50% 63%, 30% 100%, 0 84%);
}

.brand-text {
  min-width: 0;
}

.brand-button strong {
  display: block;
  color: var(--teal);
  font-size: 1.42rem;
  line-height: 1;
  letter-spacing: 0.18em;
}

.brand-button small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #9ff8ee;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-stat {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 6px 8px;
}

.brand-button span,
.hud-stat span,
.label {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-stat strong {
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
}

.hud-action {
  padding: 0 10px;
  text-transform: uppercase;
}

.playfield {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  min-height: 0;
}

.stage.nav-collapsed .playfield {
  grid-template-columns: 48px minmax(0, 1fr);
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  border: 1px solid rgba(56, 242, 223, 0.22);
  border-radius: 14px;
  padding: 8px 7px;
  background: linear-gradient(180deg, rgba(3, 27, 30, 0.86), rgba(1, 10, 12, 0.94));
  overflow: hidden;
}

.side-link {
  display: grid;
  gap: 5px;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 68px;
  border: 1px solid transparent;
  color: var(--ink);
  background: transparent;
  text-transform: uppercase;
  text-align: center;
}

.side-link span {
  color: var(--teal);
  font-size: 1.25rem;
  line-height: 1;
}

.side-link strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
}

.side-link.active,
.side-link:hover,
.side-link:focus-visible {
  border-color: rgba(56, 242, 223, 0.58);
  background: rgba(56, 242, 223, 0.12);
  box-shadow: inset 0 0 20px rgba(56, 242, 223, 0.14);
  outline: 0;
}

.stage.nav-collapsed .side-nav {
  padding: 6px 5px;
}

.stage.nav-collapsed .side-link {
  min-height: 46px;
}

.stage.nav-collapsed .side-link strong {
  display: none;
}

.map-layer {
  position: relative;
  justify-self: center;
  align-self: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(56, 242, 223, 0.22);
  border-radius: 14px;
  box-shadow: inset 0 0 42px rgba(2, 9, 10, 0.6);
}

.map-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hotspot {
  position: absolute;
  left: calc(var(--x) - var(--w) / 2);
  top: calc(var(--y) - var(--h) / 2);
  z-index: 2;
  width: var(--w);
  height: var(--h);
  border: 2px solid transparent;
  border-radius: 14px;
  color: transparent;
  background: transparent;
}

.hotspot:hover,
.hotspot:focus-visible {
  border-color: rgba(56, 242, 223, 0.58);
  background: rgba(56, 242, 223, 0.07);
  outline: 0;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 26px;
  background: radial-gradient(circle at top, #07272a, #02090a 62%);
}

.start-screen.hidden {
  display: none;
}

.start-frame {
  position: relative;
  width: min(1180px, calc(100vw - 52px));
  max-height: calc(100vh - 52px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(56, 242, 223, 0.28);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(2, 9, 10, 0.9), rgba(2, 9, 10, 0.18)), url("assets/astroc-map.png") center / cover;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.start-copy {
  position: absolute;
  left: 5%;
  top: 50%;
  width: min(680px, 100%);
  transform: translateY(-50%);
}

.start-copy p {
  margin: 0 0 8px;
  color: #9ff8ee;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.start-copy h1 {
  margin: 0;
  color: var(--teal);
  font-size: clamp(4rem, 18vw, 9rem);
  line-height: 0.9;
  letter-spacing: 0.16em;
}

.start-copy span {
  display: block;
  max-width: 560px;
  margin: 12px 0 22px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
}

.dialogue-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.16);
}

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

.character-sprite {
  position: absolute;
  right: clamp(10px, 5vw, 70px);
  bottom: 0;
  width: clamp(210px, 26vw, 385px);
  aspect-ratio: 434 / 701;
  background-repeat: no-repeat;
  background-size: 258.5% 200%;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.58));
}

.recruit-female-top-center {
  background-image: url("assets/rekrutin.png");
  background-position: 45.5% 0%;
}

.speech-bubble {
  position: absolute;
  right: clamp(220px, 27vw, 430px);
  bottom: clamp(220px, 42vh, 360px);
  width: min(400px, 42vw);
  border: 1px solid rgba(56, 242, 223, 0.55);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(2, 23, 26, 0.94);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45), 0 0 30px rgba(56, 242, 223, 0.18);
  font-size: clamp(0.9rem, 1.7vw, 1.2rem);
  font-weight: 850;
  line-height: 1.25;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: 18px;
  width: 18px;
  height: 18px;
  border-right: 1px solid rgba(56, 242, 223, 0.55);
  border-bottom: 1px solid rgba(56, 242, 223, 0.55);
  background: rgba(2, 23, 26, 0.94);
  transform: rotate(-45deg);
}

.primary {
  color: #031011;
  background: linear-gradient(180deg, #73fff2, #18b8aa);
  box-shadow: 0 0 20px rgba(56, 242, 223, 0.24);
}

.secondary {
  color: var(--ink);
  background: #31505b;
}

.danger {
  color: var(--ink);
  background: var(--danger);
}

.full {
  width: 100%;
}

dialog {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.location-dialog {
  width: min(730px, calc(100vw - 34px));
  max-height: min(82vh, 520px);
}

.location-dialog form,
.recruit-dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(2, 23, 26, 0.96), rgba(1, 10, 12, 0.97));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52), 0 0 36px rgba(56, 242, 223, 0.18);
  backdrop-filter: blur(16px);
}

.modal-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2,
.section-title h3,
.mode-card h3 {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(56, 242, 223, 0.1);
  font-size: 1.1rem;
}

.modal-body {
  max-height: calc(min(82vh, 520px) - 74px);
  overflow: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.modal-body.quiz-first {
  overflow-y: auto;
}

.location-panel {
  display: none;
}

.location-panel.active,
.deploy-column,
.slots,
.upgrade-list,
.crew-list,
.quest-list,
.mission-list,
.research-tree {
  display: grid;
  gap: 10px;
}

.compact {
  margin-bottom: 10px;
}

.segmented-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.location-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.location-tabs[hidden] {
  display: none;
}

.welcome-tab,
.location-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(56, 242, 223, 0.06);
  text-transform: uppercase;
}

.welcome-tab.active,
.location-tab.active {
  color: #031011;
  background: linear-gradient(180deg, #73fff2, #18b8aa);
}

.welcome-tab-panel {
  display: none;
}

.welcome-tab-panel.active {
  display: grid;
  gap: 10px;
}

.mode-card,
.slot,
.recruit-card,
.upgrade,
.quest-card,
.research-node,
.quiz-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(3, 35, 38, 0.72), rgba(1, 13, 15, 0.86));
  box-shadow: inset 0 0 22px rgba(56, 242, 223, 0.07);
}

.quest-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quest-card p,
.quest-card span {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.quest-card b {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 0.82rem;
}

.quest-card.done {
  opacity: 0.62;
}

.research-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(108px, 0.24fr);
  gap: 10px;
  align-items: center;
}

.research-node strong {
  display: block;
}

.research-node p,
.research-node span:not(.label) {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.research-node.done {
  opacity: 0.68;
}

.quiz-panel.gatekeeper {
  margin-top: 0;
  padding: 12px;
}

.slot-header,
.card-header,
.upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.slot select,
.mode-card select {
  width: 100%;
  min-height: 40px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #10191f;
}

.drill-detail,
.upgrade p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(56, 242, 223, 0.14);
  color: #b7efe9;
  font-size: 0.72rem;
  font-weight: 900;
}

.weak {
  background: rgba(123, 48, 56, 0.34);
  color: #ffc1c6;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.stat {
  min-width: 0;
  border-radius: 8px;
  padding: 7px;
  background: rgba(8, 13, 16, 0.55);
}

.stat span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(246, 240, 223, 0.12);
}

.bar i {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

progress {
  width: 100%;
  height: 10px;
  margin: 10px 0;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(246, 240, 223, 0.12);
}

progress::-webkit-progress-bar {
  background: rgba(246, 240, 223, 0.12);
}

progress::-webkit-progress-value {
  background: var(--teal);
}

.metric {
  margin: 7px 0 0;
  color: var(--amber);
  font-size: 1.2rem;
  font-weight: 950;
}

.mode-card button,
.recruit-card button,
.upgrade button,
.research-node button,
.slot button {
  width: 100%;
  margin-top: 9px;
}

.leader {
  color: var(--amber);
}

.empty {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.quiz-panel {
  margin-top: 10px;
}

.quiz-panel[hidden] {
  display: none;
}

.quiz-question {
  display: grid;
  gap: 7px;
}

.quiz-question strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.quiz-option {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: rgba(246, 240, 223, 0.1);
  line-height: 1.2;
  text-align: left;
}

.quiz-option.correct {
  color: #102016;
  background: var(--green);
}

.quiz-option.wrong {
  background: var(--danger);
}

.quiz-explain {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
}

.quiz-feedback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, 0.28fr);
  gap: 10px;
  align-items: center;
  margin-top: 2px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.quiz-feedback[hidden] {
  display: none;
}

.quiz-feedback button {
  width: 100%;
}

.recruit-dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--ink);
  background: rgba(2, 18, 20, 0.94);
  box-shadow: 0 0 28px rgba(56, 242, 223, 0.22);
  font-weight: 900;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 760px), (max-height: 430px) {
  .landscape-shell {
    padding: 0;
  }

  .device-frame {
    width: 100vw;
    height: 100vh;
    min-width: 320px;
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .stage {
    grid-template-rows: 44px auto;
    gap: 0;
    border-radius: 0;
  }

  .game-hud {
    grid-template-columns: minmax(120px, 1fr) repeat(3, 54px) 88px;
    gap: 5px;
    min-height: 44px;
    padding: 5px;
  }

  .brand-lockup {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 5px;
  }

  .brand-mark,
  .brand-button small,
  .hud-stat span {
    display: none;
  }

  .brand-button,
  .hud-stat,
  .hud-action,
  .nav-toggle {
    min-height: 34px;
    padding: 4px 6px;
  }

  .brand-button strong {
    font-size: 0.9rem;
    letter-spacing: 0.08em;
  }

  .playfield {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0;
  }

  .side-nav {
    border-radius: 0;
    padding: 5px 4px;
  }

  .side-link {
    min-height: 44px;
  }

  .side-link strong {
    display: none;
  }

  .map-layer {
    border-radius: 0;
  }

  .location-dialog {
    width: min(760px, calc(100vw - 116px));
    max-height: calc(100vh - 84px);
  }

  .modal-header {
    padding: 9px 12px 8px;
  }

  .modal-header h2 {
    font-size: 1.35rem;
  }

  .modal-body {
    max-height: calc(100vh - 162px);
    padding: 10px;
  }

  .quiz-panel.gatekeeper {
    padding: 10px;
  }

  .quiz-question strong {
    font-size: 0.9rem;
  }

  .quiz-option {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 0.82rem;
  }

  .quiz-feedback {
    grid-template-columns: minmax(0, 1fr) 116px;
    gap: 8px;
    padding-top: 6px;
  }

  .quiz-explain {
    font-size: 0.74rem;
  }
}
