/* 우리 집 놀이터 — 런처 스타일.
   별숲 아카데미의 색을 그대로 빌려 와서 앱을 열었을 때 이질감이 없게 했다. */

:root {
  --cream: #fbf7ee;
  --paper: #fffdf7;
  --ink: #2b3a30;
  --ink-soft: #6b7d70;
  --forest: #4a8f63;
  --forest-deep: #2c5e3f;
  --star: #ffc94d;
  --radius: 22px;
  --shadow: 0 6px 24px rgba(22, 53, 31, 0.1), 0 2px 6px rgba(22, 53, 31, 0.06);
  --font: "Pretendard Variable", "Malgun Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  /* 터치 화면에서 꾹 눌렀을 때 뜨는 말풍선·돋보기 끄기 (iOS 전용이지만 두어도 해롭지 않다) */
  -webkit-touch-callout: none;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  overflow: hidden;
}

/* hidden 속성은 무조건 이겨야 한다.
   브라우저가 주는 `[hidden] { display: none }`은 기본 스타일시트라
   내가 쓴 클래스 규칙(.timeup { display: flex })에 그냥 진다.
   그래서 숨겼다고 생각한 차단 화면이 앱 위에 계속 떠 있었다. */
[hidden] {
  display: none !important;
}

/* ---------- 런처 ---------- */
body.launcher {
  display: flex;
  flex-direction: column;
  padding: 20px 26px 16px;
  background:
    radial-gradient(1200px 600px at 80% -10%, #dff0e4 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #f4ecd8 0%, transparent 55%),
    var(--cream);
}

.launcher header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.launcher h1 {
  font-size: 30px;
  color: var(--forest-deep);
  margin: 0;
  letter-spacing: -0.5px;
}
.daily-limit-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.14);
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
  user-select: none;
  animation: pillPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.daily-limit-pill strong {
  font-size: 19px;
  font-weight: 900;
  color: #b45309;
  text-decoration: underline;
  text-decoration-color: rgba(180, 83, 9, 0.3);
  text-underline-offset: 3px;
}
@keyframes pillPop {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.child-pill {
  border: 1px solid rgba(44, 94, 63, 0.2);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--paper);
  color: var(--forest-deep);
  box-shadow: 0 2px 6px rgba(22, 53, 31, 0.08);
  transition: transform 0.08s ease, background 0.15s ease;
}
.child-pill:active {
  transform: scale(0.95);
  background: #eef6f0;
}
.greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hello {
  font-size: 20px;
  color: var(--ink-soft);
  margin: 6px 0 16px;
}

/* 별숲 공부 연동 배너 */
.study-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  animation: bannerFadeIn 0.3s ease;
}
@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.study-banner.parent-unlocked {
  background: #edf7f1;
  border: 1.5px solid #a7ddba;
  color: #1a5732;
}
.study-banner.completed {
  background: #e8f5e9;
  border: 1.5px solid #81c784;
  color: #1b5e20;
}

.study-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.study-banner-icon {
  font-size: 32px;
  line-height: 1;
}
.study-banner-text strong {
  font-size: 16px;
  display: block;
}
.study-banner-text p {
  margin: 3px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.btn-relock {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(44, 94, 63, 0.12);
  color: #1a5732;
  cursor: pointer;
  transition: background 0.1s ease;
}
.btn-relock:active {
  background: rgba(44, 94, 63, 0.22);
}

.ghost-key {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  background: rgba(44, 94, 63, 0.08);
  color: var(--forest-deep);
  transition: transform 0.08s ease, background 0.1s ease;
}
.ghost-key:active {
  transform: scale(0.92);
  background: rgba(44, 94, 63, 0.16);
}

/* ========================================================
   [1단계] 오늘의 별숲 퀘스트 영역
   ======================================================== */
.quest-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  overflow-y: auto;
  align-items: center;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 4px 0 16px;
}

.quest-card {
  width: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f4faf6 100%);
  border: 2px solid #84c99b;
  border-radius: 26px;
  box-shadow: 0 10px 30px rgba(44, 94, 63, 0.12), 0 2px 8px rgba(44, 94, 63, 0.06);
  padding: 30px 24px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.quest-card.shake {
  animation: questShake 0.4s ease-in-out;
}
@keyframes questShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.quest-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef6f0;
  color: #2c5e3f;
  font-weight: 800;
  font-size: 16px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(44, 94, 63, 0.2);
  margin-bottom: 12px;
}

.quest-title {
  font-size: 25px;
  font-weight: 800;
  color: #2c5e3f;
  margin: 0 0 18px;
  line-height: 1.35;
}

.quest-progress-wrap {
  width: 100%;
  max-width: 440px;
  margin-bottom: 22px;
}
.quest-progress-bar {
  height: 13px;
  background: #e3ede6;
  border-radius: 999px;
  overflow: hidden;
}
.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a8f63 0%, #f59e0b 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
}
.quest-progress-text {
  font-size: 14px;
  font-weight: 700;
  color: #3b7450;
  margin-top: 6px;
}

