:root{
  --bg-1:#fff8fc;
  --bg-2:#f6f4ff;
  --card:rgba(255,255,255,.92);
  --text:#2f2440;
  --muted:#786d8a;
  --pink:#ff78b2;
  --pink-dark:#e05597;
  --purple:#9f7dff;
  --blue:#79d0ff;
  --mint:#7adbc7;
  --gold:#ffc85f;
  --shadow:0 18px 46px rgba(86,53,116,.14);
  --shadow-soft:0 10px 24px rgba(86,53,116,.10);
  --panel:#7d6aa8;
  --panel-dark:#5d4f7e;
  --grid-bg:rgba(126, 145, 175, .45);
}

*{box-sizing:border-box}

html{direction:rtl}

body{
  margin:0;
  min-height:100vh;
  font-family:Tahoma, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top right, rgba(255,203,227,.55), transparent 28%),
    radial-gradient(circle at bottom left, rgba(215,223,255,.72), transparent 34%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

a{
  color:inherit;
  text-decoration:none;
}

button{
  font-family:inherit;
}

.game-page{
  min-height:100vh;
  padding:20px 14px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.game-shell{
  width:min(100%, 1120px);
}

.game-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.back-link,
.brand-badge{
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 16px;
  border-radius:999px;
  background:rgba(255,255,255,.85);
  box-shadow:var(--shadow-soft);
  font-weight:700;
}

.back-link{color:var(--muted)}

.brand-badge{
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
}

.game-card{
  background:var(--card);
  box-shadow:var(--shadow);
  border-radius:32px;
  padding:22px;
}

.game-header{
  display:grid;
  grid-template-columns:minmax(0,1fr) 220px;
  gap:18px;
  align-items:start;
  margin-bottom:18px;
}

.game-kicker{
  margin:0 0 8px;
  color:var(--pink-dark);
  font-size:14px;
  font-weight:800;
}

h1{
  margin:0 0 8px;
  font-size:clamp(34px, 6vw, 58px);
  line-height:1.08;
}

.game-desc{
  margin:0;
  color:var(--muted);
  line-height:1.9;
  font-size:15px;
  max-width:720px;
}

.scoreBoard{
  background:linear-gradient(180deg, #8fdfff, #78c7ff);
  border-radius:24px;
  min-height:160px;
  padding:18px 14px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  text-align:center;
  color:#3f3550;
  box-shadow:var(--shadow-soft);
}

.scoreBoard h3,
.scoreBoard h2{
  margin:0;
}

.scoreBoard h3{
  font-size:14px;
  font-weight:800;
}

.scoreBoard h2{
  font-size:40px;
  margin:6px 0 10px;
}

#timer{
  min-height:24px;
  font-size:15px;
  font-weight:700;
  color:#5b4d72;
}

#changeMode{
  margin-top:10px;
  border:0;
  min-height:42px;
  padding:0 14px;
  border-radius:14px;
  background:linear-gradient(135deg, #ff8d8d, #ff6e8b);
  color:#fff;
  font-size:14px;
  font-weight:800;
  cursor:pointer;
}

.game-stage{
  display:flex;
  justify-content:center;
}

.grid{
  display:grid;
  grid-template-columns:repeat(8, 1fr);
  gap:4px;
  width:min(100%, 560px);
  aspect-ratio:1 / 1;
  background:var(--grid-bg);
  padding:8px;
  border-radius:24px;
  box-shadow:inset 0 2px 10px rgba(0,0,0,.08);
}

.grid div{
  width:100%;
  aspect-ratio:1 / 1;
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  border-radius:14px;
  transition:transform .15s ease;
}

.grid div:hover{
  transform:scale(1.04);
}

.game-note{
  margin:16px 0 0;
  color:var(--muted);
  line-height:1.9;
  font-size:15px;
  text-align:center;
}

.mode-overlay{
  position:fixed;
  inset:0;
  z-index:40;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:linear-gradient(135deg, rgba(255,248,252,.95), rgba(246,244,255,.95));
}

.mode-card{
  width:min(100%, 420px);
  background:rgba(255,255,255,.95);
  border-radius:28px;
  padding:24px;
  text-align:center;
  box-shadow:var(--shadow);
}

.mode-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  padding:0 14px;
  border-radius:999px;
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
  font-weight:800;
  margin-bottom:14px;
}

.mode-card h2{
  margin:0 0 10px;
  font-size:30px;
}

.mode-card p{
  margin:0;
  color:var(--muted);
  line-height:1.9;
  font-size:15px;
}

.mode-actions{
  display:grid;
  gap:12px;
  margin-top:18px;
}

.mode-actions button{
  border:0;
  min-height:50px;
  border-radius:16px;
  font-size:16px;
  font-weight:800;
  cursor:pointer;
  color:#fff;
  box-shadow:var(--shadow-soft);
}

#endlessMode{
  background:linear-gradient(135deg,var(--pink),var(--purple));
}

#timedMode{
  background:linear-gradient(135deg,var(--blue),var(--mint));
}

@media (max-width: 900px){
  .game-header{
    grid-template-columns:1fr;
  }

  .scoreBoard{
    width:100%;
    min-height:auto;
  }
}

@media (max-width: 640px){
  .game-page{
    padding:14px 10px;
    align-items:flex-start;
  }

  .game-card{
    padding:16px;
    border-radius:24px;
  }

  .grid{
    gap:3px;
    padding:6px;
    border-radius:18px;
  }

  .grid div{
    border-radius:10px;
  }

  .mode-card{
    padding:20px 16px;
    border-radius:24px;
  }

  .game-desc,
  .game-note,
  .mode-card p{
    font-size:14px;
  }
}