/* mamuang — shared product shell */

@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@600;700&family=Mitr:wght@400;500;600;700&display=swap");

:root {
  --color-sky-top: #7ec8ff;
  --color-sky-mid: #b8e4ff;
  --color-grove: #1f8a5b;
  --color-grove-deep: #146b45;
  --color-mango: #ff8a1f;
  --color-mango-deep: #e66a00;
  --color-mango-soft: #ffe2bd;
  --color-leaf: #3dba74;
  --color-surface: #fffdf8;
  --color-surface-strong: #ffffff;
  --color-text: #1e3a2f;
  --color-text-muted: #4d6b5c;
  --color-primary: var(--color-mango);
  --color-primary-dark: var(--color-mango-deep);
  --color-secondary: var(--color-leaf);
  --color-success: #1faa6c;
  --color-success-bg: #e4fff2;
  --color-warn: #ffb020;
  --color-warn-bg: #fff4d6;
  --color-error: #e85d4c;
  --color-error-bg: #ffe8e4;
  --shadow-soft: 0 12px 32px rgba(20, 70, 50, 0.16);
  --shadow-tile: 0 8px 0 rgba(20, 70, 50, 0.18);
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-display: "Fredoka", "Mitr", sans-serif;
  --font-family: "Mitr", "Fredoka", sans-serif;
  --max-width: 560px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(15px, 1.6vh + 0.55vw, 18px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-family);
  color: var(--color-text);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.45) 0 12%, transparent 13%),
    radial-gradient(circle at 88% 12%, rgba(255, 200, 80, 0.35) 0 10%, transparent 11%),
    radial-gradient(circle at 80% 78%, rgba(61, 186, 116, 0.28) 0 14%, transparent 15%),
    radial-gradient(circle at 18% 85%, rgba(255, 138, 31, 0.22) 0 16%, transparent 17%),
    linear-gradient(165deg, var(--color-sky-top) 0%, var(--color-sky-mid) 38%, #fff1c9 72%, #ffe0a3 100%);
  background-attachment: fixed;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.85rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(0.85rem, env(safe-area-inset-left, 0px));
}

.card {
  width: 100%;
  max-width: var(--max-width);
  background: rgba(255, 253, 248, 0.94);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.35rem 1.35rem 1.5rem;
  border: 3px solid rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  text-align: center;
  color: var(--color-grove-deep);
  letter-spacing: 0.01em;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  text-align: center;
  color: var(--color-grove-deep);
}

