/* Little Discovery World - styles.
   Palette: teal #248e8d, cream #fff5df, honey #f5a33e, ink #3c5961. */

@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf");
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: #3c5961;
  font-family: Fredoka, system-ui, sans-serif;
  background: #e8c28b;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid #f39c30; outline-offset: 2px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
img { -webkit-user-drag: none; user-select: none; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 30;
  background: #2c9b98;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #fff; text-align: center; padding: 16px;
}
#loader img { width: 96px; animation: bob 1s ease-in-out infinite alternate; }
#loader b { font-size: clamp(26px, 5vw, 42px); line-height: 1; color: #fff3c8; text-shadow: 0 4px #247270; }
.loadbar { height: 13px; width: 190px; background: #1e7776; border-radius: 20px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: #ffd45c; transition: width 0.2s; }
@keyframes bob { to { transform: translateY(-12px) rotate(10deg); } }

/* ---------- shared buttons ---------- */
.menu button, header button, .dialog button:not(#close), #hint {
  border: 2px solid #ffedc6; border-radius: 13px;
  background: #319e9b; box-shadow: 0 4px #1e7677;
  color: #fff; font-weight: 700;
}
.menu button:active, header button:active, .dialog button:not(#close):active, #hint:active {
  transform: translateY(3px); box-shadow: 0 1px #1e7677;
}
.dialog button:disabled, .menu button:disabled { filter: grayscale(0.8); opacity: 0.55; }

/* ---------- home ---------- */
#home {
  height: 100dvh; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 3% 5%;
  position: relative; isolation: isolate; overflow: hidden;
}
/* The full menu picture (1920x1072), unfiltered: no overlay, no zoom, no blur. */
#home::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: url("../assets/images/ui/menu.jpg") center center / cover no-repeat;
}
.hero { color: #fff1cc; text-shadow: 0 4px #8c563c, 0 7px 8px #48302680; }
.hero small { font-size: 13px; font-weight: 700; letter-spacing: 3px; color: #ffe6a9; }
.hero h1 { font-size: clamp(38px, 6.4vw, 90px); line-height: 0.9; letter-spacing: -2px; margin: 14px 0; }
.hero h1 em { font-style: normal; color: #fbc94e; }
.hero p { font-size: clamp(15px, 2vw, 22px); font-weight: 700; margin: 0; }

.menu {
  width: min(430px, 100%); flex: none; text-align: center; padding: 22px 24px;
  background: linear-gradient(140deg, #fff9e9, #ffe4b0);
  border: 5px solid #fff8eb; border-radius: 26px;
  box-shadow: 0 8px #ab7048, 0 16px 35px #2e272960;
}
.menu small { font-size: 10px; letter-spacing: 1.6px; color: #be865c; font-weight: 700; }
.menu h2 { font-size: 22px; margin: 4px 0 12px; }
.menu img { width: 24px; height: 24px; object-fit: contain; vertical-align: middle; margin-right: 5px; }
.menu .main { width: 100%; min-height: 60px; background: #f5a33e; box-shadow: 0 4px #b97430; font-size: 18px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 13px; }
.menu-grid button { min-height: 54px; font-size: 13px; }
.menu-icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 9px; }
.menu-icons button { min-height: 58px; font-size: 10px; background: #5aa9a7; box-shadow: 0 4px #3b7f7d; padding: 4px 2px; }
.menu-icons img { display: block; margin: 0 auto 1px; width: 20px; height: 20px; }
.menu-icons button.off { background: #a9b8b8; box-shadow: 0 4px #7c8a8a; }
#progress-home, .menu .grown-up { font-size: 11px; margin: 9px 0 0; color: #9b7b5e; }

/* ---------- game ---------- */
#game {
  height: 100dvh; display: flex; flex-direction: column;
  background: url("../assets/images/ui/table.jpg") center/cover;
}
header {
  display: flex; align-items: center; gap: 10px; flex: none;
  background: #248e8d; border-bottom: 4px solid #f9cf86; color: #fff;
  padding: 6px 14px; min-height: 58px;
}
header button { width: 42px; height: 42px; flex: none; padding: 5px; }
header button img { width: 22px; height: 22px; object-fit: contain; }
.titles { display: flex; flex-direction: column; min-width: 90px; }
header small { font-size: 10px; letter-spacing: 1px; color: #ffe4aa; white-space: nowrap; }
header b { font-size: 16px; white-space: nowrap; }
.bar { margin-left: auto; width: min(240px, 30vw); }
.bar small { display: block; margin-bottom: 3px; }
#round-dots { display: flex; gap: 5px; }
#round-dots i { flex: 1; height: 9px; border-radius: 9px; background: #176c6b; }
#round-dots i.done { background: #ffd75a; }
#round-dots i.now { background: #ffe9a3; box-shadow: 0 0 0 2px #ffd75a; }
.pill {
  display: flex; align-items: center; gap: 4px; flex: none;
  background: #176c6b; border-radius: 20px; padding: 3px 10px 3px 4px; font-size: 14px;
}
.pill img { width: 22px; height: 22px; }

.play-layout {
  display: flex; flex: 1; min-height: 0; gap: 14px; width: 100%; max-width: 1600px;
  margin: 0 auto; padding: 10px 4%;
}
.play-panel {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: #fff5df; border: 4px solid #fff8ea; border-radius: 22px; box-shadow: 0 5px #af7950;
}
.prompt {
  flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 16px; background: #ffedcc;
}
.prompt > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.prompt small { font-size: 10px; letter-spacing: 1px; color: #c28258; font-weight: 700; }
.prompt b { font-size: clamp(16px, 1.8vw, 22px); line-height: 1.15; }
.prompt span { font-size: 12px; color: #8a7560; }
#mini-clue img { width: 50px; height: 50px; object-fit: contain; border-radius: 12px; background: #fff; }

.board {
  flex: 1; min-height: 0; display: flex; gap: 16px; align-items: center; justify-content: center; padding: 10px 12px;
  background: linear-gradient(#fff4da55, #fff4da55), url("../assets/images/ui/table.jpg") center/cover;
}
.scene {
  position: relative; height: 100%; max-height: 330px; aspect-ratio: 1.6; max-width: 48%;
  background: #fff; border: 5px solid #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 4px 0 #d4a679, 0 7px 18px #72523533;
}
.scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
#scene-badge {
  position: absolute; top: 8px; left: 8px; background: #ffba43; color: #fff; border-radius: 20px;
  padding: 3px 10px; font-size: 12px; box-shadow: 0 3px #b8782c; font-weight: 700;
}
.goal {
  width: min(45%, 400px); max-height: 100%; overflow: hidden;
  background: #fff4dfee; border: 4px solid #fff; border-radius: 18px; padding: 10px 14px; box-shadow: 0 4px #d5a981;
}
.goal-head { display: flex; justify-content: space-between; font-size: 12px; color: #b37a50; }
#slots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 8px 0; min-height: 70px; }
.slot {
  width: clamp(46px, 6vw, 74px); height: clamp(46px, 6vw, 74px); display: grid; place-items: center;
  border: 3px dashed #e8c69c; background: #fffaf1; border-radius: 14px; color: #d7b18c; font-size: 24px;
}
.slot img { width: 92%; height: 92%; object-fit: contain; }
#feedback { font-size: 13px; text-align: center; margin: 0; color: #9f7554; min-height: 1.2em; }

/* baskets (Sort It) */
#slots.baskets { flex-wrap: nowrap; align-items: stretch; }
.basket {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px;
  background: #fffaf1; color: #3c5961; border: 3px solid #e8c69c; border-radius: 16px; box-shadow: 0 4px #dbb082;
}
.basket-icon { width: 38px; height: 38px; object-fit: contain; }
.basket span { font-size: 12px; font-weight: 700; line-height: 1.1; }
.basket em { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; min-height: 26px; }
.basket em img { width: 26px; height: 26px; }
.basket.flash, #options button.flash { animation: glow 0.7s ease-in-out infinite alternate; }

.options-panel { flex: none; background: #ffedcc; padding: 6px 14px 10px; }
.options-heading { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #b5794e; }
#hint { padding: 4px 13px; font-size: 11px; background: #e89a4a; box-shadow: 0 3px #ae6b37; }
#options { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 6px 4px 2px; }
#options button {
  width: clamp(60px, 11vw, 96px); height: clamp(60px, 11vw, 96px); padding: 4px;
  background: #fff; border: 3px solid #f5d3a7; border-radius: 14px; box-shadow: 0 4px #dbb082;
}
#options button img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
#options button.used { opacity: 0.25; }
#options button.selected { border-color: #f5a33e; transform: translateY(-4px); }
@keyframes glow { to { box-shadow: 0 0 0 5px #ffd45c, 0 0 18px #ffd45c; } }

/* memory cards */
#options.cards button.card { position: relative; padding: 0; background: none; border: 0; box-shadow: none; perspective: 500px; }
.face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px; padding: 6px;
  border: 3px solid #f5d3a7; backface-visibility: hidden; transition: transform 0.35s;
}
.face.back { background: #319e9b; box-shadow: 0 4px #1e7677; }
.face.back img { width: 60%; height: 60%; opacity: 0.9; }
.face.front { background: #fff; transform: rotateY(180deg); box-shadow: 0 4px #dbb082; }
.card.up .back { transform: rotateY(180deg); }
.card.up .front { transform: rotateY(360deg); }
.card.matched .front { border-color: #7bb04a; }

/* passport */
#passport {
  width: 210px; flex: none; align-self: center; padding: 16px; text-align: center;
  background: #fff4dfee; border: 4px solid #fff; border-radius: 20px; box-shadow: 0 5px #d5a981;
}
#passport small { font-size: 10px; letter-spacing: 1.4px; color: #be865c; font-weight: 700; }
#passport h2 { margin: 6px 0; font-size: 22px; color: #e07f35; }
#passport h2 em { font-style: normal; color: #319e9b; }
#passport p { font-size: 12px; margin: 6px 0; }
#badges { display: flex; gap: 5px; justify-content: center; margin: 8px 0; }
#badges span {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  background: #f5a33e; color: #fff; font-size: 13px; font-weight: 700;
}
#badges span.locked { background: #e8d8c0; color: #b8a58c; }
.friends { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.friends img { width: 30px; height: 30px; }
.friends img.locked { filter: grayscale(1); opacity: 0.35; }
.aside-note { margin-top: 10px; background: #319e9b; color: #fff; border-radius: 10px; padding: 8px; font-weight: 700; font-size: 11px; letter-spacing: 1px; }

/* "NEW" note */
#note {
  position: fixed; left: 50%; top: 68px; transform: translateX(-50%); z-index: 8; max-width: min(92vw, 520px);
  background: #ffba43; color: #fff; font-weight: 700; padding: 8px 16px; border-radius: 16px;
  box-shadow: 0 4px #b8782c; text-align: center; font-size: 14px; animation: drop 0.35s ease-out;
}
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }

/* ---------- dialogs ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 12px;
  background: #24374a99;
}
.dialog {
  position: relative; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; text-align: center;
  background: linear-gradient(140deg, #fff9e9, #ffe4b0); border: 5px solid #fff8eb; border-radius: 26px;
  box-shadow: 0 8px #ab7048; padding: 20px;
}
.dialog h2 { margin: 0 0 6px; font-size: 24px; }
.dialog p { margin: 6px 0; font-size: 14px; }
#dialog-content > button { display: block; margin: 9px auto 0; min-width: 190px; min-height: 44px; padding: 6px 18px; }
#dialog-content > button.primary { background: #f5a33e; box-shadow: 0 4px #b97430; }
#repeat { display: block; margin: 9px auto 0; min-width: 190px; padding: 4px 18px; }
.dialog button.muted, #repeat { background: #8ab6b4; box-shadow: 0 4px #5f8a88; min-height: 36px; font-size: 12px; }
#close {
  position: absolute; right: 10px; top: 8px; width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: #f5a33e; color: #fff; font-size: 24px; line-height: 1;
}
.dialog .stars { font-size: 38px; margin: 4px 0; color: #f5a33e; letter-spacing: 4px; }
.gate { background: #fff0d0; border-radius: 12px; padding: 6px 10px; color: #a8642a; }
.sticker-new img { width: 34px; vertical-align: middle; }
.tabs { display: flex; gap: 6px; justify-content: center; margin: 8px 0; }
.dialog .tabs button { min-width: 0; margin: 0; flex: 1; padding: 4px 2px; min-height: 48px; font-size: 10px; background: #8ab6b4; box-shadow: 0 3px #5f8a88; }
.dialog .tabs button.on { background: #319e9b; border-color: #f5a33e; }
.tabs img { display: block; margin: 0 auto; width: 22px; height: 22px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 8px; }
.dialog .level-grid button { min-width: 0; margin: 0; padding: 4px 2px; min-height: 64px; font-size: 13px; }
.level-grid button img { display: block; margin: 0 auto; width: 26px; height: 26px; }
.level-grid button small { display: block; font-size: 10px; color: #ffe9a3; }
.dialog .level-grid button.boss { background: #e8893b; box-shadow: 0 4px #a85f23; }
.sticker { background: #fff; border: 3px solid #f5d3a7; border-radius: 14px; padding: 6px 2px; font-size: 10px; }
.sticker img { width: 38px; height: 38px; }
.sticker small { display: block; line-height: 1.1; min-height: 1.1em; }
.sticker.empty img { filter: grayscale(1) brightness(1.6); opacity: 0.3; }
.sticker.gold { border-color: #ffd45c; box-shadow: 0 0 10px #ffd45c; background: #fffbe3; }
.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; text-align: left; }
.friend { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; background: #fff; border: 3px solid #f5d3a7; border-radius: 14px; padding: 6px 8px; }
.friend img { width: 36px; height: 36px; }
.friend > div { flex: 1; min-width: 0; }
.friend b { display: block; font-size: 13px; }
.friend small { font-size: 10px; line-height: 1.1; display: block; color: #7a6a58; }
.friend span { font-size: 10px; font-weight: 700; color: #319e9b; }
.dialog .friend button { margin: 0; min-width: 0; min-height: 30px; padding: 2px 10px; font-size: 11px; }
.friend.own { border-color: #9bd0ce; }

.confetti {
  position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 40; pointer-events: none;
  animation: fall 2s linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #passport { display: none; }
}
@media (max-width: 760px) {
  #home { flex-direction: column; justify-content: center; gap: 12px; padding: 12px; }
  .hero { text-align: center; }
  .hero h1 { margin: 8px 0; font-size: clamp(34px, 11vw, 60px); }
  .hero p { display: none; }
  .menu { padding: 14px 16px; width: min(440px, 100%); }
  .menu h2 { font-size: 19px; margin-bottom: 9px; }
  .menu .main { min-height: 54px; font-size: 17px; }
  .menu-grid button { min-height: 48px; }
  .menu-icons button { min-height: 52px; }
  #home::before { background-position: 26% center; }
  header { gap: 6px; padding: 5px 8px; min-height: 52px; }
  header button { width: 38px; height: 38px; }
  .titles { min-width: 0; }
  header b { font-size: 14px; }
  .play-layout { padding: 6px 8px; }
  .board { flex-direction: column; gap: 8px; padding: 8px; }
  .scene { height: auto; max-height: 30%; width: auto; max-width: 100%; aspect-ratio: 1.6; flex: 0 1 auto; }
  .goal { width: 100%; max-width: 420px; padding: 6px 10px; }
  #slots { min-height: 54px; padding: 4px 0; }
  .slot { width: 46px; height: 46px; }
  #options button { width: 62px; height: 62px; }
}
@media (max-width: 480px) {
  #world-title { display: none; }
  .titles { flex: none; min-width: 0; }
  .bar { flex: 1; width: auto; margin-left: 4px; min-width: 0; }
  .bar small { font-size: 9px; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) {
  .pill { display: none; }
  .dialog { padding: 14px; }
  .dialog h2 { font-size: 20px; }
}
@media (max-height: 470px) and (orientation: landscape) {
  #home { padding: 8px 4%; }
  .hero h1 { font-size: clamp(30px, 8vh, 48px); margin: 6px 0; }
  .menu { padding: 8px 14px; }
  .menu h2 { font-size: 16px; margin: 2px 0 6px; }
  .menu .main { min-height: 38px; font-size: 15px; }
  .menu-grid { margin-top: 6px; gap: 6px; }
  .menu-grid button { min-height: 32px; }
  .menu-icons { margin-top: 6px; gap: 5px; }
  .menu-icons button { min-height: 36px; }
  .menu-icons span { display: none; }
  .menu small, .menu .grown-up { display: none; }
  #progress-home { margin-top: 5px; }
  header { min-height: 44px; padding: 3px 10px; }
  header button { width: 34px; height: 34px; }
  .play-layout { padding: 5px 8px; }
  .prompt { padding: 3px 12px; }
  .prompt b { font-size: 15px; }
  .prompt span, .prompt small { display: none; }
  #mini-clue img { width: 34px; height: 34px; }
  .board { padding: 5px 8px; gap: 10px; }
  .scene { max-width: 34%; }
  .goal { padding: 4px 10px; }
  #slots { min-height: 44px; padding: 3px 0; }
  .slot { width: 40px; height: 40px; }
  .basket-icon { width: 26px; height: 26px; }
  .basket { padding: 3px; }
  .basket em { min-height: 18px; }
  .basket em img { width: 18px; height: 18px; }
  .options-panel { padding: 2px 10px 6px; }
  .options-heading b { display: none; }
  #options button { width: 54px; height: 54px; }
  #hint { position: absolute; right: 18px; margin-top: -4px; }
  .dialog { padding: 10px 16px; }
  .dialog h2 { font-size: 18px; margin-bottom: 2px; }
  .dialog p { margin: 3px 0; font-size: 12px; }
  #dialog-content > button { min-height: 34px; margin-top: 5px; }
  .dialog .stars { font-size: 26px; margin: 0; }
  .level-grid button { min-height: 44px !important; }
  .shop { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-height: 400px) and (orientation: landscape) {
  #home::before { background-position: center center; }
  .scene { display: none; }
}
@media (max-height: 360px) and (orientation: landscape) {
  .goal { width: min(80%, 460px); }
  #feedback { font-size: 11px; }
  #home { padding: 4px 4%; }
  .hero h1 { font-size: 30px; margin: 2px 0; }
  .hero small { display: none; }
  .menu { padding: 6px 12px; border-width: 4px; }
  .menu h2, #progress-home { display: none; }
  .menu .main { min-height: 32px; font-size: 14px; }
  .menu-grid { margin-top: 5px; gap: 5px; }
  .menu-grid button { min-height: 30px; font-size: 11px; }
  .menu-icons button { min-height: 30px; padding: 2px; }
  .dialog .tabs button { min-height: 34px; }
  .dialog .tabs img { display: none; }
  .dialog .level-grid button { min-height: 36px !important; }
  .level-grid button img { display: none; }
  .sticker img { width: 26px; height: 26px; }
  .friend { flex-direction: row; text-align: left; flex-wrap: wrap; padding: 3px 6px; }
  .friend img { width: 26px; height: 26px; }
  .friend small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
