/* ============ Kishu Play app shell ============ */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;800;900&display=swap');

:root {
  --sky: #E8F4FD;
  --sky-deep: #87CEEB;
  --green: #5DBB63;
  --green-dark: #4aaa54;
  --sun: #FFD700;
  --sunlight: #FFE566;
  --purple: #3C3489;
  --ink: #333;
  --muted: #7a8699;
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 6px 20px rgba(43, 78, 128, 0.10);
  --nav-h: 64px;
  --ad-h: 0px; /* height of the native AdMob banner (set from app.js) */
  --display: 'Fredoka One', 'Comic Sans MS', cursive;
  --body-font: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--body-font);
  background: var(--sky);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
body.has-nav { padding-bottom: calc(var(--nav-h) + 14px + var(--ad-h) + env(safe-area-inset-bottom, 0px)); }

/* ---------- top header ---------- */
.app-header {
  background: linear-gradient(180deg, #87CEEB 0%, #a9dcf3 100%);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 30px;
  position: relative;
  overflow: hidden;
}
.app-header .sun {
  position: absolute; top: 10px; right: 22px;
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle, var(--sunlight) 55%, var(--sun) 100%);
  box-shadow: 0 0 0 12px rgba(255, 215, 0, 0.16), 0 0 0 22px rgba(255, 215, 0, 0.07);
  animation: sunPulse 3.2s ease-in-out infinite;
}
@keyframes sunPulse {
  0%, 100% { box-shadow: 0 0 0 12px rgba(255,215,0,0.16), 0 0 0 22px rgba(255,215,0,0.07); }
  50%      { box-shadow: 0 0 0 17px rgba(255,215,0,0.20), 0 0 0 30px rgba(255,215,0,0.09); }
}
.app-header .cloud {
  position: absolute; background: #fff; border-radius: 40px; opacity: .8;
  width: 70px; height: 22px; top: 14px; left: -90px;
  animation: floatCloud 22s linear infinite;
}
.app-header .cloud::before {
  content: ''; position: absolute; background: #fff; border-radius: 50%;
  width: 30px; height: 30px; top: -14px; left: 10px;
}
.app-header .cloud.c2 { top: 44px; animation-duration: 30s; animation-delay: 6s; width: 54px; height: 17px; }
@keyframes floatCloud { from { left: -100px; } to { left: 110%; } }
.brand {
  font-family: var(--display);
  font-size: clamp(26px, 6.5vw, 40px);
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  position: relative; z-index: 1;
}
.brand span { color: var(--sunlight); }
.brand-sub {
  font-size: clamp(12px, 3vw, 15px);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
  margin-top: 2px;
  position: relative; z-index: 1;
}
.header-links { position: absolute; right: 84px; top: 22px; z-index: 2; display: none; gap: 10px; }
.header-links a {
  font-family: var(--display); font-size: 14px; color: #fff; text-decoration: none;
  background: rgba(255, 255, 255, 0.22); padding: 8px 16px; border-radius: 40px;
}
.header-links a:hover { background: rgba(255, 255, 255, 0.35); }

.grass-strip {
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  height: 26px; margin-top: -14px;
  border-radius: 50% 50% 0 0 / 16px 16px 0 0;
  position: relative; z-index: 1;
}

/* ---------- layout ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 14px 14px 30px; }

/* ---------- opening animation ---------- */
/* Only the app shows this (js/app.js adds .booting); the website paints its
   content straight away. */
