:root {
  color-scheme: light;
  --ink: #14201b;
  --muted: #62736a;
  --panel: rgba(250, 249, 239, 0.94);
  --line: rgba(36, 58, 48, 0.16);
  --deep: #17392f;
  --jungle: #2f6846;
  --leaf: #6f9447;
  --amber: #c8882e;
  --steel: #607173;
  --danger: #b64d43;
  --shadow: 0 18px 44px rgba(22, 39, 31, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(238, 246, 226, 0.9), rgba(215, 228, 193, 0.92)),
    radial-gradient(circle at 18% 14%, rgba(77, 151, 141, 0.22), transparent 35%),
    radial-gradient(circle at 90% 8%, rgba(200, 136, 46, 0.16), transparent 28%),
    #d5dfbd;
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: stretch;
}

.brand,
.stats,
.panel,
.canvas-frame,
.event-log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 3px solid #efe5c8;
  border-radius: 50%;
  background:
    radial-gradient(circle at 64% 35%, #111 0 6%, transparent 7%),
    radial-gradient(circle at 45% 58%, #6c8f4b 0 35%, #1d4a37 36% 100%);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  overflow: hidden;
}

.stats div {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 14px;
  border-left: 1px solid rgba(36, 58, 48, 0.1);
  background: rgba(255, 255, 255, 0.34);
}

.stats div:first-child {
  border-left: 0;
}

.stats span,
.panel-section h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stats strong {
  overflow: hidden;
  font-size: 20px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-layout {
  display: grid;
  grid-template-columns: 250px minmax(560px, 1fr) 300px;
  gap: 14px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 14px;
}

.panel-section {
  display: grid;
  gap: 10px;
}

.build-list,
.button-stack,
.genome-list,
.dino-list,
.facility-list,
.objective-list {
  display: grid;
  gap: 8px;
}

.build-card,
.genome-card,
.dino-card,
.facility-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  border: 1px solid rgba(36, 58, 48, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.build-card {
  cursor: pointer;
  text-align: left;
}

.build-card.is-active {
  border-color: var(--jungle);
  background: rgba(111, 148, 71, 0.18);
}

.build-card b,
.genome-card b,
.dino-card b,
.facility-card b {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.build-card span,
.genome-card span,
.dino-card span,
.facility-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pill {
  justify-self: end;
  min-width: 62px;
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(20, 32, 27, 0.08);
  color: #31443b;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.gene-bar {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(20, 32, 27, 0.12);
}

.gene-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6f9447, #c8882e);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  background: var(--deep);
  color: #fff;
}

.secondary-button {
  border: 1px solid rgba(36, 58, 48, 0.16);
  background: #fbf5df;
}

.danger-button {
  background: rgba(182, 77, 67, 0.13);
  color: #80362f;
}

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

.park-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

.canvas-frame {
  position: relative;
  display: grid;
  align-self: start;
  aspect-ratio: 1100 / 760;
  min-height: 600px;
  overflow: hidden;
  background: #6f9447;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.mode-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(20, 32, 27, 0.74);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.event-log {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  color: #31443b;
  font-size: 14px;
  line-height: 1.35;
}

.objective-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: #33453d;
  font-size: 13px;
}

.genome-list,
.dino-list,
.facility-list {
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 24, 20, 0.42);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  gap: 14px;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(250, 249, 239, 0.98);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2,
.modal-panel h3 {
  margin: 0;
}

.modal-panel h3 {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(20, 32, 27, 0.09);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-list {
  display: grid;
  gap: 8px;
}

.menu-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid rgba(36, 58, 48, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
}

.menu-card.is-active {
  border-color: var(--jungle);
  background: rgba(111, 148, 71, 0.18);
}

.menu-card b {
  display: block;
  font-size: 14px;
}

.menu-card span,
.menu-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.detail-block {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(36, 58, 48, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.detail-block b {
  font-size: 16px;
}

.detail-block span {
  color: var(--muted);
  font-size: 13px;
}

.comfort-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.comfort-grid div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  align-content: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(20, 32, 27, 0.07);
}

.comfort-grid b {
  font-size: 20px;
}

.comfort-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 240px minmax(380px, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .topbar,
  .game-layout,
  .right-panel {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .park-stage {
    order: 1;
  }

  .left-panel {
    order: 2;
  }

  .right-panel {
    order: 3;
  }

  .canvas-frame {
    aspect-ratio: 4 / 3;
    min-height: 0;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }

  .comfort-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .stats strong {
    font-size: 17px;
  }

  .build-card,
  .genome-card,
  .dino-card,
  .facility-card {
    grid-template-columns: 1fr;
  }

  .pill {
    justify-self: stretch;
  }
}
