/* =========================
   DOTS & BOXES — PRO + RESPONSIVE
   ========================= */

:root{
  --green-900:#064e3b;
  --green-700:#065f46;
  --green-500:#22c55e;
  --green-400:#34d399;
  --mint:#bbf7d0;
  --bg1:#a8ff78;
  --bg2:#78ffd6;
  --card:#ffffff;
  --shadow:0 25px 55px rgba(0,0,0,.22);
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family:"Poppins",sans-serif;
  background:linear-gradient(135deg,var(--bg1),var(--bg2));
  color:#0f172a;
  text-align:center;
  overflow-x:hidden;
}

/* ===== Floating bubbles ===== */
.bg-bubble{
  position:fixed;
  width:320px;height:320px;
  border-radius:50%;
  background:rgba(255,255,255,.16);
  z-index:0;
  filter:blur(.2px);
  animation:float 12s ease-in-out infinite;
}
.b1{ top:-90px; left:-90px; }
.b2{ bottom:-90px; right:-90px; animation-delay:3.5s; }

@keyframes float{
  0%,100%{ transform:translateY(0); }
  50%{ transform:translateY(35px); }
}

/* ===== Page ===== */
.page-wrapper{
  width:95%;
  max-width:1100px;
  margin:34px auto 70px;
  position:relative;
  z-index:2;
}

.header{
  margin-bottom:18px;
  color:var(--green-900);
}
.header h1{
  font-size:clamp(28px, 5vw, 46px);
  margin:0;
  letter-spacing:.3px;
}
.header p{
  margin:10px 0 0;
  font-size:clamp(14px, 2.6vw, 18px);
  opacity:.9;
}

/* ===== Cards ===== */
.card{
  background:var(--card);
  border-radius:34px;
  padding:clamp(22px, 4vw, 34px) clamp(16px, 3vw, 26px);
  margin:18px auto;
  box-shadow:var(--shadow);
}

.card-icon{
  font-size:72px;
  margin-bottom:10px;
}

/* ===== Controls ===== */
.start-card input,
.start-card select{
  width:min(360px, 92%);
  padding:14px 18px;
  border-radius:22px;
  border:3px solid var(--mint);
  background:#f0fdf4;
  font-size:16px;
  font-weight:700;
  outline:none;
  margin:10px auto;
  display:block;
  transition:.2s;
  text-align:center;
  color:var(--green-700);
}

.start-card input::placeholder{
  color:#6b7280;
  font-weight:600;
}

.start-card select{
  appearance:none;
  background-image:url("data:image/svg+xml;utf8,<svg fill='%23065f46' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");
  background-repeat:no-repeat;
  background-position:right 16px center;
  background-size:18px;
  cursor:pointer;
}

.start-card input:focus,
.start-card select:focus{
  border-color:var(--green-500);
  box-shadow:0 0 0 4px rgba(34,197,94,.22);
  transform:translateY(-1px);
}

/* buttons */
button{
  padding:14px 32px;
  border:none;
  border-radius:999px;
  background:var(--green-500);
  color:white;
  font-weight:800;
  cursor:pointer;
  transition:.18s;
  box-shadow:0 14px 30px rgba(34,197,94,.25);
  touch-action:manipulation;
}
button:hover{ transform:translateY(-2px); background:#16a34a; }
button:active{ transform:translateY(0px) scale(.99); }

/* ===== Score Card ===== */
.score-card{
  background:linear-gradient(180deg,#ffffff,#f6fff8);
  padding:18px 20px;
  border-radius:24px;
  box-shadow:0 14px 35px rgba(0,0,0,.18);
  margin:0 auto 18px;
  max-width:900px;
}

.match-line{
  font-size:clamp(16px, 3vw, 26px);
  font-weight:900;
  color:var(--green-700);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
}

.vs{
  padding:6px 14px;
  border-radius:999px;
  background:rgba(34,197,94,.14);
  color:#16a34a;
  font-weight:900;
  letter-spacing:.6px;
}

.round-line{
  margin-top:8px;
  font-size:clamp(14px, 2.5vw, 18px);
  font-weight:800;
  color:#111827;
  opacity:.9;
}

/* =========================
   ✅ RESPONSIVE BOARD FIX
   ========================= */

.board-wrap{
  width:100%;
  display:flex;
  justify-content:center;
  align-items:center;
  margin:0 auto;
}

/* Board scales to screen, never overflow */
#board{
  display:grid;
  width:min(92vw, 560px);
  aspect-ratio:1/1;
  padding:clamp(10px, 2.4vw, 14px);
  gap:clamp(4px, 1.3vw, 10px);
  border-radius:28px;
  background:linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.45));
  box-shadow:inset 0 0 0 2px rgba(6,95,70,.12), 0 18px 40px rgba(0,0,0,.18);
  overflow:hidden;
  touch-action:manipulation;
}

