/* 시작 페이지 (MGW-DEV-007): 게임 목록 · 시작 · 랭킹 보기를 한 화면(스크롤 없음)에
   세로 화면: 게임 3개를 위아래로 / 가로 화면: 게임 3개를 나란히. 글자는 작은 "Arcade"와 게임 이름뿐. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body.home {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--cf-bg);
  color: var(--cf-ink);
  font-family: var(--cf-font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.home-head { display: flex; align-items: center; justify-content: space-between; width: min(100vw - 24px, 980px); margin: 0 auto; }
.home-title { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: 0.2px; color: var(--cf-muted); }
.home-main { min-height: 0; padding: 4px 0 12px; }
/* 소개 페이지로 가는 작은 아이콘 (MGW-DEV-008). 누르는 범위 40×40, 그림은 작고 흐리게 */
.home-side { display: inline-flex; align-items: center; gap: 2px; }
.about-link { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--cf-muted); }
.about-link svg { width: 18px; height: 18px; }
.about-link:hover { background: rgba(29, 37, 64, 0.07); }
.about-link:focus-visible { outline: 3px solid var(--cf-accent); outline-offset: -3px; }
.games {
  list-style: none;
  height: 100%;
  width: min(100vw - 24px, 980px);
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.game {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(29, 37, 64, 0.08);
}
.card {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0 10px 12px;
  border-radius: 20px 0 0 20px;
  color: inherit;
  text-decoration: none;
}
.card:focus-visible, .rank-btn:focus-visible { outline: 3px solid var(--cf-accent); outline-offset: 2px; }
.card-name { flex: 1 1 auto; min-width: 0; font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-ic, .rank-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
}
.play-ic { background: var(--cf-accent); color: #fff; box-shadow: 0 4px 12px rgba(63, 111, 224, 0.35); }
.play-ic svg { width: 26px; height: 26px; }
.rank-btn { padding: 0; border: 0; background: #eef1f8; color: var(--cf-ink); cursor: pointer; }
.rank-btn svg { width: 24px; height: 24px; }
a.card:hover .play-ic { filter: brightness(1.08); }
.rank-btn:hover { background: #e2e7f3; }

/* 카드 그림 (그림 파일 없이 CSS로, 64px 기준 좌표를 zoom으로 키운다) */
.card-icon { --z: 1.2; flex: none; width: 64px; height: 64px; border-radius: 14px; position: relative; overflow: hidden; zoom: var(--z); }
.icon-2048 { background: #1f2638; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px; }
.icon-2048 i { border-radius: 6px; display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 800; font-size: 13px; }
.icon-2048 i:nth-child(1) { background: #e6f0f4; color: #24304a; }
.icon-2048 i:nth-child(2) { background: #6fd0c2; color: #10332f; }
.icon-2048 i:nth-child(3) { background: #5a5fe0; color: #fff; }
.icon-2048 i:nth-child(4) { background: linear-gradient(135deg, #ff7a6b, #f5b041); color: #1d2540; font-size: 9px; }
.icon-snake { background: #1f2638; }
.icon-snake i { position: absolute; width: 12px; height: 12px; border-radius: 4px; background: #3fc1ae; }
.icon-snake i:nth-child(1) { left: 12px; top: 40px; background: #1f8f86; }
.icon-snake i:nth-child(2) { left: 25px; top: 40px; }
.icon-snake i:nth-child(3) { left: 25px; top: 27px; }
.icon-snake i:nth-child(4) { left: 38px; top: 27px; background: #8ef0dc; }
.icon-snake b { position: absolute; left: 42px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #ff7a6b; }
.icon-planet { background: #1f2638; }
.icon-planet b { position: absolute; left: 8px; right: 8px; top: 14px; bottom: 6px; border: 2px solid #4a5a8a; border-top: 0; border-radius: 0 0 18px 18px; background: #283252; }
.icon-planet i { position: absolute; z-index: 1; border-radius: 50%; }
.icon-planet i:nth-child(1) { width: 14px; height: 14px; left: 13px; bottom: 10px; background: radial-gradient(circle at 35% 32%, #ffd9cf 0 12%, #e2563f 38%, #b23a28); }
.icon-planet i:nth-child(2) { width: 22px; height: 22px; left: 28px; bottom: 9px; background: radial-gradient(circle at 35% 32%, #5cc46a 0 12%, #3d8de8 38%, #2a6cc0); }
.icon-planet i:nth-child(3) { width: 12px; height: 12px; left: 26px; top: 6px; background: radial-gradient(circle at 35% 32%, #fffbea 0 12%, #efe7c6 38%, #cfc39a); }

/* 그림 크기: 화면 높이에 맞춰 (세로 화면은 한 줄 높이의 약 70%) */
/* 폭도 함께 본다: 좁은 폭(360 등)에서 그림이 커지면 게임 이름이 잘린다 */
@media (orientation: portrait) and (min-height: 640px) and (min-width: 350px) { .card-icon { --z: 1.5; } }
@media (orientation: portrait) and (min-height: 780px) and (min-width: 380px) { .card-icon { --z: 1.9; } }

/* 가로 화면: 게임 3개를 나란히 (그림 위, 이름·버튼 아래) */
@media (orientation: landscape) {
  .games { grid-template-rows: minmax(0, 1fr); grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .game { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; justify-items: center; padding: 0 0 14px; }
  .card { flex-direction: column; justify-content: center; gap: 10px; width: 100%; padding: 12px 8px 0; border-radius: 20px 20px 0 0; }
  .card-name { flex: none; text-align: center; }
  .card-icon { --z: 1.6; }
}
@media (orientation: landscape) and (min-height: 560px) { .card-icon { --z: 2.4; } .card-name { font-size: 18px; } }
@media (orientation: landscape) and (min-height: 900px) { .card-icon { --z: 3; } }
@media (orientation: landscape) and (max-height: 330px) { .card-icon { --z: 1.2; } }

/* 404 페이지 */
.nf { display: flex; align-items: center; justify-content: center; }
.nf a { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; background: var(--cf-accent); color: #fff; }
.nf svg { width: 32px; height: 32px; }

@media (prefers-reduced-motion: reduce) { a.card:hover { transform: none; } }
