/* =========================================================
   Drevion Carlsen
   ========================================================= */

:root {
  --bg: #0b0c0b;
  --bg-2: #101110;
  --panel: #151614;
  --panel-2: #1a1b18;
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #eef0e8;
  --muted: #9b9e93;
  --muted-2: #6c6f65;
  --gold: #c8a96c;
  --gold-2: #e2c68b;
  --gold-3: #9c7f45;
  --danger: #d8756a;
  --light-sq: #ebecd0;
  --dark-sq: #779556;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body.in-game,
body.overlay-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

::selection {
  background: rgba(200, 169, 108, 0.3);
  color: #fff;
}

:focus-visible {
  outline: 2px solid rgba(200, 169, 108, 0.85);
  outline-offset: 3px;
}

/* ---------------------------------------------------------
   Arka plan
   --------------------------------------------------------- */

.bg-glow,
.bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  background:
    radial-gradient(52% 38% at 50% 0%, rgba(200, 169, 108, 0.075), transparent 70%),
    radial-gradient(80% 62% at 50% 118%, rgba(24, 26, 22, 0.9), transparent 72%);
}

.bg-grain {
  opacity: 0.028;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

body.in-game .bg-grain,
body.in-analysis .bg-grain {
  display: none;
}

/* ---------------------------------------------------------
   Üst çubuk
   --------------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(62px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-left: max(clamp(16px, 3.4vw, 32px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 3.4vw, 32px), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(11, 12, 11, 0.9), rgba(11, 12, 11, 0));
}

.topbar-actions {
  pointer-events: auto;

  display: flex;
  align-items: center;
  gap: 1px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.icon-btn:active {
  transform: scale(0.95);
}

#soundBtn .icon-off {
  display: none;
}

#soundBtn[aria-pressed="false"] .icon-on {
  display: none;
}

#soundBtn[aria-pressed="false"] .icon-off {
  display: block;
}

/* ---------------------------------------------------------
   Ana yerleşim
   --------------------------------------------------------- */

#board:focus-visible {
  outline: 2px solid rgba(200, 169, 108, 0.7);
  outline-offset: 2px;
}

#main {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding-top: calc(68px + env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

.screen {
  width: 100%;
  animation: fadeIn 0.45s var(--ease) both;
}

/* ---------------------------------------------------------
   Giriş ekranı
   --------------------------------------------------------- */

.screen-setup {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 86px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.setup-card {
  width: min(392px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #161715, #101110);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 30px 80px -40px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.setup-body {
  padding: 36px 34px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 9px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.02;
  color: #f6f3ea;
}

#setupForm {
  display: grid;
  gap: 20px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.name-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar.setup-avatar {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(200, 169, 108, 0.48);
  background: #1d1e1a;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 4px 14px -7px rgba(0, 0, 0, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.setup-avatar[data-source="chesscom"] {
  border-color: rgba(200, 169, 108, 0.82);
  box-shadow:
    0 0 0 1px rgba(200, 169, 108, 0.2),
    0 4px 16px -7px rgba(0, 0, 0, 0.9);
}

.setup-avatar.loading {
  animation: avatarPulse 1s ease-in-out infinite;
}

@keyframes avatarPulse {
  50% {
    border-color: rgba(200, 169, 108, 0.9);
    box-shadow:
      0 0 0 3px rgba(200, 169, 108, 0.12),
      0 4px 16px -7px rgba(0, 0, 0, 0.9);
  }
}

#playerName {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

#playerName::placeholder {
  color: #676a60;
}

#playerName:focus {
  border-color: rgba(200, 169, 108, 0.6);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 0 0 3px rgba(200, 169, 108, 0.1);
}

.color-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.color-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-card {
  position: relative;
  height: 84px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s var(--ease);
}

.color-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.color-card[aria-pressed="true"] {
  border-color: rgba(200, 169, 108, 0.7);
  background: rgba(200, 169, 108, 0.08);
  color: var(--text);
}

.piece-disc {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #f2ead8, #d3c3a4);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    0 3px 10px -5px rgba(0, 0, 0, 0.7);
  transition: transform 0.18s var(--ease);
}

