@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
  --bg-1: #fff8fc;
  --bg-2: #f6f4ff;
  --card-bg: rgba(255, 255, 255, 0.94);
  --text: #2f2440;
  --muted: #786d8a;
  --pink: #ff78b2;
  --pink-dark: #e05597;
  --purple: #9f7dff;
  --shadow: 0 18px 46px rgba(86, 53, 116, 0.14);
  --shadow-soft: 0 10px 24px rgba(86, 53, 116, 0.1);
  --board-dark: #20283a;
  --board-mid: #293447;
  --board-cell: #212837;
  --food: #ff4d79;
  --snake: #6fd4ff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Cairo', sans-serif;
}

html {
  direction: rtl;
}

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(255, 203, 227, 0.55), transparent 28%),
    radial-gradient(circle at bottom left, rgba(215, 223, 255, 0.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%, 980px);
}

.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  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, 0.86);
  box-shadow: var(--shadow-soft);
  font-weight: 700;
}

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

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

.wrapper {
  width: min(100%, 520px);
  display: flex;
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
  border-radius: 28px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.title-wrap {
  text-align: center;
  margin-bottom: 12px;
}

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

h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  margin-bottom: 8px;
}

.game-desc {
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

.game-details {
  color: #dde7ff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, var(--board-mid), var(--board-dark));
  border-radius: 18px 18px 0 0;
}

.play-board {
  aspect-ratio: 1 / 1;
  width: 100%;
  display: grid;
  background: var(--board-cell);
  grid-template: repeat(30, 1fr) / repeat(30, 1fr);
  border-radius: 0 0 18px 18px;
  overflow: hidden;
}

.play-board .food {
  background: var(--food);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18);
}

.play-board .head {
  background: var(--snake);
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.controls {
  display: none;
  justify-content: space-between;
  margin-top: 14px;
  border-radius: 18px;
  overflow: hidden;
  background: #eef3ff;
  box-shadow: var(--shadow-soft);
}

.controls i {
  padding: 18px 0;
  text-align: center;
  font-size: 1.2rem;
  color: var(--text);
  width: calc(100% / 4);
  cursor: pointer;
  border-left: 1px solid rgba(47, 36, 64, 0.08);
}

.controls i:last-child {
  border-left: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 18, 34, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.hidden {
  display: none !important;
}

.modal {
  width: min(100%, 360px);
  background: #fff;
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-bottom: 10px;
  font-size: 28px;
}

.modal p {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 16px;
}

.restart-btn {
  border: none;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

@media screen and (max-width: 800px) {
  .wrapper {
    width: min(100%, 460px);
  }

  .controls {
    display: flex;
  }
}

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

  .wrapper {
    padding: 14px;
    border-radius: 22px;
  }

  .game-details {
    font-size: 0.95rem;
    padding: 14px 15px;
  }

  .controls i {
    padding: 14px 0;
    font-size: 1rem;
  }
}