:root{
  --bg:#f3f6fb;
  --card-back:#0a3380;
  --card-front:#f3dfdf;
  --accent:#6b8cff;
  --text:#1f2a44;
  --shadow: 0 6px 18px rgba(16,22,43,0.12);
}

*{box-sizing:border-box}
html,body{height:100%; width:100%}
body{
  margin:0;
  font-family:Inter,system-ui,Segoe UI,Roboto,"Helvetica Neue",Arial;
    background: url("image/istockphoto-1369688290-612x612.jpg");
    background-size:cover;
  color:var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
  padding:20px;
  flex-direction: column;
}

.container{
  width:100%;
  max-width:980px;
  margin:0 auto;
}

/* Topbar */
.topbar{
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:column;
  gap:16px;
  color: #0b0101;
  margin-bottom:18px;
  font-size: 2rem;
  font-style: inherit;
}
.topbar h1{margin:0; margin-top:40px; font-size: 5rem}
.controls{display:flex;flex-direction:column;align-items:center;font-size: 3rem;}
.stats{display:flex;gap:12px;font-weight:1000}
.buttons{display:flex;gap:8px;align-items:center}
select,button{
  padding:8px 12px;
  border-radius:40px;
  border:4px solid rgba(16,22,43,0.08);
  background:rgb(196, 218, 108);
  cursor:pointer;
  font-weight:1000;
  font-size: 2rem;
  border-color: #0b0101;
}
button#newGameBtn{background:var(--accent);color:white;border:none}
button#playAgain{background:var(--card-back);color:white;border:none;padding:10px 16px;border-radius:8px}

/* Grid */
#gameArea{
  background:transparent;
  border-radius:14px;
  padding:12px;
  height:100%;
}
.grid{
  display:grid;
  gap:12px;
}

#grid {
  max-width: 700px;   /* increase from default */
  margin: 0;    
  width: 600px; /* center it */
  height: 600px;
}


/* Grid sizes controlled by classes */
.grid-4{ grid-template-columns: repeat(4, 1fr); }
.grid-6{ grid-template-columns: repeat(6, 1fr); }

/* Card */
.card{
  position:relative;
  width:100%;
  padding-top:80%; /* square */
  perspective:800px;
}
.card-inner{
  position:absolute;
  inset:0;
  transition: transform 0.45s;
  transform-style:preserve-3d;
  cursor:pointer;
  border-radius:10px;
  box-shadow:var(--shadow);
}
.card.flipped .card-inner{
  transform:rotateY(180deg);
}
.card-face{
  position:absolute;
  inset:0;
  backface-visibility:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:2rem;
  border-radius:10px;
  user-select:none;
}

/* front = face-up showing value */
.card-front{
  background:var(--card-front);
  border:1px solid rgba(16,22,43,0.06);
  transform:rotateY(180deg);
  font-size:1.6rem;
}

/* back = card back design */
.card-back{
  background:linear-gradient(135deg,var(--card-back),#1b51d6);
  color:white;
  font-weight:700;
  font-size:1.2rem;
  display:flex;
  flex-direction:column;
  gap:4px;
}

/* small label on back */
.card-back .label{
  font-size:0.75rem;
  opacity:0.9;
  transform:translateY(6px);
}

/* modal */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(10,14,30,0.35);
  z-index:30;
}
.modal.hidden{display:none}
.modal-content{
  background:white;
  padding:22px;
  border-radius:14px;
  min-width:280px;
  text-align:center;
  box-shadow:var(--shadow);
}
.footer{margin-top:16px;text-align:center;color:#6b7280}

/* responsive adjustments */
@media (max-width:640px){
  .grid-4{ grid-template-columns: repeat(4, 1fr); gap:8px }
  .topbar{flex-direction:column;align-items:flex-start;gap:10px}
}
@media (max-width:420px){
  .grid-4{ grid-template-columns: repeat(2, 1fr); }
}
.center-btn {
  text-align: center;
  margin-top: 16px;
}

#newGameBtn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 3rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.2s ease-in-out;
}

#newGameBtn:hover {
  background: #4b6ad9;
}