.boot {
  position: fixed; inset: 0; z-index: 200;
  background: var(--sky);
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  opacity: 1;
}
html.booting .boot { display: flex; }
html.booting body { overflow: hidden; }
.boot-logo {
  width: 140px; height: 140px; display: block;
  filter: drop-shadow(0 10px 24px rgba(43, 78, 128, .22));
  animation: bootPop .62s cubic-bezier(.2, 1.3, .4, 1) both;
}
.boot-word {
  font-family: var(--display); font-size: 25px; color: var(--purple);
  animation: bootRise .5s .18s ease-out both;
}
.boot-dots { display: flex; gap: 7px; animation: bootRise .5s .28s ease-out both; }
.boot-dots i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  animation: bootDot 1s infinite ease-in-out;
}
.boot-dots i:nth-child(2) { animation-delay: .15s; background: var(--sun); }
.boot-dots i:nth-child(3) { animation-delay: .3s; background: var(--sky-deep); }
.boot.out { animation: bootOut .42s ease-in forwards; }
@keyframes bootPop {
  from { opacity: 0; transform: scale(.55); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes bootRise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes bootDot {
  0%, 100% { transform: translateY(0); opacity: .45; }
  50%      { transform: translateY(-7px); opacity: 1; }
}
@keyframes bootOut {
  to { opacity: 0; transform: scale(1.06); visibility: hidden; }
}

/* ---------- announcement bar (admin → Settings) ---------- */
.hidden { display: none !important; }
.announce {
  border-radius: 16px; padding: 11px 14px; margin-bottom: 12px;
  font-size: 13.5px; font-weight: 800; line-height: 1.45;
  display: flex; align-items: center; gap: 10px;
  background: #e8f1fb; color: #1e3a5f; border: 2px solid #c9def5;
}
.announce.celebrate { background: linear-gradient(135deg, #fff8e1, #ffeeb0); color: #6d4c00; border-color: #ffe08a; }
.announce.warn { background: #fff1e6; color: #8a3b00; border-color: #ffcfa8; }

/* ---------- featured game (admin → Settings) ---------- */
.featured {
  display: flex; align-items: center; gap: 14px;
  background: #fff;
  background: linear-gradient(135deg, #fff 0%, color-mix(in srgb, var(--accent, var(--green)) 18%, #fff) 100%);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 14px; text-decoration: none; color: var(--ink);
  position: relative; overflow: hidden;
  transition: transform .13s ease, box-shadow .13s ease;
}
.featured:active { transform: scale(0.98); }
.featured { animation: cardIn .5s ease-out both; }
.announce { animation: cardIn .45s ease-out both; }
@media (hover: hover) { .featured:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(43, 78, 128, 0.16); } }
.featured .f-ic {
  width: 72px; height: 72px; border-radius: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  background: #eef4fa;
  background: color-mix(in srgb, var(--accent, var(--green)) 22%, #fff);
  animation: iconBob 2.6s ease-in-out infinite;
}
.featured .f-lbl { font-size: 11.5px; font-weight: 900; letter-spacing: .4px; color: var(--accent, var(--green)); text-transform: uppercase; }
.featured .f-t { font-family: var(--display); font-size: 21px; line-height: 1.15; margin: 2px 0; }
.featured .f-d { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.featured .f-go {
  margin-left: auto; flex-shrink: 0;
  font-family: var(--display); font-size: 15px; color: #fff;
  background: var(--accent, var(--green)); padding: 10px 18px; border-radius: 40px;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
@media (max-width: 480px) { .featured .f-go { display: none; } }

/* ---------- app update prompt (admin → Settings → min app version) ---------- */
.update-bar {
  position: fixed; left: 12px; right: 12px; z-index: 60;
  bottom: calc(var(--nav-h) + 14px + var(--ad-h) + env(safe-area-inset-bottom, 0px));
  background: var(--purple); color: #fff; border-radius: 16px; padding: 12px 14px;
  font-weight: 800; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 10px;
}
.update-bar .u-txt { flex: 1; }
.update-bar a { color: var(--purple); background: var(--sunlight); text-decoration: none; padding: 7px 14px; border-radius: 30px; font-family: var(--display); font-size: 13px; }
.update-bar button { background: none; border: none; color: rgba(255,255,255,.8); font-size: 20px; cursor: pointer; line-height: 1; }

/* ---------- category chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
/* The row scrolls by swipe on a phone, but a mouse has no handle: the scrollbar
   is hidden and a vertical wheel does not move a horizontal scroller, so on a
   laptop the row simply looked stuck. app.js maps the wheel and adds
   click-and-drag; these fades are the visual half — whichever edge still has
   chips behind it dissolves, so the row reads as "there is more this way". */
.chips.can-drag { cursor: grab; }
.chips.dragging { cursor: grabbing; }
.chips.more-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent 100%);
          mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent 100%);
}
.chips.more-left {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 32px);
          mask-image: linear-gradient(to right, transparent 0, #000 32px);
}
.chips.more-left.more-right {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 32px, #000 calc(100% - 32px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 32px, #000 calc(100% - 32px), transparent 100%);
}
.chip {
  flex: 0 0 auto;
  font-family: var(--display); font-size: 14px;
  color: var(--purple); background: #fff;
  border: 2px solid transparent; border-radius: 40px;
  padding: 9px 18px; cursor: pointer;
  box-shadow: 0 3px 10px rgba(43, 78, 128, 0.08);
  transition: transform .12s, background .15s, color .15s;
  user-select: none; -webkit-user-select: none;
}
.chip:active { transform: scale(0.94); }
.chip.on { background: var(--green); color: #fff; animation: chipPop .28s ease-out; }
@keyframes chipPop {
  0%   { transform: scale(.9); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- games grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 520px)  { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px)  { .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 1060px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.gcard {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 10px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  transition: transform .13s ease, box-shadow .13s ease;
  min-height: 158px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.gcard:active { transform: scale(0.95); }
/* Cards fly in on a short stagger (js/app.js sets --i per card). */
.gcard.enter { animation: cardIn .42s cubic-bezier(.2, .9, .3, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
/* The tapped card lifts away as the player opens. */
.gcard.leaving { animation: cardLeave .26s ease-in forwards; }
@keyframes cardLeave {
  to { opacity: 0; transform: scale(1.12); }
}
@media (hover: hover) {
  .gcard:hover { transform: translateY(-5px); box-shadow: 0 14px 30px rgba(43, 78, 128, 0.16); }
}
.gcard::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: var(--accent, var(--green));
}
.gicon {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; margin-bottom: 8px;
  background: #eef4fa;
  background: color-mix(in srgb, var(--accent, var(--green)) 14%, #fff);
  animation: iconBob 2.6s ease-in-out infinite;
}
.gcard:nth-child(2n) .gicon { animation-delay: .5s; }
.gcard:nth-child(3n) .gicon { animation-delay: 1s; }
@keyframes iconBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.gtitle { font-family: var(--display); font-size: 16px; line-height: 1.15; margin-bottom: 3px; }
.gdesc { font-size: 11.5px; font-weight: 700; color: var(--muted); line-height: 1.35; }
.gbadge {
  margin-top: auto; padding-top: 8px;
  font-size: 10.5px; font-weight: 900; letter-spacing: .3px;
  color: var(--accent, var(--green));
}
.new-flag {
  position: absolute; top: 10px; right: -26px;
  background: #FF5722; color: #fff;
  font-family: var(--display); font-size: 10px;
  padding: 3px 28px; transform: rotate(38deg);
}

/* loading skeleton */
.skel { pointer-events: none; }
.skel .gicon { background: #e4edf5; animation: shimmer 1.2s ease-in-out infinite; }
.skel .bar { height: 12px; border-radius: 8px; background: #e4edf5; width: 70%; margin: 6px auto 0; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.empty-note {
  text-align: center; font-weight: 800; color: var(--muted);
  padding: 40px 20px; font-size: 15px;
}

/* ---------- section titles ---------- */
.sec-title {
  font-family: var(--display); font-size: 19px; color: #445;
  margin: 6px 0 12px; display: flex; align-items: center; gap: 8px;
}

/* ---------- parent notice (compact) ---------- */
.parent-mini {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 2px solid rgba(255, 215, 0, 0.7);
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 700; color: #6d4c00; line-height: 1.45;
}
.parent-mini .ic { font-size: 22px; flex-shrink: 0; }
.parent-mini a { color: #a06b00; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: var(--ad-h); z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(43, 78, 128, 0.14);
  display: flex; align-items: stretch; justify-content: space-around;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 11px; font-weight: 900; -webkit-user-select: none; user-select: none;
}
.nav-item .nic { font-size: 22px; line-height: 1; transition: transform .12s; }
.nav-item:active .nic { transform: scale(0.85); }
.nav-item.on { color: var(--green); }
.nav-fab {
  flex: 0 0 84px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; position: relative;
}
.nav-fab .fab {
  width: 58px; height: 58px; border-radius: 50%;
  margin-top: -26px;
  background: radial-gradient(circle at 30% 25%, var(--sunlight), var(--sun) 70%);
  box-shadow: 0 6px 16px rgba(230, 170, 0, 0.45), 0 0 0 5px #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px;
  transition: transform .12s;
}
.nav-fab:active .fab { transform: scale(0.9); }
.nav-fab .fab-label {
  position: absolute; bottom: 7px; left: 0; right: 0; text-align: center;
  font-size: 11px; font-weight: 900; color: var(--muted);
}

/* ---------- player ---------- */
.player-wrap { position: fixed; top: 0; left: 0; right: 0; bottom: var(--ad-h); background: var(--sky); }
.player-frame { width: 100%; height: 100%; border: 0; display: block; animation: gameIn .45s ease-out both; }
@keyframes gameIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: none; }
}
.back-fab {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px; z-index: 100;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  border: none; cursor: pointer;
  font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.back-fab:active { transform: scale(0.88); }
.player-loading {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--sky); z-index: 5;
}
.player-loading .spin {
  width: 54px; height: 54px; border-radius: 50%;
  border: 6px solid #cfe6f7; border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-loading .msg { font-family: var(--display); color: var(--purple); font-size: 17px; }

/* ---------- parents page ---------- */
.pcard {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.pcard h2 { font-family: var(--display); font-size: 18px; color: var(--purple); margin-bottom: 8px; }
.pcard p, .pcard li { font-size: 14px; font-weight: 600; color: #555; line-height: 1.65; }
.pcard ul { padding-left: 20px; margin-top: 6px; }
.pcard + .sec-title { margin-top: 18px; }
.link-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.link-tile {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow);
  padding: 16px 8px; text-align: center; text-decoration: none; color: var(--ink);
  transition: transform .12s;
}
.link-tile:active { transform: scale(0.94); }
.link-tile .ic { font-size: 28px; display: block; margin-bottom: 6px; }
.link-tile .t { font-family: var(--display); font-size: 13px; }

/* ---------- web-only extras ---------- */
.is-app .web-only { display: none !important; }
details.info-fold {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; margin-top: 20px;
}
details.info-fold summary {
  font-family: var(--display); font-size: 16px; color: var(--purple);
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
details.info-fold .fold-body { margin-top: 10px; }
details.info-fold h3 { font-family: var(--display); font-size: 15px; color: #445; margin: 12px 0 6px; }
details.info-fold p, details.info-fold li { font-size: 13.5px; color: #555; font-weight: 600; line-height: 1.7; }
details.info-fold ul { padding-left: 20px; }

.shop-strip { margin-top: 22px; }
.shop-strip .row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.shop-card {
  flex: 0 0 260px; background: #fff; border-radius: 14px; box-shadow: var(--shadow);
  display: flex; overflow: hidden; text-decoration: none; color: var(--ink);
}
.shop-card img { width: 86px; height: 86px; object-fit: cover; flex-shrink: 0; }
.shop-card .sc-body { padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; }
.shop-card .sc-t { font-size: 13px; font-weight: 800; line-height: 1.3; }
.shop-card .sc-d { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.shop-card .sc-btn {
  margin-top: 7px; align-self: flex-start;
  background: #ff9900; color: #fff; font-size: 11px; font-weight: 900;
  padding: 5px 12px; border-radius: 8px;
}

footer.app-footer {
  text-align: center; padding: 22px 16px 10px;
  font-size: 12.5px; font-weight: 800; color: var(--muted);
}
footer.app-footer a { color: var(--green); text-decoration: none; }

/* ---------- reduced motion ----------
   Honour the OS setting: keep the layout identical, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .app-header .cloud, .app-header .sun, .gicon, .f-ic { animation: none !important; }
}

/* ---------- desktop ---------- */
@media (min-width: 768px) {
  body.has-nav { padding-bottom: calc(30px + var(--ad-h)); }
  .bottom-nav { display: none; }
  .header-links { display: flex; }
  .gtitle { font-size: 17px; }
  .gcard { min-height: 172px; }
}
