:root {
  --bg: #000000;
  --board: #0a0a0a;
  --cell: #101010;
  --text: #08A045; /* new green */
  --text-dim: #068236;
  --tile-2: #0e2316;
  --tile-4: #12301c;
  --tile-8: #164d2a;
  --tile-16: #1a5a31;
  --tile-32: #1e6738;
  --tile-64: #23743f;
  --tile-128: #278f4d;
  --tile-256: #2ba85a;
  --tile-512: #2fb266;
  --tile-1024: #34bd72;
  --tile-2048: #39c87e;
  --tile-super: #08A045;
  --white: #e6ffe6;
  --shadow: 0 6px 18px rgba(8,160,69,0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1000px 600px at 20% -10%, rgba(8, 160, 69, 0.08), transparent 60%),
              radial-gradient(1000px 600px at 80% 110%, rgba(8, 160, 69, 0.06), transparent 60%),
              var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
  text-shadow: 0 0 12px rgba(8,160,69,0.35);
}

.scores {
  display: flex;
  gap: 8px;
}

.score {
  background: linear-gradient(180deg, #0d0d0d, #0b0b0b);
  color: var(--white);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  min-width: 84px;
  border: 1px solid rgba(8,160,69,0.18);
  box-shadow: inset 0 0 0 1px rgba(8,160,69,0.06), var(--shadow);
}

.score .label {
  font-size: 12px;
  color: var(--text-dim);
}

.score .value {
  font-size: 20px;
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 16px 0 12px;
  gap: 8px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(8,160,69,0.4);
  background: linear-gradient(180deg, rgba(8,160,69,0.14), rgba(8,160,69,0.08));
  color: var(--white);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(8,160,69,0.2), var(--shadow);
}

.btn:hover {
  background: linear-gradient(180deg, rgba(8,160,69,0.2), rgba(8,160,69,0.12));
}

.btn:active {
  transform: translateY(1px);
}

.hint {
  font-size: 14px;
  color: var(--text-dim);
}

.board-container {
  position: relative;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: radial-gradient(600px 300px at 20% 10%, rgba(8,160,69,0.05), transparent 60%),
              radial-gradient(600px 300px at 80% 90%, rgba(8,160,69,0.04), transparent 60%),
              var(--board);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 0 0 1px rgba(8,160,69,0.14), var(--shadow);
  touch-action: none;
}

/* Removed pseudo-element background grid to avoid top-left square */

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 10px;
  transition: transform 100ms ease, top 100ms ease, left 100ms ease, background 120ms ease, filter 120ms ease;
  will-change: transform, top, left;
  user-select: none;
  color: var(--white);
  text-shadow: 0 0 6px rgba(0,0,0,0.6);
  outline: 1px solid rgba(8,160,69,0.08);
}

.tile-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.tile.v2  { background: var(--tile-2); }
.tile.v4  { background: var(--tile-4); }
.tile.v8  { background: var(--tile-8); }
.tile.v16 { background: var(--tile-16); }
.tile.v32 { background: var(--tile-32); }
.tile.v64 { background: var(--tile-64); }
.tile.v128 { background: var(--tile-128); }
.tile.v256 { background: var(--tile-256); }
.tile.v512 { background: var(--tile-512); }
.tile.v1024 { background: var(--tile-1024); }
.tile.v2048 { background: var(--tile-2048); }
.tile.vsuper { background: var(--tile-super); color: #00250f; }

.tile.placeholder {
  background: rgba(8,160,69,0.08);
  border: 1px solid rgba(8,160,69,0.12);
  opacity: 0.6;
}

.score-animation {
  position: absolute;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 12px rgba(8,160,69,0.8);
  pointer-events: none;
  z-index: 20;
  animation: scoreFloat 1.5s ease-out forwards;
  transform: translate(-50%, -50%);
  background: rgba(8,160,69,0.15);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(8,160,69,0.3);
}

@keyframes scoreFloat {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -80px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -120px) scale(1);
  }
}

@keyframes confettiFall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Streak-based green intensity: increases with consecutive merge moves */
.board.streak-0 .tile { filter: none; }
.board.streak-1 .tile { filter: saturate(1.08) brightness(1.02); }
.board.streak-2 .tile { filter: saturate(1.16) brightness(1.04); }
.board.streak-3 .tile { filter: saturate(1.26) brightness(1.06); }
.board.streak-4 .tile { filter: saturate(1.38) brightness(1.08); }
.board.streak-5 .tile { filter: saturate(1.52) brightness(1.1); }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.84);
  border-radius: 14px;
  text-align: center;
  color: var(--white);
}

.overlay[hidden] {
  display: none;
}

.overlay-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  text-shadow: 0 0 12px rgba(8,160,69,0.35);
}

.overlay-sub {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.footer {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-dim);
}

@media (max-width: 420px) {
  .title { font-size: 32px; }
  .score .value { font-size: 18px; }
  .btn { padding: 10px 12px; }
}
