/* 첫 화면·나이대 화면 모양 */

.menu {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.menu-title { font-size: var(--font-title); margin: 8px 0 0; text-align: center; }
.menu-lead { margin: 0 0 16px; text-align: center; color: var(--ink-soft); }

/* ---------- 첫 화면: 나이대 6칸 ---------- */
.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
/* 넓은 화면(태블릿·가로)에서는 3칸씩 */
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
}

.tile {
  min-height: 120px;
  height: 100%;
  border-radius: 24px;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
}
.tile:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.tile-name { font-size: 24px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
.tile-sub { font-size: 18px; opacity: 0.8; }

/* 나이대별 색 */
.age-toddler { --age: var(--age-toddler); }
.age-kinder  { --age: var(--age-kinder); }
.age-lower   { --age: var(--age-lower); }
.age-teen    { --age: var(--age-teen); }
.age-adult   { --age: var(--age-adult); }
.age-senior  { --age: var(--age-senior); }
.tile { background: var(--age); }

/* ---------- 나이대 화면: 게임 3칸 ---------- */
.age-head {
  flex: 1;
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: var(--font-big);
  line-height: 1.2;
  word-break: keep-all;
}
.age-head small { font-size: 18px; color: var(--ink-soft); font-weight: 400; }
/* 가운데 제목이 정확히 가운데 오도록 왼쪽 버튼만큼 빈자리 */
.gb-topbar-gap { flex: none; width: var(--tap-big); }
body[data-page="age"] { border-top: 10px solid var(--age, transparent); }

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}
@media (min-width: 760px) {
  .games { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.game {
  min-height: 96px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--card);
  border: 3px solid var(--age);
  color: var(--ink);
  text-decoration: none;
}
a.game:active { transform: translateY(2px); }
.game-no {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--age);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
}
.game-text { display: flex; flex-direction: column; min-width: 0; }
.game-name { font-size: 24px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
.game-how { font-size: 18px; color: var(--ink-soft); word-break: keep-all; }

.game.is-soon { border-style: dashed; opacity: 0.6; position: relative; }
.soon {
  /* 칸 오른쪽 위 모서리에 붙여, 게임 이름 자리를 줄이지 않는다 */
  position: absolute;
  top: -12px;
  right: 12px;
  font-size: 16px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--line);
}

/* 시니어 화면은 글씨를 더 크게 (본문 22px 이상) */
body.age-senior { --font-body: 24px; }
body.age-senior .game-name { font-size: 28px; }
body.age-senior .game-how { font-size: 22px; }
body.age-senior .soon { font-size: 22px; }

/* =========================================================
   태블릿(가로·세로 모두 600px 이상): 카드를 키워 화면 높이를 채운다
   - 폰은 세로·가로 모두 위 모양 그대로 (높이가 600px 아래라 여기에 걸리지 않음)
   - 한 화면에 다 들어오고 스크롤이 생기지 않게, 화면 높이(100dvh)를 나눠 쓴다
   ========================================================= */
@media (min-width: 600px) and (min-height: 600px) {
  body {
    height: 100vh;   /* dvh를 모르는 옛 브라우저용 */
    height: 100dvh;  /* 주소창을 뺀 실제 보이는 높이 */
    display: flex;
    flex-direction: column;
  }
  .menu {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    padding: 24px;
  }

  /* ---------- 첫 화면: 세로 2×3, 가로 3×2 ---------- */
  .menu-title { font-size: 48px; }
  .menu-lead { font-size: 26px; margin-bottom: 24px; }
  .tiles {
    flex: 1;
    min-height: 0;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
  .tile { border-radius: 32px; gap: 6px; }
  .tile-name { font-size: 40px; }
  .tile-sub { font-size: 28px; }

  /* ---------- 나이대 화면: 세로는 큰 카드 3줄 ---------- */
  .age-head { font-size: 40px; }
  .age-head small { font-size: 26px; }
  .games {
    flex: 1;
    min-height: 0;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
  .game { gap: 28px; padding: 28px 32px; border-width: 4px; border-radius: 28px; }
  .game-no { width: 96px; height: 96px; font-size: 44px; }
  .game-name { font-size: 38px; }
  .game-how { font-size: 26px; }
  /* '준비 중'은 테두리에 걸치지 않게 카드 안쪽 모서리에 */
  .soon { top: 20px; right: 20px; font-size: 22px; padding: 6px 16px; }

  /* 시니어는 한 단계 더 크게 */
  body.age-senior .game-name { font-size: 42px; }
  body.age-senior .game-how { font-size: 30px; }
  body.age-senior .soon { font-size: 24px; }
}

/* 태블릿 가로: 첫 화면 3×2, 나이대 화면은 높은 카드 3칸 */
@media (min-width: 600px) and (min-height: 600px) and (orientation: landscape) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .games {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }
  /* 높은 카드: 번호 → 이름 → 설명을 위아래로, 가운데 맞춤 */
  .game {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 20px;
    padding: 32px 24px;
  }
  .game-text { align-items: center; }
  .game-no { width: 112px; height: 112px; font-size: 52px; }
}
