:root{
  --brand:#37a16f; --brand2:#2a7bc1;
  --bg:#f7faf8; --card:#ffffff; --ink:#1b1f23;
  --good:#22c55e; --bad:#ef4444;
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Helvetica Neue,Arial;background:var(--bg);color:var(--ink)}
.header{display:flex;align-items:center;gap:12px;padding:16px 20px;background:linear-gradient(135deg,#e7f6ee,#e6f1fb);border-bottom:1px solid #e4e4e7;position:sticky;top:0;z-index:10}
.header img{height:58px;border-radius:12px;object-fit:contain}
.header .title{font-weight:700;font-size:22px}
.header .subtitle{font-size:12px;color:#475569}
.container{max-width:1180px;margin:10px auto;padding:16px;display:grid;grid-template-columns:360px 1fr;gap:16px}
.card{background:var(--card);border:1px solid #e4e4e7;border-radius:16px;box-shadow:0 4px 10px rgba(0,0,0,.04);padding:16px}
.controls .row{display:flex;gap:10px;align-items:center;margin-bottom:10px;flex-wrap:wrap}
.controls select,.controls input{padding:10px 12px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;min-width:120px}
.controls button{padding:10px 14px;border-radius:12px;border:0;cursor:pointer;font-weight:600}
.btn-primary{background:var(--brand);color:#fff}
.btn-secondary{background:#e6f1fb;color:#0b4e94}
.btn-ghost{background:#f3f4f6;color:#111827}
.btn-wide{min-width:160px}
.badge{display:inline-block;padding:6px 10px;border-radius:999px;background:#eef2ff;color:#1e3a8a;font-weight:700;font-size:12px}
.stats{display:flex;gap:12px;flex-wrap:wrap}
.stat{background:#f3f4f6;border-radius:10px;padding:8px 10px;font-size:12px}
.small{font-size:12px;color:#475569}
footer{margin:24px auto 40px;max-width:1100px;padding:0 16px;color:#6b7280;font-size:12px;text-align:center}

.board{display:grid;gap:12px;justify-content:center;padding:10px}
/* grid auto-fit based on card count (12,16,20) */
.board.cols-6{grid-template-columns:repeat(4, minmax(110px, 1fr))} /* 12 cards */
.board.cols-8{grid-template-columns:repeat(4, minmax(110px, 1fr))} /* 16 cards */
.board.cols-10{grid-template-columns:repeat(5, minmax(110px, 1fr))} /* 20 cards */

.cardcell{
  width:140px;height:170px;perspective:1000px;position:relative
}
.cardface{
  position:absolute;inset:0;border-radius:14px;border:1px solid #e5e7eb;background:#fff;display:flex;align-items:center;justify-content:center;
  backface-visibility:hidden;transition:transform .4s ease, box-shadow .2s ease;
  box-shadow:0 6px 12px rgba(0,0,0,.05);
  overflow:hidden;padding:8px
}
.cardface.front{transform:rotateY(180deg)}
.cardface.back{background:linear-gradient(135deg,#dbeafe,#dcfce7); color:#0f172a; font-weight:800; font-size:18px; letter-spacing:.5px}
.flip .front{transform:rotateY(0)}
.flip .back{transform:rotateY(180deg)}
.cardface.found{outline:3px solid var(--brand); box-shadow:0 10px 16px rgba(0,0,0,.08)}

.mini-grid{width:100%;aspect-ratio:1;border-radius:10px;border:1px solid #e5e7eb;display:grid;grid-template-columns:repeat(10,1fr);grid-template-rows:repeat(10,1fr);overflow:hidden;background:#fff}
.mini-cell{border:1px dashed #eef2f7;display:flex;align-items:center;justify-content:center}
.mini-dot{width:60%;aspect-ratio:1;border-radius:999px;background:var(--brand2);box-shadow:inset 0 -5px 8px rgba(0,0,0,.15)}

.numBadge{position:absolute;bottom:6px;right:6px;background:#111827;color:#fff;padding:4px 8px;border-radius:999px;font-size:12px;opacity:.92;display:none}

.feedback{min-height:26px;text-align:center;font-weight:700;margin-top:8px}
.feedback.good{color:var(--good)} .feedback.bad{color:var(--bad)}

.confetti{pointer-events:none;position:fixed;inset:0;overflow:hidden;background:transparent}
.confetti span{position:absolute;animation:fly 2s ease-out forwards}
@keyframes fly{to{transform:translateY(60vh) rotate(340deg);opacity:0}}

.big-ui .controls select,.big-ui .controls input{font-size:20px;padding:16px 18px;min-width:180px}
.big-ui .controls button{font-size:20px;padding:18px 22px;min-width:160px;border-radius:16px}
.big-ui .cardcell{width:160px;height:200px}
.big-ui .board{gap:16px}
.big-ui .title{font-size:26px}
.big-ui .subtitle{font-size:14px}
