:root {
  --bg: #0f2e26;
  --panel: #143d32;
  --ink: #f4f0e6;
  --muted: #b7cfc5;
  --accent: #e8a045;
  --accent-dark: #c47a28;
  --line: rgba(244, 240, 230, 0.18);
  --top-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(232, 160, 69, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(80, 160, 130, 0.18), transparent 40%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 0;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  min-height: var(--top-h);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.pixel-crab { font-size: 22px; line-height: 1; }

.link-wetland {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid rgba(232, 160, 69, 0.45);
  padding: 6px 10px;
  border-radius: 999px;
}

.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.game-shell {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 关键保持 16:9，由壳子限制，避免竖屏被拉扁/拉长 */
#game {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  background: #1b4d3e;
  border: 3px solid #c47a28;
  border-radius: 10px;
  box-shadow:
    0 0 0 2px #0a201a,
    0 12px 36px rgba(0, 0, 0, 0.4);
  image-rendering: pixelated;
}

.touch-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(244, 240, 230, 0.7);
  background: rgba(0, 0, 0, 0.28);
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2;
}

.touch-hint.show { opacity: 1; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 22, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.overlay.hidden { display: none; }

.panel {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #1a4a3c 0%, #12352c 100%);
  border: 2px solid rgba(232, 160, 69, 0.35);
  border-radius: 16px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.panel.hidden { display: none; }

.kicker {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}

.panel h1, .panel h2 {
  font-size: 26px;
  margin-bottom: 10px;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 14px;
}

.lead b { color: var(--ink); }

.tips {
  list-style: none;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
}

.tips li + li { margin-top: 6px; }

.eco-line {
  font-size: 13px;
  color: #d7ebe1;
  background: rgba(232, 160, 69, 0.12);
  border-left: 3px solid var(--accent);
  text-align: left;
  padding: 8px 10px;
  margin: 0 0 14px;
  line-height: 1.5;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
}

.level-chip {
  appearance: none;
  border: 1px solid rgba(232, 160, 69, 0.35);
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 4px;
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
  touch-action: manipulation;
}

.level-chip small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.level-chip.active {
  border-color: var(--accent);
  background: rgba(232, 160, 69, 0.22);
  box-shadow: inset 0 0 0 1px rgba(232, 160, 69, 0.35);
}

.level-chip.locked {
  opacity: 0.42;
  cursor: not-allowed;
}

.level-chip.cleared:not(.active) {
  border-color: rgba(127, 219, 202, 0.45);
}

.level-now {
  text-align: center;
  color: #ffd166;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px;
}

.btn.hidden { display: none; }

@media (max-width: 640px) {
  .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}

.btn.primary {
  background: var(--accent);
  color: #1a2a20;
}

.btn.primary:active { background: var(--accent-dark); }

.btn.secondary {
  background: rgba(244, 240, 230, 0.12);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
}

.share-box {
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  resize: none;
  font-family: inherit;
}

.copy-ok {
  color: #9fdfa8;
  font-size: 13px;
  margin: 4px 0 0;
}

.copy-ok.hidden { display: none; }

@media (max-width: 640px) {
  .brand small { display: none; }
  .panel h1, .panel h2 { font-size: 22px; }
  #game { border-width: 2px; border-radius: 8px; }
}

/* —— 竖屏 —— */
@media (orientation: portrait) and (max-width: 900px) {
  .topbar { padding: 6px 10px; min-height: 44px; }
  .link-wetland { padding: 4px 8px; font-size: 12px; }
  .stage-wrap { padding: 4px 6px; }
}

/* —— 横屏手机：藏顶栏，画布尽量铺满 —— */
@media (orientation: landscape) and (max-height: 720px) {
  .topbar { display: none !important; }

  #app {
    max-width: none;
    height: 100dvh;
    height: 100vh;
  }

  .stage-wrap {
    padding: 0;
    height: 100%;
  }

  .game-shell {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  #game {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
    max-height: 100%;
  }

  .overlay { padding: 8px; }
  .panel {
    width: min(380px, 92vw);
    max-height: 92vh;
    overflow-y: auto;
    padding: 14px 14px 12px;
  }
  .panel h1, .panel h2 { font-size: 20px; margin-bottom: 6px; }
  .tips { font-size: 12px; margin-bottom: 10px; padding: 8px 10px; }
  .lead { font-size: 13px; margin-bottom: 8px; }
  .btn { padding: 10px 12px; font-size: 14px; margin-top: 6px; }
}