.quest-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
  width: 100%;
}

.quest-subj {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.1s ease;
}
.quest-subj.done {
  background: #e8f5e9;
  border: 1.5px solid #81c784;
  color: #1b5e20;
}
.quest-subj.pending {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  color: #92400e;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.12);
}

.subj-icon {
  font-size: 17px;
  line-height: 1;
}
.subj-name {
  font-size: 15px;
}
.subj-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 800;
}
.quest-subj.done .subj-tag {
  background: #c8e6c9;
  color: #1b5e20;
}
.quest-subj.pending .subj-tag {
  background: #fef3c7;
  color: #b45309;
}

.btn-quest-start {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #2c5e3f 0%, #3d8355 100%);
  color: #ffffff;
  text-decoration: none;
  font-size: 19px;
  font-weight: 800;
  padding: 15px 34px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(44, 94, 63, 0.32);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.btn-quest-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(44, 94, 63, 0.42);
}
.btn-quest-start:active {
  transform: translateY(2px) scale(0.98);
}
.btn-star-icon {
  font-size: 22px;
  line-height: 1;
}

.quest-hint {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 16px 0 0;
  font-weight: 500;
}

/* 놀이터 게임 잠금 선반 */
.locked-shelf {
  width: 100%;
  background: rgba(255, 253, 247, 0.85);
  border: 1.5px dashed rgba(44, 94, 63, 0.25);
  border-radius: 20px;
  padding: 16px 20px;
  box-sizing: border-box;
}

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.shelf-header h3 {
  font-size: 16px;
  margin: 0;
  color: var(--forest-deep);
  font-weight: 800;
}
.shelf-badge {
  font-size: 12px;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #fde68a;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.shelf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid rgba(44, 94, 63, 0.1);
  cursor: pointer;
  opacity: 0.85;
  transition: transform 0.08s ease, background 0.1s ease;
}
.shelf-item:hover {
  opacity: 1;
  transform: scale(1.02);
  background: #ffffff;
}
.shelf-item:active {
  transform: scale(0.96);
}
.shelf-item-emoji {
  font-size: 26px;
  line-height: 1;
  filter: grayscale(0.25);
}
.shelf-item-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.shelf-item-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.shelf-item-sub {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 1px;
}

.tiles {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  align-content: start;
  overflow-y: auto;
  padding-bottom: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 190px;
  padding: 26px 18px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid rgba(44, 94, 63, 0.1);
  border-bottom: 5px solid var(--tone, var(--forest));
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.09s ease, box-shadow 0.16s ease;
}
.tile:active {
  transform: translateY(3px) scale(0.985);
  box-shadow: 0 3px 12px rgba(22, 53, 31, 0.12);
}
.tile-emoji {
  font-size: 68px;
  line-height: 1;
}
.tile-name {
  font-size: 27px;
  font-weight: 700;
  margin-top: 8px;
}
.tile-sub {
  font-size: 15px;
  color: var(--ink-soft);
}

/* 하루 몫 — 남은 양은 조용히, 다 쓴 것은 확실하게 */
.tile-left {
  margin-top: 8px;
  font-size: 14px;
  color: var(--forest);
}
.tile-left.low {
  color: #c2543c;
  font-weight: 700;
}
.tile.done {
  opacity: 0.5;
  cursor: default;
  border-bottom-color: #b9c3bb;
  box-shadow: none;
}
.tile.done:active {
  transform: none;
}
.tile.done .tile-emoji {
  filter: grayscale(1);
}
.tile.done .tile-left {
  color: var(--ink-soft);
}

/* 공부 완료 전 잠긴 타일 */
.tile.study-locked {
  background: #fdfbf7;
  border-bottom-color: #e0b480 !important;
  opacity: 0.85;
}
.tile.study-locked:active {
  transform: translateY(2px) scale(0.99);
}
.tile.study-locked .study-badge {
  color: #b05c10 !important;
  font-weight: 700;
}

button.tile {
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

/* 티켓으로 지금 열 수 있는 게임 */
.tile.pickable {
  border: 2px dashed #4a8f63;
  border-bottom: 5px solid #4a8f63;
  background: #fbfdfc;
  cursor: pointer;
  position: relative;
  animation: pickablePulse 2s infinite ease-in-out;
}
@keyframes pickablePulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(74, 143, 99, 0.15); }
  50% { box-shadow: 0 8px 24px rgba(74, 143, 99, 0.28); }
}
.tile.pickable:active {
  transform: translateY(3px) scale(0.985);
}
.tile.pickable .tile-left {
  color: #1a5732;
  font-weight: 800;
  background: #eaf6ee;
  padding: 5px 12px;
  border-radius: 999px;
}

/* 라운드가 더 필요하거나 오늘 3개 한도를 채워 잠긴 게임 */
.tile.round-locked {
  opacity: 0.58;
  cursor: pointer;
  border-bottom-color: #cbd5e1;
  background: #f8fafc;
}
.tile.round-locked:active {
  transform: scale(0.98);
}
.tile.round-locked .tile-emoji {
  filter: grayscale(0.8);
}
.tile.round-locked .tile-left {
  color: #64748b;
  font-weight: 600;
}