.subtitle {
  margin-top: 0.65rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 1.05rem;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.6rem;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-pulse-hint {
  animation: btn-pulse-hint 1.6s ease-in-out infinite;
}

@keyframes btn-pulse-hint {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

.btn-primary {
  background: linear-gradient(180deg, #ff9d3d 0%, var(--color-mango) 55%, var(--color-mango-deep) 100%);
  color: #fff;
  box-shadow: 0 6px 0 var(--color-mango-deep);
}

.btn-primary:hover {
  filter: brightness(1.03);
}

.btn-secondary {
  background: linear-gradient(180deg, #55d089 0%, var(--color-leaf) 100%);
  color: #fff;
  box-shadow: 0 6px 0 var(--color-grove-deep);
}

.btn-choice {
  background: var(--color-surface-strong);
  color: var(--color-text);
  border: 3px solid #d7ebe0;
  border-radius: var(--radius-md);
  box-shadow: 0 5px 0 #9fcbb3;
  margin-bottom: 0.75rem;
}

.btn-choice:hover {
  border-color: var(--color-leaf);
}

.btn-choice.is-correct {
  border-color: var(--color-success);
  background: var(--color-success-bg);
}

.btn-choice.is-wrong {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

/* Picture + word: big emoji/swatch first, label for early readers */
.picture-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.choice-emoji,
.item-emoji {
  font-size: 2.45rem;
  line-height: 1;
}

.choice-label,
.item-label {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.color-swatch .choice-label {
  font-size: 1rem;
}

.link-back {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-grove-deep);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid rgba(31, 138, 91, 0.18);
}

.link-back:hover {
  background: #fff;
  color: var(--color-mango-deep);
}

/* —— Hub —— */
.page-hub .app-shell {
  justify-content: center;
  padding-top: 1.25rem;
  padding-bottom: 2rem;
}

.hub-card {
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96) 0%, rgba(255, 248, 230, 0.94) 100%);
  padding: 1.15rem 1.15rem 1.35rem;
  animation: hub-rise 0.55s ease-out;
}

.hub-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0 0.35rem;
}

.brand-mark {
  width: 3.35rem;
  height: 4.55rem;
  border-radius: 68% 42% 58% 48% / 42% 38% 62% 58%;
  background:
    radial-gradient(ellipse 45% 35% at 30% 28%, #fff7b8 0 55%, transparent 60%),
    linear-gradient(155deg, #ffe86a 0%, #ffd84a 32%, #ffc933 58%, #f0b429 82%, #e0a010 100%);
  box-shadow:
    0 7px 0 rgba(196, 130, 12, 0.32),
    inset 0 -10px 14px rgba(180, 110, 0, 0.18),
    inset 4px -2px 10px rgba(255, 255, 255, 0.25);
  position: relative;
  transform: rotate(-26deg);
  animation: brand-bob 2.8s ease-in-out infinite;
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 0.05rem;
  left: 52%;
  width: 0.28rem;
  height: 0.55rem;
  background: linear-gradient(180deg, #8a5a2b, #5c3a18);
  border-radius: 3px;
  transform: rotate(18deg);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: -0.35rem;
  right: -0.05rem;
  width: 1.35rem;
  height: 0.85rem;
  background: linear-gradient(135deg, #7ee0a0, #1f8a5b 70%);
  border-radius: 10% 80% 20% 90%;
  transform: rotate(-18deg);
  box-shadow: inset 0 -2px 4px rgba(0, 80, 40, 0.2);
}

.hub-brand {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 3.4rem);
  line-height: 1;
  color: var(--color-grove-deep);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.65);
  margin: 0;
}

.hub-hint {
  margin-top: 0.35rem;
  font-size: clamp(1.15rem, 4.5vw, 1.35rem);
  font-weight: 700;
  color: var(--color-mango-deep);
}

.hub-trust {
  margin: 0.55rem auto 0;
  max-width: 22rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.hub-parents-link {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-grove-deep);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.hub-parents-link:hover {
  color: var(--color-mango-deep);
}

.hub-install {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.hub-install-hint {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.hub-install-btn {
  width: auto;
  min-width: 12rem;
  min-height: 2.8rem;
  padding: 0.55rem 1.2rem;
  font-size: 1rem;
}

.hub-version {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(30, 58, 47, 0.45);
}

/* —— Game chrome —— */
.page-game .app-shell {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  justify-content: center;
  padding:
    max(0.45rem, env(safe-area-inset-top, 0px))
    max(0.65rem, env(safe-area-inset-right, 0px))
    max(0.45rem, env(safe-area-inset-bottom, 0px))
    max(0.65rem, env(safe-area-inset-left, 0px));
}

.page-game .game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  padding: 0.85rem 1rem 0.95rem;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.97) 0%, rgba(255, 248, 230, 0.95) 100%);
  animation: hub-rise 0.45s ease-out;
}

.page-game .top-bar {
  flex-shrink: 0;
  gap: 0.55rem;
  margin: -0.1rem -0.1rem 0.55rem;
  padding: 0.1rem 0.1rem 0.55rem;
  border-bottom: 1px solid rgba(31, 138, 91, 0.12);
  flex-wrap: nowrap;
}

.page-game .screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.page-game .prompt-area {
  font-size: clamp(2.8rem, 11vmin, 5.5rem);
  padding: 0.25rem 0;
  line-height: 1;
}

.page-game .choices,
.page-game .btn-primary,
.page-game .status-bar,
.page-game .presence-progress {
  flex-shrink: 0;
}

.page-game .btn-choice {
  min-height: clamp(3.6rem, 12vh, 5.4rem);
}

.page-game .feedback {
  min-height: 2rem;
  flex-shrink: 0;
}

.page-game .presence-mascot {
  bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.top-bar-right {
  margin-left: auto;
  flex-shrink: 0;
}

.top-bar-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(31, 138, 91, 0.14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.page-game .top-bar .link-back {
  min-height: 2.35rem;
  min-width: 2.35rem;
  justify-content: center;
  padding: 0.2rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(31, 138, 91, 0.16);
  box-shadow: none;
  white-space: nowrap;
}

.sfx-mute-btn {
  min-height: 2.15rem;
  min-width: 2.15rem;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.sfx-mute-btn:hover,
.page-game .top-bar-tools .lang-btn:hover {
  background: rgba(255, 255, 255, 0.95);
}

.sfx-mute-btn.is-muted {
  opacity: 0.72;
}

.page-game .top-bar-tools .lang-switch {
  gap: 0.15rem;
}

.page-game .top-bar-tools .lang-btn {
  min-height: 2.15rem;
  min-width: 2.55rem;
  padding: 0.2rem 0.55rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  box-shadow: none;
}

.page-game .top-bar-tools .lang-btn.is-active {
  background: var(--color-mango-soft);
  color: var(--color-mango-deep);
}

#screen-end:not(.hidden) {
  position: relative;
  overflow: hidden;
}

#screen-end:not(.hidden)::before,
#screen-end:not(.hidden)::after {
  content: "✨";
  position: absolute;
  font-size: 1.6rem;
  animation: celebrate-float 1.4s ease-in-out infinite;
  pointer-events: none;
}

#screen-end:not(.hidden)::before {
  left: 12%;
  top: 18%;
  content: "🥭";
}

#screen-end:not(.hidden)::after {
  right: 12%;
  top: 22%;
  animation-delay: 0.35s;
  content: "✨";
}

@keyframes celebrate-float {
  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.85;
  }
  50% {
    transform: translateY(-8px) scale(1.12);
    opacity: 1;
  }
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1.15rem;
}

.game-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 7.6rem;
  padding: 0.85rem 0.5rem;
  border-radius: 22px;
  text-decoration: none;
  color: var(--color-text);
  box-shadow: var(--shadow-tile);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  border: 3px solid rgba(255, 255, 255, 0.8);
  animation: tile-in 0.5s ease-out both;
}

.game-tile:nth-child(1) {
  animation-delay: 0.05s;
}
.game-tile:nth-child(2) {
  animation-delay: 0.1s;
}
.game-tile:nth-child(3) {
  animation-delay: 0.15s;
}
.game-tile:nth-child(4) {
  animation-delay: 0.2s;
}
.game-tile:nth-child(5) {
  animation-delay: 0.25s;
}
.game-tile:nth-child(6) {
  animation-delay: 0.3s;
}

.game-tile:hover {
  transform: translateY(-3px);
  filter: saturate(1.05);
}

.game-tile:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(20, 70, 50, 0.18);
}

