
:root{
  --card: 84px;
  --gap: 10px;
  --cols: 4;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:'Baloo 2', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:#13213c;
  overflow-x:hidden;
}

/* floating background */
.bg-bubbles{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:0;
  opacity:.28;
}
.bg-bubbles span{
  position:absolute;
  display:block;
  width:18px;height:18px;
  background:rgba(255,255,255,.9);
  border-radius:999px;
  animation: floatUp 12s linear infinite;
  filter: blur(.3px);
}
.bg-bubbles span:nth-child(1){ left:10%; bottom:-40px; animation-duration: 12s; transform:scale(1.2); }
.bg-bubbles span:nth-child(2){ left:30%; bottom:-40px; animation-duration: 16s; transform:scale(.9); }
.bg-bubbles span:nth-child(3){ left:55%; bottom:-40px; animation-duration: 14s; transform:scale(1.4); }
.bg-bubbles span:nth-child(4){ left:75%; bottom:-40px; animation-duration: 18s; transform:scale(1.0); }
.bg-bubbles span:nth-child(5){ left:90%; bottom:-40px; animation-duration: 20s; transform:scale(1.6); }
@keyframes floatUp{
  from{ transform: translateY(0) scale(1); opacity:.0; }
  10%{opacity:.6;}
  to{ transform: translateY(-110vh) scale(1.4); opacity:0; }
}

/* layout */
.layout-wrapper{
  position:relative;
  z-index:1;
  display:flex;
  gap:28px;
  align-items:flex-start;
  justify-content:center;
  padding:18px 18px 28px;
}

