:root {
  --bg-deep: #0b1720;
  --bg-panel: rgba(10, 21, 31, 0.82);
  --bg-soft: rgba(255, 255, 255, 0.08);
  --border: rgba(145, 195, 214, 0.16);
  --text: #ecf5f8;
  --muted: #8da4b2;
  --aqua: #3ad8d0;
  --aqua-deep: #0e7d7e;
  --orange: #ff9447;
  --gold: #f0c45a;
  --green: #6fdf98;
  --danger: #ff6f61;
  --steel: #94b4c3;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: "Chakra Petch", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(58, 216, 208, 0.2), transparent 26%),
    linear-gradient(180deg, #081117 0%, #0d1a22 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.hud,
.viewport-panel,
.start-card,
.floating-panel {
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding-right: 2px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 18px;
}

.hero-panel {
  background:
    linear-gradient(160deg, rgba(16, 41, 48, 0.94), rgba(10, 21, 31, 0.98)),
    rgba(10, 21, 31, 0.86);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--aqua);
}

.hero-panel h2,
.start-card h1,
.floating-panel h3,
.panel h3 {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
}

.hero-panel h2 {
  font-size: 2rem;
}

.status-text {
  margin: 12px 0 0;
  line-height: 1.6;
  color: var(--muted);
}

.status-text.running {
  color: var(--green);
}

.status-text.alert {
  color: #ffd0c8;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.muted-chip,
.state-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.state-chip.running {
  background: rgba(111, 223, 152, 0.18);
  color: #b9f0ca;
}

.state-chip.alert {
  background: rgba(255, 111, 97, 0.2);
  color: #ffd0c8;
}

.state-chip.idle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

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

.stat-card {
  padding: 14px;
  border-radius: 20px;
  background: var(--bg-soft);
}

.stat-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-card strong {
  font-size: 1.12rem;
}

.meter-group + .meter-group {
  margin-top: 14px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.meter {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.meter-fill {
  width: 4%;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease;
}

.meter-fill.aqua {
  background: linear-gradient(90deg, #0da0a0, var(--aqua));
}

.meter-fill.orange {
  background: linear-gradient(90deg, #cf6928, var(--orange));
}

.meter-fill.danger {
  background: linear-gradient(90deg, #b43a3a, var(--danger));
}

.meter-fill.gold {
  background: linear-gradient(90deg, #c28e22, var(--gold));
}

.meter-fill.green {
  background: linear-gradient(90deg, #2f8e58, var(--green));
}

.meter-fill.steel {
  background: linear-gradient(90deg, #577686, var(--steel));
}

.viewport-column {
  min-width: 0;
}

.viewport-panel {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: rgba(8, 17, 23, 0.85);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.floating-panel {
  position: absolute;
  background: rgba(7, 17, 23, 0.76);
  padding: 18px;
  width: min(360px, calc(100% - 32px));
}

.top-card {
  top: 16px;
  left: 16px;
}

.bottom-card {
  left: 16px;
  bottom: 16px;
}

.floating-panel h3 {
  font-size: 1.8rem;
}

.slider-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 10px;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--aqua);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.action-button,
.shop-card,
.start-button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.action-button,
.start-button {
  min-height: 48px;
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.action-button.primary,
.start-button {
  background: linear-gradient(135deg, var(--aqua-deep), var(--aqua));
  color: #081117;
  font-weight: 700;
}

.action-button:hover,
.shop-card:hover,
.start-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.quest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.quest-item {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(145, 195, 214, 0.08);
}

.quest-item.complete {
  background: rgba(111, 223, 152, 0.12);
}

.quest-item strong {
  display: block;
  margin-bottom: 6px;
}

.quest-item span {
  display: block;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.shop-list {
  display: grid;
  gap: 10px;
}

.shop-card {
  text-align: left;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.shop-card[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.shop-name {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.shop-desc {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.log-feed {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.log-entry {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.log-entry time {
  display: block;
  margin-bottom: 6px;
  color: var(--aqua);
  font-size: 0.78rem;
}

.log-entry p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(8, 17, 23, 0.74), rgba(8, 17, 23, 0.94)),
    radial-gradient(circle at top, rgba(58, 216, 208, 0.18), transparent 30%);
}

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

.start-card {
  width: min(980px, 100%);
  padding: 32px;
  background:
    linear-gradient(150deg, rgba(10, 28, 33, 0.96), rgba(6, 14, 20, 0.98));
}

.start-card h1 {
  max-width: 13ch;
  font-size: clamp(2.8rem, 5vw, 5.2rem);
  line-height: 0.92;
}

.intro-copy,
.small-note {
  color: var(--muted);
  line-height: 1.7;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.brief-grid article {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
}

.brief-grid strong {
  display: block;
  margin-bottom: 8px;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.15rem;
}

.brief-grid span {
  color: var(--muted);
  line-height: 1.55;
}

.start-button {
  min-width: 220px;
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 290px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .viewport-panel {
    min-height: 620px;
  }

  .floating-panel {
    width: min(420px, calc(100% - 32px));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .brief-grid,
  .stat-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .floating-panel h3 {
    font-size: 1.45rem;
  }

  .start-card {
    padding: 22px;
  }
}