.game-tile-icon {
  font-size: clamp(2.7rem, 12vw, 3.5rem);
  line-height: 1;
  user-select: none;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.08));
}

.game-tile-label {
  font-size: 1.08rem;
  font-weight: 700;
  font-family: var(--font-display);
}

.tile-match {
  background: linear-gradient(160deg, #ffe08a, #ffb14a);
}

.tile-count {
  background: linear-gradient(160deg, #7de3ff, #5bb8ff);
}

.tile-color {
  background: linear-gradient(160deg, #ff8ec8, #ffc56d);
}

.tile-order {
  background: linear-gradient(160deg, #9aefc0, #5ad0ff);
}

.tile-shadow {
  background: linear-gradient(160deg, #d5dde8, #9aa7b8);
}

.tile-missing {
  background: linear-gradient(160deg, #ffb39a, #ffe29a);
}

.shadow-icon {
  filter: grayscale(1) contrast(1000%) brightness(0) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.08));
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
}

.lang-btn {
  min-height: 2.5rem;
  min-width: 3.4rem;
  padding: 0.35rem 0.8rem;
  border: 2px solid rgba(31, 138, 91, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-grove-deep);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.is-active {
  border-color: var(--color-mango);
  background: var(--color-mango-soft);
  color: var(--color-mango-deep);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.top-bar .link-back {
  margin-top: 0;
}

.top-bar .lang-switch {
  margin-bottom: 0;
}

.game-card h1 {
  margin-top: 0.25rem;
}

@keyframes hub-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes brand-bob {
  0%,
  100% {
    transform: rotate(-26deg) translateY(0);
  }
  50% {
    transform: rotate(-26deg) translateY(-5px);
  }
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hub-card,
  .brand-mark,
  .game-tile,
  .hub-hint-swap,
  .btn-pulse-hint,
  .presence-mascot.is-idle,
  .presence-mascot.is-happy,
  .presence-mascot.is-sad,
  #screen-end:not(.hidden)::before,
  #screen-end:not(.hidden)::after {
    animation: none;
  }
}

@media (min-width: 768px) {
  html {
    font-size: clamp(16px, 1.5vh + 0.45vw, 20px);
  }

  .card {
    padding: 1.35rem 1.5rem 1.5rem;
  }

  .page-game .game-card {
    padding: 0.9rem 1.15rem 1rem;
  }

  .hub-card {
    padding: 1.35rem 1.45rem 1.55rem;
  }

  .game-tile {
    min-height: clamp(6.5rem, 18vh, 8.6rem);
  }

  .brand-mark {
    width: 3.7rem;
    height: 5rem;
  }
}

@media (max-height: 760px) {
  .page-game .app-shell {
    padding-top: max(0.3rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.3rem, env(safe-area-inset-bottom, 0px));
  }

  .page-game .top-bar {
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
  }

  .page-game .screen {
    gap: 0.4rem;
  }

  .presence-progress {
    margin: 0.15rem 0 0.4rem;
    padding: 0.22rem 0.3rem;
  }

  .page-game h1 {
    font-size: clamp(1.45rem, 5vh, 1.85rem);
  }

  .page-hub .app-shell,
  .page-parents .app-shell {
    justify-content: flex-start;
    overflow: auto;
  }
}

@media (max-height: 640px) {
  .page-game .btn-choice {
    min-height: 3.4rem;
  }

  .page-game .prompt-area {
    font-size: clamp(2.4rem, 9vmin, 4rem);
  }

  .presence-mascot {
    width: 2rem;
    height: 2rem;
  }

  .presence-mascot-face {
    font-size: 1.15rem;
  }
}


.game-tile.is-pressed {
  transform: scale(0.94) translateY(2px);
  filter: brightness(1.05);
}

.hub-hint-swap {
  animation: hub-hint-fade 0.32s ease;
}

@keyframes hub-hint-fade {
  from { opacity: 0.35; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.presence-progress {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 0.18rem;
  margin: 0.35rem 0 0.75rem;
  padding: 0.35rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 138, 31, 0.18);
}

.presence-slot {
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.22;
  filter: grayscale(1);
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.presence-slot.is-filled {
  opacity: 1;
  filter: none;
  transform: scale(1.08);
}

.presence-mascot {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  z-index: 2;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.presence-mascot-face {
  font-size: 1.55rem;
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.08));
}

.presence-mascot.is-idle { animation: mascot-bob 2.8s ease-in-out infinite; }
.presence-mascot.is-happy { animation: mascot-pop 0.55s ease; }
.presence-mascot.is-sad { animation: mascot-droop 0.55s ease; }

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes mascot-pop {
  0% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.2) rotate(-8deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes mascot-droop {
  0% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(4px) rotate(8deg) scale(0.92); }
  100% { transform: translateY(0) rotate(0deg); }
}

@media (max-width: 390px) {
  .presence-slot { font-size: 0.62rem; }
  .presence-mascot { width: 2.2rem; height: 2.2rem; right: 0.35rem; bottom: 0.35rem; }
  .presence-mascot-face { font-size: 1.3rem; }
}

