/* =========================================================
   Oyun stilleri — Zar Atma 2024 & Tetris
   ========================================================= */

.game { padding-top: 40px; padding-bottom: 60px; max-width: 880px; }
.game__head { margin: 18px 0 34px; }
.game__head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 850; letter-spacing: -0.02em; }
.game__head p { color: var(--text-dim); margin-top: 8px; }
.game__head strong { color: var(--text); }

/* ---------- Ortak istatistik ---------- */
.stat, .panel {
  display: flex; flex-direction: column; gap: 2px;
}
.stat__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
}
.stat__val { font-size: 1.7rem; font-weight: 800; }

/* =================== ZAR ATMA =================== */
.zar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}
.zar__stats {
  display: flex; justify-content: center; gap: 48px; margin-bottom: 8px;
}
.zar__table {
  display: flex; justify-content: center; gap: 28px;
  padding: 40px 0 26px;
  perspective: 600px;
}
.die {
  width: 88px; height: 88px;
  background: linear-gradient(145deg, #ffffff, #d7ddec);
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 12px;
  gap: 2px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.45), inset 0 -4px 8px rgba(0,0,0,0.12);
}
.die .pip { display: block; }
.die .pip--on {
  width: 16px; height: 16px;
  background: #1a1f2e;
  border-radius: 50%;
  place-self: center;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.4);
}
.die.rolling { animation: tumble 0.8s ease; }
@keyframes tumble {
  0%   { transform: rotateX(0) rotateY(0) scale(1); }
  25%  { transform: rotateX(220deg) rotateY(140deg) scale(1.12); }
  50%  { transform: rotateX(420deg) rotateY(300deg) scale(0.95); }
  75%  { transform: rotateX(640deg) rotateY(480deg) scale(1.08); }
  100% { transform: rotateX(720deg) rotateY(720deg) scale(1); }
}
.zar__msg {
  min-height: 26px;
  font-size: 1.05rem;
  color: var(--text-dim);
  margin-bottom: 22px;
  transition: var(--trans);
}
.zar__msg--win { color: var(--accent-2); font-weight: 700; }
.zar__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* --- Kazanma oranı çubuğu --- */
.winbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.winbar__side { display: flex; flex-direction: column; min-width: 96px; }
.winbar__side--right { text-align: right; align-items: flex-end; }
.winbar__name { font-weight: 700; font-size: 0.95rem; }
.winbar__pct { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 800; }
.winbar__track {
  flex: 1;
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.winbar__seg { transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.winbar__seg--1 { background: linear-gradient(90deg, var(--accent), #8a6cff); }
.winbar__seg--2 { background: linear-gradient(90deg, var(--accent-3), #ff9f43); }

/* --- 2 oyuncu yerleşimi --- */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.player {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.player__name {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
}
.player__name:focus { outline: none; border-color: var(--accent); }

/* renk seçici */
.player__colors { display: flex; justify-content: center; gap: 10px; margin: 16px 0 4px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--trans);
  padding: 0;
}
.swatch:hover { transform: scale(1.1); }
.swatch--on { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(56,225,196,0.25); }

.player .zar__table { padding: 26px 0 18px; gap: 20px; }
.player .die { width: 72px; height: 72px; }

.player__stats { display: flex; justify-content: space-around; margin-top: 20px; }
.player__stats .stat__val { font-size: 1.3rem; }

/* geçmiş */
.history { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 18px; min-height: 28px; }
.hchip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 9px;
  border-radius: 7px;
}
.hchip b { color: var(--text); }
.hchip--dbl { border-color: var(--accent-2); color: var(--accent-2); }
.hchip--dbl b { color: var(--accent-2); }

@media (max-width: 620px) {
  .players { grid-template-columns: 1fr; }
  .winbar { flex-wrap: wrap; }
  .winbar__track { order: 3; flex-basis: 100%; }
}

/* =================== HAFIZA KARTLARI =================== */
.hafiza { max-width: 560px; }
.hafiza__hud { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.hafiza__hud .panel { flex: 1; min-width: 78px; }
.hafiza__select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: var(--font-sans); cursor: pointer;
}
.hafiza__grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: 10px;
}
.mcard {
  position: relative;
  aspect-ratio: 1 / 1;
  background: none; border: none; padding: 0; cursor: pointer;
  -webkit-perspective: 600px;
  perspective: 600px;
}
.mcard__inner {
  position: absolute; inset: 0;
  transition: transform 0.4s;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
.mcard.flip .mcard__inner, .mcard.done .mcard__inner { transform: rotateY(180deg); }
.mcard__face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  font-size: clamp(1.3rem, 6vw, 2rem);
}
.mcard__face--back {
  background: linear-gradient(135deg, var(--surface-2), var(--bg-soft));
  border: 1px solid var(--border);
  color: var(--text-mute);
}
.mcard__face--front {
  background: var(--surface);
  border: 1px solid var(--accent);
  transform: rotateY(180deg);
}
.mcard.done .mcard__face--front { border-color: var(--accent-2); box-shadow: 0 0 16px rgba(56,225,196,0.35); opacity: 0.85; }

/* =================== MAYIN TARLASI =================== */
.mayin { max-width: 600px; }
.mayin__hud { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.mayin__hud .panel { flex: 1; min-width: 78px; }
.mayin__board {
  display: grid;
  grid-template-columns: repeat(var(--n, 9), 1fr);
  gap: 3px;
  background: var(--border);
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
}
.mcell {
  aspect-ratio: 1 / 1;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  font-size: clamp(0.7rem, 2.4vw, 1rem);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.1s;
}
.mcell:hover { background: var(--surface); }
.mcell.open { background: var(--bg-soft); cursor: default; }
.mcell.flag { background: var(--surface-2); }
.mcell.mine { background: rgba(255,107,157,0.25); }

/* =================== TETRIS =================== */
.tetris {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.tetris__board {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.tetris__side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 150px;
  flex: 1;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.panel .stat__val { font-size: 1.4rem; }
#next {
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 56px;
  height: 56px;
  align-self: flex-start;   /* flex içinde esneyip bulanıklaşmasını engeller */
}
.tetris__hint { font-size: 0.85rem; color: var(--text-mute); text-align: center; }

@media (max-width: 560px) {
  .zar__stats { gap: 24px; }
  .die { width: 70px; height: 70px; }
}

/* =================== 2048 =================== */
.g2048 { max-width: 460px; }
.g2048__hud { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.g2048__hud .panel { flex: 1; }
.g2048__hud .btn { white-space: nowrap; }
.g2048__board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  touch-action: none;
}
.g2048__grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3%;
  padding: 3%;
}
.g2048__cell { background: var(--bg); border-radius: 8px; }
.g2048__tiles { position: absolute; inset: 0; }
.g2048__tile {
  position: absolute;
  display: grid; place-items: center;
  border-radius: 8px;
  font-weight: 800;
  font-size: clamp(1.1rem, 5vw, 1.9rem);
  color: #11141d;
  background: #cdd5e8;
  transition: left 0.12s ease, top 0.12s ease;
  animation: pop 0.12s ease;
}
@keyframes pop { from { transform: scale(0.8); } to { transform: scale(1); } }
.g2048__tile.v2    { background: #dfe6f5; }
.g2048__tile.v4    { background: #cdd9f2; }
.g2048__tile.v8    { background: #8fb0ff; color: #fff; }
.g2048__tile.v16   { background: #6c8cff; color: #fff; }
.g2048__tile.v32   { background: #7d6cff; color: #fff; }
.g2048__tile.v64   { background: #a05cff; color: #fff; }
.g2048__tile.v128  { background: #38e1c4; color: #11141d; font-size: clamp(1rem,4.5vw,1.7rem); }
.g2048__tile.v256  { background: #2bd1b0; color: #11141d; }
.g2048__tile.v512  { background: #ffd166; color: #11141d; }
.g2048__tile.v1024 { background: #ff9f43; color: #fff; font-size: clamp(0.9rem,4vw,1.5rem); }
.g2048__tile.v2048 { background: #ff6b9d; color: #fff; box-shadow: 0 0 22px rgba(255,107,157,0.6); }
.g2048__tile.vbig  { background: #ff5e7a; color: #fff; }
.g2048__over {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  background: rgba(12,15,23,0.82);
  backdrop-filter: blur(3px);
  border-radius: var(--radius);
  font-size: 1.5rem; font-weight: 800;
}
.g2048__over.show { display: flex; }