/* Each grid cell */
.cell{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
  min-height:0;
}

/* dots scale */
.dot{
  width:clamp(10px, 2.3vw, 20px);
  height:clamp(10px, 2.3vw, 20px);
  background:var(--green-900);
  border-radius:50%;
  box-shadow:0 6px 16px rgba(0,0,0,.18);
}

/* lines scale and fill their cell */
.line{
  background:#e5e7eb;
  border-radius:999px;
  cursor:pointer;
  transition:.15s;
  box-shadow:inset 0 0 0 2px rgba(0,0,0,.03);
}

.line:hover{ transform:scale(1.05); background:#cbd5e1; }

/* Horizontal line fills width */
.line.h{
  width:100%;
  height:clamp(10px, 1.8vw, 16px);
}

/* Vertical line fills height */
.line.v{
  height:100%;
  width:clamp(10px, 1.8vw, 16px);
}

/* boxes fill their cell */
.box{
  width:100%;
  height:100%;
  border-radius:clamp(12px, 2vw, 24px);
  background:#f1f5f9;
  font-size:clamp(16px, 3.8vw, 36px);
  display:flex;
  align-items:center;
  justify-content:center;
  transform:scale(.7);
  opacity:.4;
  transition:.22s;
  box-shadow:0 12px 22px rgba(0,0,0,.08);
}
.box.show{
  transform:scale(1);
  opacity:1;
}

/* ===== Helpers ===== */
.hidden{ display:none; }

/* ===== End Overlay ===== */
.endOverlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.82);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:999;
  padding:20px;
}
.endOverlay.show{ display:flex; }

.endBox{
  width:min(520px, 96%);
  background:white;
  padding:36px 28px;
  border-radius:28px;
  text-align:center;
  position:relative;
  overflow:hidden;
  box-shadow:0 30px 80px rgba(0,0,0,.4);
}

#endEmoji{
  font-size:84px;
  margin-bottom:8px;
  animation:bounce 1s infinite;
}
#endText{
  margin:0 0 14px;
  font-size:clamp(18px, 4vw, 28px);
  font-weight:900;
  color:var(--green-700);
}

@keyframes bounce{
  0%,100%{ transform:translateY(0); }
  50%{ transform:translateY(-18px); }
}

#fireworks{
  position:absolute;
  inset:0;
  pointer-events:none;
}

/* ===== GAME ACTION BUTTONS ===== */
.game-actions{
  margin-top:18px;
  display:flex;
  justify-content:center;
  gap:14px;
  flex-wrap:wrap;
}

.other-games-btn{
  padding:12px 26px;
  border-radius:999px;
  font-weight:800;
  border:none;
  cursor:pointer;
  text-decoration:none;
  color:white;
  background:#16a34a;
  transition:.2s;
  box-shadow:0 10px 25px rgba(0,0,0,.2);
}
.other-games-btn:hover{
  transform:translateY(-2px);
  background:#15803d;
}

/* small devices spacing */
@media (max-width:420px){
  .page-wrapper{ margin-top:22px; }
  .card-icon{ font-size:60px; }
}
