/* Tavla Sayaç — tavla-sayac.html tarzı: sıcak tahta, DM Sans, mavi + altın oyuncu rengi */
:root {
  --bg: #1a1510;
  --panel: #2d2419;
  --text: #f4ebe0;
  --muted: #9a8b78;
  /* 1. oyuncu: mavi (Erdal) · 2. oyuncu: altın (Selim) */
  --accent-p1: #4a9fd4;
  --accent-p2: #c9a227;
  --danger: #c45c4a;
  --radius: 16px;
  --radius-sm: 10px;
  --line: rgba(255, 255, 255, 0.06);
  --line-bright: rgba(255, 255, 255, 0.1);
  --font: "DM Sans", system-ui, sans-serif;
  --font-mono: "DM Sans", system-ui, sans-serif;
  --topbar-h: 3.5rem;
  font-size: 16px;
}

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

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #3d2f1f 0%, transparent 55%), var(--bg);
  color: var(--text);
  padding-top: var(--topbar-h);
}

.hidden {
  display: none !important;
}

/* ---- Oyuncu rengi (içeride --player-accent) ---- */
.player[data-player="1"] {
  --player-accent: var(--accent-p1);
}
.player[data-player="2"] {
  --player-accent: var(--accent-p2);
}

/* --- Topbar --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 0.75rem 0 1rem;
  background: color-mix(in srgb, var(--panel) 88%, #000);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.topbar__inner {
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.5rem 0 0.15rem;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.topbar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.05rem;
  height: 2.05rem;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.6rem;
  line-height: 1;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
}

.topbar__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sub {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.topbar__titles {
  display: flex;
  flex-direction: column;
  gap: 0.04rem;
  min-width: 0;
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

/* --- Page --- */
.page {
  max-width: 58rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.lede {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.h2 {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  font-weight: 600;
  margin: 0 0 0.4rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.h2--modal {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.3rem;
}

.h2--drawer {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}

.h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.h3--periyot {
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  letter-spacing: 0.1em;
  color: var(--text);
  margin: 0 0 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line-bright);
  padding-bottom: 0.5rem;
}

.hint,
.hint--form {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
}
.hint--form {
  margin: 0.5rem 0 0.1rem;
}

/* --- Card (kurulum / üst paneller) --- */
.card {
  position: relative;
  background: linear-gradient(165deg, #352a20 0%, var(--panel) 45%, #231c15 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.2rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.card--main {
  padding: 1.3rem 1.25rem 1.4rem;
}

.card--hud {
  text-align: center;
  line-height: 1.6;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
  padding: 0.8rem 1rem;
  background: color-mix(in srgb, var(--panel) 65%, #1a1510);
}
.card--hud strong,
.hud__note {
  color: var(--text);
  font-weight: 600;
}
.hud__note {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.summary {
  text-align: center;
  padding: 0.9rem 1rem;
  background: color-mix(in srgb, var(--accent-p2) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent-p2) 22%, transparent);
}
.summary__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.summary__val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.3rem;
}

/* Form */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.grid-2 {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 30rem) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.field--row {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--text) 90%, var(--muted));
  margin: 0.1rem 0 0.05rem;
}
.field--row input {
  margin-top: 0.2rem;
  accent-color: var(--accent-p2);
  width: 1.1rem;
  height: 1.1rem;
}
.label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.input {
  font: inherit;
  color: var(--text);
  background: color-mix(in srgb, #1a1510 70%, var(--panel));
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}
.input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent-p2) 50%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-p2) 18%, transparent);
}
select.input {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 0.9rem) 50%, calc(100% - 0.6rem) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0.1rem 0 0.35rem;
}
.row--end {
  justify-content: flex-end;
  margin-top: 0.9rem;
}
.modal__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* Buttons: genel */
button {
  font-family: inherit;
}
.btn {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--accent-p2) 20%, #1a1510);
  border: 1px solid color-mix(in srgb, var(--accent-p2) 35%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  transition: filter 0.12s, transform 0.08s;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn:focus-visible {
  outline: 2px solid var(--accent-p2);
  outline-offset: 2px;
}

.btn--header {
  padding: 0.4rem 0.85rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.btn--header:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  filter: none;
}
.btn--header.btn--soft {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}
.btn--header.btn--soft:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn--soft {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn--soft:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  filter: none;
}

.btn--accent {
  background: color-mix(in srgb, var(--accent-p2) 38%, #1a1510);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent-p2) 50%, transparent);
  font-weight: 600;
}
.btn--accent:hover {
  filter: brightness(1.1);
}
.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn--ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  filter: none;
}
.btn--lg {
  padding: 0.7rem 1.2rem;
  font-size: 0.88rem;
}

/* +1: oyuncu rengine mix */
.btn--score {
  min-width: 7rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
  color: var(--text);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--player-accent) 25%, #1a1510);
  border: 1px solid color-mix(in srgb, var(--player-accent) 45%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.btn--score:hover {
  filter: brightness(1.1);
  border-color: color-mix(in srgb, var(--player-accent) 60%, transparent);
}
.btn--undo {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
}
.btn--undo:hover {
  color: #e8c4be;
  background: rgba(255, 255, 255, 0.08);
  filter: none;
}

/* Periyot */
.periyot {
  text-align: center;
}

.periyot--large {
  padding: 1.2rem 1.15rem 1.3rem;
}

.periyot__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}
.periyot__p {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.65rem;
  max-width: 100%;
}
.periyot--large .periyot__name {
  color: color-mix(in srgb, var(--text) 90%, var(--muted));
  max-width: 10em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 600;
}

.periyot__name {
  color: var(--muted);
  max-width: 8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
}

.badge {
  min-width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a1510;
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  border-radius: 10px;
  font-family: var(--font);
}

.periyot--large .badge {
  min-width: 2.65rem;
  height: 2.65rem;
  font-size: 1.15rem;
  border-radius: 12px;
}

.periyot--large .periyot__vs {
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 300;
  opacity: 0.9;
  padding: 0 0.1rem;
}

.periyot__vs {
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 400;
}

/* Oyun alanı: referanstaki board gibi */
.game-surface {
  position: relative;
  margin: 0.2rem 0 0;
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(0.65rem, 2.5vw, 1.25rem);
  width: 100%;
  align-items: stretch;
  padding: 0.5rem 0.15rem 0.35rem;
}

@media (max-width: 640px) {
  .board {
    grid-template-columns: 1fr;
  }
  .board__divider {
    display: none;
  }
}

.board__divider {
  width: 2px;
  align-self: stretch;
  min-height: 120px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(255, 255, 255, 0.1) 15%,
    rgba(255, 255, 255, 0.1) 85%,
    transparent
  );
  border-radius: 2px;
}