.color-card[data-color="white"] .piece-disc {
  background: radial-gradient(circle at 50% 38%, #2b2c26, #17180f);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 3px 10px -5px rgba(0, 0, 0, 0.7);
}

.color-card:hover .piece-disc {
  transform: scale(1.05);
}

.piece-disc img {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.color-name {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-transform: uppercase;
}

.color-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #17130b;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.16s ease, transform 0.16s var(--ease);
}

.color-card[aria-pressed="true"] .color-check {
  opacity: 1;
  transform: scale(1);
}

.btn-primary {
  position: relative;
  width: 100%;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #dfc185, #b7955a);
  color: #17130b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 14px 30px -16px rgba(200, 169, 108, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: filter 0.18s ease, transform 0.18s var(--ease), box-shadow 0.18s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.994);
}

.btn-primary:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed;
  box-shadow: none;
  filter: saturate(0.5);
}

.time-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

.time-note svg {
  opacity: 0.85;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------
   Oyun ekranı
   --------------------------------------------------------- */

.screen-game {
  display: flex;
  justify-content: center;
}

/* Oyunda tahta üstte kalsın, boşluk ortada birikmesin */
body.in-game #main {
  place-items: start center;
  padding-top: calc(56px + env(safe-area-inset-top));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.game {
  --board: min(
    calc(100dvh - 208px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),
    calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)),
    760px
  );
  width: var(--board);
  display: flex;
  flex-direction: column;
}

.move-no,
.move-san {
  padding-left: 7px;
  padding-right: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: #dcdfd2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.player-row {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 2px;
}

.player-row + .board-frame {
  margin-top: 2px;
}

.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  user-select: none;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.bot-avatar {
  background: #1d1e1a;
  border: 1px solid rgba(200, 169, 108, 0.5);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 4px 14px -6px rgba(0, 0, 0, 0.9);
}

.bot-avatar.thinking {
  box-shadow:
    0 0 0 1px rgba(200, 169, 108, 0.85),
    0 0 20px rgba(200, 169, 108, 0.35);
}

.player-avatar {
  background: #1d1e1a;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 3px 12px -6px #000;
}

.player-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.name-line {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 18px;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
}

.bot-name {
  font-family: var(--font-display);
  font-size: 16.5px;
  letter-spacing: 0.01em;
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 7px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.thinking.on {
  opacity: 1;
}

.thinking i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold);
  animation: think 1.15s ease-in-out infinite;
}

.thinking i:nth-child(2) {
  animation-delay: 0.14s;
}

.thinking i:nth-child(3) {
  animation-delay: 0.28s;
}

.thinking:not(.on) i {
  animation: none;
}

.captured {
  height: 20px;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  padding-left: 1px;
}

.captured img {
  width: 20px;
  height: 20px;
  margin-left: -7px;
  opacity: 0.92;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.captured img:first-child {
  margin-left: 0;
}

.captured img.dark-piece {
  background: radial-gradient(circle at 50% 55%, rgba(236, 238, 226, 0.28), rgba(236, 238, 226, 0.1) 62%, transparent 72%);
  border-radius: 50%;
}

.captured .material {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.clock {
  position: relative;
  flex: 0 0 auto;
  min-width: 84px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(238, 240, 232, 0.55);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.015em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.clock::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: calc(var(--p, 100) * 1%);
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.clock.active {
  background: #e9ead8;
  border-color: #e9ead8;
  color: #14150f;
  box-shadow: 0 8px 20px -12px rgba(0, 0, 0, 0.9);
}

.clock.active::after {
  opacity: 1;
  background: rgba(20, 21, 15, 0.35);
}

.clock.low {
  background: rgba(216, 117, 106, 0.12);
  border-color: rgba(216, 117, 106, 0.38);
  color: #ef9d92;
}

.clock.low::after {
  background: #d8756a;
  opacity: 1;
}

.clock.low.active {
  background: #d8756a;
  border-color: #d8756a;
  color: #20100e;
}

.clock.low.active::after {
  background: rgba(32, 16, 14, 0.35);
}

.board-frame {
  position: relative;
  width: 100%;
  padding: 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, #171815, #121310);
  border: 1px solid rgba(200, 169, 108, 0.16);
  box-shadow:
    0 30px 70px -42px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.board-frame::before,
.board-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 169, 108, 0.55), transparent);
}

.board-frame::before {
  top: -1px;
  left: 12%;
  right: 12%;
}

.board-frame::after {
  display: none;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--light-sq);
}

