@import url(fonts/clear-sans.css?v=2);
/* 2026-10-12: tüm ölçüler tahta genişliğinden (--b, js/Layout ile pencereye göre hesaplanır) türetilir.
   --g: hücre arası boşluk, --c: hücre/karo boyu, --pw: yan yerleşimde sol panel genişliği, --p: kenar payı */
:root {
  --b: 500px;
  --pw: 210px;
  --p: 12px;
  --g: calc(var(--b) * 0.03);
  --c: calc((var(--b) - 5 * var(--g)) / 4);
  --t: clamp(13px, calc(var(--b) * 0.032), 22px);
  --btn-h: clamp(34px, calc(var(--b) * 0.08), 56px); }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #faf8ef;
  color: #776e65;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--t); }

body {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-text-size-adjust: 100%; }

button {
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; }
  button:focus { outline: none; }
  button:focus-visible { outline: 3px solid #f2b179; outline-offset: 2px; }

/* ---------- yerleşim ---------- */
.container {
  width: var(--b);
  display: flex;
  flex-direction: column;
  gap: var(--p); }

.panel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--p) * 0.6); }

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

h1.title {
  font-size: clamp(30px, calc(var(--b) * 0.15), 80px);
  line-height: 1;
  font-weight: bold;
  margin: 0; }

.scores-container {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end; }

.above-game {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px; }

.game-intro {
  margin: 0;
  line-height: 1.3; }

.buttons {
  flex: none;
  display: flex;
  gap: 8px; }

.restart-button, .rekor-button, .bitir-button {
  flex: none;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 1.2em;
  color: #f9f6f2;
  height: var(--btn-h); }