/* Oyuncu paneli: referanstaki .player */
.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(165deg, #352a20 0%, var(--panel) 45%, #231c15 100%);
  border-radius: var(--radius);
  padding: 1.15rem 1rem 1.1rem;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  min-width: 0;
}

.player__name {
  margin: 0 0 0.9rem;
  width: 100%;
  font-size: clamp(1.25rem, 4.5vw, 1.65rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--player-accent);
  text-align: center;
  border-bottom: 2px solid color-mix(in srgb, var(--player-accent) 35%, transparent);
  padding-bottom: 0.6rem;
}

.player__score {
  font-size: clamp(2.6rem, 11vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-height: 1.05em;
  font-family: var(--font);
  letter-spacing: -0.02em;
}

.player__btns {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 8.5rem;
  margin-top: 0.4rem;
}

/* Alt: işlemler */
.game-lower {
  margin-top: 0.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
  border-radius: 0 0 var(--radius) var(--radius);
}

.action-deck {
  padding: 0.45rem 0.25rem 0.4rem;
  max-width: 40rem;
  margin: 0 auto;
}
.action-deck__label {
  margin: 0 0 0.4rem;
  text-align: center;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-weight: 600;
}
.action-deck__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  background: transparent;
  border: none;
}
@media (min-width: 32rem) {
  .action-deck__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
  }
}
.action-deck__btn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.55rem 0.4rem;
  text-align: center;
  width: 100%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.1s, background 0.1s;
  user-select: none;
}
.action-deck__btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}
.action-deck__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.action-deck__text {
  line-height: 1.2;
  max-width: 11rem;
}
.action-deck__btn--pri {
  color: var(--text);
  background: color-mix(in srgb, var(--accent-p2) 32%, #1a1510);
  border: 1px solid color-mix(in srgb, var(--accent-p2) 48%, transparent);
}
.action-deck__btn--pri:hover:not(:disabled) {
  color: var(--text);
  filter: brightness(1.12);
}

/* Auth + modal */
.auth-msg {
  margin: 0.35rem 0 0.6rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  background: #2a1815;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: #e0b0a8;
  border-radius: var(--radius-sm);
}
.auth-msg.hidden,
.auth-msg:empty {
  display: none !important;
  margin: 0;
  padding: 0;
  border: none;
}
.auth-msg--ok {
  color: #c8e6d0;
  background: color-mix(in srgb, #3a5a4a 35%, #1a1510);
  border-color: color-mix(in srgb, #4a7a5a 40%, transparent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 10, 0.82);
  backdrop-filter: blur(3px);
}
.modal__box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 24rem;
  background: linear-gradient(165deg, #352a20 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.2rem 1.15rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: pop 0.2s ease;
}
.modal__x {
  position: absolute;
  top: 0.55rem;
  right: 0.5rem;
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.modal__x:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.win-text {
  margin: 0.5rem 0 0.3rem;
  line-height: 1.6;
  color: var(--muted);
  font-size: 0.9rem;
}
.win-text strong {
  color: var(--text);
}
@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Drawer */
body.drawer-locked {
  overflow: hidden;
}
.drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  visibility: hidden;
}
.drawer--open {
  pointer-events: auto;
  visibility: visible;
}
.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 10, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
}
.drawer--open .drawer__backdrop {
  opacity: 1;
}
.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 24rem);
  max-width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #2d2419 0%, #1a1510 100%);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 40px rgba(0, 0, 0, 0.4);
  padding: 1rem 0.9rem 1.25rem;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.drawer--open .drawer__panel {
  transform: translateX(0);
}
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.4rem;
}
.drawer__x {
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.drawer__x:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.history-list {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
}
.history-item {
  margin-bottom: 0.4rem;
  padding: 0.65rem 0.6rem;
  background: #231c15;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
}
.history-item--empty,
.history-item--err {
  color: var(--muted);
  font-size: 0.72rem;
  border-style: dashed;
  text-align: center;
}
.history-item--err {
  color: #e0a8a0;
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.history-item__title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.1rem;
}
.history-item__sub {
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--font);
}

@media (max-width: 22rem) {
  .periyot__row {
    flex-direction: column;
  }
  .periyot__vs {
    display: none;
  }
  .topbar__sub {
    display: none;
  }
  .action-deck__text {
    max-width: 100%;
  }
}
@media (max-width: 420px) {
  .topbar__actions {
    max-width: 9rem;
  }
  .btn--header {
    padding: 0.3rem 0.45rem;
    font-size: 0.62rem;
  }
}