.underboard {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.text-btn:hover {
  color: #e79a90;
  background: rgba(216, 117, 106, 0.08);
}

/* ---------------------------------------------------------
   Tahta — chess.com yeşili
   --------------------------------------------------------- */

.cg-wrap cg-container {
  /* Chessground tahtayı 8'in katına yuvarlar; kalan boşluk kenarda kalmasın. */
  width: 100% !important;
  height: 100% !important;
}

.cg-wrap cg-board {
  background-color: var(--dark-sq);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Crect width='8' height='8' fill='%23779556'/%3E%3Cpath d='M0 0h1v1H0zM2 0h1v1H2zM4 0h1v1H4zM6 0h1v1H6zM1 1h1v1H1zM3 1h1v1H3zM5 1h1v1H5zM7 1h1v1H7zM0 2h1v1H0zM2 2h1v1H2zM4 2h1v1H4zM6 2h1v1H6zM1 3h1v1H1zM3 3h1v1H3zM5 3h1v1H5zM7 3h1v1H7zM0 4h1v1H0zM2 4h1v1H2zM4 4h1v1H4zM6 4h1v1H6zM1 5h1v1H1zM3 5h1v1H3zM5 5h1v1H5zM7 5h1v1H7zM0 6h1v1H0zM2 6h1v1H2zM4 6h1v1H4zM6 6h1v1H6zM1 7h1v1H1zM3 7h1v1H3zM5 7h1v1H5zM7 7h1v1H7z' fill='%23ebecd0'/%3E%3C/svg%3E");
  background-size: cover;
}

.cg-wrap piece {
  background-size: 100% 100%;
  /* Bütün taşlardaki filtre her animasyon karesini pahalılaştırır. */
  filter: none;
}

.cg-wrap piece.dragging {
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.32));
}

.cg-wrap cg-board square.move-dest {
  background: radial-gradient(circle at center, rgba(20, 30, 15, 0.22) 0 16%, transparent 17%);
}

.cg-wrap cg-board square.oc.move-dest {
  background: radial-gradient(circle at center, transparent 0 70%, rgba(20, 30, 15, 0.2) 71% 84%, transparent 85%);
}

.cg-wrap cg-board square.move-dest:hover {
  background: radial-gradient(circle at center, rgba(20, 30, 15, 0.32) 0 16%, transparent 17%);
}

.cg-wrap cg-board square.oc.move-dest:hover {
  background: radial-gradient(circle at center, transparent 0 70%, rgba(20, 30, 15, 0.3) 71% 84%, transparent 85%);
}

.cg-wrap cg-board square.last-move {
  background-color: rgba(255, 255, 51, 0.34);
}

.cg-wrap cg-board square.selected {
  background-color: rgba(255, 255, 51, 0.42);
}

.cg-wrap cg-board square.check {
  background: radial-gradient(
    ellipse at center,
    rgba(255, 60, 40, 0.92) 0%,
    rgba(220, 30, 20, 0.7) 26%,
    rgba(180, 20, 15, 0) 72%
  );
}

.cg-wrap coords {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.01em;
  opacity: 1;
}

/* Koordinatlar — chess.com gibi kare içinde */
.coord-layer {
  position: absolute;
  inset: 6px;
  z-index: 4;
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
}

.coord-file,
.coord-rank {
  position: absolute;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  pointer-events: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}

.coord-file {
  bottom: 0;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 5px 4px 0;
}

.coord-rank {
  top: 0;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: flex-start;
  padding: 4px 0 0 5px;
}

.coord-file.on-light,
.coord-rank.on-light {
  color: rgba(94, 111, 68, 0.95);
}

.coord-file.on-dark,
.coord-rank.on-dark {
  color: rgba(243, 245, 224, 0.95);
}

/* ---------------------------------------------------------
   Oyun analizi
   --------------------------------------------------------- */

body.in-analysis {
  overflow: auto;
}

