/* World Explorer — styles. Bright and playful, like the other kids' games: a
   teal bar with 70s stripes, a cream page, a sky-blue sea around the map. */
:root {
  --bg: #fdf6e3;
  --panel: #ffffff;
  --text: #2a2420;
  --muted: #6b625a;
  --line: #e4dccb;
  --blue: #1b8f8c;
  --blue-dark: #11615f;
  --blue-soft: #e6eef9;
  --go: #e2622c;
  --go-dark: #b84a1c;
  --mustard: #f2b134;
  --right: #2fa35a;
  --wrong: #d0402e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 8px 16px; cursor: pointer; touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }
button.go { background: var(--go); border-color: var(--go-dark); color: #fff; font-size: 18px; padding: 10px 22px; }
button.go:not(:disabled):hover { background: var(--go-dark); }
button.secondary { background: #fff; }
button.danger { color: var(--wrong); border-color: #f0c4be; }
button.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 20px; }
button.plain { border: none; background: none; }
.small { color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--blue); color: #fff;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { font-size: 22px; background: #fff; border-radius: 8px; padding: 0 4px; line-height: 1.3; }
.top-right { display: flex; gap: 8px; align-items: center; }
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.apps-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; box-sizing: border-box; padding: 6px 14px;
  border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .5);
  color: #fff; text-decoration: none; font-weight: 700; font-size: 16px;
}
.apps-link:hover { background: rgba(255, 255, 255, .3); }
.apps-link svg { fill: currentColor; flex: none; }
.player-chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); padding: 6px 14px; }
.topbar button.icon { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .5); }
.topbar, .stripes, .update-note { flex-shrink: 0; }
.stripes { height: 9px; background: linear-gradient(var(--mustard) 0 3px, var(--go) 3px 6px, #8a4b2a 6px 9px); }
.update-note {
  display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #fff4d6;
  border-bottom: 1px solid #f0d58a; font-weight: 600;
}

/* ---------- home ---------- */
.home { max-width: 1180px; width: 100%; margin: 0 auto; padding: 12px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.home h2 { margin: 0 0 10px; font-size: 18px; color: var(--blue-dark); display: flex; align-items: baseline; gap: 10px; }
.trip-total { margin-left: auto; color: #c48a00; font-size: 16px; }
.players { display: flex; flex-wrap: wrap; gap: 10px; }
.player { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 30px; border: 3px solid var(--line); }
.player-emoji { font-size: 28px; line-height: 1; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #f6f1e4; }
.player.on { border-color: var(--pc, var(--blue)); background: color-mix(in srgb, var(--pc, var(--blue)) 10%, #fff); }
.player.add { color: var(--muted); border-style: dashed; }
.player-badges { font-size: 18px; letter-spacing: 1px; margin-left: 2px; }
.home-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: 12px; align-items: start; }
.trip { display: flex; flex-direction: column; gap: 8px; }
.leg { display: grid; grid-template-columns: 196px 1fr; gap: 10px; align-items: center; }
.leg-name { font-weight: 800; color: var(--blue-dark); display: flex; align-items: center; gap: 8px; line-height: 1.15; }
.leg-name > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.leg-dot { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--rc); color: #fff; font-weight: 900; font-size: 17px; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.leg-levels { display: flex; gap: 8px; }
.lvl { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 5px 4px; border-width: 3px; min-width: 0; }
.lvl-icon { font-size: 22px; line-height: 1.1; }
.lvl-name { font-size: 13px; }
.lvl-stars { color: #f2b705; letter-spacing: 1px; font-size: 14px; }
.lvl.on { border-color: var(--go); background: #fff1e8; }
.lvl.locked { background: #f4f1ea; color: var(--muted); border-style: dashed; }
.lvl.locked .lvl-stars { opacity: .4; }
.lesson-about { margin: 10px 2px 0; color: var(--muted); font-weight: 600; }
.overview-panel { padding: 8px; position: sticky; top: 8px; }
.overview { position: relative; }
.overview-map { width: 100%; height: auto; display: block; border-radius: 10px; aspect-ratio: 1028 / 443; }
.region-name { font-weight: 900; fill: rgba(23, 59, 117, .35); paint-order: stroke; stroke: rgba(255, 255, 255, .5); stroke-width: 3px; }
.region-name.on { fill: #173b75; stroke: #fff; stroke-width: 5px; }
.home-go {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; bottom: 0; z-index: 2;
  padding: 10px 0 12px; background: linear-gradient(rgba(253, 246, 227, 0), var(--bg) 30%);
}
.home-go .go { font-size: 22px; padding: 12px 36px; }

/* ---------- the compass ---------- */
.compass-box { width: 84px; flex: none; pointer-events: none; filter: drop-shadow(0 2px 4px rgba(20, 40, 80, .25)); }
.side-head { display: flex; align-items: center; gap: 10px; }
.region-note { font-size: 14px; line-height: 1.3; color: var(--muted); font-weight: 600; border-left: 5px solid var(--rc, var(--blue)); padding-left: 8px; }
.region-note b { color: var(--blue-dark); font-size: 16px; }
.compass { width: 100%; height: auto; display: block; }
.compass .lit { animation: litPulse 1.8s ease-in-out infinite; }
.edge-letters text { font-weight: 900; paint-order: stroke; stroke: #ffffff; stroke-width: .12em; stroke-linejoin: round; }
@keyframes litPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- a level ---------- */
.play { flex: 1; display: grid; grid-template-rows: auto 1fr; gap: 6px; padding: 6px 10px 10px; min-height: 0; }
.play-bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.bar-title { font-weight: 800; font-size: 18px; color: var(--blue-dark); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.progress .count { font-weight: 900; color: var(--blue-dark); font-size: 17px; }
.pip { width: 14px; height: 14px; border-radius: 50%; background: #e6dfcc; border: 2px solid #d8cfb8; }
.pip.done { background: var(--right); border-color: #23824a; }
.pip.now { background: #fff; border-color: var(--go); box-shadow: 0 0 0 3px #ffd9c4; }
.board { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 10px; min-height: 0; }
.map-box { position: relative; min-height: 0; background: #d6ecfa; border-radius: 14px; overflow: hidden; border: 2px solid #b9d7ee; }
.map { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.st { cursor: default; transition: fill .25s; }
.st.ctx { pointer-events: none; }
.st.placed, .st.quiz { cursor: pointer; }
.st.loose { cursor: grab; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.st.hint-slot { animation: slotGlow 1s ease-in-out infinite; }
@keyframes slotGlow { 0%, 100% { fill: #fffaf0; } 50% { fill: #ffd7bd; } }
.st.ask { animation: askGlow 1.1s ease-in-out infinite; }
@keyframes askGlow { 0%, 100% { fill: #ff8a4c; } 50% { fill: #ffc39c; } }
.st.near { stroke: #e2622c; stroke-width: .6%; }
.st.nope { fill: #e8a6a0 !important; }
.st.pop { animation: statePop .5s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes statePop { 0% { scale: .85; } 60% { scale: 1.08; } 100% { scale: 1; } }
.lbl { font-weight: 900; fill: #1f2b3d; paint-order: stroke; stroke: #fff; stroke-width: .3em; stroke-linejoin: round; pointer-events: none; }
.loose-lbl { fill: #4a3f2e; }
#ghost { pointer-events: none; }
.info {
  position: absolute; left: 10px; top: 10px; max-width: calc(100% - 20px); z-index: 2; background: rgba(255, 255, 255, .95);
  border: 2px solid #b9d7ee; border-radius: 12px; padding: 6px 12px; font-size: 16px; line-height: 1.35; box-shadow: 0 3px 10px rgba(20, 40, 80, .15);
}
.side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.prompt { font-size: 20px; font-weight: 800; line-height: 1.25; }
.prompt .lit { color: #e2622c; }
.tray { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.tray:empty { display: none; }
.piece {
  display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 10px;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 2px 0 #e4dccb;
}
.piece:hover { border-color: var(--blue); }
.piece.sel { border-color: var(--go); background: #fff4ec; }
.piece.dragging { opacity: .35; }
.card-shape { width: 64px; height: 52px; flex: none; }
.piece-text { display: flex; flex-direction: column; min-width: 0; }
.piece-text b { font-size: 17px; }
.piece-text span { font-size: 14px; color: #8a5a00; font-weight: 700; }
.tray-more { color: var(--muted); font-weight: 700; font-size: 13px; text-align: center; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choices:empty { display: none; }
.choice { font-size: 19px; padding: 10px 12px; border-width: 3px; text-align: left; }
.choice:not(:disabled):hover { border-color: var(--blue); }
.choice.no { text-decoration: line-through; background: #f6e2de; color: #b06a5c; border-color: #e7b9ae; }
.hint { padding: 8px 12px; border-radius: 12px; background: #fff8dc; border: 2px solid #f2d27a; font-size: 15px; line-height: 1.4; }
.tools { display: flex; gap: 8px; margin-top: auto; }
.tool { flex: 1; font-size: 17px; }
.result {
  position: absolute; inset: 0; margin: auto; width: min(420px, 92%); height: fit-content; background: #fff; border-radius: 18px;
  border: 3px solid var(--blue); box-shadow: 0 10px 40px rgba(20, 50, 110, .25); padding: 18px 20px; text-align: center; z-index: 3;
}
.result-stars { font-size: 46px; color: #f2b705; letter-spacing: 4px; }
.result-text { font-size: 26px; font-weight: 800; color: var(--blue-dark); }
.result-detail { color: var(--muted); font-weight: 600; margin: 6px 0 14px; }
.result-buttons { display: flex; gap: 10px; justify-content: center; }

/* ---------- dialogs ---------- */
.dialog { max-width: 460px; width: calc(100% - 28px); border: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 760px; }
.dialog::backdrop { background: rgba(20, 30, 50, .45); }
.dialog h2 { margin: 0 0 12px; color: var(--blue-dark); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field input[type=text], .field select { font: inherit; font-weight: 500; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; }
.field input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.field-label { font-weight: 700; margin-bottom: 6px; }
.emoji-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.emoji-pick button { font-size: 26px; padding: 4px 0; border-radius: 10px; }
.emoji-pick button.on { border-color: var(--blue); background: var(--blue-soft); }
.dialog-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }
.help li { margin-bottom: 8px; line-height: 1.45; }
.scores { border-collapse: collapse; width: 100%; font-size: 15px; }
.scores th, .scores td { padding: 6px 5px; border-bottom: 1px solid var(--line); text-align: center; }
.scores th { font-size: 22px; }
.scores .who { text-align: left; white-space: nowrap; font-weight: 700; }
.scores small { color: var(--muted); }
#scores { overflow-x: auto; }

/* ---------- rewards: streaks, badges, celebrations ---------- */
.streak {
  font-weight: 900; font-size: 18px; color: #c2410c; background: #fff1e0; border: 2px solid #f6b98a; border-radius: 999px;
  padding: 2px 12px; white-space: nowrap;
}
.streak.bump { animation: pop .35s ease-out; }
.leg-badge {
  font-size: 11.5px; font-weight: 800; color: #a59a88; border: 2px dashed #ddd3bf; border-radius: 999px; padding: 1px 8px;
  width: fit-content; white-space: nowrap;
}
.leg-badge.won { color: #7a5200; background: linear-gradient(#fff3c4, #f7d36a); border: 2px solid #d9a521; box-shadow: 0 1px 0 #c08f12; }
.player-badges { font-size: 18px; letter-spacing: 1px; margin-left: 2px; }
.result-rewards { list-style: none; padding: 0; margin: -6px 0 14px; display: flex; flex-direction: column; gap: 4px; font-weight: 800; color: #7a4a00; }
.result-rewards li { background: #fff6dc; border-radius: 10px; padding: 4px 10px; }
.result-rewards:empty { display: none; }

.toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 20; pointer-events: none;
  background: #c2410c; color: #fff; font-weight: 900; font-size: 20px; padding: 8px 20px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(194, 65, 12, .35);
}
.toast.show { animation: toastIn 2.2s ease-out forwards; }
@keyframes toastIn {
  0% { opacity: 0; translate: 0 -12px; scale: .8; } 12% { opacity: 1; translate: 0 0; scale: 1.08; } 20% { scale: 1; }
  80% { opacity: 1; } 100% { opacity: 0; translate: 0 -8px; }
}

.celebrate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(20, 35, 70, .45); overflow: hidden; }
.cel-card {
  position: relative; z-index: 2; background: #fff; border-radius: 22px; border: 4px solid var(--mustard); padding: 22px 28px 20px;
  width: min(420px, 90%); text-align: center; box-shadow: 0 16px 50px rgba(20, 35, 70, .4); animation: celIn .5s cubic-bezier(.2, 1.6, .4, 1);
}
.cel-icon { font-size: 72px; line-height: 1.1; animation: wiggle 1.2s ease-in-out .4s 2; }
.celebrate.badge .cel-icon {
  width: 120px; height: 120px; margin: 0 auto 6px; display: grid; place-items: center; font-size: 62px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8d6, #f7d36a 60%, #d9a521); border: 5px solid #c08f12;
  box-shadow: 0 0 0 6px #fff3c4, 0 0 30px 10px rgba(247, 211, 106, .7);
}
.cel-title { font-size: 30px; font-weight: 900; color: var(--blue-dark); margin-top: 4px; }
.cel-text { color: var(--muted); font-weight: 600; margin: 8px 0 16px; line-height: 1.4; }
@keyframes celIn { from { scale: .4; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -12deg; } 75% { rotate: 12deg; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; opacity: 0;
  animation-name: fall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
.confetti i.round { width: 12px; height: 12px; border-radius: 50%; }
@keyframes fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: .9; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}
/* ---------- explore ---------- */
.explore-btn { font-size: 17px; }
.regions { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
.region-btn { padding: 6px 10px; font-size: 14px; border-width: 3px; border-color: color-mix(in srgb, var(--rc) 60%, #fff); }
.region-btn.on { background: var(--rc); border-color: color-mix(in srgb, var(--rc) 70%, #000); color: #1f2b3d; }
.st.picked { filter: drop-shadow(0 0 6px rgba(255, 255, 255, .9)); }
.explore-empty { color: var(--muted); font-weight: 700; font-size: 17px; text-align: center; padding: 20px 6px; }
.explore-card {
  background: #fff; border: 3px solid var(--rc); border-radius: 16px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px;
  animation: pop .3s ease-out;
}
.explore-card .card-shape { width: 100%; height: 64px; }
#play[data-kind=explore] .tray { flex: 1; }
.ec-name { font-size: 22px; font-weight: 900; color: var(--blue-dark); }
.ec-name small { font-size: 14px; color: var(--muted); }
.ec-cap { font-size: 18px; color: #7a4a00; }
.ec-region { font-weight: 800; color: color-mix(in srgb, var(--rc) 60%, #000); }
.ec-near { font-size: 14px; color: var(--muted); font-weight: 700; margin-top: 4px; }
.ec-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 3px 9px; font-size: 13px; border-radius: 999px; border-width: 2px; }
@keyframes pop { 0% { scale: .9; } 70% { scale: 1.03; } 100% { scale: 1; } }

.ec-nick { font-weight: 800; font-style: italic; color: var(--blue-dark); }
.ec-facts { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.ec-fact { display: grid; grid-template-columns: 22px 92px 1fr; gap: 4px; align-items: baseline; font-size: 14px; line-height: 1.25; }
.ec-ic { font-size: 15px; }
.ec-lab { color: var(--muted); font-weight: 700; font-size: 12.5px; }
.ec-fact b { font-weight: 800; }
.ec-fun { margin-top: 4px; padding: 6px 9px; border-radius: 10px; background: #fff8dc; border: 2px solid #f2d27a; font-size: 14px; font-weight: 600; line-height: 1.35; }
@media (min-width: 761px) and (min-aspect-ratio: 1/1) {
  #play[data-kind=explore] .board { grid-template-columns: minmax(0, 1fr) 330px; }
}
.ec-head { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.ec-head .card-shape { width: 64px !important; height: 52px !important; }
#play[data-kind=explore] .tray { overflow-y: auto; }

/* ---------- smaller screens ---------- */
@media (max-height: 700px) {
  .home { gap: 8px; }
  .panel { padding: 8px 12px; }
  .players-panel h2 { display: none; }
  .lvl { padding: 3px 4px; }
  .lvl-icon { font-size: 19px; }
  .prompt { font-size: 18px; }
  .piece { padding: 4px 8px; }
  .card-shape { width: 54px; height: 42px; }
  .compass-box { width: 70px; }
}
@media (max-width: 900px) {
  .home-main { grid-template-columns: 1fr; }
  .overview-panel { position: static; order: -1; }
}
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .board { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .side { min-width: 0; }
  .side { max-height: 42vh; }
  .tray { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: none; }
  .piece { flex: none; }
  .choices { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .apps-link span { display: none; }
  .brand { font-size: 18px; }
  .leg { grid-template-columns: 1fr; gap: 4px; }
  .leg-name > span:last-child { flex-direction: row; align-items: center; gap: 8px; }
  .compass-box { width: 60px; }
}
@media (max-width: 420px) {
  .brand { display: none; }
}

/* ---------- World Explorer additions ---------- */
.big-flag { display: block; font-size: 84px; line-height: 1.1; margin-top: 6px; text-align: center; }
.ec-flag { font-size: 52px; line-height: 1; }
.ec-head .ec-flag + div { min-width: 0; }
.ec-shape .card-shape { width: 100%; height: 70px; }
.ring { animation: ringPulse 1s ease-in-out infinite; }
@keyframes ringPulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .25; } }
.ocean-mark { animation: ringPulse 1.2s ease-in-out infinite; }
.cap-lbl { fill: #7a4a00; }
.leg-dot { background: color-mix(in srgb, var(--rc) 30%, #fff); font-size: 18px; }
.st.ask { animation: askGlow2 1s ease-in-out infinite; }
@keyframes askGlow2 { 0%, 100% { fill: #ff5a36; } 50% { fill: #ffd23f; } }
.ask-line { animation: ringPulse 1s ease-in-out infinite; }
