/*
  펭귄 키우기 — 모바일 세로 우선. penguin.css 와 같은 뼈대.

  게임은 .bw-penguin-stage 박스 안에만 산다 (공통 헤더·푸터·방명록·자동 광고와 같은 페이지).
  #game #hud #pause-overlay 와 버튼 id 는 js/penguin/main.js 가 그대로 찾는다. 이름을 바꾸지 않는다.
*/

.bw-penguin-shell {
  width: min(960px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.65rem 0 1.75rem;
}

/* ── 게임 박스 ──
   세로 9:16 게임이라 높이를 기준으로 잡고 폭은 게임이 비율에 맞춰 정한다 (main.js designWidth).
   화면을 꽉 채우지 않는다 — 자동 광고가 들어갈 여백을 남긴다. */
.bw-penguin-stage {
  position: relative;
  width: 100%;
  /* 높이: 위아래로 스크롤을 잡을 여백을 항상 남긴다.
     vh 는 iOS 사파리에서 주소창 포함 큰 화면 기준이라 실제보다 커서 박스가 화면을 꽉 채웠다.
     dvh(보이는 높이)로 바꾸고 값도 낮춰, 아이폰처럼 세로 짧은 폰에서 박스 밖 스크롤 띠를 확보한다.
     박스는 touch-action:none 이라 그 위를 끌어선 페이지가 안 내려가므로, 이 여백이 유일한 스크롤 손잡이다. */
  height: min(72vh, 720px);
  height: min(72dvh, 720px);
  min-height: 380px;
  margin: 0.75rem 0 1rem;
  overflow: hidden;
  border: 1px solid var(--bw-border);
  border-radius: 1rem;
  background: #1a4f8f;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

/* 전체화면이면 박스 장식을 빼고 꽉 채운다 */
.bw-penguin-stage:fullscreen,
.bw-penguin-stage:-webkit-full-screen {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.bw-penguin-stage #game {
  position: absolute;
  inset: 0;
}

.bw-penguin-stage #game canvas {
  display: block;
}

/* ── HUD (원본 index.html 의 스타일을 박스 기준으로 옮김) ── */
.bw-penguin-stage #hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bw-penguin-stage #hud button {
  pointer-events: auto;
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.bw-penguin-stage #btn-full,
.bw-penguin-stage #btn-pause {
  position: absolute;
  top: 10px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.85);
  color: #2b2733;
  font-size: 18px;
}

.bw-penguin-stage #btn-full { right: 64px; }
.bw-penguin-stage #btn-full.hidden { display: none; }
.bw-penguin-stage #btn-pause { right: 12px; display: none; }

.bw-penguin-stage:fullscreen #btn-full,
.bw-penguin-stage:fullscreen #btn-pause {
  top: calc(10px + env(safe-area-inset-top));
}

.bw-penguin-stage #pause-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(20, 16, 28, 0.72);
  pointer-events: auto;
}

.bw-penguin-stage #pause-overlay h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 32px;
}

.bw-penguin-stage #pause-overlay button {
  min-width: min(300px, calc(100% - 32px));
  padding: 16px;
  background: #ffb400;
  color: #2b2733;
  font-size: 20px;
  box-shadow: 0 5px 0 #b07a00;
}

.bw-penguin-stage #pause-overlay button.sub {
  background: #fff;
  box-shadow: 0 5px 0 #bbb;
}

/* 계속하기만 크게, 나머지는 두 칸씩 (작은 폰에서 버튼 6개가 넘치지 않게) */
.bw-penguin-stage #pause-overlay .pause-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(300px, calc(100% - 32px));
}

.bw-penguin-stage #pause-overlay .pause-grid button {
  min-width: 0;
  padding: 12px 6px;
  font-size: 17px;
}

.bw-penguin-stage #pause-overlay .pause-grid button.wide {
  grid-column: 1 / -1;
}

/* 터치 기기가 가로일 때 (세로 전용 게임). 리듬게임과 같은 방식.
   박스 최소 높이 380 이 가로 폰 화면(약 330)보다 커서 페이지를 못 내리던 문제도 같이 막음 */
.bw-penguin-stage #rotate {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: #1a2c4a;
  color: #fff;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  pointer-events: auto;
}

@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) {
  .bw-penguin-stage {
    height: 70dvh;
    min-height: 0;
  }
  .bw-penguin-stage #rotate { display: flex; }
}

/* ── 게임 방법 창 (일시정지 창 위에 뜸) ── */
.bw-penguin-stage .bw-sheet {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(20, 16, 28, 0.72);
  pointer-events: auto;
}

.bw-penguin-stage .help-card {
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  max-height: 100%;
  overflow: hidden;
  border: 3px solid #1d2638;
  border-radius: 20px;
  background: #fff;
  color: #1d2638;
  box-shadow: 0 8px 0 rgba(29, 38, 56, 0.35);
}

.bw-penguin-stage .help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px 18px;
  border-bottom: 2px solid #e3e8f0;
}

.bw-penguin-stage .help-head h2 {
  margin: 0;
  font-size: 22px;
}

