/* 브레인스톤 놀이터 — 화면 놀이 4가지 전용 디자인 (brainstone.html에서만 불러요)
   색은 css/brainstone.css의 .bs 변수(--bs-ink, --lv1~3 등)를 그대로 써요. */

.bs-play { background: linear-gradient(180deg, #FFF 0%, var(--bs-cream) 100%); }
.bs-play .pg-b { --cm: 15px; height: calc(var(--h) * var(--cm)); width: auto; filter: drop-shadow(0 5px 5px rgba(60,40,10,0.2)); }

/* 놀이 고르기 탭 */
.pg-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.pg-tabs button {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 6px 10px;
  border-radius: 16px; border: 2px solid #EAD9BF; background: #fff; cursor: pointer;
  font-family: var(--bs-font); font-size: 17px; color: var(--bs-ink);
}
.pg-tabs button span { font-size: 22px; }
.pg-tabs button[aria-pressed="true"] { background: var(--bs-ink); border-color: var(--bs-ink); color: #fff; box-shadow: 0 6px 14px rgba(92,74,34,0.25); }

.pg-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pg-modes { display: inline-flex; background: #F1E8DA; border-radius: 999px; padding: 3px; }
.pg-modes[hidden] { display: none; }
.pg-modes button { border: 0; background: none; border-radius: 999px; min-height: 40px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--bs-ink); cursor: pointer; }
.pg-modes button[aria-pressed="true"] { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.pg-mute { margin-left: auto; border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--color-text-sub); min-height: 40px; cursor: pointer; }

/* 놀이 무대 */
.pg-stage {
  background: #fff; border-radius: 24px; padding: 18px 12px 22px; min-height: 380px; text-align: center;
  box-shadow: 0 10px 30px rgba(92,74,34,0.10); border: 1px solid #F0E4D2;
}
.pg-stage.pg-in { animation: pg-in 0.3s ease; }
@keyframes pg-in { from { opacity: 0; transform: translateY(8px); } }
.pg-q { font-size: 15px; color: #4A4A4A; margin-bottom: 12px; line-height: 1.5; }
.pg-lv { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; vertical-align: 1px; }
.pg-lv.lv1, .pg-lvbtn.lv1 { background: var(--lv1); color: var(--lv1-ink); }
.pg-lv.lv2, .pg-lvbtn.lv2 { background: var(--lv2); color: var(--lv2-ink); }
.pg-lv.lv3, .pg-lvbtn.lv3 { background: var(--lv3); color: var(--lv3-ink); }

.pg-row {
  display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; gap: 4px 6px;
  min-height: 150px; padding: 14px 6px 10px; margin: 0 -4px 14px; border-radius: 18px;
  background: repeating-linear-gradient(100deg, #F7EBD8 0 10px, #F3E4CD 10px 22px); /* 원목 판 */
}
.pg-cell { display: inline-flex; align-items: flex-end; }
.pg-slot {
  display: inline-grid; place-items: center; min-width: 52px; min-height: 72px; padding: 2px;
  border: 3px dashed var(--bs-accent); border-radius: 14px; background: rgba(255,255,255,0.7);
  font-family: var(--bs-font); font-size: 28px; color: var(--bs-accent); cursor: pointer;
}
button.pg-slot { font: inherit; font-family: var(--bs-font); font-size: 20px; }
.pg-slot.filled { border-style: solid; border-color: #E6D6BC; background: #fff; }
.pg-slot.ok { border: 3px solid #5E9B57; background: #EEF7EC; }
.pg-slot.no { border: 3px solid #D9705A; background: #FDEFEC; }
.pg-drop { animation: pg-drop 0.45s cubic-bezier(.3,1.5,.6,1); }
@keyframes pg-drop { from { transform: translateY(-50px); opacity: 0; } }

.pg-opts { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.pg-opt {
  display: grid; place-items: center; width: 84px; height: 110px; border-radius: 18px; cursor: pointer;
  background: #FFF9F0; border: 2px solid #EAD9BF; transition: transform 0.12s, box-shadow 0.12s;
}
.pg-opts.many .pg-opt { width: 68px; height: 96px; }
.pg-opt:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(92,74,34,0.15); }
.pg-opt:active:not(:disabled) { transform: scale(0.95); }
.pg-opt .pg-b, .pg-slot .pg-b { max-height: 86%; }
.pg-slot .pg-b { max-height: 120px; }
.pg-opt.used { opacity: 0.3; }
.pg-opt.hint { border-color: #5E9B57; background: #EEF7EC; animation: pg-wiggle 0.5s 2; }
.pg-opt:disabled { cursor: default; }
@keyframes pg-wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

.pg-msg { margin-top: 14px; font-family: var(--bs-font); font-size: 22px; animation: pg-in 0.25s ease; }
.pg-msg.ok { color: #3F7A39; }
.pg-msg.no { color: #B5543F; font-size: 19px; }
.pg-answer { min-height: 0; margin-top: 10px; background: #F5F0E8; transform: scale(0.85); }

/* 둘이서 */
.pg-turn { display: flex; justify-content: center; gap: 8px; margin-bottom: 6px; }
.pg-turn span { padding: 6px 14px; border-radius: 999px; background: #F1E8DA; font-weight: 700; font-size: 14px; color: #8A7656; }
.pg-turn span.on { background: var(--lv1); color: var(--lv1-ink); box-shadow: 0 3px 8px rgba(228,185,94,0.5); }
.pg-who { font-family: var(--bs-font); font-size: 18px; color: var(--bs-ink); margin-bottom: 6px; }

/* 10초 기억 */
.pg-timer { height: 10px; border-radius: 999px; background: #F1E8DA; overflow: hidden; margin: 0 8px 4px; }
.pg-timer span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--lv2), var(--lv1)); }
.pg-count { font-family: var(--bs-font); font-size: 34px; color: var(--bs-accent); line-height: 1; margin-bottom: 6px; }

/* 그림자 퀴즈 */
.pg-shadow { display: grid; place-items: end center; min-height: 190px; padding: 10px; margin-bottom: 14px; border-radius: 18px; background: radial-gradient(circle at 50% 80%, #F3E4CD, #FFF9F0 70%); }
.bs-play .pg-shadow .pg-b { --cm: 34px; max-height: 210px; }
.pg-sil { filter: brightness(0) opacity(0.78) !important; transition: filter 0.5s ease; }
.pg-sil.show { filter: drop-shadow(0 6px 6px rgba(60,40,10,0.2)) !important; animation: pg-drop 0.4s ease; }
.pg-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pg-name {
  min-height: 54px; border-radius: 16px; border: 2px solid #EAD9BF; background: #FFF9F0; cursor: pointer;
  font-family: var(--bs-font); font-size: 19px; color: var(--bs-ink);
}
.pg-name.ok { background: #EEF7EC; border-color: #5E9B57; color: #3F7A39; }
.pg-name.no { background: #FDEFEC; border-color: #D9705A; color: #B5543F; }

/* 오늘의 카드 */
.pg-levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.pg-lvbtn { min-height: 48px; border-radius: 14px; border: 0; cursor: pointer; font-family: var(--bs-font); font-size: 17px; background: #F1E8DA; color: var(--bs-ink); }
.pg-lvbtn:active { transform: scale(0.96); }
.pg-flip { perspective: 900px; width: 190px; margin: 4px auto 10px; aspect-ratio: 90 / 130; }
.pg-flip-in { position: relative; width: 100%; height: 100%; transition: transform 0.55s cubic-bezier(.3,1.2,.5,1); transform-style: preserve-3d; }
.pg-flip.on .pg-flip-in { transform: rotateY(180deg); }
.pg-flip img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; backface-visibility: hidden; box-shadow: 0 10px 24px rgba(60,40,10,0.18); }
.pg-front { transform: rotateY(180deg); }
.pg-mission { font-size: 16px; line-height: 1.6; min-height: 52px; padding: 0 6px; }
.pg-mission b { color: var(--bs-accent); }
.pg-had { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #F1E8DA; color: #8A7656; }

/* 결과 */
.pg-result { padding: 6px 4px; }
.pg-stars { font-size: 44px; color: #E9A23B; letter-spacing: 4px; line-height: 1.1; animation: pg-pop 0.5s cubic-bezier(.3,1.6,.6,1); }
.pg-stars span { color: #EDE3D3; }
@keyframes pg-pop { from { transform: scale(0.3); opacity: 0; } }
.pg-result h3 { font-family: var(--bs-font); font-weight: 400; font-size: 28px; color: var(--bs-ink); margin-top: 6px; }
.pg-final { color: #6B5B40; margin-top: 4px; }
.pg-new { margin-top: 10px; display: inline-block; padding: 6px 14px; border-radius: 999px; background: #FFF3D6; color: #8A5A12; }
.pg-real { display: flex; gap: 12px; align-items: center; text-align: left; margin: 16px auto 4px; max-width: 360px; padding: 12px; border-radius: 16px; background: var(--bs-cream); }
.pg-real img { width: 70px; border-radius: 8px; box-shadow: 0 4px 10px rgba(60,40,10,0.15); }
.pg-real p { font-size: 13.5px; line-height: 1.5; color: #4A4A4A; }
.pg-real b { display: block; font-family: var(--bs-font); font-weight: 400; font-size: 17px; color: var(--bs-ink); }
.pg-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pg-actions .btn-primary { background: var(--bs-ink); }
.pg-actions .btn-secondary { color: var(--bs-ink); border-color: var(--bs-ink); background: #fff; }
.pg-actions [hidden] { display: none; }

/* 도장판 */
.pg-board { margin-top: 18px; padding: 18px; border-radius: 22px; background: #fff; border: 2px dashed #E6D3B3; }
.pg-board-head { display: flex; justify-content: space-between; align-items: center; }
.pg-board .h3 { font-family: var(--bs-font); font-weight: 400; font-size: 22px; color: var(--bs-ink); }
.pg-board .h3 span { font-size: 15px; color: #8A7656; margin-left: 6px; }
.pg-board .h3 b { color: var(--bs-accent); font-weight: 400; }
.pg-board > .sub { font-size: 13.5px; margin: 4px 0 12px; }
.pg-reset { border: 0; background: none; color: #A8977A; font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; min-height: 36px; }
.pg-stamps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.pg-stamp {
  aspect-ratio: 1 / 1; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  border: 2px dashed; color: #B9A88A;
}
.pg-stamp.lv1 { border-color: var(--lv1); } .pg-stamp.lv2 { border-color: var(--lv2); } .pg-stamp.lv3 { border-color: var(--lv3); }
.pg-stamp.got { border-style: solid; font-size: 18px; }
.pg-stamp.got.lv1 { background: #FBF0D6; } .pg-stamp.got.lv2 { background: #EAF0E5; } .pg-stamp.got.lv3 { background: #E7EEF6; }
.pg-stamp.fresh { animation: pg-stampin 0.5s cubic-bezier(.3,1.8,.6,1); }
@keyframes pg-stampin { from { transform: scale(2.2) rotate(-20deg); opacity: 0; } }
.pg-medals { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pg-medal { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; background: #F3EEE6; color: #A8977A; }
.pg-medal.got { background: #FFF3D6; color: #8A5A12; font-weight: 700; }
.pg-note { font-size: 12.5px; color: #A8977A; margin-top: 10px; }
.pg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (min-width: 720px) {
  .pg-tabs { grid-template-columns: repeat(4, 1fr); }
  .pg-stage { padding: 26px 24px 30px; min-height: 440px; }
  .bs-play .pg-b { --cm: 20px; }
  .pg-slot { min-width: 70px; min-height: 96px; }
  .pg-opt { width: 104px; height: 140px; }
  .pg-opts.many .pg-opt { width: 88px; height: 124px; }
  .pg-names { grid-template-columns: repeat(4, 1fr); }
  .pg-levels { grid-template-columns: repeat(4, 1fr); }
  .pg-flip { width: 230px; }
  .pg-stamps { grid-template-columns: repeat(12, 1fr); }
}
@media (min-width: 1024px) {
  .bs-play .container { max-width: 880px; }
}
@media (prefers-reduced-motion: reduce) {
  .pg-stage.pg-in, .pg-drop, .pg-stars, .pg-stamp.fresh, .pg-opt.hint, .pg-sil.show { animation: none; }
  .pg-flip-in { transition: none; }
}
