/* Defter tasarım sistemi (bedirhanoktu.dev) — sayfa ve paneller kâğıt, masa deniz keçesi */
:root {
  --bg: #f6f2ea;
  --panel: #fffdf8;
  --sunk: #ede6d9;
  --line: #ddd3c2;
  --grid: #e4dccd;
  --text: #1d1813;
  --muted: #655b4f;
  --kiremit: #b03f17;
  --on-kiremit: #ffffff;
  --deniz: #1d5c57;
  --win-ink: #1d5c57;
  --lose-ink: #b03f17;
  --shadow-lift: 0 1px 0 rgba(29, 24, 19, .04), 0 8px 24px -12px rgba(29, 24, 19, .18);

  /* Masa her iki temada da koyu: keçe, çerçeve ve üstündeki renkler */
  --gold: #f6d873;
  --gold-2: #d9b44a;
  --felt: #1d5c57;
  --felt-2: #123f3b;
  --felt-hi: #2a7770;
  --wood: #3a2a1d;
  --red: #b03f17;
  --win: #7fd1b3;
  --lose: #f19a7a;
  --push: #e6ddd0;
  --cw: 88px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --panel: #1e1b16;
    --sunk: #25211b;
    --line: #38322a;
    --grid: #26221c;
    --text: #f0e9dd;
    --muted: #a89d8d;
    --kiremit: #ef8a5e;
    --on-kiremit: #1a0e07;
    --win-ink: #7fc6bc;
    --lose-ink: #ef8a5e;
    --shadow-lift: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --wood: #2a2018;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  background-color: var(--bg);
  /* Noktalı defter ızgarası */
  background-image: radial-gradient(var(--grid) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  background-position: -12px -12px;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button { touch-action: manipulation; -webkit-user-select: none; user-select: none; }

/* Ana ekrandan açıldığında çentik ve ana ekran çubuğu için boşluk */
.app {
  max-width: 1280px; margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}
.gold { color: var(--kiremit); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; margin: 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-size: 24px; color: var(--on-kiremit);
  background: var(--kiremit);
}
h1 {
  font-family: var(--font-display); font-weight: 600; font-variation-settings: 'opsz' 48;
  font-size: 26px; letter-spacing: -.015em; margin: 0;
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.bank { display: flex; gap: 10px; }
.stat {
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 10px; padding: 8px 14px; min-width: 120px;
}
.stat .label {
  display: block; font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.stat .value {
  font-family: var(--font-display); font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
.table {
  position: relative; display: flex; flex-direction: column;
  min-height: 640px; padding: 24px 20px; border-radius: 28px;
  color: #f0e9dd;
  background: radial-gradient(ellipse at 50% 30%, var(--felt-hi) 0%, var(--felt) 45%, var(--felt-2) 100%);
  border: 12px solid var(--wood);
  box-shadow:
    inset 0 0 0 2px rgba(246, 216, 115, .3),
    inset 0 0 90px rgba(0, 0, 0, .4),
    var(--shadow-lift);
}

.zone-head {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  margin-bottom: 10px; font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .7);
}
.total, .pill {
  font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: none;
  padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, .4); color: #fff;
  font-variant-numeric: tabular-nums;
}

.cards { display: flex; justify-content: center; min-height: calc(var(--cw) * 1.4); }
.cards .card + .card { margin-left: calc(var(--cw) * -0.38); }

.center-line {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 20px 0;
}
.rules {
  font-family: var(--font-display); font-style: italic; font-size: 15px; letter-spacing: .02em;
  color: rgba(246, 216, 115, .85); text-align: center;
  border-top: 1px solid rgba(246, 216, 115, .3); border-bottom: 1px solid rgba(246, 216, 115, .3);
  padding: 6px 18px;
}
.message {
  min-height: 38px; max-width: 100%; padding: 9px 18px; border-radius: 999px;
  background: rgba(0, 0, 0, .35); font-weight: 600; text-align: center;
}
.message.win { color: var(--win); }
.message.lose { color: var(--lose); }
.message.push { color: var(--push); }
.message.info { color: var(--gold); }

.hands { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: calc(var(--cw) * 1.4 + 40px); }
.hand {
  padding: 12px 12px 10px; border-radius: 16px; border: 2px solid transparent;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.hand.active {
  border-color: rgba(246, 216, 115, .85); background: rgba(0, 0, 0, .15);
  box-shadow: 0 0 24px rgba(246, 216, 115, .2);
}
.hand.dim { opacity: .6; }
.hand-foot { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.pill.bet { color: var(--gold); }
.pill.over { background: var(--lose); color: #2a0707; }
.pill.bj { background: var(--gold); color: #1d1407; }
.pill.result.win, .pill.result.blackjack { background: var(--win); color: #062313; }
.pill.result.lose, .pill.result.bust { background: var(--lose); color: #2a0707; }
.pill.result.push { background: var(--push); color: #1a1f1c; }

.bet-spot {
  align-self: center; width: 118px; height: 118px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed rgba(246, 216, 115, .55); color: var(--gold);
}
.bet-spot small { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; opacity: .8; }
.bet-spot strong { font-family: var(--font-display); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card {
  position: relative; flex: none; width: var(--cw); height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * .09); color: #1d1813; user-select: none;
  background: linear-gradient(160deg, #fffdf8, #f3ede1);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), 0 1px 0 rgba(0, 0, 0, .2);
}
.card.red { color: var(--red); }
.corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  line-height: 1; font-weight: 700;
}
.corner b { font-size: calc(var(--cw) * .2); letter-spacing: -.04em; }
.corner i { font-style: normal; font-size: calc(var(--cw) * .17); }
.corner.tl { top: 6%; left: 8%; }
.corner.br { bottom: 6%; right: 8%; transform: rotate(180deg); }
.pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * .46); }
.pip .frame {
  width: 54%; height: 58%; border: 1.5px solid currentColor; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: calc(var(--cw) * .34); line-height: 1;
  background: rgba(0, 0, 0, .03);
}
.pip .frame small { font-family: var(--font-sans); font-size: calc(var(--cw) * .16); margin-top: 2px; }

.card.back, .shoe .layer, .riffle .c {
  background: repeating-linear-gradient(45deg, #9a3614 0 6px, #b03f17 6px 12px);
  border: 4px solid #fffdf8;
}
.card.back::after {
  content: ''; position: absolute; inset: 5px; border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, .35);
}

.card.deal { animation: deal .38s cubic-bezier(.2, .8, .25, 1) both; }
.card.flip { animation: flip .45s ease both; }
@keyframes deal {
  from { transform: translate(260px, -240px) rotate(25deg); opacity: 0; }
  50% { opacity: 1; }
  to { transform: none; }
}
@keyframes flip {
  from { transform: rotateY(90deg); }
  to { transform: rotateY(0); }
}

/* ---------- Controls ---------- */
.controls { margin-top: 18px; display: flex; justify-content: center; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  color: #fff; font: 700 14px var(--font-sans); text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  background:
    radial-gradient(circle, var(--c) 0 56%, transparent 57%),
    repeating-conic-gradient(#f4f1e8 0 14deg, var(--c) 14deg 45deg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4), inset 0 0 0 3px rgba(255, 255, 255, .15);
  transition: transform .12s;
}
.chip:hover:not(:disabled) { transform: translateY(-3px); }
.chip:disabled { opacity: .3; cursor: not-allowed; }

.btn {
  appearance: none; display: inline-flex; gap: 8px; align-items: center;
  padding: 11px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(0, 0, 0, .3);
  color: #f0e9dd; font: 500 15px var(--font-sans);
  transition: background .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: rgba(0, 0, 0, .45); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: #ef8a5e; color: #1a0e07; border-color: transparent; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #f39b74; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
kbd {
  font: 500 11px var(--font-mono); padding: 1px 6px; border-radius: 5px;
  background: rgba(255, 255, 255, .14);
}
.btn.primary kbd { background: rgba(0, 0, 0, .15); }

/* ---------- Side panels ---------- */
.side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: 16px; padding: 16px; }
.panel h2 {
  margin: 0; font-family: var(--font-display); font-weight: 600; font-variation-settings: 'opsz' 24;
  font-size: 18px; letter-spacing: -.01em;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.panel-head .muted { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

.shoe { position: relative; height: 150px; }
.shoe .layer {
  position: absolute; left: 50%; width: 76px; height: 106px; border-radius: 7px;
  bottom: calc(var(--i) * 2px); transform: translateX(-50%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .35);
}
.shoe-empty {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 76px; height: 106px; border-radius: 7px; border: 2px dashed var(--line);
  display: grid; place-items: center; color: var(--muted); font-size: 12px;
}
.progress { height: 6px; border-radius: 99px; background: var(--sunk); overflow: hidden; margin: 12px 0 10px; }
.progress > div { height: 100%; background: var(--kiremit); transition: width .3s; }

.tracker { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; margin-bottom: 10px; }
.tcell {
  padding: 5px 0; border-radius: 4px; text-align: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: -.03em;
  background: #fffdf8; color: #1d1813; box-shadow: inset 0 0 0 1px #ddd3c2;
  transition: background .2s, color .2s;
}
.tcell.red { color: #b03f17; }
.tcell.suit { background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; padding: 3px 0; }
.tcell.suit.red { color: var(--kiremit); }
.tcell.seen { background: var(--sunk); box-shadow: none; color: var(--muted); opacity: .45; text-decoration: line-through; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.history li { display: flex; justify-content: space-between; gap: 8px; }
.history li span { color: var(--muted); }
.history b { font-variant-numeric: tabular-nums; }
.history .win { color: var(--win-ink); }
.history .lose { color: var(--lose-ink); }
.history .push { color: var(--muted); }
.history .empty { color: var(--muted); }

.link-btn {
  align-self: center; background: none; border: none; cursor: pointer;
  color: var(--muted); font: 500 13px var(--font-sans); text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--kiremit); }

/* ---------- Shuffle overlay ---------- */
.shuffle-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in oklab, var(--bg) 85%, transparent); backdrop-filter: blur(3px);
}
.shuffle-box { text-align: center; padding: 16px; }
.shuffle-box h3 { font-family: var(--font-display); font-weight: 600; font-size: 28px; margin: 0 0 6px; }
.shuffle-box p { margin: 0; color: var(--muted); }
.riffle { position: relative; width: 240px; height: 150px; margin: 0 auto 20px; }
.riffle .c {
  position: absolute; left: 83px; top: calc(24px - var(--i) * 3px);
  width: 74px; height: 104px; border-radius: 7px;
  box-shadow: var(--shadow-lift);
  animation: .9s ease-in-out infinite; animation-delay: calc(var(--i) * 45ms);
}
.riffle .c.l { animation-name: riffle-l; }
.riffle .c.r { animation-name: riffle-r; }
@keyframes riffle-l {
  0%, 100% { transform: translateX(0) rotate(0); }
  35%, 55% { transform: translateX(-62px) rotate(-12deg); }
}
@keyframes riffle-r {
  0%, 100% { transform: translateX(0) rotate(0); }
  35%, 55% { transform: translateX(62px) rotate(12deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  :root { --cw: 62px; }
  h1 { font-size: 20px; }
  .bank { width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .table { min-height: 560px; padding: 18px 10px; border-width: 8px; border-radius: 22px; }
  .rules { font-size: 12px; }
  .btn { padding: 11px 14px; font-size: 14px; }
  .btn kbd { display: none; }
  .chip { width: 50px; height: 50px; font-size: 13px; }
  .hands { gap: 6px; }
  .hand { padding: 8px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .card.deal, .card.flip, .riffle .c { animation: none; }
}
