/* ============================================================
   iplay.free — SHARED design system (the ONE candy look).
   Every game links this. Change the palette / chrome here and
   ALL games update. Game-specific visuals (tiles, disks, pegs,
   picture mode) live in each game's own <style>/game CSS.

   Color utilities are generic (c-pink, c-teal, c-grape, c-lime,
   c-orange, c-white) so new games don't inherit game-specific
   class names. Fonts (Fredoka + Nunito) are loaded per game via
   a Google Fonts <link> in the game's index.html.
   ============================================================ */

:root {
  --bg1: #ffd54a; --bg2: #ff8a5c; --bg3: #7c6cff;
  --ink: #2b1a4a; --panel: #fffdf5;
  --pink: #ff5d8f; --teal: #19c3b2; --grape: #7c6cff; --lime: #9be15d;
  --shadow: 0 8px 0 rgba(43, 26, 74, .18), 0 16px 30px rgba(43, 26, 74, .22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Nunito', sans-serif; color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #fff3b0 0%, transparent 55%),
    radial-gradient(1000px 700px at 100% 0%, #ffc1d6 0%, transparent 50%),
    linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 45%, var(--bg3) 120%);
  background-attachment: fixed; overflow-x: hidden; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
}

.doodle { position: fixed; font-size: 34px; opacity: .32; animation: bob 6s ease-in-out infinite; pointer-events: none; z-index: 0; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .1)); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-8deg) } 50% { transform: translateY(-22px) rotate(8deg) } }

.wrap { position: relative; z-index: 1; width: 100%; max-width: 880px; margin-block: auto; padding: 22px 16px; }

header { text-align: center; margin-bottom: 8px; }
.logo {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: clamp(32px, 8vw, 58px); line-height: 1;
  color: #fff; letter-spacing: .5px;
  text-shadow: 0 3px 0 var(--pink), 0 6px 0 rgba(43, 26, 74, .35), 0 10px 18px rgba(43, 26, 74, .4);
  transform-origin: center center; animation: seesaw 2.6s ease-in-out infinite;
}
@keyframes seesaw { 0%, 100% { transform: rotate(-4deg) } 50% { transform: rotate(4deg) } }
.tag {
  font-family: 'Fredoka'; font-weight: 500; color: var(--ink); background: #fff; display: inline-block;
  padding: 4px 14px; border-radius: 999px; margin-top: 20px; font-size: 14px;
  box-shadow: 0 4px 0 rgba(43, 26, 74, .18); transform: rotate(1deg);
}