/* rekor tablosu düğmesi: altın, kupa simgeli (diğer rekoroyun oyunlarıyla aynı görünüm) */
.rekor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  padding: 0 1em;
  background: linear-gradient(90deg, #ffb31e 0%, #ffe600 100%);
  color: #3a2300;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15); }
  .rekor-button svg { width: 1.2em; height: 1.2em; flex: none; }
  .rekor-button:hover { filter: brightness(1.05); }

/* 2048 sonrası devam edilen oyunda Kaydet (oyunu durdurup rekor formunu açar; .container.bitir) */
.bitir-button {
  display: none;
  background: #2e9e57; }
  .container.bitir .bitir-button { display: inline-block; }

/* dar dik ekran: tanıtım yazısı gizli, iki düğme satırı doldurur */
.container.dar .game-intro { display: none; }
.container.dar .buttons { flex: 1; }
.container.dar .buttons button { flex: 1; padding: 0 .5em; }

/* yan yerleşim (yatay ekran / iframe): solda panel, sağda tahta */
.container.yan {
  width: auto;
  flex-direction: row;
  align-items: center; }
  .container.yan .panel {
    width: var(--pw);
    gap: calc(var(--p) * 0.8); }
  .container.yan .heading {
    flex-direction: column;
    align-items: stretch; }
  .container.yan h1.title {
    font-size: clamp(34px, calc(var(--pw) * 0.33), 100px);
    text-align: center; }
  .container.yan .scores-container {
    justify-content: stretch; }
  .container.yan .score-container, .container.yan .best-container {
    flex: 1 1 auto;
    padding-left: 0.4em;
    padding-right: 0.4em; }
  .container.yan .above-game {
    flex-direction: column;
    align-items: stretch;
    text-align: center; }
  .container.yan .buttons {
    flex-direction: column; }
  .container.yan .restart-button, .container.yan .rekor-button, .container.yan .bitir-button {
    width: 100%; }

/* ---------- puan kutuları ---------- */
@keyframes move-up {
  0% {
    top: 25px;
    opacity: 1; }

  100% {
    top: -50px;
    opacity: 0; } }

.score-container, .best-container {
  position: relative;
  min-width: 3.4em;
  box-sizing: border-box;
  background: #bbada0;
  padding: calc(var(--t) * 1.25) 0.7em calc(var(--t) * 0.35);
  font-size: clamp(16px, calc(var(--b) * 0.048), 32px);
  line-height: 1.2;
  font-weight: bold;
  border-radius: 3px;
  color: white;
  text-align: center; }
  .score-container:after, .best-container:after {
    position: absolute;
    width: 100%;
    top: calc(var(--t) * 0.35);
    left: 0;
    text-transform: uppercase;
    font-size: clamp(10px, calc(var(--b) * 0.025), 15px);
    line-height: 1;
    text-align: center;
    color: #eee4da; }
  .score-container .score-addition {
    position: absolute;
    right: 0;
    left: 0;
    font-size: 1em;
    line-height: 1;
    font-weight: bold;
    color: rgba(119, 110, 101, 0.9);
    z-index: 100;
    pointer-events: none;
    animation: move-up 600ms ease-in;
    animation-fill-mode: both; }

.score-container:after {
  content: "Puan"; }

.best-container:after {
  content: "Rekor"; }

/* ---------- tahta ---------- */
@keyframes fade-in {
  0% {
    opacity: 0; }

  100% {
    opacity: 1; } }

.game-container {
  flex: none;
  position: relative;
  padding: var(--g);
  cursor: default;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  background: #bbada0;
  border-radius: 6px;
  width: var(--b);
  height: var(--b);
  box-sizing: border-box; }

.game-container .game-message, .game-container .game-confirm {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 6px;
  background: rgba(238, 228, 218, 0.73);
  z-index: 100;
  text-align: center;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--b) * 0.035); }
  .game-container .game-message {
    background: rgba(238, 228, 218, 0.86);
    padding: 0 6%;
    animation: fade-in 800ms ease 1200ms;
    animation-fill-mode: both; }
  .game-container .game-message .game-score {
    font-size: clamp(16px, calc(var(--b) * 0.05), 28px);
    font-weight: bold;
    margin-top: calc(var(--b) * -0.02); }

  /* rekor formu (yalnız kaydedilebilir oyunda: .kayit) */
  .game-container .rekor-form {
    display: none;
    width: 100%;
    max-width: 420px; }
  .game-container .game-message.kayit .rekor-form {
    display: block; }
  .game-container .rekor-satir {
    display: flex;
    gap: 6px; }
  .game-container .rekor-isim {
    flex: 1;
    min-width: 0;
    height: var(--btn-h);
    box-sizing: border-box;
    padding: 0 .6em;
    border: 2px solid #8f7a66;
    border-radius: 3px;
    background: #fff;
    color: #3c3a32;
    font: inherit;
    font-size: max(16px, var(--t)); /* 16px altı iOS'ta sayfayı yakınlaştırır */
    -webkit-user-select: text;
    user-select: text; }
  .game-container .rekor-isim:focus {
    outline: none;
    border-color: #f2b179; }
  .game-container .rekor-kaydet {
    flex: none;
    background: #2e9e57;
    border-radius: 3px;
    padding: 0 1em;
    color: #fff;
    height: var(--btn-h); }
  .game-container .rekor-durum {
    margin-top: 5px;
    font-size: clamp(12px, calc(var(--b) * 0.03), 16px);
    line-height: 1.3; }
  .game-container .rekor-durum.hata {
    color: #c0392b;
    font-weight: bold; }
  .game-container .rekor-not {
    font-size: clamp(12px, calc(var(--b) * 0.032), 17px);
    font-weight: bold;
    line-height: 1.3; }
  .game-container .rekor-not:empty {
    display: none; }
  .game-container .lower .rekor-ac {
    background: linear-gradient(90deg, #ffb31e 0%, #ffe600 100%);
    color: #3a2300; }
  .game-container .game-message p, .game-container .game-confirm p {
    font-size: clamp(26px, calc(var(--b) * 0.12), 64px);
    font-weight: bold;
    line-height: 1.1;
    margin: 0;
    padding: 0 10px; }
  .game-container .game-confirm p {
    font-size: clamp(22px, calc(var(--b) * 0.08), 44px); }
  .game-container .game-confirm.uzun p {
    font-size: clamp(17px, calc(var(--b) * 0.055), 30px);
    padding: 0 6%; }
  .game-container .lower {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: center; }
  .game-container .lower button {
    background: #8f7a66;
    border-radius: 3px;
    padding: 0 1.2em;
    color: #f9f6f2;
    height: var(--btn-h); }
  .game-container .game-message .keep-playing-button {
    display: none; }
  .game-container .game-message.game-won {
    background: rgba(237, 194, 46, 0.82);
    color: #fff; }
    .game-container .game-message.game-won .rekor-durum,
    .game-container .game-message.game-won .rekor-not {
      color: #5c4300; }
    .game-container .game-message.game-won .rekor-durum.hata {
      color: #7a1a10; }
    .game-container .game-message.game-won .keep-playing-button {
      display: inline-block; }
    .game-container .game-message.game-won.kaydedildi .keep-playing-button {
      display: none; }
  .game-container .game-message.hemen {
    animation-delay: 0s; }
  .game-container .game-message.game-won, .game-container .game-message.game-over {
    display: flex; }
  .game-container.confirming .game-confirm {
    display: flex;
    background: rgba(250, 248, 239, 0.92);
    z-index: 101;
    animation: fade-in 150ms ease;
    animation-fill-mode: both; }

.grid-container {
  position: absolute;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, var(--c));
  gap: var(--g); }

.grid-row {
  display: contents; }

.grid-cell {
  width: var(--c);
  height: var(--c);
  border-radius: 3px;
  background: rgba(238, 228, 218, 0.35); }

.tile-container {
  position: absolute;
  z-index: 2; }

/* ---------- karolar ---------- */
.tile, .tile .tile-inner {
  width: var(--c);
  height: var(--c);
  line-height: var(--c); }

.tile {
  --x: 0;
  --y: 0;
  position: absolute;
  transform: translate(calc(var(--x) * (var(--c) + var(--g))), calc(var(--y) * (var(--c) + var(--g))));
  transition: 100ms ease-in-out;
  transition-property: transform; }

.tile-position-1-1 { --x: 0; --y: 0; }
.tile-position-1-2 { --x: 0; --y: 1; }
.tile-position-1-3 { --x: 0; --y: 2; }
.tile-position-1-4 { --x: 0; --y: 3; }
.tile-position-2-1 { --x: 1; --y: 0; }
.tile-position-2-2 { --x: 1; --y: 1; }
.tile-position-2-3 { --x: 1; --y: 2; }
.tile-position-2-4 { --x: 1; --y: 3; }
.tile-position-3-1 { --x: 2; --y: 0; }
.tile-position-3-2 { --x: 2; --y: 1; }
.tile-position-3-3 { --x: 2; --y: 2; }
.tile-position-3-4 { --x: 2; --y: 3; }
.tile-position-4-1 { --x: 3; --y: 0; }
.tile-position-4-2 { --x: 3; --y: 1; }
.tile-position-4-3 { --x: 3; --y: 2; }
.tile-position-4-4 { --x: 3; --y: 3; }

.tile .tile-inner {
  border-radius: 3px;
  background: #eee4da;
  text-align: center;
  font-weight: bold;
  z-index: 10;
  font-size: calc(var(--c) * 0.5); }

/* yazı boyutu basamak sayısına göre (karo boyuyla orantılı) */
.tile.tile-d3 .tile-inner { font-size: calc(var(--c) * 0.42); }
.tile.tile-d4 .tile-inner { font-size: calc(var(--c) * 0.34); }
.tile.tile-d5 .tile-inner { font-size: calc(var(--c) * 0.28); }
.tile.tile-d6 .tile-inner { font-size: calc(var(--c) * 0.23); }

.tile.tile-2 .tile-inner {
  background: #eee4da; }
.tile.tile-4 .tile-inner {
  background: #ede0c8; }
.tile.tile-8 .tile-inner {
  color: #f9f6f2;
  background: #f2b179; }
.tile.tile-16 .tile-inner {
  color: #f9f6f2;
  background: #f59563; }
.tile.tile-32 .tile-inner {
  color: #f9f6f2;
  background: #f67c5f; }
.tile.tile-64 .tile-inner {
  color: #f9f6f2;
  background: #f65e3b; }
.tile.tile-128 .tile-inner {
  color: #f9f6f2;
  background: #edcf72;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.14286); }
.tile.tile-256 .tile-inner {
  color: #f9f6f2;
  background: #edcc61;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746), inset 0 0 0 1px rgba(255, 255, 255, 0.19048); }
.tile.tile-512 .tile-inner {
  color: #f9f6f2;
  background: #edc850;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.39683), inset 0 0 0 1px rgba(255, 255, 255, 0.2381); }
.tile.tile-1024 .tile-inner {
  color: #f9f6f2;
  background: #edc53f;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.47619), inset 0 0 0 1px rgba(255, 255, 255, 0.28571); }
.tile.tile-2048 .tile-inner {
  color: #f9f6f2;
  background: #edc22e;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333); }
.tile.tile-super .tile-inner {
  color: #f9f6f2;
  background: #3c3a32; }
/* 4096 ve üstü: her değer ayrı renk (altın 2048'den sonra mor → mavi → yeşil → koyu) */
.tile.tile-4096 .tile-inner {
  background: #c45ad6;
  box-shadow: 0 0 30px 10px rgba(196, 90, 214, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.tile.tile-8192 .tile-inner {
  background: #8a4fe0;
  box-shadow: 0 0 30px 10px rgba(138, 79, 224, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.tile.tile-16384 .tile-inner {
  background: #3d7be0;
  box-shadow: 0 0 30px 10px rgba(61, 123, 224, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.tile.tile-32768 .tile-inner {
  background: #12a0a8;
  box-shadow: 0 0 30px 10px rgba(18, 160, 168, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.tile.tile-65536 .tile-inner {
  background: #24a35a;
  box-shadow: 0 0 30px 10px rgba(36, 163, 90, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.tile.tile-131072 .tile-inner {
  background: linear-gradient(135deg, #e0453a 0%, #8a4fe0 100%);
  box-shadow: 0 0 30px 10px rgba(224, 69, 58, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.35); }

/* ---------- rekor tablosu (ortak servisin HTML'i bunun içine yüklenir) ---------- */
#rekor-kap {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  background: #f5f5f5;
  overflow: hidden; }
#rekor-kap .rekor-yukleniyor {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  font-size: 18px;
  line-height: 1.6;
  color: #776e65; }
#rekor-kap .rekor-yukleniyor button {
  margin-top: 10px;
  background: #8f7a66;
  color: #fff;
  border-radius: 3px;
  padding: 0 1.2em;
  height: 40px; }

@keyframes appear {
  0% {
    opacity: 0;
    transform: scale(0); }

  100% {
    opacity: 1;
    transform: scale(1); } }
.tile-new .tile-inner {
  animation: appear 200ms ease 100ms;
  animation-fill-mode: backwards; }

@keyframes pop {
  0% {
    transform: scale(0); }

  50% {
    transform: scale(1.2); }

  100% {
    transform: scale(1); } }
.tile-merged .tile-inner {
  z-index: 20;
  animation: pop 200ms ease 100ms;
  animation-fill-mode: backwards; }

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile-new .tile-inner, .tile-merged .tile-inner { animation: none; } }
