/* ============================================================
   KumaszTo Gry edukacyjne - playful game styles.
   Everything is scoped under .gry-app so it cannot leak into
   platform.css (which has its own --ink, .btn, .card, .chip-*).
   ============================================================ */

/* .gry-layer = fixed overlays (modal/toast/confetti roots) that core.js
   re-parents to <body>, away from any transformed page wrapper - they
   need the same variables and font as the in-page .gry-app column. */
.gry-app, .gry-layer {
  --ink: #4a3653;
  --ink-soft: #8a7a93;
  --paper: #ffffff;
  --coral: #ff6b6b;
  --orange: #ff9f45;
  --yellow: #ffc93c;
  --mint: #6bcb77;
  --teal2: #4ecdc4;
  --blue2: #4d96ff;
  --purple: #9b5de5;
  --pink: #f15bb5;
  --radius: 24px;
  --shadow: 0 10px 24px rgba(120, 80, 140, .12);

  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Montserrat", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.gry-app {
  max-width: 640px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.gry-app *, .gry-layer * { box-sizing: border-box; }
.gry-app button, .gry-layer button { font-family: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }

/* ---------- buttons / pills ---------- */
.gry-app .gbtn, .gry-layer .gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 17px; line-height: 1.2;
  padding: 13px 20px; border-radius: 999px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 4px 0 rgba(90, 60, 110, .16), var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
  min-height: 48px; text-decoration: none;
}
.gry-app .gbtn:hover, .gry-layer .gbtn:hover { color: var(--ink); }
.gry-app .gbtn:active, .gry-layer .gbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(90, 60, 110, .16); }
.gry-app .gbtn.primary, .gry-layer .gbtn.primary { background: var(--ac, var(--coral)); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.12); }
.gry-app .gbtn.small, .gry-layer .gbtn.small { font-size: 15px; padding: 10px 16px; min-height: 42px; }
.gry-app .gbtn.round, .gry-layer .gbtn.round { width: 48px; height: 48px; padding: 0; font-size: 21px; }

.gry-app .gpill, .gry-layer .gpill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border-radius: 999px;
  padding: 9px 14px; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow);
}

/* ---------- game hub ---------- */
.gry-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 2px 2px 14px;
}
.gry-top .hi { font-weight: 800; font-size: 17px; }
.gry-top .pills { display: flex; gap: 8px; align-items: center; }

.gry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 560px) { .gry-grid { grid-template-columns: repeat(3, 1fr); } }

.game-card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  border: 3px solid transparent;
  box-shadow: var(--shadow);
  padding: 16px 12px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
  transition: transform .12s ease, border-color .12s ease;
  overflow: hidden;
}
.game-card:active { transform: scale(.96); }
.game-card:hover { border-color: var(--ac); }
.game-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 8px;
  background: var(--ac); opacity: .9;
}
.game-card .blob {
  width: 72px; height: 72px; border-radius: 26px;
  background: var(--ac-soft);
  display: grid; place-items: center;
  font-size: 40px; margin-top: 6px;
}
.game-card h3 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.25; }
.game-card .tag { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: -4px; min-height: 2.1em; }
.game-card .prog {
  font-size: 13px; font-weight: 800;
  background: var(--ac-soft); border-radius: 999px; padding: 5px 12px;
}

