:root{
  --bg:#faf8ef;
  --card:#ffffff;
  --text:#333;
  --muted:#666;
  --board:#bbada0;
  --cell: rgba(238, 228, 218, 0.35);
  --shadow: 0 8px 24px rgba(0,0,0,.08);
  --radius: 16px;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 18px;
}

.eqsy2048{
  max-width: 520px;
  margin: 0 auto;
}

.top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom: 10px;
}

.title{
  margin:0;
  font-size: 40px;
  line-height: 1;
}
.subtitle{
  margin: 6px 0 0;
  color: var(--muted);
}

.scores{
  display:flex;
  gap:10px;
}
.scoreBox{
  background: #eee4da;
  color: #3c3a32;
  padding: 10px 12px;
  border-radius: 14px;
  min-width: 88px;
  text-align:center;
}
.scoreBox .label{
  font-size: 12px;
  opacity: .75;
  font-weight: 700;
  letter-spacing: .02em;
}
.scoreBox .value{
  font-size: 22px;
  font-weight: 900;
  margin-top: 2px;
}

.controls{
  display:flex;
  align-items:center;
  gap:10px;
  margin: 12px 0;
}

.btn{
  border: 0;
  background: #8f7a66;
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.btn:disabled{
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn.primary{
  background:#2f7d32;
}

.mode{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
}
.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  background: var(--card);
  padding: 8px 10px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.toggle input{ transform: scale(1.1); }
.dailyDateWrap{
  display:flex;
  flex-direction:column;
  gap:4px;
  background: var(--card);
  padding: 8px 10px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.dailyDateWrap label{
  font-size: 12px;
  font-weight: 700;
}
.dailyDateWrap input{
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  padding: 6px 8px;
}
.hint{
  color: var(--muted);
  font-size: 13px;
}

.boardWrap{
  position: relative;
}
.board{
  background: var(--board);
  border-radius: var(--radius);
  padding: 12px;
  position: relative;
  box-shadow: var(--shadow);
  touch-action: none; /* important for swipe */
}

.cellLayer{
  display:grid;
  gap: 12px;
  pointer-events:none;
}

.cell{
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: var(--cell);
  border-radius: 14px;
}
.tile{
  position:absolute;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 14px;
  font-weight: 900;
  font-size: 28px;
  user-select:none;
  will-change: transform;
  pointer-events:none;
}

.tileLayer{
  position:absolute;
  inset: 12px;
  pointer-events:none;
}

.footer{
  margin-top: 12px;
  color: var(--muted);
  text-align:center;
}
.keys{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}
.kbd{
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.7);
  padding: 4px 8px;
  border-radius: 10px;
  font-weight: 800;
  color:#333;
}
.sep{ margin: 0 6px; opacity:.8; }

.overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(250, 248, 239, .75);
  border-radius: var(--radius);
}
.overlay[hidden]{
  display: none !important; /* ensure overlay actually hides when JS toggles hidden */
}
.overlayCard{
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: min(360px, 92%);
}
.overlayCard h2{ margin:0 0 6px; }
.overlayCard p{ margin:0 0 12px; color: var(--muted); }
.overlayActions{ display:flex; gap:10px; justify-content:flex-end; }
.overlaySave{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin: 6px 0 14px;
}
.overlaySave label{ font-weight:700; font-size:14px; }
.overlaySave input{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.08);
  font-size:14px;
}
.overlaySave .saveHint{ color: var(--muted); font-size: 13px; }

/* Tile colors (simple + cohesive) */
.t2   { background:#eee4da; color:#776e65; }
.t4   { background:#ede0c8; color:#776e65; }
.t8   { background:#f2b179; color:#f9f6f2; }
.t16  { background:#f59563; color:#f9f6f2; }
.t32  { background:#f67c5f; color:#f9f6f2; }
.t64  { background:#f65e3b; color:#f9f6f2; }
.t128 { background:#edcf72; color:#f9f6f2; font-size: 24px; }
.t256 { background:#edcc61; color:#f9f6f2; font-size: 24px; }
.t512 { background:#edc850; color:#f9f6f2; font-size: 24px; }
.t1024{ background:#edc53f; color:#f9f6f2; font-size: 22px; }
.t2048{ background:#edc22e; color:#f9f6f2; font-size: 22px; }
.tbig { background:#3c3a32; color:#f9f6f2; font-size: 20px; }

.leaderboards{
  margin: 0 0 14px 0;
  display:flex;
  flex-direction:column;
  gap: 12px;
}
.lbCard{
  background: var(--card);
  padding: 14px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.lbCard h3{ margin: 0 0 8px; font-size: 18px; }
.lbCard table{ width:100%; border-collapse: collapse; font-size: 14px; }
.lbCard th, .lbCard td{ padding:6px 4px; text-align:left; }
.lbCard tbody tr:nth-child(odd){ background: rgba(0,0,0,.025); }
.lbCard .muted{ color: var(--muted); font-size: 13px; }
