/* Satranç — yeşil çuha, ceviz tahta, pirinç vurgu */
:root {
  --bg: #1b2a26;
  --surface: #24352f;
  --surface-2: #2d4039;
  --line: #3b5048;
  --text: #eee8da;
  --muted: #a9b5ad;
  --brass: #d4a33b;
  --brass-ink: #1b1a14;
  --danger: #c9573f;
  --sq-light: #e8d9b5;
  --sq-dark: #7d5a3c;
  --sq-last: rgba(212, 163, 59, .45);
  --sq-sel: rgba(212, 163, 59, .75);
  --sq-check: rgba(201, 87, 63, .8);
  --radius: 10px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
a { color: var(--brass); }
h1, h2 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
.muted { color: var(--muted); }
small { font-size: .85em; }

/* Üst çubuk */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: env(safe-area-inset-top, 0); z-index: 5;
}
.brand { font-family: var(--font-display); font-size: 1.3rem; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a { color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
.topbar nav a:hover { color: var(--brass); }
.who { color: var(--muted); font-size: .9rem; }

.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 14px; border-top: 1px solid var(--line); }

/* Düğmeler, formlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: 600 .95rem var(--font-body);
  text-decoration: none; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--brass); }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: #f0a899; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 32px; font-size: .85rem; }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-weight: 600; margin-bottom: 14px; }
label input:not([type=radio]):not([type=file]), select {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font: 1rem var(--font-body);
}
select { width: auto; padding: 6px 8px; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.choice { display: inline-flex; margin: 0 8px 8px 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice span {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600;
}
.choice input:checked + span { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.choice input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.notice.error { border-color: var(--danger); color: #f0a899; }
.inline { display: inline; }

/* Giriş / kayıt */
.auth-page { align-items: center; justify-content: center; padding: 16px; }
.auth-card { max-width: 420px; margin: 24px auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.auth-card .btn { width: 100%; }

/* Lobi */
.lobby { max-width: 640px; }
.lobby-hero { margin-bottom: 20px; }
.new-game { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.game-list { list-style: none; padding: 0; margin: 0; }
.game-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}

/* Oyun sayfası */
.game-page { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 8px; width: min(100%, 72vh, 640px); margin: 0 auto; }
.side-col { display: flex; flex-direction: column; gap: 14px; }
.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1 / 1;
  width: 100%; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 6px #4a3425, 0 18px 40px rgba(0, 0, 0, .45);
  container-type: inline-size; /* taş boyutu tahtaya göre ölçülür */
}
.sq {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden;
  border: 0; padding: 0; margin: 0; cursor: pointer; appearance: none; font: inherit; line-height: 1;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.sq > * { max-width: 100%; max-height: 100%; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last { box-shadow: inset 0 0 0 100px var(--sq-last); }
.sq.selected { box-shadow: inset 0 0 0 100px var(--sq-sel); }
.sq.check { background: radial-gradient(circle, var(--sq-check) 0, var(--sq-check) 45%, transparent 75%); }
.sq.target::after {
  content: ''; position: absolute; width: 28%; height: 28%; border-radius: 50%;
  background: rgba(27, 42, 38, .55);
}
.sq.target-capture::after {
  content: ''; position: absolute; inset: 6%; border-radius: 50%;
  border: 4px solid rgba(27, 42, 38, .55);
}
.sq .coord { position: absolute; font-size: clamp(8px, 1.8cqw, 12px); line-height: 1; font-style: normal; font-weight: 700; opacity: .65; pointer-events: none; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 3px; }
.piece-glyph { font-size: 9cqw; line-height: 1; pointer-events: none; user-select: none; display: block; }
@supports not (font-size: 1cqw) { .piece-glyph { font-size: clamp(26px, 9vw, 58px); } }
.piece-glyph.white { color: #fbf6ea; text-shadow: 0 0 2px #2a2016, 0 1px 2px #2a2016, 0 0 6px rgba(0,0,0,.4); }
.piece-glyph.black { color: #1c1611; text-shadow: 0 0 2px #f1e6cc, 0 0 1px #f1e6cc; }
.piece-img { width: 84%; height: 84%; display: block; object-fit: contain; pointer-events: none; user-select: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }

.player-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; min-height: 42px;
}
.player-strip.active { border-color: var(--brass); box-shadow: inset 3px 0 0 var(--brass); }
.player-strip .captured { color: var(--muted); font-size: 1rem; letter-spacing: -2px; }
.player-strip .captured b { letter-spacing: 0; margin-left: 6px; color: var(--brass); font-size: .85rem; }

.status { font-family: var(--font-display); font-size: 1.35rem; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.status.over { border-color: var(--brass); }
.move-list {
  margin: 0; padding: 10px 14px; list-style: decimal; max-height: 260px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-variant-numeric: tabular-nums; column-count: 1;
}
.move-list li { display: grid; grid-template-columns: 1fr 1fr; padding: 2px 0; }
.move-list li::marker { color: var(--muted); }
.actions { display: flex; flex-direction: column; gap: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; }
.promo-choices { display: flex; gap: 10px; justify-content: center; }
.promo { width: 68px; height: 68px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--sq-light); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.promo .piece-glyph { font-size: 44px; }
.promo .piece-img { width: 80%; height: 80%; }
.promo:hover { border-color: var(--brass); }

/* Taşlarım */
.pieces-page { max-width: 760px; }
.piece-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin: 18px 0; }
.piece-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.piece-card.loading { opacity: .6; }
.piece-preview { height: 150px; display: flex; align-items: center; justify-content: center; }
.piece-preview.on-dark { background: var(--sq-dark); }
.piece-preview.on-light { background: var(--sq-light); }
.piece-preview img { max-width: 70%; max-height: 70%; object-fit: contain; }
.piece-preview .glyph { font-size: 78px; line-height: 1; }
.on-dark .glyph { color: #fbf6ea; text-shadow: 0 1px 2px #2a2016; }
.on-light .glyph { color: #1c1611; }
.piece-meta { padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.piece-meta strong { width: 100%; }

/* Yönetim */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 520px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 820px) {
  .game-page { grid-template-columns: 1fr; gap: 14px; }
  .board-col { width: min(100%, 78vh); }
  .move-list { max-height: 150px; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { flex: 1; }
  .topbar nav { gap: 10px; font-size: .9rem; }
  .who { display: none; }
  .page { padding: 14px 12px 32px; }
  h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .sq { transition: box-shadow .12s ease; }
}