/* =====================================================================
   Peanut Games — 2048. Self-contained; every class is prefixed pg2048-.
   Theme: dark navy panel (#0C2340), gold accents (#f4b400), white text,
   rounded tiles. Builds on css/styles.css tokens (--radius, --shadow).
   ===================================================================== */

.pg2048-wrap {
  background: #0C2340;
  color: #fff;
  border-radius: var(--radius, 16px);
  border: 1px solid rgba(244, 180, 0, .25);
  box-shadow: var(--shadow, 0 6px 20px rgba(12, 35, 64, .2));
  padding: 18px 16px 22px;
  max-width: 460px;
  margin: 0 auto;
}

/* ------------------------------ Start screen ------------------------ */
.pg2048-start { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.pg2048-start-emoji { font-size: 2.6rem; line-height: 1; }
.pg2048-start-title { font-size: 2rem; font-weight: 900; letter-spacing: .02em; color: #f4b400; }
.pg2048-rules { font-size: .9rem; line-height: 1.45; color: rgba(255, 255, 255, .82); max-width: 34ch; }

.pg2048-namelabel { align-self: flex-start; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .7); margin-top: 2px; }
.pg2048-nameinput {
  width: 100%; font: inherit; padding: 11px 12px; min-height: 44px;
  border-radius: var(--radius-sm, 10px); border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .06); color: #fff;
}
.pg2048-nameinput::placeholder { color: rgba(255, 255, 255, .5); }
.pg2048-nameinput:focus { outline: 2px solid #f4b400; outline-offset: 1px; border-color: #f4b400; }

.pg2048-controlnote { font-size: .76rem; color: rgba(255, 255, 255, .55); }

/* Start / Play-Again button (gold, matches the theme) */
.pg2048-startbtn {
  font: inherit; font-weight: 800; cursor: pointer;
  border: 1px solid transparent; border-radius: 999px;
  padding: 11px 26px; min-height: 46px;
  background: #f4b400; color: #0C2340;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(12, 35, 64, .2));
  transition: transform .06s ease, background .15s ease;
}
.pg2048-startbtn:hover { background: #ffc529; }
.pg2048-startbtn:active { transform: translateY(1px); }
.pg2048-startbtn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ------------------------------ HUD (during play) ------------------- */
.pg2048-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pg2048-brand { font-size: 1.9rem; font-weight: 900; color: #f4b400; letter-spacing: .01em; }
.pg2048-scores { display: flex; gap: 8px; }
.pg2048-scorebox {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(244, 180, 0, .25);
  border-radius: var(--radius-sm, 10px); padding: 6px 14px; min-width: 62px;
}
.pg2048-scorelabel { font-size: .6rem; font-weight: 800; letter-spacing: .1em; color: rgba(255, 255, 255, .6); }
.pg2048-scoreval { font-size: 1.2rem; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }

.pg2048-playerline { font-size: .8rem; color: rgba(255, 255, 255, .7); margin-bottom: 10px; }
.pg2048-playername { font-weight: 800; color: #f4b400; }

/* ------------------------------ Board ------------------------------- */
.pg2048-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  background: #081a30;
  border: 1px solid rgba(244, 180, 0, .18);
  border-radius: 14px;
  padding: 10px;
  width: min(88vw, 420px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
.pg2048-cell {
  background: rgba(255, 255, 255, .05);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.pg2048-tile {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1;
  font-size: clamp(1.3rem, 8vw, 2.1rem);
  animation: pg2048-pop .13s ease both;
}
.pg2048-tile.pg2048-t-3d { font-size: clamp(1.1rem, 6.4vw, 1.7rem); }
.pg2048-tile.pg2048-t-4d { font-size: clamp(.9rem, 5vw, 1.35rem); }
.pg2048-tile.pg2048-t-5d { font-size: clamp(.75rem, 4vw, 1.05rem); }

@keyframes pg2048-pop { from { transform: scale(.82); } to { transform: scale(1); } }

/* value palette — blue ramp climbing into brand gold */
.pg2048-t-2    { background: #dfe7f2; color: #12233b; }
.pg2048-t-4    { background: #cbd8ec; color: #12233b; }
.pg2048-t-8    { background: #86a9dc; color: #fff; }
.pg2048-t-16   { background: #5f88cf; color: #fff; }
.pg2048-t-32   { background: #4870bd; color: #fff; }
.pg2048-t-64   { background: #345aa6; color: #fff; }
.pg2048-t-128  { background: #f6d873; color: #3a2e00; }
.pg2048-t-256  { background: #f4cd57; color: #3a2e00; }
.pg2048-t-512  { background: #f4b400; color: #3a2e00; }
.pg2048-t-1024 { background: #e39c00; color: #fff; box-shadow: 0 0 12px rgba(244, 180, 0, .5); }
.pg2048-t-2048 { background: #d98400; color: #fff; box-shadow: 0 0 18px rgba(244, 180, 0, .7); }
.pg2048-t-super { background: #0a1526; color: #f4b400; border: 2px solid #f4b400; box-shadow: 0 0 18px rgba(244, 180, 0, .6); }

/* ------------------------------ Direction pad ----------------------- */
.pg2048-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 64px));
  grid-template-rows: repeat(2, minmax(0, 48px));
  gap: 8px; justify-content: center;
  margin: 14px auto 2px;
}
.pg2048-dirbtn {
  font: inherit; font-size: 1.15rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .08); color: #f4b400;
  border: 1px solid rgba(244, 180, 0, .3); border-radius: 10px;
  transition: background .12s ease, transform .06s ease;
}
.pg2048-dirbtn:hover { background: rgba(244, 180, 0, .18); }
.pg2048-dirbtn:active { transform: translateY(1px); }
.pg2048-dirbtn:focus-visible { outline: 2px solid #f4b400; outline-offset: 2px; }
.pg2048-up    { grid-column: 2; grid-row: 1; }
.pg2048-left  { grid-column: 1; grid-row: 2; }
.pg2048-down  { grid-column: 2; grid-row: 2; }
.pg2048-right { grid-column: 3; grid-row: 2; }

.pg2048-hint { text-align: center; font-size: .74rem; color: rgba(255, 255, 255, .5); margin-bottom: 8px; }

/* ------------------------------ Leaderboard ------------------------- */
.pg2048-lb {
  margin-top: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(244, 180, 0, .2);
  border-radius: var(--radius-sm, 10px);
  padding: 10px 12px;
}
.pg2048-lb-title { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #f4b400; margin-bottom: 7px; }
.pg2048-lb-list { display: flex; flex-direction: column; gap: 3px; }
.pg2048-lb-empty { font-size: .82rem; color: rgba(255, 255, 255, .55); padding: 4px 0; }
.pg2048-lb-row {
  display: grid; grid-template-columns: 2.4em 1fr auto; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 8px; font-size: .86rem;
}
.pg2048-lb-row.is-you { background: rgba(244, 180, 0, .16); border: 1px solid rgba(244, 180, 0, .4); }
.pg2048-lb-rank { color: rgba(255, 255, 255, .55); font-weight: 700; font-variant-numeric: tabular-nums; }
.pg2048-lb-name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg2048-lb-row.is-you .pg2048-lb-name { color: #f4b400; font-weight: 800; }
.pg2048-lb-score { color: rgba(255, 255, 255, .9); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ------------------------------ Game over --------------------------- */
.pg2048-over { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.pg2048-over-title { font-size: 1.8rem; font-weight: 900; color: #f4b400; }
.pg2048-over-final { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pg2048-over-score { font-size: 2.4rem; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.pg2048-over-best { font-size: .95rem; font-weight: 800; color: #7be08a; }
.pg2048-over-rank { font-size: .95rem; font-weight: 800; color: #f4b400; }
.pg2048-over-pending { font-size: .85rem; color: rgba(255, 255, 255, .6); }
.pg2048-over .pg2048-lb { width: 100%; }
.pg2048-again { margin-top: 6px; }