body.in-analysis .topbar {
  display: none;
}

body.in-analysis #main {
  min-height: 100dvh;
  padding: 0;
  display: block;
}

.screen-analysis {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) clamp(12px, 2.6vw, 30px)
    max(24px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

.analysis-shell {
  width: min(1240px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.8vw, 18px);
}

.analysis-head {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 18px);
  min-height: 52px;
}

.analysis-back {
  flex: 0 0 auto;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.analysis-back:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line-2);
}

.analysis-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.analysis-heading .eyebrow {
  margin-bottom: 3px;
}

.analysis-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.analysis-title {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 2.8vw, 38px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--gold-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-title[data-result="loss"],
.analysis-title[data-result="draw"] {
  color: #e8e4d8;
}

.readonly-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid rgba(200, 169, 108, 0.28);
  border-radius: 999px;
  background: rgba(200, 169, 108, 0.07);
  color: var(--gold);
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pgn-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-2);
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.pgn-btn:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: rgba(255, 255, 255, 0.04);
}

.pgn-btn.copied {
  color: #b8dc8a;
  border-color: rgba(143, 191, 90, 0.4);
  background: rgba(143, 191, 90, 0.1);
}

.analysis-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-acc {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
}

.acc-item {
  min-width: 82px;
  padding: 6px 10px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  text-align: right;
}

.acc-item.me {
  border-color: rgba(200, 169, 108, 0.32);
  background: rgba(200, 169, 108, 0.055);
}

.acc-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.acc-label {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 7.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, min(760px, calc(100dvh - 196px))) 360px;
  gap: clamp(16px, 2vw, 26px);
  align-items: start;
  justify-content: center;
}

.analysis-board-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.analysis-board-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.eval-bar {
  position: relative;
  flex: 0 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  overflow: hidden;
  background: #26271f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.eval-white {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--white, 50) * 1%);
  background: linear-gradient(180deg, #f3f4e4, #d9dbc7);
  transition: height 0.32s var(--ease);
}

.eval-bar.flip .eval-white {
  bottom: auto;
  top: 0;
}

.analysis-frame {
  flex: 1 1 auto;
  min-width: 0;
}

.analysis-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 1px;
}

.nav-buttons {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
}

.nav-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-2);
}

.nav-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.nav-play[aria-pressed="true"] {
  color: #17130b;
  border-color: var(--gold);
  background: var(--gold);
}

#navPlay .pause-icon {
  display: none;
}

#navPlay[aria-pressed="true"] .play-icon {
  display: none;
}

#navPlay[aria-pressed="true"] .pause-icon {
  display: block;
}

.analysis-slider {
  flex: 1 1 auto;
  min-width: 60px;
  height: 18px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.analysis-pos {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.analysis-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-now,
.analysis-engine,
.graph-wrap,
.move-list-wrap,
.analysis-stats {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.012));
}

.analysis-now {
  padding: 12px 14px 11px;
}

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

.now-head .eyebrow {
  margin: 0;
}

.now-pos {
  color: var(--muted-2);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.now-move-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
}

.now-move {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.now-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 14px;
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 10px;
}

.now-meta span:empty {
  display: none;
}

.analysis-engine {
  padding: 12px 14px;
}

.engine-eval-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.engine-eval {
  font-size: 25px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}