/* ---------- level select ---------- */
.screen-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.screen-head .titles { flex: 1; min-width: 0; }
.screen-head h2 { margin: 0; font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.screen-head .sub { font-size: 13px; color: var(--ink-soft); font-weight: 600; }

.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 6px; }
.level-btn {
  background: var(--paper); border-radius: 20px;
  box-shadow: 0 4px 0 rgba(90,60,110,.14), var(--shadow);
  padding: 14px 6px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-weight: 800; transition: transform .08s;
}
.level-btn:active { transform: translateY(3px); }
.level-btn .num {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--ac-soft); color: var(--ink);
  display: grid; place-items: center; font-size: 20px;
}
.level-btn .stars { font-size: 13px; letter-spacing: 1px; }
.level-btn .stars .off { opacity: .25; }
.level-btn.locked { opacity: .55; filter: saturate(.4); }
.level-btn.locked .num { background: #eee; }
.level-btn.cta-lock { opacity: .8; filter: none; border: 2px dashed var(--gold, #d4b25f); }

/* difficulty tiers (1-5 / 6-10 / 11-15) */
.level-btn .num.t1 { background: #e2f6e5; }
.level-btn .num.t2 { background: #fff1d1; }
.level-btn .num.t3 { background: #ffe1e1; }
.tier-legend {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  margin-top: 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
}
.tier-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tier-legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.tier-legend .dot.t1 { background: #6bcb77; }
.tier-legend .dot.t2 { background: #ffc93c; }
.tier-legend .dot.t3 { background: #ff6b6b; }

.howto-inline { margin: 16px 0 6px; display: flex; justify-content: center; }

/* ---------- play screen ---------- */
.play-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; }
.play-head .titles { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.play-head h2 { margin: 0; font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gchip {
  background: var(--ac, var(--coral)); color: #fff;
  font-size: 13px; font-weight: 800;
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}

.gpanel {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.game-status { text-align: center; font-weight: 800; font-size: 16px; margin: 10px 0; min-height: 24px; }
.gcontrols { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* generic feedback */
@keyframes gry-wiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.gry-app .wiggle, .gry-layer .wiggle { animation: gry-wiggle .4s ease; }
@keyframes gry-pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.gry-app .pop, .gry-layer .pop { animation: gry-pop .3s ease; }
@keyframes gry-hint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 60, 0); }
  50% { box-shadow: 0 0 0 6px rgba(255, 201, 60, .85); }
}
.gry-app .hint-flash, .gry-layer .hint-flash { animation: gry-hint .6s ease 3; z-index: 2; }

/* ---------- Szlak liczb ---------- */
.trail-wrap { position: relative; margin: 0 auto; touch-action: none; }
.trail-grid { display: grid; gap: 0; border-radius: 18px; overflow: hidden; border: 3px solid #efe6f5; }
.trail-cell { aspect-ratio: 1; background: #fbf8fd; border: 1px solid #f0e9f6; transition: background .15s; }
.trail-cell.on { background: var(--ac-soft); }
.trail-svg { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); pointer-events: none; }

/* ---------- Sudoku ---------- */
.sudoku-grid { display: grid; gap: 3px; margin: 0 auto; }
.sudoku-cell {
  aspect-ratio: 1; background: #fbf8fd; border-radius: 10px;
  display: grid; place-items: center;
  font-size: clamp(18px, 6.4vw, 30px); font-weight: 800;
  border: 2px solid #f0e9f6;
  transition: background .12s, border-color .12s;
}
.sudoku-cell.given { background: var(--ac-soft); border-color: transparent; }
.sudoku-cell.sel { border-color: var(--ac); background: #fff; box-shadow: 0 0 0 3px var(--ac-soft); }
.sudoku-cell.same { background: #fff3d6; }
.sudoku-cell.flash-bad { background: #ffd9d9 !important; border-color: var(--coral); }
.sudoku-cell.box-r { margin-right: 6px; }
.sudoku-cell.box-b { margin-bottom: 6px; }
.palette { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pal-btn {
  width: 52px; height: 52px; border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(90,60,110,.14), var(--shadow);
  font-size: 26px; font-weight: 800;
  display: grid; place-items: center;
  transition: transform .08s;
}
.pal-btn:active { transform: translateY(3px); }

/* ---------- Słońce i Księżyc ---------- */
.tango-grid { display: grid; gap: 5px; margin: 0 auto; }
.tango-cell {
  aspect-ratio: 1; border-radius: 12px;
  background: #fbf8fd; border: 2px solid #f0e9f6;
  font-size: clamp(20px, 7vw, 32px);
  display: grid; place-items: center;
  transition: background .12s;
}
.tango-cell.given { background: #fff3d6; border-color: transparent; }
.tango-cell.bad { border-color: var(--coral); background: #ffe3e3; }

/* ---------- Memo ---------- */
.memory-grid { display: grid; gap: 10px; margin: 0 auto; perspective: 900px; }
.mem-card { aspect-ratio: 1; position: relative; }
.mem-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.4, 1.4, .6, 1); }
.mem-card.flipped .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; border-radius: 16px;
  display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.mem-front {
  background: linear-gradient(135deg, var(--ac), var(--purple));
  color: rgba(255,255,255,.9);
  font-size: clamp(16px, 5vw, 24px);
  box-shadow: 0 4px 0 rgba(90,60,110,.18);
}
.mem-back { background: #fff; border: 3px solid var(--ac-soft); transform: rotateY(180deg); font-size: clamp(24px, 8vw, 40px); }
.mem-card.matched .mem-back { background: #eafbe7; border-color: var(--mint); animation: gry-pop .35s ease; }

/* ---------- Łowca słów ---------- */
.words-grid { display: grid; gap: 4px; margin: 0 auto; touch-action: none; }
.word-cell {
  aspect-ratio: 1; background: #fbf8fd;
  border: 2px solid #f0e9f6; border-radius: 10px;
  display: grid; place-items: center;
  font-size: clamp(13px, 4.4vw, 22px); font-weight: 800;
  color: var(--ink);
  transition: background .1s, color .1s;
  position: relative;
}
.word-cell.sel { background: var(--yellow); border-color: transparent; transform: scale(1.06); z-index: 1; }
.word-cell.found { color: #fff; border-color: transparent; }
.word-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.word-chip {
  background: var(--paper); border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 14px; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.word-chip.done { background: #eafbe7; text-decoration: line-through; opacity: .75; }

/* ---------- modal / toast / confetti ---------- */
.gry-overlay {
  position: fixed; inset: 0; z-index: 1050;
  background: rgba(74, 44, 90, .45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 18px;
  animation: gry-fade .18s ease;
}
@keyframes gry-fade { from { opacity: 0; } }
.gry-modal {
  background: var(--paper);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(60, 30, 80, .35);
  max-width: 430px; width: 100%;
  max-height: min(86vh, 700px);
  overflow-y: auto;
  padding: 22px 20px 20px;
  text-align: center;
  animation: gry-modal-pop .3s cubic-bezier(.34, 1.56, .64, 1);
  font-family: "Baloo 2", "Comic Sans MS", "Montserrat", sans-serif;
  color: var(--ink, #4a3653);
}
@keyframes gry-modal-pop { from { transform: scale(.72); opacity: 0; } }
.gry-modal h2 { margin: 2px 0 4px; font-size: 24px; font-weight: 800; }
.gry-modal .goal { color: var(--ink-soft, #8a7a93); font-weight: 700; margin: 0 0 12px; }
.gry-modal .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.howto-steps { text-align: left; margin: 14px 2px 2px; display: grid; gap: 10px; }
.howto-steps .step {
  display: flex; gap: 12px; align-items: center;
  background: #faf6ff; border-radius: 16px; padding: 10px 12px;
  font-weight: 700; font-size: 15px;
}
.howto-steps .step .ico { font-size: 26px; flex: 0 0 auto; }

@keyframes gry-bounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(5deg); } }
.win-emoji { font-size: 56px; animation: gry-bounce 1.6s ease-in-out infinite; }
.win-stars { font-size: 44px; letter-spacing: 6px; margin: 6px 0 2px; }
.win-stars span { display: inline-block; opacity: 0; transform: scale(0); }
.win-stars span.earn { animation: gry-star .5s cubic-bezier(.34, 1.56, .64, 1) forwards; }
.win-stars span.dud { opacity: .2; transform: none; filter: grayscale(1); }
@keyframes gry-star { to { opacity: 1; transform: scale(1) rotate(-6deg); } }
.win-stars span:nth-child(2).earn { animation-delay: .22s; }
.win-stars span:nth-child(3).earn { animation-delay: .44s; }

#gry-toast-root {
  position: fixed; left: 0; right: 0; bottom: 26px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 1060; pointer-events: none;
}
.gry-toast {
  background: #4a3653; color: #fff;
  font-weight: 700; font-size: 15px;
  font-family: "Baloo 2", "Montserrat", sans-serif;
  border-radius: 999px; padding: 11px 20px;
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  animation: gry-toast-in .25s ease, gry-toast-out .3s ease 1.9s forwards;
}
@keyframes gry-toast-in { from { transform: translateY(16px); opacity: 0; } }
@keyframes gry-toast-out { to { opacity: 0; transform: translateY(8px); } }

#gry-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1070; width: 100%; height: 100%; }

/* ---------- how-to demos ---------- */
.demo {
  height: 150px; display: grid; place-items: center;
  background: #faf6ff; border-radius: 20px;
  overflow: hidden; position: relative;
}
.demo svg { height: 130px; width: auto; }
.demo-path {
  fill: none; stroke: var(--ac, #ff9f45);
  stroke-width: 30; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 100;
  animation: gry-dash 3.2s ease-in-out infinite;
}
@keyframes gry-dash {
  0% { stroke-dashoffset: 100; opacity: 1; }
  70% { stroke-dashoffset: 0; opacity: 1; }
  92% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.demo-mini-grid { display: grid; gap: 5px; }
.demo-mini-grid .c {
  width: 46px; height: 46px;
  background: #fff; border: 2px solid #eadff5; border-radius: 10px;
  display: grid; place-items: center; font-size: 24px; font-weight: 800;
  position: relative;
}
.demo-swap { position: relative; width: 1.3em; height: 1.3em; }
.demo-swap span { position: absolute; inset: 0; display: grid; place-items: center; }
.demo-swap .q { animation: gry-q 2.4s infinite; }
.demo-swap .a { animation: gry-a 2.4s infinite; }
@keyframes gry-q { 0%, 45% { opacity: 1; transform: scale(1); } 55%, 100% { opacity: 0; transform: scale(.4); } }
@keyframes gry-a { 0%, 45% { opacity: 0; transform: scale(.4); } 60%, 100% { opacity: 1; transform: scale(1); } }
.demo-cards { display: flex; gap: 14px; }
.demo-card { width: 62px; height: 62px; position: relative; perspective: 500px; }
.demo-card i {
  position: absolute; inset: 0; border-radius: 14px;
  display: grid; place-items: center; font-size: 30px; font-style: normal;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.demo-card .f { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; font-size: 20px; animation: gry-flip-f 3s infinite; }
.demo-card .b { background: #fff; border: 3px solid #ffd6ef; animation: gry-flip-b 3s infinite; }
.demo-card:nth-child(2) .f, .demo-card:nth-child(2) .b { animation-delay: .5s; }
@keyframes gry-flip-f { 0%, 30% { transform: rotateY(0); } 45%, 85% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
@keyframes gry-flip-b { 0%, 30% { transform: rotateY(-180deg); } 45%, 85% { transform: rotateY(0); } 100% { transform: rotateY(180deg); } }
.demo-letters { display: flex; gap: 6px; position: relative; padding-bottom: 26px; }
.demo-letters .c { width: 44px; height: 44px; animation: gry-letter 2.8s infinite; }
.demo-letters .c:nth-child(2) { animation-delay: .35s; }
.demo-letters .c:nth-child(3) { animation-delay: .7s; }
@keyframes gry-letter {
  0%, 20% { background: #fff; }
  35%, 75% { background: var(--yellow); border-color: transparent; }
  90%, 100% { background: #fff; }
}
.demo-finger { position: absolute; bottom: 0; left: 0; font-size: 28px; animation: gry-finger 2.8s infinite; }
@keyframes gry-finger {
  0% { transform: translateX(6px); }
  40%, 70% { transform: translateX(106px); }
  100% { transform: translateX(6px); }
}
.demo-row { display: flex; gap: 6px; }
.demo-row .c.ok { animation: gry-ok 2.6s infinite; }
@keyframes gry-ok { 0%, 40% { opacity: 0; transform: scale(.4); } 55%, 100% { opacity: 1; transform: scale(1); } }

/* ---------- teaser page ---------- */
.gry-public-wrap { max-width: 900px; margin: 0 auto; padding: 18px 16px 60px; }
.gry-public-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.gry-public-top .brandline { display: flex; align-items: center; gap: 12px; }
.gry-public-top img { height: 44px; width: auto; display: block; }
.gry-public-top .t1 { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 22px; color: #4a3653; line-height: 1.1; }
.gry-public-top .t2 { font-size: 13px; color: #8a7a93; font-weight: 600; }
.gry-hero-strip {
  background: linear-gradient(120deg, #ffe3ec, #e8f1ff 70%);
  border: 3px solid #fff; border-radius: 24px;
  box-shadow: 0 10px 24px rgba(120, 80, 140, .12);
  padding: 16px 20px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 14px;
  font-family: "Baloo 2", sans-serif; color: #4a3653;
}
.gry-hero-strip .big { font-size: 42px; }
.gry-hero-strip h1 { margin: 0 0 2px; font-size: 21px; font-weight: 800; line-height: 1.2; }
.gry-hero-strip p { margin: 0; color: #6f5f7a; font-weight: 600; font-size: 14px; }

/* ---------- ranking (platform-side, matches platform cards) ---------- */
.rank-table { width: 100%; border-collapse: collapse; }
.rank-table td, .rank-table th { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line-soft, #f0ece1); }
.rank-table tr:last-child td { border-bottom: 0; }
.rank-table .num { width: 44px; font-weight: 700; color: var(--muted, #6b7a86); }
.rank-table .stars-col { text-align: right; font-weight: 700; white-space: nowrap; }
.rank-table tr.me td { background: var(--gold-soft, #f7f3e8); font-weight: 700; }
.rank-medal { font-size: 17px; }

@media (max-width: 380px) {
  .gry-hero-strip .big { font-size: 34px; }
}
