@font-face {
  font-family: "Bricolage";
  src: url(/fonts/bricolage-latin-ext.woff2) format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage";
  src: url(/fonts/bricolage-latin.woff2) format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --room: #14100c;
  --panel: #1f1914;
  --panel-2: #2a221b;
  --panel-3: #3a2f25;
  --ink: #f4ecdb;
  --ink-2: #b8ac95;
  --felt: #1d6446;
  --felt-hi: #26805a;
  --felt-lo: #0f3e2b;
  --felt-ink: #d3e8dc;
  --chip: rgba(6, 28, 19, 0.62);
  --accent: #f0ac3f;
  --accent-2: #ffc366;
  --accent-ink: #231505;
  --danger: #d2443a;

  --bone-hi: #fffbf1;
  --bone: #f3e9d2;
  --bone-edge: #d4c39c;
  --bone-edge-2: #ad9b72;
  --c0: #cf3a2e;
  --c1: #d98a07;
  --c2: #1f62c4;
  --c3: #1d1c1a;

  --easy: #3f8a54;
  --medium: #b0831f;
  --hard: #b23b31;

  /* app.js ekran boyutuna göre günceller */
  --tw: 48px;
  --ttw: 46px;
  --av: 52px;
  --th: calc(var(--tw) * 1.38);
  --tth: calc(var(--ttw) * 1.38);
  --gap: 3px;
  --ease: cubic-bezier(.2, .8, .3, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Bricolage", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--room);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}
input { user-select: text; -webkit-user-select: text; }
button { touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-weight: 750; letter-spacing: -0.02em; line-height: 1.08; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.code { font-weight: 750; letter-spacing: 0.08em; color: var(--accent); }
.lead { color: var(--ink-2); font-size: 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.screen { position: fixed; inset: 0; }

/* ---------- Kontroller ---------- */
input {
  font: inherit; font-size: 16px;
  padding: 12px 14px; border-radius: 10px; border: 0;
  background: var(--panel-3); color: var(--ink);
  outline: none; min-width: 0;
  transition: background .15s, box-shadow .15s;
}
input::placeholder { color: #8f846f; }
input:focus { background: #46392d; box-shadow: 0 0 0 2px var(--accent); }

.btn {
  font: inherit; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 0;
  background: var(--panel-3); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: transform .12s var(--ease), background .15s, color .15s, opacity .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: #4a3c2f; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #b77a1d; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #b77a1d; transform: translateY(2px); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.big { padding: 15px 26px; font-size: 18px; font-weight: 750; }
.btn.wide { width: 100%; }
.btn .ic { width: 18px; height: 18px; }

.icon-btn {
  position: relative; flex: none;
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip); color: var(--ink); cursor: pointer;
  transition: transform .12s var(--ease), background .15s;
}
.icon-btn:hover { background: rgba(6, 28, 19, .85); }
.icon-btn:active { transform: scale(.9); }

.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; width: 100%; }
.row .btn { flex: none; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.panel { background: var(--panel); border-radius: 18px; padding: clamp(20px, 3vw, 32px); }

/* Seviye seçici: kartlar (lobi) ve bölmeli düğme (bekleme odası) */
.level-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.level-cards button {
  font: inherit; text-align: left; color: var(--felt-ink); cursor: pointer;
  background: rgba(6, 28, 19, .45); border: 0; border-radius: 14px; padding: 14px 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: inset 0 0 0 2px transparent;
  transition: background .15s, box-shadow .15s, transform .15s var(--ease);
}
.level-cards button b { font-size: 20px; color: #fff; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.level-cards button b::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--lc); }
.level-cards button span { font-size: 14px; line-height: 1.35; }
.level-cards button:hover { background: rgba(6, 28, 19, .65); }
.level-cards button:active { transform: scale(.97); }
.level-cards button.on { background: rgba(6, 28, 19, .8); box-shadow: inset 0 0 0 3px var(--lc); }
[data-level="easy"] { --lc: var(--easy); }
[data-level="medium"] { --lc: var(--medium); }
[data-level="hard"] { --lc: var(--hard); }

.seg { display: inline-flex; background: var(--panel-3); border-radius: 12px; padding: 4px; gap: 4px; align-self: flex-start; }
.seg button {
  font: inherit; font-size: 15px; font-weight: 650; color: var(--ink-2); background: transparent;
  border: 0; border-radius: 9px; padding: 8px 16px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { color: #fff; background: var(--lc); }

.lvl {
  display: inline-block; font: inherit; font-size: 11px; font-weight: 750; line-height: 1.7;
  padding: 0 7px; border-radius: 6px; border: 0; color: #fff; vertical-align: middle; background: var(--lc);
}
button.lvl { cursor: pointer; transition: filter .15s, transform .1s; }
button.lvl:hover { filter: brightness(1.15); }
button.lvl:active { transform: scale(.94); }
.lvl-easy { --lc: var(--easy); }
.lvl-medium { --lc: var(--medium); }
.lvl-hard { --lc: var(--hard); }

.avatar {
  width: var(--av); height: var(--av); border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--av) * .42); color: var(--accent-ink);
  background: hsl(var(--hue, 35) 55% 74%);
}
.avatar.sm { --av: 30px; }
.avatar.bot { background: #2c3a33; color: #fff; box-shadow: inset 0 0 0 3px var(--lc, var(--ink-2)); }
.avatar.bot.l-easy { --lc: var(--easy); }
.avatar.bot.l-medium { --lc: var(--medium); }
.avatar.bot.l-hard { --lc: var(--hard); }
.avatar.empty { background: var(--panel-3); color: var(--ink-2); }

/* Üst çubuk */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-t)) max(16px, var(--safe-r)) 12px max(16px, var(--safe-l));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 18px; }
.brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .icon-btn { background: var(--panel-2); }
.me {
  font: inherit; color: var(--ink); background: var(--panel-2); border: 0; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 4px 14px 4px 4px; border-radius: 999px;
  max-width: 55vw; transition: background .15s;
}
.me:hover { background: var(--panel-3); }
#lobby-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 35px; border-radius: 4px;
  background: linear-gradient(var(--bone-hi), var(--bone));
  box-shadow: 0 2px 0 var(--bone-edge), 0 3px 0 var(--bone-edge-2);
  font-weight: 800; font-size: 18px; line-height: 1;
}
.mini-tile.c0 { color: var(--c0); } .mini-tile.c1 { color: var(--c1); }
.mini-tile.c2 { color: var(--c2); } .mini-tile.c3 { color: var(--c3); }

/* ---------- Giriş ---------- */
.screen-login {
  display: grid; place-items: center; overflow-y: auto; padding: 24px max(20px, var(--safe-r)) calc(24px + var(--safe-b)) max(20px, var(--safe-l));
  background: radial-gradient(120% 90% at 50% 20%, var(--felt-hi), var(--felt) 45%, var(--felt-lo));
}
.login { width: min(560px, 100%); display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.wordmark-big { display: flex; gap: clamp(8px, 2.4vw, 14px); margin-bottom: 18px; }
.wordmark-big .t {
  position: relative;
  width: clamp(58px, 17vw, 96px); height: clamp(80px, 23.5vw, 132px); border-radius: clamp(7px, 1.6vw, 10px);
  background: linear-gradient(var(--bone-hi), var(--bone) 70%);
  box-shadow: 0 6px 0 var(--bone-edge), 0 10px 0 var(--bone-edge-2), 0 16px 26px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 10% 0 13%;
  animation: deal .6s var(--spring) both;
}
.wordmark-big .t b { font-size: clamp(40px, 11.5vw, 66px); font-weight: 800; line-height: 1; }
.wordmark-big .t::after { content: ""; width: 15%; aspect-ratio: 1; border-radius: 50%; background: currentColor; }
.wordmark-big .t:nth-child(2) { animation-delay: .08s; }
.wordmark-big .t:nth-child(3) { animation-delay: .16s; }
.wordmark-big .t:nth-child(4) { animation-delay: .24s; }
.wordmark-big .c0 { color: var(--c0); } .wordmark-big .c1 { color: var(--c1); }
.wordmark-big .c2 { color: var(--c2); } .wordmark-big .c3 { color: var(--c3); }
@keyframes deal { from { opacity: 0; transform: translateY(-40px) rotate(-8deg) scale(.9); } to { opacity: 1; transform: none; } }
.login-title { font-size: clamp(32px, 7vw, 54px); max-width: 14ch; }
.login-lead { font-size: 17px; color: var(--felt-ink); max-width: 44ch; }
.login-form { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 10px; }
.login-form .field-label { color: var(--felt-ink); }
.name-row { display: flex; gap: 8px; }
.name-row input { flex: 1; font-size: 19px; font-weight: 650; padding: 15px 16px; background: rgba(6, 28, 19, .5); }
.name-row input:focus { background: rgba(6, 28, 19, .7); }
.icon-btn.dice { width: 56px; height: auto; border-radius: 10px; background: rgba(6, 28, 19, .5); }
.icon-btn.dice svg { width: 26px; height: 26px; }
.icon-btn.dice.roll svg { animation: roll .45s var(--ease); }
@keyframes roll { from { transform: rotate(-200deg) scale(.6); } to { transform: none; } }

/* ---------- Lobi ---------- */
.screen-lobby, .screen-room { overflow-y: auto; display: flex; flex-direction: column; }
.lobby {
  display: grid; gap: 16px; padding: 4px max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l));
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  grid-template-areas: "quick tables" "quick howto";
  width: min(1240px, 100%); margin: 0 auto; align-items: start;
}
.quick { grid-area: quick; background: radial-gradient(120% 100% at 30% 0%, var(--felt-hi), var(--felt) 55%, var(--felt-lo)); display: flex; flex-direction: column; gap: 18px; }
.quick h2 { font-size: clamp(30px, 4vw, 48px); max-width: 13ch; }
.quick .lead { color: var(--felt-ink); font-size: 17px; max-width: 46ch; }
.quick .level-cards { margin-top: 6px; }
.tables { grid-area: tables; display: flex; flex-direction: column; gap: 16px; }
.tables h2, .howto h2 { font-size: 26px; }
.sub-head { font-size: 16px; color: var(--ink-2); font-weight: 650; letter-spacing: 0; }
.tables-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-form { display: flex; flex-direction: column; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.room-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.room-empty { background: var(--panel-2); border-radius: 12px; padding: 16px 18px; color: var(--ink-2); font-size: 15px; }
.room-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--panel-2);
  animation: rise .3s var(--ease) both;
}
.room-item .rname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .rsub { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.seats-dots { display: flex; gap: 3px; }
.seat-dot { width: 9px; height: 12px; border-radius: 2px; background: var(--panel-3); }
.seat-dot.human { background: var(--accent); }
.seat-dot.bot { background: var(--ink-2); }
.tag.live { color: #f29286; }
.howto { grid-area: howto; display: flex; flex-direction: column; gap: 14px; }
.howto-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px; align-items: center; }
.howto-row p { color: var(--ink-2); font-size: 15px; }
.howto-row p b { color: var(--ink); }
.howto .tiles { display: flex; gap: 3px; }
.howto .lead { font-size: 15px; }

/* ---------- Bekleme ---------- */
.waiting {
  display: grid; gap: 16px; padding: 4px max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l));
  grid-template-columns: minmax(0, 1fr) 380px; width: min(1240px, 100%); margin: 0 auto; flex: 1; min-height: 0;
}
.wait-main { display: flex; flex-direction: column; gap: 20px; }
.wait-code {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: radial-gradient(120% 140% at 20% 0%, var(--felt-hi), var(--felt) 60%, var(--felt-lo)); border-radius: 14px; padding: 18px 22px;
}
.wait-code .field-label { color: var(--felt-ink); display: block; }
.big-code { font-size: clamp(36px, 6vw, 52px); letter-spacing: .16em; color: #fff; line-height: 1.1; }
.code-btns { display: flex; gap: 8px; }
.code-btns .btn { background: rgba(6, 28, 19, .5); }
.code-btns .btn:hover { background: rgba(6, 28, 19, .75); }
.wait-seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.wait-seat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 18px 10px; border-radius: 14px; background: var(--panel-2); min-height: 170px; --av: 56px;
  animation: rise .35s var(--ease) both; min-width: 0;
}
.wait-seat.me { box-shadow: inset 0 0 0 2px var(--accent); }
.wait-seat .nm { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-seat .sub { font-size: 13px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.wait-seat.empty { background: transparent; box-shadow: inset 0 0 0 2px var(--panel-3); }
.wait-host { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.wait-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wait-chat { display: flex; flex-direction: column; gap: 14px; min-height: 360px; }
.wait-chat h2 { font-size: 24px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Oyun ---------- */
.screen-game {
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  background:
    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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"),
    radial-gradient(110% 85% at 50% 42%, var(--felt-hi), var(--felt) 50%, var(--felt-lo));
  touch-action: none;
}
.table { position: relative; min-height: 0; }

.hud { position: absolute; top: calc(10px + var(--safe-t)); display: flex; align-items: center; gap: 8px; z-index: 6; }
.hud-left { left: max(10px, var(--safe-l)); }
.hud-right { right: max(10px, var(--safe-r)); }
.hud-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.hud-title b { font-size: 15px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-title span { font-size: 13px; color: var(--felt-ink); }
.hud .icon-btn svg { width: 21px; height: 21px; }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 10px; font-size: 12px; font-weight: 750;
  display: flex; align-items: center; justify-content: center; animation: pop .3s var(--spring);
}

/* Oyuncular */
.player {
  position: absolute; display: flex; align-items: center; gap: 10px; z-index: 4;
  padding: 5px 16px 5px 5px; border-radius: 999px; background: var(--chip);
  transition: background .25s, color .25s, box-shadow .25s;
  max-width: 46%;
}
.player.active { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px rgba(240, 172, 63, .28), 0 8px 24px rgba(0, 0, 0, .3); }
.player.active .pmeta { color: #4a3210; }
.av-wrap { position: relative; flex: none; width: var(--av); height: var(--av); }
.ring { position: absolute; inset: -5px; width: calc(var(--av) + 10px); height: calc(var(--av) + 10px); transform: rotate(-90deg); stroke-width: 3.5; pointer-events: none; }
.ring .track { stroke: rgba(35, 21, 5, .25); }
.ring .prog { stroke: #fff; transition: stroke .3s; }
.ring.low .prog { stroke: var(--danger); }
.player .pinfo { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.player .pname { font-weight: 750; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .pmeta { font-size: 13px; color: var(--felt-ink); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.player .pmeta .score { font-weight: 800; }
.player .dealer { font-size: 11px; font-weight: 750; background: rgba(255,255,255,.16); padding: 0 6px; border-radius: 6px; }
.player.active .dealer { background: rgba(35, 21, 5, .15); }
.p-top { top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); }
.p-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.p-left, .p-right { top: 50%; transform: translateY(-50%); flex-direction: column; padding: 10px 10px 12px; border-radius: 18px; text-align: center; gap: 8px; max-width: 130px; }
.p-left { left: max(10px, var(--safe-l)); }
.p-right { right: max(10px, var(--safe-r)); }
.p-left .pinfo, .p-right .pinfo { align-items: center; max-width: 100%; }
.p-left .pname, .p-right .pname { max-width: 100%; }
.p-left .pmeta, .p-right .pmeta { flex-wrap: wrap; justify-content: center; row-gap: 3px; white-space: normal; }
.offline { opacity: .55; }
.player:has(.bubble) { z-index: 25; }

/* Konuşma balonu */
.bubble {
  position: absolute; z-index: 20; width: max-content; max-width: min(220px, 60vw);
  background: var(--bone-hi); color: #2a2118; font-size: 14px; font-weight: 600; line-height: 1.3;
  padding: 8px 12px; border-radius: 14px; box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
  animation: bubble .35s var(--spring) both; pointer-events: none; white-space: normal; text-align: left;
}
.bubble.still { animation: none; }
.bubble.out { animation: bubble-out .3s ease forwards; }
.p-top .bubble { top: calc(100% + 10px); left: 50%; translate: -50% 0; }
.p-bottom .bubble { bottom: calc(100% + 10px); left: 50%; translate: -50% 0; }
.p-left .bubble { left: calc(100% + 10px); top: 10px; }
.p-right .bubble { right: calc(100% + 10px); top: 10px; }
@keyframes bubble { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }
@keyframes bubble-out { to { opacity: 0; scale: .8; } }

/* Atılan taşlar */
.discard {
  position: absolute; width: calc(var(--ttw) * 1.5); height: calc(var(--tth) * 1.3);
  border-radius: 12px; background: rgba(6, 28, 19, .28); box-shadow: inset 0 0 0 2px rgba(211, 232, 220, .12);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, box-shadow .15s, transform .15s var(--ease);
}
.discard .count {
  position: absolute; bottom: -9px; right: -9px; background: var(--chip); color: var(--felt-ink); border-radius: 8px;
  padding: 0 7px; font-size: 12px; font-weight: 700; z-index: 2;
}
.discard .under { position: absolute; transform: translate(5px, 4px) rotate(6deg); filter: brightness(.9); }
.discard.can-take { box-shadow: inset 0 0 0 3px var(--accent), 0 0 24px rgba(240, 172, 63, .45); cursor: grab; animation: glow 1.6s ease-in-out infinite; }
.discard.drop-ok { box-shadow: inset 0 0 0 3px var(--accent); background: rgba(240, 172, 63, .14); }
.discard.drop-hover { background: rgba(240, 172, 63, .32); transform: scale(1.06); }
.d-tl { left: 23%; top: 13%; }
.d-tr { right: 23%; top: 13%; }
.d-bl { left: 23%; bottom: 11%; }
.d-br { right: 23%; bottom: 11%; }

.table-mid {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px; width: max-content; max-width: 46%;
}
.center {
  display: flex; gap: clamp(12px, 2vw, 26px); align-items: flex-start; padding: 12px 18px; border-radius: 16px;
  transition: background .15s, box-shadow .15s;
}
.center.drop-ok { box-shadow: inset 0 0 0 3px var(--accent); background: rgba(240, 172, 63, .1); }
.center.drop-hover { background: rgba(240, 172, 63, .28); }
.indicator-wrap, .deck-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.label { font-size: 13px; color: var(--felt-ink); font-weight: 650; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.deck-wrap .label { width: 5.5em; text-align: center; white-space: nowrap; }
.deck {
  position: relative; width: calc(var(--ttw) * 1.06); height: calc(var(--tth) * 1.04); border-radius: 7px;
  background: linear-gradient(#e7dbbd, var(--bone-edge));
  box-shadow: 0 3px 0 var(--bone-edge-2), 0 6px 0 #c3b28a, 0 9px 0 var(--bone-edge-2), 0 14px 18px rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #6b5a31; font-size: calc(var(--ttw) * .4); cursor: default;
  transition: transform .15s var(--ease), box-shadow .2s;
}
.deck.can-take { cursor: grab; box-shadow: 0 3px 0 var(--bone-edge-2), 0 6px 0 #c3b28a, 0 9px 0 var(--bone-edge-2), 0 0 0 4px var(--accent), 0 0 30px 4px rgba(240, 172, 63, .55); animation: glow 1.6s ease-in-out infinite; }
.deck.can-take:hover { transform: translateY(-3px); }
.deck.can-finish { box-shadow: 0 3px 0 var(--bone-edge-2), 0 6px 0 #c3b28a, 0 9px 0 var(--bone-edge-2), 0 0 0 3px rgba(240, 172, 63, .45); }
@keyframes glow { 50% { filter: brightness(1.12); } }

.turn-info {
  text-align: center; line-height: 1.3; max-width: 100%;
  font-size: 15px; font-weight: 700; background: var(--chip); color: var(--felt-ink); padding: 8px 16px; border-radius: 999px;
}
.turn-info:empty { display: none; }
.turn-info.mine { background: var(--accent); color: var(--accent-ink); animation: pop .35s var(--spring); }
.turn-info .btn { margin-left: 6px; padding: 5px 12px; }

/* ---------- Taş ---------- */
.tile {
  --th: calc(var(--tw) * 1.38);
  width: var(--tw); height: var(--th); border-radius: calc(var(--tw) * .13);
  background: linear-gradient(170deg, var(--bone-hi), var(--bone) 75%);
  box-shadow: 0 2px 0 var(--bone-edge), 0 4px 0 var(--bone-edge-2), 0 5px 7px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: calc(var(--th) * .09);
  position: relative; cursor: grab; flex: none;
  transition: transform .14s var(--ease), box-shadow .14s;
}
.table .tile, .flyer { --tw: var(--ttw); }
.tile .num { font-size: calc(var(--tw) * .62); font-weight: 800; line-height: 1; letter-spacing: -0.05em; }
.tile .dot { width: calc(var(--tw) * .2); height: calc(var(--tw) * .2); border-radius: 50%; margin-top: calc(var(--th) * .1); }
.tile.c0 .num { color: var(--c0); } .tile.c0 .dot { background: var(--c0); }
.tile.c1 .num { color: var(--c1); } .tile.c1 .dot { background: var(--c1); }
.tile.c2 .num { color: var(--c2); } .tile.c2 .dot { background: var(--c2); }
.tile.c3 .num { color: var(--c3); } .tile.c3 .dot { background: var(--c3); }
.tile.fake .num { color: #2f8045; font-size: calc(var(--tw) * .72); }
.tile.fake .dot { background: transparent; }
.tile.okey .dot { visibility: hidden; }
.tile.okey::after {
  content: "OKEY"; position: absolute; bottom: calc(var(--th) * .07); font-size: calc(var(--tw) * .2); font-weight: 800;
  color: #fff; background: var(--c3); padding: 0 calc(var(--tw) * .08); border-radius: 3px; letter-spacing: .02em;
}
.tile.selected { transform: translateY(calc(var(--th) * -.18)); box-shadow: 0 2px 0 var(--bone-edge), 0 4px 0 var(--bone-edge-2), 0 0 0 3px var(--accent), 0 10px 14px rgba(0, 0, 0, .35); }
.tile.new { animation: newtile .7s var(--spring); }
.tile.sm { --tw: clamp(22px, 2.6vw, 34px); }
@keyframes newtile { 0% { transform: translateY(-30px) scale(1.1); box-shadow: 0 0 0 3px #8fd6a9; } 100% { transform: none; } }
.tile.back { background: linear-gradient(#e7dbbd, var(--bone-edge)); }

/* ---------- Istaka ---------- */
.rack-area {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 6px max(10px, var(--safe-r)) calc(10px + var(--safe-b)) max(10px, var(--safe-l));
}
.rack {
  position: relative; flex: none;
  display: grid; grid-template-columns: repeat(15, var(--tw)); grid-auto-rows: calc(var(--th) + var(--tw) * .2 + 4px);
  gap: 4px var(--gap); padding: calc(var(--tw) * .18) calc(var(--tw) * .22) 4px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) 0 3px, transparent 3px 11px, rgba(255, 255, 255, .03) 11px 13px, transparent 13px 23px),
    linear-gradient(#a2683a, #87532b 55%, #6e4220);
  border-radius: calc(var(--tw) * .22);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .16), 0 5px 0 #4c2c14, 0 12px 26px rgba(0, 0, 0, .45);
  transition: box-shadow .15s;
}
.rack.drop-ok { box-shadow: inset 0 2px 0 rgba(255, 255, 255, .16), 0 5px 0 #4c2c14, 0 0 0 3px var(--accent), 0 0 28px rgba(240, 172, 63, .4); }
.slot { width: var(--tw); height: 100%; position: relative; display: flex; align-items: flex-start; }
.slot::after {
  content: ""; position: absolute; left: calc(var(--gap) * -.5 - 1px); right: calc(var(--gap) * -.5 - 1px); bottom: 0; height: calc(var(--tw) * .2);
  background: linear-gradient(#6a3f1d, #55321a); box-shadow: 0 -1px 0 rgba(255, 255, 255, .12); z-index: 0;
}
.slot > * { position: relative; z-index: 1; }
.hole { width: var(--tw); height: var(--th); border-radius: calc(var(--tw) * .13); background: rgba(255, 236, 196, .25); box-shadow: inset 0 0 0 2px rgba(255, 228, 160, .9); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: none; width: 196px; }
.ctl { padding: 10px 8px; font-size: 14px; background: var(--chip); color: var(--ink); border-radius: 10px; }
.ctl:hover:not(:disabled) { background: rgba(6, 28, 19, .85); }
.ctl.primary { grid-column: span 2; }

/* Sürükleme */
.tile, #deck, .discard { touch-action: none; }
#rack .tile { cursor: grab; }
@media (hover: hover) { #rack .tile:not(.selected):hover { transform: translateY(-4px); } }
#rack .tile.taken { box-shadow: 0 2px 0 var(--bone-edge), 0 4px 0 var(--bone-edge-2), 0 0 0 2px #8fd6a9; }
.tile.pending { opacity: .8; box-shadow: 0 2px 0 var(--bone-edge), 0 0 0 2px #8fd6a9; }
.tile.ghost {
  position: fixed; left: 0; top: 0; pointer-events: none; z-index: 1000; margin: 0;
  box-shadow: 0 2px 0 var(--bone-edge), 0 4px 0 var(--bone-edge-2), 0 22px 30px rgba(0, 0, 0, .45); transition: none; will-change: transform;
}
.tile.lifted { opacity: .3; }
body.dragging, body.dragging * { cursor: grabbing !important; }
.tile.pop { animation: pop .4s var(--spring); }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: none; } }
.flyer { position: fixed; left: 0; top: 0; z-index: 900; pointer-events: none; margin: 0; will-change: transform; }
.discard[data-hint]::after, .deck.can-take::after {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100% + 8px); z-index: 3;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 750; padding: 2px 9px; border-radius: 8px; white-space: nowrap;
}
.discard[data-hint]::after { content: attr(data-hint); }
.discard.d-tl[data-hint]::after, .discard.d-tr[data-hint]::after { bottom: auto; top: calc(100% + 8px); }
.discard.can-take .tile.top { cursor: grab; }

/* ---------- Sohbet ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 10px; }
.chat-slot { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-log { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; user-select: text; -webkit-user-select: text; }
.chat-log .msg { background: var(--panel-2); padding: 7px 11px; border-radius: 12px; overflow-wrap: anywhere; font-size: 15px; align-self: flex-start; max-width: 92%; animation: rise .25s var(--ease) both; }
.chat-log .msg b { color: var(--accent); font-weight: 700; display: block; font-size: 12px; }
.chat-log .msg.bot b { color: #9fc7b2; }
.chat-log .msg.mine { align-self: flex-end; background: #4a3a22; }
.chat-log .msg.still { animation: none; }
.chat-log .chat-empty { color: var(--ink-2); font-size: 14px; }
.quick-msgs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none; padding-bottom: 2px; padding-right: 24px; mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.quick-msgs::-webkit-scrollbar { display: none; }
.quick-msgs button {
  font: inherit; font-size: 13px; font-weight: 650; color: var(--ink); background: var(--panel-3); border: 0;
  padding: 7px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; transition: background .15s, transform .1s;
}
.quick-msgs button:hover { background: #4a3c2f; }
.quick-msgs button:active { transform: scale(.94); }
.chat-form { display: flex; gap: 8px; flex: none; }
.chat-form input { flex: 1; }
.icon-btn.send, .drawer .icon-btn.send { background: var(--accent); color: var(--accent-ink); width: 46px; height: 46px; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 60;
  background: var(--panel); padding: calc(16px + var(--safe-t)) max(16px, var(--safe-r)) calc(16px + var(--safe-b)) 16px;
  display: flex; flex-direction: column; gap: 12px;
  transform: translateX(105%); transition: transform .3s var(--ease); box-shadow: -20px 0 50px rgba(0, 0, 0, .4);
  touch-action: auto;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 22px; }
.drawer .icon-btn { background: var(--panel-2); }

.rotate-hint {
  position: fixed; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 4px; background: rgba(6, 28, 19, .85); color: var(--felt-ink); font-size: 13px; font-weight: 650;
  padding: 3px 3px 3px 14px; border-radius: 999px; white-space: nowrap; animation: rise .4s var(--ease);
}
.rotate-hint .icon-btn { width: 28px; height: 28px; background: transparent; }
.rotate-hint svg { width: 16px; height: 16px; }

/* ---------- Sonuç ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 8, 6, .7); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 16px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }
.result-card {
  width: min(880px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--panel); border-radius: 20px; padding: clamp(20px, 4vw, 36px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55); animation: rise .4s var(--spring) both;
}
.result-card h2 { font-size: clamp(28px, 5vw, 44px); }
.result-card .lead { margin-top: 8px; font-size: 17px; }
.result-groups { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; padding: 18px; background: radial-gradient(120% 140% at 30% 0%, var(--felt-hi), var(--felt)); border-radius: 14px; align-items: center; }
.result-groups .grp { display: flex; gap: 3px; align-items: center; }
.result-groups .fin-label { color: var(--felt-ink); font-size: 14px; margin-right: 8px; font-weight: 650; }
.result-hands { display: flex; flex-direction: column; gap: 8px; margin: 0 0 22px; }
.result-hands h3 { font-size: 17px; color: var(--ink-2); margin-bottom: 4px; }
.result-hands .hand-row { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.result-hands .who { width: 110px; font-size: 14px; color: var(--ink-2); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.result-scores { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.result-scores div { padding: 10px 14px; background: var(--panel-2); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.result-scores div span { color: var(--ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-scores div b { font-size: 26px; font-weight: 800; }
.result-scores div.win { background: var(--accent); color: var(--accent-ink); }
.result-scores div.win span { color: #4a3210; }
.result-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.overlay.confirm { z-index: 80; }
.confirm-card { width: min(400px, 100%); background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); animation: rise .3s var(--spring) both; }
.confirm-card p { font-size: 17px; font-weight: 600; line-height: 1.4; }
.confirm-card .result-actions { margin-top: 18px; }

/* ---------- Bildirimler ---------- */
.toast {
  position: fixed; left: 50%; top: calc(12px + var(--safe-t)); transform: translate(-50%, -140px);
  background: var(--danger); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 2000;
  transition: transform .3s var(--spring); font-weight: 650; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: calc(100vw - 24px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast.info { background: #2c2a26; }
.conn-status { position: fixed; top: calc(10px + var(--safe-t)); right: 10px; z-index: 3000; background: var(--danger); padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 650; }

/* ---------- Duyarlı düzen ---------- */
@media (max-width: 1000px) {
  .lobby { grid-template-columns: minmax(0, 1fr); grid-template-areas: "quick" "tables" "howto"; }
  .waiting { grid-template-columns: minmax(0, 1fr); }
  .wait-chat { min-height: 320px; }
}
@media (max-width: 640px) {
  .level-cards { grid-template-columns: minmax(0, 1fr); }
  .level-cards button { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .level-cards button b { width: 76px; flex: none; font-size: 18px; }
  .tables-forms { grid-template-columns: minmax(0, 1fr); }
  .wait-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wait-seat { min-height: 140px; --av: 48px; }
  .wait-host { flex-direction: column; align-items: stretch; }
  .wait-actions .btn { flex: 1; }
  .howto-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .result-scores { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-hands .who { width: 100%; }
  .result-actions .btn { flex: 1; }
}

/* Telefon yatay ve kısa ekranlar */
body[data-layout="compact"] .hud-title { display: none; }
body[data-layout="compact"] .label { display: none; }
body[data-layout="compact"] .center { padding: 6px 10px; }
body[data-layout="compact"] .table-mid { gap: 6px; }
body[data-layout="compact"] .turn-info { font-size: 13px; padding: 5px 12px; }
body[data-layout="compact"] .player { padding: 3px 12px 3px 3px; gap: 8px; }
body[data-layout="compact"] .p-left, body[data-layout="compact"] .p-right { padding: 6px 6px 8px; gap: 4px; }
body[data-layout="compact"] .player .pname { font-size: 13px; }
body[data-layout="compact"] .player .pmeta { font-size: 12px; }
body[data-layout="compact"] .icon-btn { width: 36px; height: 36px; }
body[data-layout="compact"] .hud { top: 6px; }
body[data-layout="compact"] .p-top { top: 6px; }
body[data-layout="compact"] .p-bottom { bottom: 4px; }
body[data-layout="compact"] .controls { width: 150px; gap: 4px; }
body[data-layout="compact"] .ctl { padding: 7px 6px; font-size: 13px; }
body[data-layout="compact"] .rack-area { padding-top: 2px; padding-bottom: calc(6px + var(--safe-b)); }
body[data-layout="compact"] .d-tl, body[data-layout="compact"] .d-tr { top: 8%; }
body[data-layout="compact"] .d-bl, body[data-layout="compact"] .d-br { bottom: 8%; }

/* Telefon dikey */
body[data-layout="portrait"] .rack-area { flex-direction: column-reverse; gap: 8px; }
body[data-layout="portrait"] .controls { width: 100%; display: flex; gap: 5px; }
body[data-layout="portrait"] .ctl { flex: 1; padding: 9px 2px; font-size: 13px; }
body[data-layout="portrait"] .hud-title b { max-width: 130px; }
body[data-layout="portrait"] .p-top { top: calc(62px + var(--safe-t)); }
body[data-layout="portrait"] .p-left, body[data-layout="portrait"] .p-right { top: 27%; max-width: 108px; }
body[data-layout="portrait"] .d-tl { left: 5%; top: 46%; }
body[data-layout="portrait"] .d-tr { right: 5%; top: 46%; }
body[data-layout="portrait"] .d-bl { left: 5%; bottom: 13%; }
body[data-layout="portrait"] .d-br { right: 5%; bottom: 13%; }
body[data-layout="portrait"] .table-mid { top: 54%; max-width: 64%; }
body[data-layout="portrait"] .turn-info { font-size: 13px; }
body[data-layout="portrait"] .center { gap: 12px; padding: 8px 10px; }
body[data-layout="portrait"] .player .pname { font-size: 14px; }
body[data-layout="portrait"] .p-bottom { bottom: 6px; }

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

/* Kaydırma çubukları */
.chat-log, .room-list, .drawer, .result-card, .screen { scrollbar-width: thin; scrollbar-color: rgba(232, 199, 138, .45) transparent; }
.chat-log::-webkit-scrollbar, .room-list::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-track, .room-list::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb, .room-list::-webkit-scrollbar-thumb { background: rgba(232, 199, 138, .35); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.chat-log::-webkit-scrollbar-thumb:hover, .room-list::-webkit-scrollbar-thumb:hover { background-color: rgba(232, 199, 138, .6); }
.chat-log { padding-right: 4px; overscroll-behavior: contain; }
html { scrollbar-width: thin; scrollbar-color: rgba(232, 199, 138, .35) #15110d; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #15110d; }
::-webkit-scrollbar-thumb { background: rgba(232, 199, 138, .3); border-radius: 10px; border: 3px solid #15110d; }
::-webkit-scrollbar-thumb:hover { background: rgba(232, 199, 138, .55); }