.engine-depth {
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.engine-status {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.engine-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.engine-label {
  color: var(--muted-2);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.engine-best {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.engine-line {
  min-height: 14px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.engine-progress {
  height: 2px;
  margin-top: 9px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.engine-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-2));
  transition: width 0.25s ease;
}

.graph-wrap {
  padding: 11px 12px 8px;
}

.graph-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.graph-head .eyebrow {
  margin: 0;
}

.graph-legend {
  color: var(--muted-2);
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.eval-graph {
  display: block;
  width: 100%;
  height: 118px;
  cursor: pointer;
  touch-action: manipulation;
}

.graph-grid {
  stroke: rgba(255, 255, 255, 0.055);
  stroke-width: 1;
}

.graph-zero {
  stroke: rgba(255, 255, 255, 0.13);
  stroke-width: 1;
}

.graph-area {
  fill: url(#evalArea);
}

.graph-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.graph-cursor {
  stroke: rgba(238, 240, 232, 0.5);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
}

.graph-current {
  fill: var(--gold-2);
  stroke: #0b0c0b;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.move-list-wrap {
  padding: 11px 10px 8px;
}

.move-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 6px;
}

.move-list-head .eyebrow {
  margin: 0;
}

.move-list-hint {
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.analysis-moves {
  max-height: min(246px, 24dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 169, 108, 0.35) transparent;
}

.analysis-moves::-webkit-scrollbar {
  width: 5px;
}

.analysis-moves::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(200, 169, 108, 0.3);
}

.move-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr);
  gap: 2px;
  align-items: center;
}

.move-no {
  padding-right: 3px;
  color: var(--muted-2);
  font-size: 9.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.move-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #dcdfd2;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.move-cell:hover {
  background: rgba(255, 255, 255, 0.04);
}

.move-cell.active {
  border-color: rgba(200, 169, 108, 0.22);
  background: rgba(200, 169, 108, 0.12);
}

.move-cell.empty {
  cursor: default;
}

.move-cell .san {
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.move-cell .time {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tag-dot {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted-2);
}

.tag-dot.brilliant {
  background: #3fd0b0;
}

.tag-dot.best,
.tag-dot.excellent {
  background: #8fbf5a;
}

.tag-dot.good {
  background: #a9b39a;
}

.tag-dot.inaccuracy {
  background: #e8c14a;
}

.tag-dot.mistake {
  background: #f0a05a;
}

.tag-dot.blunder {
  background: #e2604f;
}

.tag-dot.mate {
  background: var(--gold-2);
}

.move-empty {
  margin: 4px;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
}

.analysis-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.stat {
  min-width: 0;
  padding: 8px 11px;
  border-top: 1px solid var(--line);
}

.stat:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.stat:nth-child(-n + 2) {
  border-top: 0;
}

.stat-label {
  display: block;
  color: var(--muted-2);
  font-size: 7.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 2px;
  color: #d9dcd0;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-badge.brilliant {
  color: #8fe8d5;
  border-color: rgba(63, 208, 176, 0.32);
  background: rgba(63, 208, 176, 0.1);
}

.now-badge.best,
.now-badge.excellent {
  color: #b8dc8a;
  border-color: rgba(143, 191, 90, 0.32);
  background: rgba(143, 191, 90, 0.1);
}

.now-badge.good {
  color: #c2cbb5;
  border-color: rgba(169, 179, 154, 0.25);
  background: rgba(169, 179, 154, 0.08);
}

.now-badge.inaccuracy {
  color: #f0d27a;
  border-color: rgba(232, 193, 74, 0.32);
  background: rgba(232, 193, 74, 0.1);
}

.now-badge.mistake {
  color: #f5b77e;
  border-color: rgba(240, 160, 90, 0.32);
  background: rgba(240, 160, 90, 0.1);
}

.now-badge.blunder {
  color: #f08b7d;
  border-color: rgba(226, 96, 79, 0.34);
  background: rgba(226, 96, 79, 0.11);
}

.now-badge.mate {
  color: #efd9a7;
  border-color: rgba(226, 198, 139, 0.34);
  background: rgba(226, 198, 139, 0.1);
}

/* ---------------------------------------------------------
   Katmanlar
   --------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 7, 6, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease both;
}

.overlay-card {
  position: relative;
  width: min(392px, 100%);
  padding: 30px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: linear-gradient(180deg, #1a1b18, #121311);
  box-shadow: 0 44px 100px -40px #000, inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
  animation: cardIn 0.3s var(--ease) both;
}

.end-card {
  width: min(368px, 100%);
  padding: 30px 28px 24px;
}

.end-emblem {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(200, 169, 108, 0.32);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(200, 169, 108, 0.14), transparent 70%);
}

.end-king {
  width: 48px;
  height: 48px;
  transition: transform 0.4s var(--ease), opacity 0.3s ease;
}

.end-emblem.on-plate {
  border-color: rgba(200, 169, 108, 0.45);
  background: radial-gradient(circle at 50% 40%, #efe7d6, #d2c0a0);
  box-shadow: 0 0 30px -10px rgba(200, 169, 108, 0.5);
}

.end-king.loss {
  opacity: 0.92;
}

.end-king.draw {
  opacity: 0.6;
}

.end-card .eyebrow {
  margin-bottom: 4px;
}

.end-title {
  margin: 0 0 20px;
  font-size: 42px;
  color: var(--gold-2);
}

#endCard[data-result="loss"] .end-title,
#endCard[data-result="draw"] .end-title {
  color: #dcd8cc;
}

.end-actions {
  display: grid;
  gap: 8px;
}

.end-actions .btn-primary {
  height: 50px;
  gap: 8px;
}

.end-actions .btn-primary svg {
  flex: 0 0 auto;
  opacity: 0.9;
}

.end-actions .btn-ghost,
.confirm-actions .btn-ghost,
.confirm-actions .btn-danger {
  height: 44px;
}

.end-actions .btn-ghost {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: #b9b6ac;
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-indent: 0.17em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-ghost {
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.btn-danger {
  border: 1px solid rgba(216, 117, 106, 0.36);
  background: rgba(216, 117, 106, 0.1);
  color: #e79a90;
}

.btn-danger:hover {
  border-color: rgba(216, 117, 106, 0.55);
  background: rgba(216, 117, 106, 0.18);
}

.confirm-card {
  width: min(344px, 100%);
  padding: 28px 26px 24px;
}

.confirm-title {
  margin: 0 0 7px;
  font-family: var(--font-display);
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.confirm-text {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.promo-card {
  width: auto;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.promo-card .eyebrow {
  font-size: 8.5px;
  margin-bottom: 0;
}

.promo-options {
  display: flex;
  gap: 8px;
}

.promo-options button {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s var(--ease);
}

.promo-options button:hover {
  border-color: rgba(200, 169, 108, 0.6);
  background: rgba(200, 169, 108, 0.08);
  transform: translateY(-2px);
}

.promo-options img {
  width: 48px;
  height: 48px;
}

/* ---------------------------------------------------------
   Yardımcı
   --------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 70;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #1b1c19;
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 18px 44px -18px #000;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shake {
  animation: shake 0.36s ease;
}

/* ---------------------------------------------------------
   Animasyonlar
   --------------------------------------------------------- */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes think {
  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

/* ---------------------------------------------------------
   Duyarlılık
   --------------------------------------------------------- */


@media (max-width: 600px) {
  #main {
    padding-top: calc(60px + env(safe-area-inset-top));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .topbar {
    height: calc(54px + env(safe-area-inset-top));
    padding-left: 12px;
    padding-right: 10px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .screen-setup {
    min-height: calc(100dvh - 74px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .setup-card {
    border-radius: 16px;
  }

  .setup-body {
    padding: 30px 22px 24px;
  }

  #setupForm {
    gap: 18px;
  }

  #playerName {
    height: 48px;
  }

  .avatar.setup-avatar {
    width: 46px;
    height: 46px;
  }

  .color-card {
    height: 76px;
    gap: 8px;
  }

  .piece-disc {
    width: 40px;
    height: 40px;
  }

  .piece-disc img {
    width: 33px;
    height: 33px;
  }

  .btn-primary {
    height: 48px;
  }

  .game {
    --board: min(
      calc(100dvh - 210px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),
      calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)),
      720px
    );
  }

  .player-row {
    height: 46px;
    gap: 8px;
  }

  .avatar {
    width: 30px;
    height: 30px;
  }

  .bot-name {
    font-size: 15.5px;
  }

  .player-name {
    font-size: 12.5px;
  }


  .board-frame {
    padding: 4px;
    border-radius: 7px;
  }

  .coord-layer {
    display: none;
  }

  .clock {
    min-width: 76px;
    height: 36px;
    font-size: 17px;
    padding: 0 10px;
  }

  .captured {
    height: 18px;
  }

  .captured img {
    width: 18px;
    height: 18px;
    margin-left: -6px;
  }

  .cg-wrap coords.squares {
    font-size: 9px;
  }

  .cg-wrap coords.ranks,
  .cg-wrap coords.files {
    font-size: 8px;
  }

  .underboard {
    height: 34px;
  }

  .overlay {
    padding: 14px;
  }

  .overlay-card {
    padding: 26px 22px;
    border-radius: 16px;
  }

  .end-title {
    font-size: 38px;
    margin-bottom: 18px;
  }

  .promo-options button {
    width: 57px;
    height: 57px;
  }

  .promo-options img {
    width: 44px;
    height: 44px;
  }
}

@media (max-height: 820px) and (min-width: 1041px) {
  /* Kısa ekranlarda tahtayı küçültmek yerine sayfa hafifçe kaysın */
  .analysis-grid {
    grid-template-columns: minmax(0, min(760px, calc(100vw - 430px))) 360px;
  }
}

@media (max-width: 1040px) {
  .analysis-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .analysis-board-col,
  .analysis-panel {
    width: min(100%, 720px);
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 700px) {
  /* Tahta genişlikle sınırlı; dikeyde dengeli dursun */
  body.in-game #main {
    place-items: center;
    padding-top: calc(54px + env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .screen-analysis {
    padding-left: 10px;
    padding-right: 10px;
  }

  .analysis-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .analysis-heading {
    flex: 1 1 calc(100% - 48px);
  }

  .analysis-acc {
    width: 100%;
  }

  .acc-item {
    flex: 1 1 0;
    text-align: left;
  }

  .analysis-title {
    font-size: 30px;
  }

  .analysis-sub {
    white-space: normal;
  }

  .analysis-controls {
    flex-wrap: wrap;
  }

  .analysis-slider {
    flex-basis: 100%;
    order: 10;
  }

  .analysis-pos {
    order: 11;
    margin-left: auto;
  }

  .eval-graph {
    height: 100px;
  }

  .analysis-moves {
    max-height: 230px;
  }
}

@media (max-width: 420px) {
  .analysis-title {
    font-size: 27px;
  }

  .analysis-back {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .analysis-back span {
    display: none;
  }

  .nav-btn {
    width: 32px;
    height: 32px;
  }

  .analysis-now,
  .analysis-engine {
    padding: 10px 12px;
  }

  .now-move {
    font-size: 20px;
  }

  .engine-eval {
    font-size: 22px;
  }
}

@media (max-height: 680px) {
  #main {
    padding-top: calc(58px + env(safe-area-inset-top));
  }

  .game {
    --board: min(
      calc(100dvh - 214px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),
      calc(100vw - 24px),
      760px
    );
  }

  .player-row {
    height: 48px;
  }

  .underboard {
    height: 32px;
  }
}

@media (max-width: 600px) and (max-height: 680px) {
  .game {
    --board: min(
      calc(100dvh - 200px - env(safe-area-inset-top) - env(safe-area-inset-bottom)),
      calc(100vw - 20px),
      760px
    );
  }

  .player-row {
    height: 43px;
  }
}

@media (max-height: 560px) and (min-width: 480px) {
  /* Yatay telefon: tahta solda, oyuncu bilgileri sağda */
  .topbar {
    height: calc(46px + env(safe-area-inset-top));
  }

  body.in-game #main {
    place-items: center;
    padding-top: calc(46px + env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .game {
    --board: calc(
      100dvh - 56px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    width: min(100%, calc(var(--board) + 314px));
    display: grid;
    grid-template-columns: auto minmax(0, 300px);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "board bot"
      "board ."
      "board me"
      "board actions";
    align-items: center;
    column-gap: 12px;
    row-gap: 6px;
  }

  #botRow {
    grid-area: bot;
  }

  #meRow {
    grid-area: me;
  }

  .board-frame {
    grid-area: board;
    width: var(--board);
  }

  .underboard {
    grid-area: actions;
    height: 28px;
    justify-content: flex-start;
  }

  .game .player-row {
    height: 42px;
  }

  .screen-analysis {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .analysis-head {
    min-height: 0;
    flex-wrap: nowrap;
    align-items: center;
  }

  .analysis-heading {
    flex: 1 1 auto;
  }

  .analysis-back {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .analysis-back span {
    display: none;
  }

  .analysis-title {
    font-size: 22px;
  }

  .readonly-pill {
    display: none;
  }

  .analysis-sub {
    font-size: 10px;
  }

  .acc-item {
    min-width: 62px;
    padding: 4px 8px 5px;
  }

  .acc-value {
    font-size: 15px;
  }

  #navFirst,
  #navLast {
    display: none;
  }

  .analysis-acc {
    width: auto;
  }

  .acc-item {
    flex: 0 0 auto;
    text-align: right;
  }

  .analysis-sub {
    white-space: nowrap;
  }

  .analysis-slider {
    flex-basis: auto;
    order: 0;
    min-width: 0;
  }

  .analysis-pos {
    order: 0;
    margin-left: 0;
    display: none;
  }

  .analysis-controls {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .nav-buttons {
    gap: 2px;
  }

  .nav-btn {
    width: 29px;
    height: 29px;
  }

  .analysis-shell {
    width: 100%;
    gap: 10px;
  }

  .analysis-grid {
    grid-template-columns: calc(100dvh - 132px) minmax(0, 420px);
    gap: 12px;
  }

  .analysis-board-col {
    width: auto;
    margin: 0;
  }

  .analysis-panel {
    width: auto;
    margin: 0;
    max-height: calc(100dvh - 100px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .eval-graph {
    height: 70px;
  }

  .analysis-moves {
    max-height: 120px;
  }
}

@media (max-width: 370px) {
  .setup-body {
    padding-left: 17px;
    padding-right: 17px;
  }

  .color-card {
    gap: 6px;
  }

  .piece-disc {
    width: 36px;
    height: 36px;
  }

  .piece-disc img {
    width: 30px;
    height: 30px;
  }

  .clock {
    min-width: 60px;
    font-size: 14px;
  }
}

@media (max-height: 560px) {
  /* Kısa ekran / yatay telefon: giriş kartı taşmasın */
  .screen-setup {
    min-height: 0;
    padding: 6px 0 10px;
  }

  .setup-body {
    padding: 16px 22px 14px;
  }

  #setupForm {
    gap: 10px;
  }

  .field-label {
    margin-bottom: 5px;
  }

  .avatar.setup-avatar {
    width: 40px;
    height: 40px;
  }

  #playerName {
    height: 40px;
  }

  .color-card {
    height: 58px;
  }

  .piece-disc {
    width: 34px;
    height: 34px;
  }

  .piece-disc img {
    width: 28px;
    height: 28px;
  }

  .btn-primary {
    height: 40px;
  }

  .time-note {
    font-size: 9.5px;
  }
}

@media (max-height: 430px) {
  /* Çok kısa ekran: bitiş/kart katmanları taşmasın, gerekirse kaydırılsın */
  .overlay {
    place-items: start center;
    padding: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .overlay-card {
    margin: auto;
    padding: 20px 22px;
  }

  .end-emblem {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
  }

  .end-king {
    width: 32px;
    height: 32px;
  }

  .end-title {
    font-size: 28px;
    margin-bottom: 14px;
  }

  .end-actions {
    gap: 6px;
  }

  .end-actions .btn-primary {
    height: 40px;
  }

  .end-actions .btn-ghost,
  .confirm-actions .btn-ghost,
  .confirm-actions .btn-danger {
    height: 36px;
  }

  .promo-options button {
    width: 46px;
    height: 46px;
  }

  .promo-options img {
    width: 36px;
    height: 36px;
  }
}

@media (max-height: 360px) {
  .screen-setup {
    padding: 0 0 2px;
  }

  .setup-body {
    padding: 10px 18px 8px;
  }

  #setupForm {
    gap: 7px;
  }

  .field-label {
    margin-bottom: 3px;
  }

  .avatar.setup-avatar,
  #playerName {
    height: 36px;
  }

  .avatar.setup-avatar {
    width: 36px;
  }

  #playerName {
    padding: 0 10px;
    font-size: 14px;
  }

  .color-card {
    height: 48px;
    gap: 6px;
  }

  .piece-disc {
    width: 28px;
    height: 28px;
  }

  .piece-disc img {
    width: 23px;
    height: 23px;
  }

  .color-name {
    font-size: 9px;
  }

  .btn-primary {
    height: 36px;
  }

  .time-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