.hud { display: flex; gap: 12px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.stat { background: var(--panel); border-radius: 18px; padding: 8px 18px; min-width: 96px; text-align: center; box-shadow: var(--shadow); border: 3px solid #fff; }
.stat .k { font-family: 'Fredoka'; font-weight: 600; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; opacity: .6; }
.stat .v { font-family: 'Fredoka'; font-weight: 700; font-size: 26px; line-height: 1; }
.stat.c-grape .v { color: var(--grape); }
.stat.c-pink .v { color: var(--pink); }
.stat.c-teal .v { color: var(--teal); }

.board-card { background: rgba(255, 255, 255, .55); backdrop-filter: blur(4px); border-radius: 30px; padding: 16px; margin: 0 auto; width: max-content; max-width: 100%; box-shadow: var(--shadow); border: 4px solid #fff; }

.goalwrap { text-align: center; margin-top: 14px; }
.goal-pill { display: inline-flex; gap: 8px; align-items: center; font-family: 'Fredoka'; font-weight: 600; font-size: 15px; background: var(--panel); border: 3px solid #fff; border-radius: 999px; padding: 9px 18px; box-shadow: var(--shadow); color: var(--ink); }
.goal-pill b { color: var(--pink); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
button.btn { font-family: 'Fredoka'; font-weight: 600; font-size: 17px; color: #fff; border: none; cursor: pointer; padding: 13px 20px; border-radius: 16px; position: relative; transition: transform .08s, box-shadow .08s, filter .1s; box-shadow: 0 5px 0 rgba(0, 0, 0, .22); }
button.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.btn.c-pink { background: linear-gradient(var(--pink), #e63e74); }
.btn.c-teal { background: linear-gradient(var(--teal), #0fa394); }
.btn.c-grape { background: linear-gradient(var(--grape), #5a4ad1); }
.btn.c-orange { background: linear-gradient(#ff9f43, #f0820f); }
.btn.c-lime { background: linear-gradient(var(--lime), #6fb83a); color: #1d3d00; }
.btn.c-white { background: #fff; color: var(--ink); box-shadow: 0 5px 0 rgba(43, 26, 74, .18); }

footer { text-align: center; margin-top: 26px; font-family: 'Fredoka'; font-weight: 500; color: var(--ink); opacity: .7; font-size: 13px; }

/* ---------- Settings drawer (right) + Rules flyout (left) ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(43, 26, 74, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 54; }
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(400px, 92vw); background: linear-gradient(160deg, #fff7e6, #ffe9f1); transform: translateX(105%); transition: transform .32s cubic-bezier(.4, 1.2, .5, 1); z-index: 55; overflow-y: auto; box-shadow: -12px 0 40px rgba(43, 26, 74, .35); padding: 18px 18px 40px; border-left: 5px solid #fff; }
.drawer.open { transform: translateX(0); }
.rules-drawer { position: fixed; top: 0; left: 0; height: 100%; width: min(420px, 92vw); background: linear-gradient(160deg, #fff7e6, #e9f3ff); transform: translateX(-105%); transition: transform .32s cubic-bezier(.4, 1.2, .5, 1); z-index: 55; overflow-y: auto; box-shadow: 12px 0 40px rgba(43, 26, 74, .35); padding: 18px 18px 40px; border-right: 5px solid #fff; }
.rules-drawer.open { transform: translateX(0); }
.rule { display: flex; gap: 12px; align-items: flex-start; font-family: 'Nunito'; font-weight: 700; font-size: 15px; line-height: 1.45; margin: 12px 2px; }
.rule .ic { font-size: 24px; flex: 0 0 auto; line-height: 1.2; }
.rule b { color: var(--grape); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; position: sticky; top: -18px; background: linear-gradient(#fff7e6, #fff7e6); padding: 10px 0 8px; z-index: 2; }
.drawer-head .t { font-family: 'Fredoka'; font-weight: 700; font-size: 26px; color: var(--grape); }
.xbtn { font-family: 'Fredoka'; font-weight: 700; font-size: 24px; line-height: 1; border: none; background: #fff; color: var(--ink); width: 42px; height: 42px; border-radius: 50%; cursor: pointer; box-shadow: 0 4px 0 rgba(43, 26, 74, .18); }
.xbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(43, 26, 74, .18); }

.panel { background: var(--panel); border-radius: 22px; padding: 15px; margin-top: 14px; box-shadow: 0 5px 0 rgba(43, 26, 74, .1); border: 3px solid #fff; }
.panel h2 { font-family: 'Fredoka'; font-weight: 600; margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.panel .hint-txt { font-size: 13px; opacity: .6; margin: 0 0 10px; font-family: 'Nunito'; font-weight: 700; }

.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.lvlbtn { font-family: 'Fredoka'; font-weight: 600; font-size: 14px; cursor: pointer; border: 3px solid transparent; padding: 9px 8px; border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 4px 0 rgba(43, 26, 74, .14); transition: transform .08s, border-color .1s, box-shadow .08s; text-align: center; line-height: 1.15; }
.lvlbtn small { display: block; font-weight: 600; font-size: 11px; opacity: .55; }
.lvlbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(43, 26, 74, .14); }
.lvlbtn.active { border-color: var(--pink); color: var(--pink); background: #fff0f5; box-shadow: 0 4px 0 rgba(255, 93, 143, .3); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.toggle-row .lab { font-family: 'Fredoka'; font-weight: 500; font-size: 15px; }
.switch { position: relative; width: 54px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d9d3e8; border-radius: 999px; cursor: pointer; transition: .2s; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15); }
.slider:before { content: ""; position: absolute; height: 22px; width: 22px; left: 4px; top: 4px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.switch input:checked + .slider { background: var(--teal); }
.switch input:checked + .slider:before { transform: translateX(24px); }
.drawer .btn.done { width: 100%; justify-content: center; margin-top: 18px; font-size: 18px; }

/* ---------- Win modal + confetti + toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(43, 26, 74, .55); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 70; padding: 20px; }
.modal-back.show { display: flex; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--panel); border-radius: 30px; padding: 26px; text-align: center; max-width: 340px; width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); border: 5px solid #fff; animation: pop .4s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pop { from { transform: scale(.7); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal .big { font-size: 64px; line-height: 1; animation: spin 1.2s ease; }
@keyframes spin { from { transform: rotate(-20deg) scale(.5) } to { transform: rotate(0) scale(1) } }
.modal h3 { font-family: 'Fredoka'; font-weight: 700; font-size: 30px; margin: 8px 0 4px; color: var(--pink); }
.modal p { font-family: 'Nunito'; font-weight: 700; margin: 4px 0 14px; }
.stars { font-size: 40px; letter-spacing: 6px; margin: 6px 0 14px; }
.modal .btn { width: 100%; justify-content: center; font-size: 18px; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; display: none; }
.toast { position: fixed; left: 50%; bottom: 42px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; font-family: 'Fredoka'; font-weight: 600; padding: 12px 22px; border-radius: 16px; box-shadow: 0 10px 28px rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 75; font-size: 15px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Accessibility: respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; transform: rotate(-2deg); }
  .doodle { animation: none; }
}
