:root{
  --bg-1:#fff8fc;
  --bg-2:#f6f4ff;
  --card-bg:rgba(255,255,255,.92);
  --text:#2f2440;
  --muted:#786d8a;
  --pink:#ff78b2;
  --pink-dark:#e05597;
  --purple:#9f7dff;
  --blue:#79d0ff;
  --shadow:0 18px 46px rgba(86,53,116,.14);
  --shadow-soft:0 10px 24px rgba(86,53,116,.10);
}

*{
  box-sizing:border-box;
}

html{
  direction:rtl;
}

body{
  margin:0;
  min-height:100vh;
  font-family:Arial, Helvetica, sans-serif;
  font-weight:bold;
  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%, 920px);
}

.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-bg);
  box-shadow:var(--shadow);
  border-radius:32px;
  padding:24px;
}

.game-header{
  display:grid;
  grid-template-columns:minmax(0,1fr) 260px;
  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 10px;
  font-size:clamp(30px, 5vw, 52px);
  line-height:1.1;
}

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

.status-panel{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.status-box{
  background:linear-gradient(180deg,#eef3ff,#dde7ff);
  padding:16px;
  border-radius:20px;
  box-shadow:var(--shadow-soft);
  text-align:center;
}

.status-label{
  display:block;
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}

.status-box strong{
  font-size:24px;
  color:var(--text);
}

.action-buttons{
  display:grid;
  gap:10px;
}

#flag-button,
#restart-button{
  width:100%;
  min-height:48px;
  font-size:18px;
  font-weight:700;
  border:none;
  border-radius:16px;
  cursor:pointer;
  box-shadow:var(--shadow-soft);
}

#flag-button{
  background:#f1f1f1;
  color:#3d3651;
}

#restart-button{
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
}

#board {
  width: min(400px, 90vw);
  aspect-ratio: 1 / 1;
  border: 10px solid darkgray;
  background-color: lightgray;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

#board div {
  width: 100%;
  height: 100%;
  border: 1px solid whitesmoke;
  font-size: clamp(18px, 3vw, 30px);
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
}
.tile-clicked{
  background-color:darkgrey;
}

.x1{ color:blue; }
.x2{ color:green; }
.x3{ color:red; }
.x4{ color:navy; }
.x5{ color:brown; }
.x6{ color:teal; }
.x7{ color:black; }
.x8{ color:gray; }

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

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

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

 #board{
    width: min(320px, 92vw);
    border-width: 8px;
  }

  #board div{
    font-size: clamp(16px, 5vw, 24px);
  }

  .game-desc{
    font-size:14px;
  }

  #flag-button,
  #restart-button{
    font-size:16px;
    min-height:44px;
  }
}