/* sidebar */
.online-sidebar{
  width:260px;
  background:rgba(255,255,255,.92);
  border-radius:22px;
  padding:18px 18px 14px;
  box-shadow:0 14px 40px rgba(20,30,60,.12);
  position:sticky;
  top:18px;
  height:fit-content;
  backdrop-filter: blur(6px);
}
.side-title{ font-weight:800; font-size:18px; text-align:center; }
.side-count{ text-align:center; margin-top:6px; }
.side-count span{
  display:inline-flex;
  min-width:64px;
  justify-content:center;
  padding:8px 14px;
  border-radius:999px;
  background:linear-gradient(135deg,#b7ffcd,#e7fff0);
  color:#167d2f;
  font-size:28px;
  font-weight:900;
  box-shadow: inset 0 0 0 2px rgba(22,125,47,.12);
}
.side-sub{ text-align:center; font-size:12px; opacity:.7; margin-top:6px; }
.side-list{ list-style:none; padding:0; margin:12px 0 10px; max-height:320px; overflow:auto; }
.side-list li{
  padding:8px 10px;
  border-radius:14px;
  margin-bottom:8px;
  background:rgba(19,33,60,.04);
  font-weight:800;
  display:flex;
  align-items:center;
  gap:10px;
}
.side-list li .dot{ width:9px; height:9px; border-radius:99px; background:#25c46b; box-shadow:0 0 0 4px rgba(37,196,107,.18); }
.side-note{ font-size:12px; opacity:.75; text-align:center; }

/* content */
.game-content{
  width:min(980px, calc(100vw - 320px));
  min-width:320px;
}

.site-header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
  margin:6px auto 10px;
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-radius:18px;
  background:rgba(255,255,255,.88);
  box-shadow:0 12px 36px rgba(20,30,60,.10);
}
.brand-badge{
  width:44px;height:44px;
  display:grid;place-items:center;
  font-size:22px;
  border-radius:14px;
  background:linear-gradient(135deg,#ffe7a8,#ffd0f3);
}
.brand-text h1{ margin:0; font-size:22px; line-height:1.1; }
.tagline{ margin:2px 0 0; font-size:13px; opacity:.75; }
.tagline a{ color:#0b67ff; text-decoration:none; }

.header-badges{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:flex-end;
}
.badge{
  background:rgba(255,255,255,.9);
  border-radius:999px;
  padding:10px 12px;
  box-shadow:0 10px 30px rgba(20,30,60,.10);
  font-weight:800;
  font-size:14px;
}

/* container */
.container{
  background:rgba(255,255,255,.82);
  border-radius:24px;
  box-shadow:0 18px 60px rgba(20,30,60,.12);
  padding:16px 16px 18px;
  margin:10px auto;
}

/* toolbar */
.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:end;
  justify-content:space-between;
}
.tool label{ display:block; font-size:12px; opacity:.75; margin:0 0 4px; font-weight:800;}
.tool select{
  width:190px;
  padding:10px 12px;
  border-radius:14px;
  border:2px solid rgba(19,33,60,.12);
  background:#fff;
  font-family:inherit;
  font-weight:800;
  outline:none;
}
.kid-btn{
  border:none;
  padding:11px 14px;
  border-radius:16px;
  cursor:pointer;
  font-family:inherit;
  font-weight:900;
  background:linear-gradient(135deg,#8ad0ff,#b1ffdf);
  box-shadow:0 12px 30px rgba(20,30,60,.14);
  transition: transform .12s ease, filter .12s ease;
}
.kid-btn:hover{ transform: translateY(-1px); filter:saturate(1.1); }
.kid-btn:active{ transform: translateY(1px) scale(.99); }
.kid-btn.alt{ background:linear-gradient(135deg,#ffd1a8,#ffd0f3); }
.kid-btn.ghost{ background:rgba(255,255,255,.85); border:2px solid rgba(19,33,60,.12); box-shadow:none; }
.kid-btn.big{ padding:13px 16px; border-radius:18px; font-size:16px; }

/* start screen */
.start-screen{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  background:radial-gradient(circle at 20% 10%, rgba(255,255,255,.75), rgba(255,255,255,.3)),
             linear-gradient(135deg, rgba(138,208,255,.75), rgba(177,255,223,.75));
}
.welcome-box{
  width:min(420px, 92vw);
  background:rgba(255,255,255,.92);
  border-radius:26px;
  padding:18px 18px 16px;
  box-shadow:0 22px 80px rgba(20,30,60,.20);
  text-align:center;
  animation: popIn .22s ease both;
}
@keyframes popIn{ from{ transform: translateY(10px) scale(.98); opacity:0;} to{ transform:none; opacity:1;} }
.welcome-emoji{ font-size:44px; }
.welcome-top h2{ margin:6px 0 2px; }
.name-area{ text-align:left; margin:10px 0 12px; }
.name-area input{
  width:100%;
  padding:12px 12px;
  border-radius:16px;
  border:2px solid rgba(19,33,60,.12);
  font-family:inherit;
  font-weight:900;
  font-size:16px;
}
.welcome-hint{ font-size:12px; opacity:.75; margin-top:10px; }

/* board */
.game-area{ padding:14px 6px 8px; }
.board{
  margin:12px auto 6px;
  display:grid;
  justify-content:center;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols), var(--card));
}
.card{
  width: var(--card);
  height: var(--card);
  perspective: 800px;
  cursor:pointer;
  user-select:none;
}
.inner{
  width:100%;
  height:100%;
  position:relative;
  transform-style:preserve-3d;
  transition: transform .35s cubic-bezier(.2,.9,.2,1);
}
.card.flip .inner{ transform: rotateY(180deg); }
.face{
  position:absolute;
  inset:0;
  border-radius:18px;
  display:grid;
  place-items:center;
  backface-visibility:hidden;
  font-weight:900;
  box-shadow:0 14px 30px rgba(20,30,60,.12);
}
.front{
  background:linear-gradient(135deg,#ffffff,#f2fbff);
  border:2px solid rgba(19,33,60,.10);
  font-size:28px;
}
.back{
  transform: rotateY(180deg);
  background:linear-gradient(135deg,#fff3c6,#ffd2f4);
  border:2px solid rgba(19,33,60,.08);
  font-size:34px;
}
.card.matched .face{ animation: matchedPop .38s ease; }
@keyframes matchedPop{
  0%{ transform: scale(1); }
  40%{ transform: scale(1.10); }
  100%{ transform: scale(1); }
}
.card.wrong .inner{ animation: shake .32s ease; }
@keyframes shake{
  0%,100%{ transform: translateX(0) rotateY(180deg); }
  25%{ transform: translateX(-6px) rotateY(180deg); }
  75%{ transform: translateX(6px) rotateY(180deg); }
}

/* modal */
.modal{
  position:fixed;
  inset:0;
  background:rgba(10,20,40,.35);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
}
.modal.show{ display:flex; }
.modal .box{
  width:min(420px, 92vw);
  background:rgba(255,255,255,.95);
  border-radius:26px;
  padding:18px 18px 16px;
  text-align:center;
  box-shadow:0 26px 90px rgba(10,20,40,.25);
  animation: popIn .22s ease both;
}
.win-badge{ font-size:44px; }
.win-line{ font-size:16px; font-weight:900; margin:10px 0 12px; }
.win-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.stars-row{ margin:8px 0 12px; display:flex; gap:10px; justify-content:center; }
.stars-row .star{ font-size:24px; animation: twinkle 1.2s ease-in-out infinite; }
.stars-row .star:nth-child(2){ animation-delay:.15s; }
.stars-row .star:nth-child(3){ animation-delay:.3s; }
@keyframes twinkle{ 0%,100%{ transform: translateY(0) scale(1); opacity:.8;} 50%{ transform: translateY(-4px) scale(1.12); opacity:1;} }

/* emoji rain */
.emoji-rain{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:9998;
}
.emoji{
  position:absolute;
  top:-40px;
  animation: fall linear forwards;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.12));
}
@keyframes fall{
  to{ transform: translateY(110vh) rotate(20deg); opacity:0.95; }
}

/* confetti canvas */
#confetti{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:9997;
}

/* seo block */
.seo-block{ margin-top:12px; opacity:.9; }
.seo-block h2{ margin:6px 0 4px; font-size:18px; }
.seo-block p{ margin:0; }

/* footer */
.site-footer{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:10px 6px 0;
  opacity:.75;
  font-weight:800;
}
.site-footer a{ color:#0b67ff; text-decoration:none; }

/* themes */
body.theme-kids{ background: linear-gradient(135deg,#9ad7ff,#c2ffe7); }
body.theme-animals{ background: linear-gradient(135deg,#a6ffcc,#ffe6a3); }
body.theme-fruits{ background: linear-gradient(135deg,#ffd1e1,#ffeaa8); }
body.theme-toys{ background: linear-gradient(135deg,#b8c7ff,#ffd0f3); }
body.theme-space{ background: linear-gradient(135deg,#1a2a6c,#b21f1f,#fdbb2d); color:#fff; }
body.theme-ocean{ background: linear-gradient(135deg,#00c6ff,#0072ff); color:#fff; }
body.theme-candy{ background: linear-gradient(135deg,#ff9a9e,#fad0c4,#fbc2eb); }

body.theme-space .container,
body.theme-ocean .container{
  background: rgba(255,255,255,.92);
  color:#13213c;
}
body.theme-space .brand,
body.theme-ocean .brand{ background: rgba(255,255,255,.92); color:#13213c; }
body.theme-space .badge,
body.theme-ocean .badge{ background: rgba(255,255,255,.92); color:#13213c; }

@media (max-width: 1020px){
  .layout-wrapper{ flex-direction:column; align-items:stretch; }
  .online-sidebar{ width:auto; position:relative; top:auto; }
  .game-content{ width:auto; }
  .site-header{ flex-direction:column; align-items:stretch; }
  .header-badges{ justify-content:flex-start; }
}

/* ✅ MOBILE EMOJI FIX ONLY */
@media (max-width:900px){

  .face{
    font-size: calc(var(--card) * 0.42);
    line-height:1;
    display:flex;
    align-items:center;
    justify-content:center;
  }

}
