@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("../fonts/NotoKufiArabic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("../fonts/NotoKufiArabic-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("../fonts/NotoKufiArabic-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("../fonts/NotoKufiArabic-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}


* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Noto Kufi Arabic", "Noto Sans Arabic", Arial, sans-serif;
  color: #776e65;
  background: #faf8ef;
  line-height: 1.4;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==== Helpers ==== */
.text-center {
  text-align: center;
}

.text-muted {
  color: #8f8a83;
}

/* ==== Layout (Bootstrap-free) ==== */
.container {
  width: 100%;
  max-width: 980px;
  padding: 0 16px;
  margin: 0 auto;
  flex: 1;
}

.page-wrap {
  margin: 16px auto 24px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

.col {
  flex: 1 1 300px;
}

/* ==== Header width matches board ==== */
.game-header {
  max-width: min(92vw, 520px);
  margin: 0 auto 14px auto;
}

/* Robust header layout */
.game-header .row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
}

.left {
  flex: 1 1 calc(100% - 200px);
  min-width: 220px;
}

.header-controls {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* start looks natural in RTL */
  gap: 8px;
}

/* Stack neatly on very small screens */
@media (max-width: 420px) {
  .left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .header-controls {
    flex: 1 1 100%;
    margin-top: 10px;
  }
}

/* ==== Header visuals ==== */
.game-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(42px, 10vw, 64px);
  line-height: 1;
  color: #776e65;
}

.game-subtitle {
  margin-top: 6px;
  font-size: 18px;
  color: #7a6e64;
}

.game-subtitle strong {
  color: #7a6e64;
}

/* ==== Score boxes (exact 2048 style) ==== */
.score-container {
  margin-bottom: 8px;
}

.score-box {
  background: #bbada0;
  color: #f9f6f2;
  text-align: center;
  border-radius: 3px;
  padding: 5px 12px;
  min-width: 60px;
  display: inline-block;
  vertical-align: top;

  /* spacing logical + fallback */
  margin-inline-end: 6px;
  margin-right: 6px;
}

.score-box:last-child {
  margin-inline-end: 0;
  margin-right: 0;
}

.score-box .label {
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 2px;
}

.score-box #score,
.score-box #best {
  font-size: 22px;
  font-weight: bold;
  line-height: 1.2;
}

/* ==== Buttons ==== */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
    font-family: "Noto Kufi Arabic", "Noto Sans Arabic", Arial, sans-serif;
}

.btn-primary {
  background: #8f7a66;
  border-color: #8f7a66;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(0.95);
}

.btn-primary:active {
  transform: translateY(1px);
}

/* Undo button */
.btn-undo {
  background: #cdc1b4;
  border-color: #cdc1b4;
  color: #fff;

  /* spacing logical + fallback */
  margin-inline-end: 6px;
  margin-right: 6px;
}

.btn-undo[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==== Board ==== */
.board {
  position: relative;
  background: #bbada0;
  border-radius: 6px;
  padding: 10px;

  /* Keep board layout LTR even in RTL page */
  direction: ltr;

  width: min(92vw, 520px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 10px;
  margin: 0 auto;
}

.cell {
  background: #cdc1b4;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.cell .tile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(18px, 4.8vw, 26px);
  border-radius: 4px;
  transition: transform 120ms ease, background-color 120ms ease;
}

/* Tile colors */
.tile-0 {
  background: transparent;
}

.tile-2 {
  background: #eee4da;
  color: #776e65;
}

.tile-4 {
  background: #ede0c8;
  color: #776e65;
}

.tile-8 {
  background: #f2b179;
  color: #f9f6f2;
}

.tile-16 {
  background: #f59563;
  color: #f9f6f2;
}

.tile-32 {
  background: #f67c5f;
  color: #f9f6f2;
}

.tile-64 {
  background: #f65e3b;
  color: #f9f6f2;
}

.tile-128 {
  background: #edcf72;
  color: #f9f6f2;
  font-size: clamp(16px, 4vw, 22px);
}

.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: clamp(16px, 4vw, 22px);
}

.tile-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: clamp(16px, 4vw, 22px);
}

.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: clamp(14px, 3.6vw, 18px);
}

.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: clamp(14px, 3.6vw, 18px);
}

.tile-super {
  background: #3c3a32;
  color: #f9f6f2;
}

/* ==== Alerts / footer ==== */
.alert {
  background: #d9edf7;
  color: #31708f;
  border: 1px solid #bce8f1;
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 12px;
}

.footer {
  margin: 10px 0;
  text-align: center;
  font-size: 14px;
}
.footer .text-center{
	max-width: 980px;
	margin: 0 auto;
	border-top: 1px solid #d5d1c1;
	padding: 10px 0;
}
.footer a{
	color: #776e65;
	text-decoration: none;
	padding: 0 15px;
}
.footer a:hover{
	text-decoration: underline;
}
.help {
  color: #776e65;
  text-align: center;
}
.game-hint{
	text-align: center;
	background: #f5f1de;
	max-width: 480px;
	margin: 15px auto 0px auto;
	padding: 10px;
	border-radius: 12px;
	border: 1px solid #d5d1c1;
	font-size: 13px;
}
.game-hint p{
	padding: 0;
	margin: 0 0 10px 0;
}
.game-hint p:last-child{
	margin: 0px;
}
.hide{
	visibility: hidden;
}
.none{
	display: none;
}
.test {
	border: 1px solid red;
}
.contents{
	font-size: 16px;
	line-height: 32px;
}
#contact{
	max-width: 600px;
	margin: 0 auto;
}
.form-control {
    display: block;
    width: 100%;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
    -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
}
#contact input[type="text"], #contact input[type="email"] {
    height: 45px;
}
#contact .form-control {
    border: 1px solid #CCCCCC;
    border-radius: 0px;
    font-size: 16px;
}
.error {
    color: #f12a2a;
}
textarea.form-control {
    height: auto;
}
.form-group{
	margin-bottom: 15px;
}
.form-group p{
	padding: 0;
	margin: 0 0 0px 0;
	font-weight: bold;
}
.bold{
	font-weight: bold;
}
.terms p{
	padding:0;
	margin: 0 0 15px 0;
}
.terms p.bold{
	margin:0px;
}
.inner .game-header{
	max-width: 100%;
	border-bottom: 1px solid #d5d1c1;
	padding-bottom: 20px;
}
.center-content{
  max-width: 530px;
  margin: 0 auto;
}
.tags{
    font-size: 12px;
    padding: 0 0 10px 0;
}