.bw-penguin-stage #hud #btn-help-close,
.bw-penguin-stage #hud #btn-dex-close,
.bw-penguin-stage #hud #btn-sound-close {
  width: 40px;
  height: 40px;
  background: #eef2f8;
  color: #1d2638;
  font-size: 18px;
}

/* 박스 전체가 touch-action:none 이라 여기만 세로 스크롤을 풀어 줌 */
.bw-penguin-stage .help-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 4px 18px 18px;
  font-size: 15px;
  line-height: 1.5;
}

.bw-penguin-stage .help-body h3 {
  margin: 16px 0 6px;
  color: #2a5db0;
  font-size: 16px;
}

.bw-penguin-stage .help-body ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bw-penguin-stage .help-body li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.bw-penguin-stage .help-body li.warn {
  color: #c0392b;
}

.bw-penguin-stage .help-body img {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.bw-penguin-stage .medal-dot {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 0 9px;
  border: 3px solid #1d2638;
  border-radius: 50%;
}

.bw-penguin-stage .medal-dot.gold { background: #ffc21a; }
.bw-penguin-stage .medal-dot.silver { background: #b9c6d8; }
.bw-penguin-stage .medal-dot.bronze { background: #e0925f; }

/* 소리 설정 */
.bw-penguin-stage .sound-card {
  width: min(360px, 100%);
}

.bw-penguin-stage .sound-body {
  display: grid;
  gap: 6px;
  padding: 14px 20px 20px;
}

.bw-penguin-stage .sound-body label {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 17px;
  font-weight: 800;
}

.bw-penguin-stage .sound-body output {
  color: #2a5db0;
}

.bw-penguin-stage .sound-body input[type="range"] {
  width: 100%;
  height: 32px;
  accent-color: #ffb400;
  touch-action: none;
}

.bw-penguin-stage .sound-body p {
  margin: 10px 0 0;
  color: #6b778c;
  font-size: 13px;
}

/* 도감 */
.bw-penguin-stage .dex-count {
  color: #6b778c;
  font-size: 13px;
  font-weight: 700;
}

.bw-penguin-stage .dex-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 2px solid #e3e8f0;
}

.bw-penguin-stage #hud .dex-tabs button {
  flex: 1;
  padding: 8px 4px;
  background: #eef2f8;
  color: #4b5870;
  font-size: 14px;
}

.bw-penguin-stage #hud .dex-tabs button[aria-selected="true"] {
  background: #ffb400;
  color: #1d2638;
  box-shadow: 0 3px 0 #b07a00;
}

.bw-penguin-stage .dex-note {
  margin: 10px 0 0;
  color: #6b778c;
  font-size: 13px;
}

.bw-penguin-stage .dex-item {
  align-items: flex-start;
  border-bottom: 1px solid #eef2f8;
}

.bw-penguin-stage .dex-item img {
  flex-basis: 56px;
  width: 56px;
  height: 56px;
}

.bw-penguin-stage .dex-item b {
  display: block;
  font-size: 16px;
}

.bw-penguin-stage .dex-item small {
  display: block;
  color: #2a5db0;
  font-size: 12px;
  font-weight: 700;
}

.bw-penguin-stage .dex-item p {
  margin: 2px 0 0;
  font-size: 14px;
}

/* 아직 못 만난 건 실루엣 */
.bw-penguin-stage .dex-item.locked img {
  filter: brightness(0) opacity(0.3);
}

.bw-penguin-stage .dex-item.locked b {
  color: #9aa6b8;
}

/* 방명록 바로 위 한 줄 */
.bw-penguin-guest {
  width: min(960px, calc(100% - 1rem));
  margin: 1.5rem auto 0.5rem;
  color: var(--bw-muted);
  font-size: 0.95rem;
  text-align: center;
}

/* ── 설명 본문 ── */
.bw-penguin-help {
  padding: 1rem 1.1rem;
  border: 1px solid var(--bw-border);
  border-radius: 0.9rem;
  background: var(--bw-surface);
  color: var(--bw-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.bw-penguin-help h2 {
  margin: 0 0 0.4rem;
  color: var(--bw-text);
  font-size: 1rem;
}

.bw-penguin-help h2 + p,
.bw-penguin-help h2 + ol,
.bw-penguin-help h2 + ul {
  margin-top: 0;
}

.bw-penguin-help p + h2,
.bw-penguin-help ol + h2,
.bw-penguin-help ul + h2 {
  margin-top: 1rem;
}

.bw-penguin-help ul {
  margin: 0;
  padding-left: 1.2rem;
}


.bw-penguin-help ol {
  padding-left: 1.2rem;
}

.bw-penguin-help li + li {
  margin-top: 0.3rem;
}

.bw-penguin-help strong {
  color: var(--bw-text);
}

@media (min-width: 640px) {
  .bw-penguin-stage {
    /* 넓은 화면(태블릿·PC)은 세로 여유가 있어 더 크게. 여기도 dvh 로. */
    height: min(80vh, 820px);
    height: min(80dvh, 820px);
  }
}
