/* 潇洒割草机 - 全局样式 / 布局 / 移动端适配 */
:root {
  --bg-0: #07130f;
  --bg-1: #0f2a22;
  --bg-2: #123428;
  --ink: #eafff5;
  --ink-dim: #9fc4b6;
  --green: #7ee0a8;
  --green-deep: #2f9c6a;
  --gold: #ffd166;
  --red: #ff6b6b;
  --blue: #8fd0ff;
  --panel: rgba(12, 32, 26, 0.9);
  --border: rgba(126, 224, 168, 0.28);
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(126, 224, 168, 0.16), transparent 65%),
    linear-gradient(160deg, #07130f 0%, #0b211a 45%, #071512 100%);
  overflow: hidden;
}

body.in-game { background: #050e0b; }

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------------- 加载页 ---------------- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #123428, #06100d 75%);
  transition: opacity .45s ease;
}

.loading.done { opacity: 0; pointer-events: none; }

.loading-inner { text-align: center; padding: 24px; }

.loading-logo {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(126, 224, 168, 0.55);
}

.loading-logo span { color: var(--green); }

.loading-bar {
  width: min(260px, 62vw);
  height: 6px;
  margin: 18px auto 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.loading-bar i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green), #c8ffdf);
  animation: loadingSlide 1.1s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

#loading-text {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.7;
}

#loading-text.error { color: #ffb2b2; max-width: 460px; margin: 0 auto; }
#loading-text .small { font-size: 12px; color: var(--ink-dim); }

/* ---------------- 屏幕切换 ---------------- */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.screen.active { display: flex; }

/* ---------------- 主菜单 ---------------- */
.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 400px at 18% 20%, rgba(126, 224, 168, 0.15), transparent 70%),
    radial-gradient(600px 420px at 82% 78%, rgba(143, 208, 255, 0.12), transparent 70%);
  pointer-events: none;
}

.menu-card {
  position: relative;
  z-index: 2;
  width: min(560px, 92vw);
  padding: 34px 30px 26px;
  text-align: center;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(16, 44, 35, 0.94), rgba(8, 24, 19, 0.96));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: cardIn .5s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.game-title {
  margin: 0;
  font-size: clamp(28px, 7vw, 44px);
  letter-spacing: 4px;
  font-weight: 900;
  text-shadow: 0 6px 24px rgba(126, 224, 168, 0.3);
}

.game-title span { color: var(--green); }

.game-sub {
  margin: 10px 0 22px;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.7;
}

.menu-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.menu-stats > div {
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(126, 224, 168, 0.14);
}

.menu-stats span {
  display: block;
  font-size: 11px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

.menu-stats strong { font-size: 17px; color: var(--green); letter-spacing: 1px; }

.menu-actions {
  display: grid;
  gap: 10px;
}

.menu-foot {
  margin: 18px 0 0;
  font-size: 11px;
  color: rgba(159, 196, 182, 0.7);
  letter-spacing: .5px;
}

/* ---------------- 角色选择 ---------------- */
#screen-select {
  padding: 20px;
  gap: 14px;
  justify-content: flex-start;
  padding-top: max(24px, 6vh);
  overflow-y: auto;
}

.panel-head {
  width: min(880px, 94vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 { margin: 0; font-size: 20px; letter-spacing: 2px; }

.char-list {
  width: min(880px, 94vw);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.char-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  background: linear-gradient(180deg, rgba(18, 48, 38, 0.9), rgba(9, 26, 21, 0.95));
  border: 1px solid rgba(126, 224, 168, 0.2);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.char-card:hover { transform: translateY(-3px); border-color: rgba(126, 224, 168, 0.55); box-shadow: 0 12px 28px rgba(0, 0, 0, .35); }

.char-card.selected { border-color: var(--green); box-shadow: 0 0 0 2px rgba(126, 224, 168, .35); }

.char-card.locked { opacity: .55; cursor: not-allowed; }

.char-avatar {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  color: #06211a;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, .25);
}

.char-info { flex: 1; min-width: 0; }

.char-info h3 {
  margin: 0 0 6px;
  font-size: 15px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.char-info h3 em { font-style: normal; font-size: 11px; color: var(--gold); letter-spacing: 1px; }

.char-info p { margin: 0 0 8px; font-size: 12px; color: var(--ink-dim); line-height: 1.6; }

.char-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: rgba(159, 196, 182, .85);
  align-items: center;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  border: 1px solid currentColor;
}

.tag.ok { color: var(--green); }
.tag.lock { color: var(--gold); }

.panel-tip { font-size: 12px; color: var(--ink-dim); text-align: center; max-width: 90vw; }

/* ---------------- 对局舞台 ---------------- */
#screen-game { padding: 0; }

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050e0b;
}

#game-canvas {
  display: block;
  width: min(100%, calc(100vh * 16 / 9));
  width: min(100%, calc(100dvh * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 10px;
  background: #0f2a22;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(126, 224, 168, .16), 0 22px 60px rgba(0, 0, 0, .6);
  image-rendering: auto;
}

/* 手机竖屏：画布占满宽度，上下留白 */
@media (max-aspect-ratio: 1/1) {
  #game-canvas {
    width: 100%;
    max-height: 78dvh;
  }
}

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 12px 18px;
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(126, 224, 168, 0.28);
  transition: transform .12s ease, background .16s ease, border-color .16s ease;
}

.btn:hover { background: rgba(126, 224, 168, 0.14); border-color: rgba(126, 224, 168, 0.6); }
.btn:active { transform: scale(.975); }

.btn-primary {
  color: #061a14;
  background: linear-gradient(180deg, #a6f5c8, #55c98c);
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(85, 201, 140, .35);
  font-weight: 800;
}

.btn-primary:hover { background: linear-gradient(180deg, #b9ffd7, #63da99); }

.btn-danger { color: #ffdada; background: rgba(255, 107, 107, .14); border-color: rgba(255, 107, 107, .45); }
.btn-danger:hover { background: rgba(255, 107, 107, .24); }

.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .16); color: var(--ink-dim); }

.btn-sm { padding: 8px 14px; font-size: 12px; }

.btn-icon {
  width: 40px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  border-radius: 10px;
  background: rgba(4, 18, 14, .55);
  border: 1px solid rgba(126, 224, 168, .3);
}

/* ---------------- 提示 / 文本 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, 5vh);
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast-item {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: #07211a;
  background: linear-gradient(180deg, #b9ffd7, #6fe0a4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .4);
  animation: toastIn .22s ease both;
}

.toast-item.out { opacity: 0; transform: translateY(6px); transition: all .4s ease; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

.field-label {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin: 12px 0 6px;
}

.field-textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #d9fff0;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(126, 224, 168, .22);
  outline: none;
}

.field-textarea:focus { border-color: rgba(126, 224, 168, .6); }

/* ---------------- 小屏微调 ---------------- */
@media (max-width: 480px) {
  .menu-card { padding: 26px 20px 20px; }
  .menu-stats span { font-size: 10px; }
  .menu-stats strong { font-size: 15px; }
  .btn { padding: 11px 14px; font-size: 13px; }
  .char-list { grid-template-columns: 1fr; }
}

@media (max-height: 520px) {
  .menu-card { padding: 18px 18px 14px; }
  .game-sub { margin: 6px 0 12px; }
  .menu-stats { margin-bottom: 12px; }
  .menu-actions { grid-template-columns: 1fr 1fr; }
}
