:root {
  --bg: #f7f9fc;
  --text: #1a1a1a;
  --card: #ffffff;
  --border: #e2e8f0;
  --accent: #4da6ff;
  --accent-glow: rgba(77,166,255,0.25);
}

[data-theme="dark"] {
  --bg: #0d0d0d;
  --text: #ffffff;
  --card: #1a1a1a;
  --border: #333;
  --accent-glow: rgba(77,166,255,0.6);
}

/* BASE */
* {
  box-sizing: border-box;
  transition: all 0.25s ease;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  perspective: 900px;
}

/* HEADER */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 25px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav a {
  text-decoration: none;
  color: var(--text);
  opacity: 0.7;
}

.nav a:hover,
.nav a.active {
  opacity: 1;
  color: var(--accent);
}

/* THEME BUTTON */
.theme-toggle {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}

/* HERO */
.hero {
  text-align: center;
  padding: 80px 20px 60px;
}
/* FORCE PAGE CONTENT CENTERING */
.features,
.grid {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.hero h1 {
  font-size: 42px;
  text-shadow: 0 0 10px var(--accent-glow);
}

/* BUTTONS */
.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  background: var(--accent);
  color: white;
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

/* =========================
   ✅ FEATURES FIXED
========================= */
.features {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;

  gap: 20px;

  max-width: 900px;
  margin: 0 auto;

  padding: 30px 20px;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;

  padding: 18px 22px;

  display: flex;
  justify-content: center;
  align-items: center;

  text-align: center;

  min-width: 180px;
  flex: 0 0 auto;

  font-weight: 500;

  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.feature-card:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 10px 25px var(--accent-glow);
  border-color: var(--accent);
}

/* =========================
   HOMEPAGE GRID
========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 30px;
}

/* CARD */
.card {
  position: relative;
  height: 180px;
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: white;
  border: 1px solid var(--border);
  display: block;
}

.preview {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

.preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
}

.card-content {
  position: absolute;
  bottom: 0;
  padding: 15px;
  z-index: 2;
}

.card:hover {
  transform: scale(1.04);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* =========================
   GAME GRID (SAFE)
========================= */
#game .grid {
  width: 360px;
  height: 360px;
  margin: 25px auto;
  background: #bbada0;
  border-radius: 12px;
  padding: 10px;
  position: relative;

  transform: rotateX(18deg);
  transform-style: preserve-3d;
  touch-action: none;
}

#game .bg {
  position: absolute;
  width: 75px;
  height: 75px;
  background: #d6d0c4;
  border-radius: 6px;
  transform: translateZ(-10px);
  opacity: 0.6;
}

#game .tile {
  position: absolute;
  width: 75px;
  height: 75px;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 26px;

  transform-style: preserve-3d;
  box-shadow: 0 12px 25px rgba(0,0,0,0.25);
  transition: transform 0.12s ease, left 0.12s ease, top 0.12s ease;
}

/* COLORS */
.tile[data-v="2"] { background:#eee4da; }
.tile[data-v="4"] { background:#ede0c8; }
.tile[data-v="8"] { background:#f2b179; color:white; }
.tile[data-v="16"] { background:#f59563; color:white; }
.tile[data-v="32"] { background:#f67c5f; color:white; }
.tile[data-v="64"] { background:#f65e3b; color:white; }
.tile[data-v="128"] { background:#edcf72; color:white; }
.tile[data-v="256"] { background:#edcc61; color:white; }
.tile[data-v="512"] { background:#edc850; color:white; }
.tile[data-v="1024"] { background:#edc53f; color:white; }
.tile[data-v="2048"] { background:#edc22e; color:white; }

/* BUTTON */
button {
  padding: 12px 25px;
  border: none;
  border-radius: 8px;
  background: #8f7a66;
  color: white;
  font-weight: bold;
  cursor: pointer;
}

/* OVERLAY */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
}

.popup {
  background: white;
  padding: 40px;
  border-radius: 10px;
  text-align: center;
}

/* NAV ACTIONS */
.nav-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

/* FOOTER */
.footer {
  text-align: center;
  padding: 20px;
  opacity: 0.6;
}