/* 팝업 모달 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 53, 31, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  padding: 20px;
}
.modal-card {
  text-align: center;
  padding: 34px 30px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  max-width: 420px;
  width: 100%;
  animation: bannerFadeIn 0.2s ease;
}
.modal-emoji { font-size: 60px; line-height: 1; }
.modal-card h2 { font-size: 23px; color: var(--forest-deep); margin: 12px 0 8px; }
.modal-card p { font-size: 15px; color: var(--ink-soft); margin: 0 0 14px; line-height: 1.5; }
.modal-waiting {
  font-size: 14px;
  font-weight: 700;
  color: var(--forest);
  background: #edf7f0;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.pin-input-row {
  margin: 18px 0;
  display: flex;
  justify-content: center;
}
.pin-input-row input {
  font-size: 30px;
  letter-spacing: 14px;
  text-align: center;
  width: 170px;
  padding: 10px 14px;
  border: 2px solid #84c99b;
  border-radius: 14px;
  outline: none;
  background: #fdfdfd;
  color: var(--forest-deep);
  font-family: inherit;
}
.pin-input-row input:focus {
  border-color: #2c5e3f;
  box-shadow: 0 0 0 3px rgba(44, 94, 63, 0.15);
}
.pin-error {
  color: #c2543c;
  font-size: 14px;
  font-weight: 700;
  margin: -8px 0 16px;
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c5e3f;
  color: #ffffff;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(22, 53, 31, 0.28);
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.fade-in {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

/* 사람 바꾸기 모달 */
.switch-modal-card {
  max-width: 440px !important;
}
.switch-accounts-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 16px 0 20px;
  flex-wrap: wrap;
}
.switch-acc-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 18px;
  border-radius: 18px;
  background: #fdfbf7;
  border: 2px solid rgba(44, 94, 63, 0.15);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  min-width: 90px;
}
.switch-acc-card:hover {
  transform: translateY(-2px);
  border-color: #4a8f63;
}
.switch-acc-card.selected {
  border-color: #2c5e3f;
  background: #eef6f0;
  box-shadow: 0 4px 12px rgba(44, 94, 63, 0.2);
  transform: scale(1.05);
}
.switch-acc-art {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 6px;
}
.switch-acc-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--forest-deep);
}
.switch-acc-current {
  font-size: 11px;
  font-weight: 800;
  color: #4a8f63;
  background: #dff0e4;
  padding: 2px 6px;
  border-radius: 999px;
  margin-top: 4px;
}
.switch-pin-prompt {
  font-size: 15px;
  font-weight: 700;
  color: var(--forest-deep);
  margin: 12px 0 6px;
}
.pin-hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: -6px 0 12px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-ghost-modal {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: rgba(44, 94, 63, 0.08);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost-modal:active {
  background: rgba(44, 94, 63, 0.16);
}

.timeup-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.btn-sub {
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  background: rgba(44, 94, 63, 0.1);
  color: var(--forest-deep);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-sub:active {
  background: rgba(44, 94, 63, 0.2);
}

.launcher footer {
  padding-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: right;
}
.err {
  color: #c2543c;
  font-size: 18px;
}

/* ---------- 앱 껍데기 ---------- */
body.shell {
  display: flex;
  flex-direction: column;
  background: var(--cream);
}

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 12px;
  background: var(--tone, var(--forest));
  color: #fff;
  box-shadow: 0 2px 10px rgba(22, 53, 31, 0.18);
  z-index: 2;
}
.home {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}
.home:active {
  background: rgba(255, 255, 255, 0.4);
}
.bar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  opacity: 0.95;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bar-left {
  font-size: 15px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  white-space: nowrap;
}
.bar-left.low {
  background: rgba(255, 255, 255, 0.92);
  color: #c2543c;
  font-weight: 700;
}

/* 하루 몫을 다 썼을 때 덮는 화면 */
.timeup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef4ef, #dfe9e2);
  z-index: 10;
}
.timeup-card {
  text-align: center;
  padding: 40px 44px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  max-width: 460px;
}
.timeup-emoji { font-size: 74px; line-height: 1; }
.timeup-card h2 { font-size: 30px; color: var(--forest-deep); margin: 14px 0 8px; }
.timeup-card p { font-size: 17px; color: var(--ink-soft); margin: 0 0 24px; line-height: 1.5; }
.btn-big {
  display: inline-block;
  padding: 15px 32px;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}
.btn-big:active { transform: translateY(2px); }

/* 앱은 남은 자리를 전부 쓴다 */
#frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--cream);
}

.ghost {
  border: 0;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}
.launcher .ghost {
  background: rgba(44, 94, 63, 0.1);
  color: var(--forest-deep);
}

/* 세로로 짧은 화면(태블릿 가로 등)에서는 막대를 더 얇게 */
@media (max-height: 620px) {
  .bar { height: 40px; }
  .tile { min-height: 150px; }
  .tile-emoji { font-size: 52px; }
}
