/* style.css —— 双模式教育贪吃蛇 H5（Sprint 1 v1 视觉）
   色板 = 美术圣经 §2 CSS 变量表，直接对齐，禁裸值。 */

:root {
  /* 主色板（美术圣经 §2） */
  --grass: #8FD14F;
  --sand: #F7E3B0;
  --sand-line: #D9BC82;
  --sky: #CDEBFF;
  --sea: #A8DCEF;
  --cream: #FDEBB2;
  --leaf: #3E7A1F;
  --snake-body: #4FC3C7;
  --snake-belly: #B2EBDF;
  --snake-line: #2B8A8E;
  --blush: #FF9FB2;
  --orange: #FF9F45;
  --pink: #FF6B9D;
  --blue: #5B9BE6;
  --ink: #33261D;
  --gold: #FFD54F;
  /* 字母块/汉字块 */
  --block-char-bg: #FFE8CC;
  --block-letter-bg: #D9E9FF;
  --block-letter-ink: #2B5FA8;
  /* 字体栈（美术圣经 §3，不加载 webfont） */
  --font-cn: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans",
             "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-en: "Comic Sans MS", "Chalkboard SE", var(--font-cn);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-cn);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app { height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ---------- 主菜单 ---------- */
#screen-menu {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: linear-gradient(180deg, #FFE3EC 0%, var(--cream) 55%, var(--grass) 130%);
}

.menu-title {
  font-size: clamp(32px, 9vw, 44px);
  font-weight: 700;
  text-align: center;
}

.menu-stars {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 8px 24px;
}

.mode-card {
  width: 85%;
  min-height: 22vh;
  border: 3px solid transparent;
  border-radius: 24px;
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 700;
  font-family: var(--font-cn);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.12s;
}
.mode-card:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.mode-card small { font-size: 18px; font-weight: 400; }

#card-kids { background: #FFE3EC; border-color: var(--pink); }
#card-student { background: var(--sky); border-color: var(--blue); }

/* ---------- 游戏屏 ---------- */
#screen-game {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sky) 0%, var(--cream) 30%);
}
#screen-game.mode-kids { background: linear-gradient(180deg, #FFE3EC 0%, var(--cream) 30%); }
#screen-game.mode-student { background: linear-gradient(180deg, var(--sky) 0%, var(--cream) 30%); }

#hud {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  min-height: 56px;
}

#hud-hearts { display: flex; gap: 4px; }
#hud-hearts svg { width: 32px; height: 32px; }
#hud-hearts .heart path { fill: var(--pink); stroke: #E0558A; stroke-width: 6; }
#hud-hearts .heart.lost path { fill: none; stroke: #D8C9B8; }

#hud-stars {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  background: var(--cream);
  border-radius: 999px;
  padding: 4px 14px;
  border: 2px solid var(--gold);
}

#btn-home,
#btn-pause,
#btn-projects {
  margin-left: auto;
  min-width: 64px; /* 返回键触控 ≥64px（美术圣经触控红线），稍小于暂停键区分层级 */
  min-height: 48px;
  border: 2px solid var(--orange);
  border-radius: 16px;
  background: var(--orange);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
#btn-home { margin-left: 0; background: var(--blue); border-color: var(--blue); font-size: 26px; }
#btn-projects { margin-left: 0; font-size: 18px; } /* TASK-12：回作品页（HUD 最左） */

#game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* 滑动手势专属区：禁页面滚动 */
  min-height: 0;
}
#game-canvas { border-radius: 16px; }

/* 虚拟方向键（ui-input GDD：≥88px，间距 ≥8px） */
#dpad {
  display: flex;
  justify-content: center;
  padding: 10px 0 18px;
}
.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  grid-template-rows: repeat(2, 88px);
  gap: 8px;
}
.dpad-btn {
  border: 2px solid var(--orange);
  border-radius: 20px;
  background: var(--orange);
  color: #fff;
  font-size: 36px;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  touch-action: none;
}
.dpad-btn:active { transform: translateY(3px); box-shadow: none; }
.dpad-btn.d-up { grid-column: 2; grid-row: 1; }
.dpad-btn.d-left { grid-column: 1; grid-row: 2; }
.dpad-btn.d-down { grid-column: 2; grid-row: 2; }
.dpad-btn.d-right { grid-column: 3; grid-row: 2; }

/* ---------- 浮层（暂停 / 局终） ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(51, 38, 29, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay-panel {
  background: var(--cream);
  border-radius: 24px;
  padding: 32px 28px;
  width: 82%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  text-align: center;
}
.overlay-panel h2 { font-size: 28px; }
.overlay-panel p { font-size: 20px; }
.overlay-btn {
  min-height: 64px;
  border: none;
  border-radius: 18px;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-cn);
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}
.overlay-btn.primary { background: var(--orange); }
.overlay-btn.secondary { background: var(--blue); }
.overlay-btn:active { transform: translateY(3px); box-shadow: none; }
