/* TAVLA — kahvehane tahtası: ceviz kasa, kırmızı ve fildişi haneler, pirinç kenar */

:root {
  --bg: #0d0806;
  --panel: #1d130d;
  --panel2: #2b1d13;
  --line: #4a3322;
  --ink: #f3e9d8;
  --dim: #a99377;
  --brass: #e2b85a;
  --red: #c8503a;
  --mine: #f1e4c8;
  --theirs: #e0614a;
  --ok: #6cc28a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}

#game {
  position: relative;
  height: 100vh; height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(900px 560px at 50% -8%, #2c1c12 0%, var(--bg) 62%);
}
.hidden { display: none !important; }

/* ---------- Üst çubuk ---------- */
#topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 7px 12px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 21px; filter: drop-shadow(0 0 8px rgba(226,184,90,.5)); }
.brand .bTitle {
  font-weight: 800; letter-spacing: 3.5px; font-size: 15px;
  background: linear-gradient(180deg, #fff3c9, var(--brass));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stats { display: flex; gap: 6px; flex: 1 1 auto; justify-content: center; flex-wrap: wrap; }
.stat {
  min-width: 60px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(0,0,0,.3); text-align: center; line-height: 1.15;
}
.stat.wide { min-width: 84px; }
.stat b { display: block; font-size: 9px; letter-spacing: 1.3px; color: var(--dim); font-weight: 700; }
.stat span { display: block; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat.mine span { color: var(--mine); }
.stat.theirs span { color: var(--theirs); }
#pipVal { font-size: 14px; padding-top: 2px; }
.tools { display: flex; gap: 6px; }
.tools button {
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(0,0,0,.3); color: var(--ink);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.tools button:hover { background: var(--panel2); border-color: var(--brass); }

/* ---------- Sıra çubuğu ---------- */
#turnBar {
  flex: 0 0 auto; text-align: center; padding: 5px 8px 6px;
  border-bottom: 1px solid var(--line); background: rgba(0,0,0,.28);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#turnVal { font-size: 12.5px; font-weight: 800; letter-spacing: .6px; color: var(--dim); }
#turnVal.mine { color: var(--mine); }
#turnVal.theirs { color: var(--theirs); }

/* ---------- Oyun alanı ---------- */
#play { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* Tuval düzenden çıkarılır: kendi boyutu ebeveyni etkilemez (ResizeObserver döngüsü olmasın) */
#arena { position: relative; flex: 1 1 auto; min-height: 0; touch-action: none; }
#cv { position: absolute; inset: 0; display: block; }

/* ---------- Eylem çubuğu ---------- */
#actionBar {
  flex: 0 0 auto;
  display: flex; gap: 8px; justify-content: center;
  padding: 8px 12px 12px;
  background: linear-gradient(0deg, var(--panel), transparent);
}
#actionBar button { padding: 10px 16px; font-size: 14px; min-width: 112px; }
#doneBtn.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(226,184,90,.0); } 50% { box-shadow: 0 0 0 5px rgba(226,184,90,.35); } }

/* ---------- Örtüler ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,4,2,.84); backdrop-filter: blur(3px); padding: 16px;
}

/* ---------- Giriş ---------- */
#titleScreen {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(700px 460px at 50% 32%, #3a2416 0%, #0d0806 70%);
  padding: 14px; overflow-y: auto;
}
.tBox { text-align: center; max-width: 480px; width: 100%; margin: auto; }
.tLogo { font-size: 56px; filter: drop-shadow(0 0 24px rgba(226,184,90,.55)); }
.tBox h1 {
  margin-top: 4px; font-size: 42px; font-weight: 900; letter-spacing: 8px;
  background: linear-gradient(180deg, #fff6d4, var(--brass) 58%, #96661a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tSub { color: var(--theirs); letter-spacing: 3.5px; font-size: 12px; font-weight: 700; text-transform: uppercase; margin-top: 2px; }
.tClaim {
  margin-top: 14px; font-size: 12.5px; line-height: 1.65; color: var(--dim);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px;
  background: rgba(0,0,0,.25);
}
.tClaim b { color: var(--ink); }
.tLabel { margin-top: 14px; font-size: 10.5px; letter-spacing: 2px; color: var(--dim); font-weight: 700; text-transform: uppercase; }
.lvRow { display: flex; gap: 6px; margin-top: 6px; justify-content: center; }
.lvBtn, .lenBtn { padding: 9px 10px; font-size: 13px; flex: 1 1 0; }
.lvBtn.on, .lenBtn.on { border-color: var(--brass); color: #fff3c9; background: linear-gradient(180deg, #4d3420, #30200f); }
.tBtns { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.tRow { display: flex; gap: 8px; }
.tRow button { flex: 1 1 0; }
.tHint { margin-top: 14px; font-size: 12px; color: var(--dim); line-height: 1.6; }

/* ---------- Düğmeler ---------- */
button {
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 12px 20px; border-radius: 11px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  color: var(--ink); cursor: pointer;
  transition: filter .12s ease, transform .1s ease;
}
button:hover { filter: brightness(1.18); }
button:active { transform: translateY(1px); }
button.primary {
  border-color: var(--brass);
  background: linear-gradient(180deg, #f0d273, #b98b22);
  color: #241a04; font-weight: 800;
}
button.ghost { background: transparent; color: var(--dim); }
button.ghost:hover { color: var(--ink); }
button:disabled { opacity: .38; cursor: default; transform: none; filter: none; }

/* ---------- Modal ---------- */
.modal {
  width: min(540px, 100%); max-height: 100%; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.65);
}
.modal h3 { font-size: 19px; font-weight: 800; letter-spacing: .6px; text-align: center; color: var(--brass); margin-bottom: 12px; }
#modalBody { font-size: 13.5px; line-height: 1.65; color: #ddd0b8; }
#modalBody p + p { margin-top: 8px; }
#modalBody b { color: var(--ink); }
#modalBody .good { color: var(--ok); }
#modalBody .bad { color: var(--theirs); }
#modalBody .dim { color: var(--dim); }
#modalBody .center { text-align: center; }
#modalActions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.bigScore { text-align: center; font-size: 40px; font-weight: 900; letter-spacing: 2px; margin-bottom: 6px; color: var(--brass); font-variant-numeric: tabular-nums; }
.bigScore.good { color: var(--ok); }
.bigScore.bad { color: var(--theirs); }

/* Zar defteri */
.defter { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: 6px; }
.defter th, .defter td { padding: 4px 6px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.06); }
.defter th { font-size: 11px; color: var(--dim); letter-spacing: 1px; font-weight: 700; }
.defter td.l { text-align: left; color: var(--dim); }
.bar { display: inline-block; height: 7px; border-radius: 4px; vertical-align: middle; background: var(--brass); opacity: .85; }
.bar.t { background: var(--theirs); }

/* ---------- Bildirimler ---------- */
#toasts {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%);
  z-index: 70; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  padding: 8px 16px; border-radius: 999px; text-align: center;
  background: rgba(22,14,8,.95); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700;
  animation: toastIn .22s ease-out;
}
.toast.good { border-color: var(--ok); color: #c7f0d6; }
.toast.err { border-color: var(--theirs); color: #ffcabd; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Dar ekran ---------- */
@media (max-width: 680px) {
  .brand .bTitle { display: none; }
  #topbar { gap: 8px; padding: 6px 8px; }
  .stat { min-width: 48px; padding: 3px 6px; }
  .stat span { font-size: 15px; }
  .stat.wide { min-width: 0; }
  #actionBar button { min-width: 0; flex: 1 1 0; padding: 10px 6px; font-size: 13px; }
  .tBox h1 { font-size: 34px; letter-spacing: 6px; }
}

/* ---------- Alçak ekran (yatay telefon): düğmeler sağa, sütun olur ---------- */
@media (max-height: 520px) {
  #topbar { padding: 4px 8px; }
  .tools button { width: 30px; height: 30px; }
  .stat { padding: 2px 8px; }
  .stat span { font-size: 14px; }
  #turnBar { padding: 3px 8px 4px; }
  #play { flex-direction: row; }
  #actionBar {
    flex-direction: column; justify-content: center; padding: 6px 8px 6px 4px;
    background: linear-gradient(270deg, var(--panel), transparent);
  }
  #actionBar button { min-width: 96px; padding: 9px 8px; font-size: 13px; }
  #toasts { top: 64px; }
  .tLogo { font-size: 34px; }
  .tBox h1 { font-size: 28px; }
  .tClaim { margin-top: 8px; }
  .tLabel { margin-top: 8px; }
  .tBtns { margin-top: 10px; }
}
