/* Kelime 101 — ceviz masa, yeşil çuha, fildişi taşlar
   Tek DOM, iki yerleşim: masaüstü (ızgara) ve yatay telefon (max-height: 540px). */

:root {
    --wood:        #24160d;
    --wood-2:      #2e1d11;
    --wood-3:      #33210f;
    --rim:         #4a2e1a;
    --rack:        #7a4a22;
    --rack-hi:     #9a6232;
    --rack-lo:     #4f2e14;
    --rack-ledge:  #5a3519;
    --felt:        #1e5b40;
    --felt-hi:     #2a7052;
    --felt-lo:     #174a34;
    --felt-line:   #3d7a5c;
    --ivory:       #f3ead6;
    --ivory-line:  #d9c9a3;
    --ivory-edge:  #b9a57a;
    --ink:         #1c1c1c;
    --joker:       #b02a20;
    --joker-bg:    #f6e3dc;
    --brass:       #d4a64a;
    --brass-lo:    #8f6a22;
    --gold:        #e8c77a;
    --valid:       #3fae74;
    --ok:          #6fd19c;
    --muted:       #c8b89a;
    --felt-text:   #cfe3d6;
    --dim:         #a8977a;
    --danger:      #e0675a;
    --grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 2px, transparent 2px 11px);
    --font-ui: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-tile: Rubik, "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
    background: var(--wood) var(--grain);
    color: var(--ivory);
    font-family: var(--font-ui);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
}
button { font: inherit; color: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── Düğmeler ─────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 48px; padding: 0 16px; border-radius: 14px; border: none;
    font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.btn:disabled { cursor: not-allowed; }
.btn-primary {
    background: var(--brass); color: var(--wood);
    font-family: var(--font-tile); font-weight: 700; font-size: 17px;
    box-shadow: 0 4px 0 var(--brass-lo);
}
.btn-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--brass-lo); }
.btn-primary:disabled { background: #6b5634; color: #2e2112; box-shadow: 0 4px 0 #4a3b22; }
.btn-lg { height: 56px; font-size: 20px; }
.btn-outline { background: transparent; border: 1.5px solid var(--rim); color: var(--ivory); }
.btn-outline:hover:not(:disabled) { background: rgba(255,255,255,0.04); }
.btn-outline:disabled { color: var(--dim); }
.btn-felt { background: rgba(0,0,0,0.22); border: 1px solid var(--felt-line); color: var(--ivory); }
.link-btn {
    background: none; border: none; padding: 6px; cursor: pointer;
    color: var(--ivory); font-size: 14px; font-weight: 500;
    text-decoration: underline; text-underline-offset: 3px;
}
.link-btn.small { font-size: 13px; color: var(--muted); }
.icon-btn {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--rim); border-radius: 10px; cursor: pointer;
}
.chip-btn {
    height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
    background: var(--wood-3); border: 1px solid var(--rim); font-size: 13px; font-weight: 500;
}

/* ── Taş ──────────────────────────────────────────────────── */
/* Boyut --tw ile verilir (genişlik); yükseklik 1.24 katı. */

.tile {
    --s: var(--tw, 52px);
    width: var(--s); height: calc(var(--s) * 1.24);
    position: relative; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--ivory); color: var(--ink);
    border: 1px solid var(--ivory-line); border-radius: calc(var(--s) * 0.15);
    box-shadow: 0 calc(var(--s) * 0.07) 0 var(--ivory-edge), 0 calc(var(--s) * 0.12) calc(var(--s) * 0.22) rgba(0,0,0,0.3);
    font-family: var(--font-tile);
}
.tile .l { font-weight: 800; font-size: calc(var(--s) * 0.58); line-height: 1; }
.tile .p {
    position: absolute; right: calc(var(--s) * 0.09); bottom: calc(var(--s) * 0.05);
    font-weight: 700; font-size: max(8px, calc(var(--s) * 0.21)); opacity: 0.75; line-height: 1;
}
.tile.joker { background: var(--joker-bg); color: var(--joker); }
.tile.valid {
    box-shadow: 0 0 0 calc(max(2px, var(--s) * 0.055)) var(--valid), 0 calc(var(--s) * 0.07) 0 var(--ivory-edge);
}
.tile.ring {
    box-shadow: 0 0 0 calc(max(2px, var(--s) * 0.06)) var(--brass), 0 calc(var(--s) * 0.07) 0 var(--ivory-edge), 0 8px 16px rgba(0,0,0,0.35);
}
.tile.from-discard { outline: 2px dashed #5aa0e0; outline-offset: 2px; }
.tile.staged { box-shadow: 0 0 0 calc(max(2px, var(--s) * 0.06)) var(--gold), 0 calc(var(--s) * 0.07) 0 var(--ivory-edge); transform: translateY(-4px); }
.tile .badge-n {
    position: absolute; top: -8px; left: -6px; min-width: 18px; height: 18px; padding: 0 4px;
    border-radius: 9px; background: var(--brass); color: var(--wood);
    font: 700 11px/18px var(--font-ui); text-align: center;
}
.tile.ghosted { opacity: 0.3; }

/* ── GİRİŞ EKRANI ─────────────────────────────────────────── */

/* İçerik sığmazsa üstten taşmasın, kaydırılsın: ortalama auto boşluklarla */
.start {
    position: fixed; inset: 0; overflow: auto;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 40px; padding: 32px 20px 16px;
}
.start-hero { margin-top: auto; }
.start-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.logo-rack {
    background: var(--rack); border-radius: 18px; padding: 18px 24px 8px;
    display: flex; flex-direction: column; gap: 14px;
    box-shadow: inset 0 2px 0 var(--rack-hi), 0 24px 50px rgba(0,0,0,0.5);
    border-bottom: 10px solid var(--rack-lo);
}
.logo-row {
    --tw: 76px;
    display: flex; gap: 8px; justify-content: center;
    padding-bottom: 10px; border-bottom: 7px solid var(--rack-ledge);
}
.logo-row.small { --tw: 60px; }
.logo-row .tile { box-shadow: 0 5px 0 var(--ivory-edge), 0 10px 18px rgba(0,0,0,0.35); }
.tagline { margin: 6px 0 0; font-size: 16px; color: var(--muted); }

.start-card {
    width: min(440px, 100%);
    background: var(--felt); border: 10px solid var(--rim); border-radius: 22px;
    padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 0 0 1px var(--felt-hi);
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: #d9ecdf; }
.field-hint  { font-size: 13px; color: var(--felt-text); min-height: 1.3em; }
.seg {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
    background: var(--felt-lo); padding: 4px; border-radius: 12px;
}
.seg button {
    height: 44px; border: none; border-radius: 9px; cursor: pointer;
    background: transparent; color: #d9ecdf; font-size: 15px; font-weight: 600;
}
.seg button[aria-checked="true"] { background: var(--ivory); color: var(--wood); box-shadow: 0 2px 0 var(--ivory-edge); }
.start-card .btn-outline { border-color: var(--felt-line); color: var(--felt-text); }
.soon {
    font-size: 12px; font-weight: 600; background: var(--felt-lo); color: var(--gold);
    padding: 3px 8px; border-radius: 999px;
}
.start-card .link-btn { align-self: center; }
.start-foot { margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--dim); text-align: center; }

@media (max-height: 820px) and (min-height: 541px) {
    .start { gap: 22px; padding-top: 20px; }
    .start-hero { gap: 8px; }
    .logo-rack { padding: 12px 18px 6px; gap: 10px; border-bottom-width: 8px; }
    .logo-row { --tw: 52px; gap: 6px; padding-bottom: 7px; border-bottom-width: 5px; }
    .logo-row.small { --tw: 42px; }
    .start-card { padding: 20px 24px 16px; gap: 14px; }
}
@media (max-width: 520px) {
    .start { gap: 32px; padding-top: 40px; }
    .logo-rack { padding: 12px 14px 6px; gap: 10px; border-radius: 14px; border-bottom-width: 7px; }
    .logo-row { --tw: 46px; gap: 5px; padding-bottom: 7px; border-bottom-width: 5px; }
    .logo-row.small { --tw: 40px; }
    .start-card { border-width: 8px; padding: 22px 18px 18px; gap: 16px; }
}
@media (max-height: 540px) and (orientation: landscape) {
    .start { flex-direction: row; align-items: safe center; justify-content: safe center; gap: 36px; padding: 12px 24px; }
    .start-hero { gap: 8px; margin-top: 0; }
    .logo-rack { padding: 10px 14px 5px; gap: 8px; border-radius: 14px; border-bottom-width: 7px; }
    .logo-row { --tw: 44px; gap: 5px; padding-bottom: 6px; border-bottom-width: 5px; }
    .logo-row.small { --tw: 36px; }
    .tagline { font-size: 14px; }
    .start-card { width: 340px; flex-shrink: 0; border-width: 7px; padding: 12px 16px; gap: 10px; }
    .seg button { height: 38px; }
    .field { gap: 6px; }
    .btn-lg { height: 46px; font-size: 18px; }
    .start-card .btn-outline { height: 38px; }
    .start-card .link-btn { padding: 2px; }
    .start-foot { display: none; }
}
@media (max-height: 540px) and (orientation: landscape) and (max-width: 760px) {
    .start { gap: 20px; padding: 8px 16px; }
    .logo-row { --tw: 36px; gap: 4px; }
    .logo-row.small { --tw: 30px; }
    .start-card { width: 300px; padding: 10px 14px; gap: 8px; }
    .seg button { height: 34px; font-size: 14px; }
    .field-hint { display: none; }
    .btn-lg { height: 42px; }
    .start-card .btn-outline { height: 34px; }
}

/* ── OYUN: masaüstü ızgarası ──────────────────────────────── */

.game {
    position: fixed; inset: 0;
    padding: 14px 24px 18px;
    display: grid; gap: 12px 16px;
    grid-template-columns: 250px minmax(0, 1fr) 220px;
    grid-template-rows: 48px auto minmax(0, 1fr) auto auto;
    grid-template-areas:
        "head   head  head"
        ".      top   ."
        "left   board right"
        ".      pool  drop"
        "status rack  actions";
}
.felt {
    grid-row: 2 / 5; grid-column: 1 / -1;
    background: var(--felt); border: 12px solid var(--rim); border-radius: 30px;
    box-shadow: inset 0 0 0 1px var(--felt-hi), inset 0 0 80px rgba(0,0,0,0.35), 0 18px 40px rgba(0,0,0,0.4);
}

/* Üst çubuk */
.topbar { grid-area: head; display: flex; align-items: center; gap: 16px; padding-right: 230px; min-width: 0; }
.brand {
    display: flex; align-items: center; gap: 10px; background: none; border: none; padding: 0; cursor: pointer;
    font-family: var(--font-tile); font-weight: 700; font-size: 20px;
}
.brand-tile {
    width: 30px; height: 36px; background: var(--ivory); border-radius: 6px; box-shadow: 0 3px 0 var(--ivory-edge);
    display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink);
}
.badge { font-size: 13px; color: var(--muted); background: var(--wood-3); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.ticker { flex: 1; display: flex; justify-content: center; min-width: 0; }
.ticker-pill {
    display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
    background: var(--wood-3); border: 1px solid var(--rim); border-radius: 999px;
    padding: 7px 16px 7px 8px; font-size: 14px; color: var(--muted);
    white-space: nowrap; overflow: hidden;
}
.ticker-pill b { color: var(--ivory); font-weight: 600; }
.ticker-pill .dot { color: #6e5a44; }
.ticker-pill > span { overflow: hidden; text-overflow: ellipsis; }

.menu-btn { display: none; grid-area: menu; }
.tools { grid-area: head; justify-self: end; align-self: center; display: flex; gap: 8px; }
.tool-btn {
    height: 40px; padding: 0 14px; display: flex; align-items: center; gap: 8px;
    background: transparent; border: 1px solid var(--rim); border-radius: 10px; cursor: pointer;
    font-size: 14px; font-weight: 500;
}

/* Oturanlar */
.seats { display: contents; }
.seat { display: flex; align-items: center; gap: 12px; --tw: 44px; z-index: 1; }
.seat[data-pos="top"]   { grid-area: top;   justify-self: center; margin-top: 18px; }
.seat[data-pos="left"]  { grid-area: left;  justify-self: start; align-self: center; margin-left: 34px; }
.seat[data-pos="right"] { grid-area: right; justify-self: end;   align-self: center; margin-right: 34px; }
.seat[data-pos="left"], .seat[data-pos="right"] { flex-direction: column; gap: 8px; width: 130px; text-align: center; }
.avatar {
    width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: var(--ivory);
    border: 3px solid var(--felt-lo); transition: box-shadow .25s;
}
.seat.active .avatar { box-shadow: 0 0 0 3px var(--brass), 0 0 18px rgba(212,166,74,0.6); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--brass), 0 0 6px rgba(212,166,74,0.3); } }
.seat-texts { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.seat-name { font-weight: 600; font-size: 15px; }
.seat-info { font-size: 13px; color: var(--felt-text); }
.seat-info .opened { color: var(--gold); font-weight: 600; }
.seat-info .neg { color: #f0a090; }
.seat-discard { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.seat[data-pos="left"] .seat-discard, .seat[data-pos="right"] .seat-discard { margin-top: 6px; }
.seat-discard .empty-slot {
    width: var(--tw); height: calc(var(--tw) * 1.24); border-radius: 8px;
    border: 1px dashed rgba(255,255,255,0.18); background: rgba(0,0,0,0.1);
}
.seat-discard .tile.takeable { cursor: pointer; }
.seat-discard .tile.takeable:hover { transform: translateY(-2px); }
.take-label { font-size: 12px; font-weight: 600; color: var(--gold); }

/* Masa (açılan kelimeler) */
.board {
    grid-area: board; --tw: 38px; position: relative; z-index: 1;
    display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
    gap: 18px 22px; padding: 8px; overflow: auto; min-height: 0;
    scrollbar-width: thin; scrollbar-color: var(--felt-line) transparent;
}
.board-empty { color: rgba(207,227,214,0.55); font-size: 14px; align-self: center; text-align: center; }
.bw { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; border-radius: 12px; transition: background .15s; }
.bw-owner { font-size: 12px; font-weight: 600; color: var(--felt-text); }
.bw-tiles { display: flex; gap: 3px; }
.bw.can-extend { cursor: pointer; }
.bw.can-extend:hover { background: rgba(0,0,0,0.14); }
.bw.selected { background: rgba(0,0,0,0.26); box-shadow: 0 0 0 2px var(--brass); }
.bw.fresh .tile { animation: fresh 1.4s ease-out; }
@keyframes fresh { 0% { box-shadow: 0 0 0 4px var(--gold), 0 0 20px var(--gold); } }
.bw .tile.stealable { cursor: pointer; box-shadow: 0 0 0 3px var(--gold), 0 3px 0 var(--ivory-edge); }
.bw-ext { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.bw-ext .preview { display: flex; gap: 2px; --tw: 24px; }
.ext-btn {
    height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--felt-line);
    background: rgba(0,0,0,0.25); color: var(--felt-text); font-size: 13px; font-weight: 600; cursor: not-allowed;
}
.ext-btn.ok { background: var(--brass); border-color: var(--brass); color: var(--wood); cursor: pointer; box-shadow: 0 2px 0 var(--brass-lo); }
.ext-btn b { font-family: var(--font-tile); letter-spacing: 0.5px; }

/* Havuz */
.pool {
    grid-area: pool; justify-self: center; align-self: end; margin-bottom: 30px; z-index: 1;
    display: flex; align-items: center; gap: 14px;
    background: none; border: none; padding: 4px 8px; border-radius: 14px; cursor: default;
}
.pool-stack { position: relative; width: 58px; height: 64px; }
.pool-stack i {
    position: absolute; width: 46px; height: 58px; border-radius: 8px; border: 1px solid var(--ivory-edge);
}
.pool-stack i:nth-child(1) { left: 8px; top: 0; background: #d8c7a0; }
.pool-stack i:nth-child(2) { left: 4px; top: 3px; background: #e3d4b0; }
.pool-stack i:nth-child(3) { left: 0; top: 6px; background: #ece0c4; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.pool-stack i:nth-child(3)::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 34px; transform: translate(-50%, -50%);
    border: 2px solid #c9b388; border-radius: 5px;
}
.pool-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.pool-text strong { font-family: var(--font-tile); font-weight: 700; font-size: 22px; }
.pool-text span { font-size: 12px; color: var(--felt-text); }
.pool.can-draw { cursor: pointer; }
.pool.can-draw .pool-stack i:nth-child(3) { box-shadow: 0 0 0 3px var(--brass), 0 4px 14px rgba(0,0,0,0.35); animation: pulse-tile 1.6s ease-in-out infinite; }
.pool.can-draw .pool-text span { color: var(--gold); font-weight: 600; }
@keyframes pulse-tile { 50% { box-shadow: 0 0 0 3px rgba(212,166,74,0.45), 0 4px 10px rgba(0,0,0,0.3); } }

/* Atma yeri */
.drop {
    grid-area: drop; justify-self: end; align-self: end; margin: 0 38px 28px 0; z-index: 1;
    display: flex; align-items: center; gap: 12px;
}
.drop-label { font-size: 13px; color: var(--felt-text); text-align: right; line-height: 1.35; }
.drop-label-short { display: none; font-size: 11px; color: var(--felt-text); }
.drop-box {
    --tw: 40px;
    width: 52px; height: 64px; border: 2px dashed #8fc4a7; border-radius: 9px; background: rgba(0,0,0,0.12);
    display: flex; align-items: center; justify-content: center; transition: transform .12s, background .12s;
}
.drop-box .tile { opacity: 0.55; box-shadow: none; }
.drop.armed .drop-box { border-color: var(--brass); background: rgba(212,166,74,0.14); }
.drop.armed .drop-label { color: var(--gold); }
.drop.hot .drop-box { transform: scale(1.12); background: rgba(212,166,74,0.3); }

/* Durum kartı */
.status {
    grid-area: status; min-width: 0;
    background: var(--wood-2); border: 1px solid var(--rim); border-radius: 16px;
    padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.status.mine { border-color: var(--brass); }
.st-turn { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ring { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: var(--rim); }
.ring-fg { stroke: var(--brass); stroke-linecap: round; stroke-dasharray: 150.8; transition: stroke-dashoffset 1s linear, stroke .3s; }
.ring-fg.warn { stroke: #e0a040; }
.ring-fg.low  { stroke: var(--danger); }
.ring span {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-tile); font-weight: 700; font-size: 14px;
}
.st-texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-title { font-family: var(--font-tile); font-weight: 700; font-size: 17px; color: var(--gold); }
.st-title.wait { color: var(--ivory); }
.st-sub { font-size: 13px; color: var(--muted); line-height: 1.35; }
.st-sep { height: 1px; background: var(--rim); }
.st-open { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.st-open-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.st-open-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.st-open-num { font-family: var(--font-tile); font-weight: 800; font-size: 24px; color: var(--ivory); }
.st-open-num small { font-size: 15px; color: var(--muted); font-weight: 600; }
.st-open-num.ready { color: var(--ok); }
.st-bar { height: 8px; background: var(--rim); border-radius: 4px; overflow: hidden; }
.st-bar div { height: 100%; width: 0; background: var(--brass); border-radius: 4px; transition: width .3s; }
.st-bar div.ready { background: var(--ok); }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 64px; overflow: hidden; }
.st-chips span { font-size: 13px; font-weight: 600; background: var(--felt); padding: 4px 8px; border-radius: 7px; }
.st-chips span small { color: var(--felt-text); font-weight: 500; font-size: 13px; }
.st-chips .none { background: none; padding: 0; color: var(--dim); font-weight: 400; }

/* Istaka */
.rack-wrap { grid-area: rack; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rack-bar { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.rack-bar #rack-info { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; }
.rack-bar #rack-info .neg { color: #f0a090; font-weight: 600; }
.rack {
    --tw: 50px; --gap: 4px;
    background: var(--rack); border-radius: 16px; padding: 12px 14px 4px;
    display: flex; flex-direction: column; gap: 6px;
    box-shadow: inset 0 2px 0 var(--rack-hi), 0 10px 24px rgba(0,0,0,0.45);
    border-bottom: 8px solid var(--rack-lo);
}
.rack-row { display: flex; gap: var(--gap); justify-content: center; padding-bottom: 8px; border-bottom: 5px solid var(--rack-ledge); }
.slot { position: relative; width: var(--tw); height: calc(var(--tw) * 1.24); flex-shrink: 0; touch-action: none; }
.slot.empty { border-radius: calc(var(--tw) * 0.14); background: rgba(0,0,0,0.14); border: 1px dashed rgba(0,0,0,0.25); }
.slot.hover.empty { background: rgba(212,166,74,0.25); border-color: var(--brass); }
.slot.hover .tile { transform: translateY(-3px); }
.slot .tile { cursor: grab; touch-action: none; }
.slot .lift {
    position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 20;
    pointer-events: none;
}
.slot .lift .tile { --s: calc(var(--tw) * 1.5); box-shadow: 0 0 0 3px var(--brass), 0 14px 28px rgba(0,0,0,0.55); }

/* Eylemler */
.actions { grid-area: actions; display: flex; flex-direction: column; gap: 10px; padding-top: 38px; min-width: 0; }
.open-btn { height: 64px; flex-direction: column; gap: 2px; }
.open-main { font-size: 20px; }
.open-sub { font-family: var(--font-ui); font-size: 12px; font-weight: 600; opacity: 0.8; }
.sort-phone { display: none; }
.hint { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.45; }

/* Bildirim */
.toast {
    grid-area: board; justify-self: center; align-self: start; z-index: 30; margin-top: 4px;
    max-width: min(560px, 90%); padding: 10px 16px; border-radius: 12px;
    background: rgba(20,12,6,0.92); border: 1px solid var(--rim); color: var(--ivory);
    font-size: 14px; line-height: 1.4; text-align: center; box-shadow: 0 10px 24px rgba(0,0,0,0.4);
    pointer-events: none; opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error   { border-color: var(--danger); }
.toast.success { border-color: var(--valid); }

.rotate { display: none; }

/* Sürüklenen taş */
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; will-change: transform; }
.drag-ghost .tile { box-shadow: 0 0 0 3px var(--brass), 0 16px 30px rgba(0,0,0,0.55); }

/* ── Hamle geçmişi çekmecesi ──────────────────────────────── */

.drawer-back { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 20000; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 88vw); z-index: 20001;
    background: var(--wood-2) var(--grain); border-left: 1px solid var(--rim);
    display: flex; flex-direction: column; box-shadow: -20px 0 40px rgba(0,0,0,0.4);
}
.drawer-head {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--rim); font-family: var(--font-tile); font-weight: 700; font-size: 17px;
}
.move-log { flex: 1; overflow-y: auto; padding: 8px 10px 16px; -webkit-user-select: text; user-select: text; }
.log-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 6px; border-bottom: 1px solid rgba(74,46,26,0.6); font-size: 13px; line-height: 1.4; }
.log-row .av { width: 24px; height: 24px; font-size: 10px; border-width: 0; flex-shrink: 0; }
.log-row .who { font-weight: 600; margin-right: 4px; }
.log-row .what { color: var(--muted); }
.log-empty { padding: 20px 8px; color: var(--dim); font-size: 13px; }

/* ── Pencereler ───────────────────────────────────────────── */

.modal {
    position: fixed; inset: 0; z-index: 30000; background: rgba(10,6,3,0.7);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
    width: min(480px, 100%); max-height: calc(100dvh - 32px);
    background: var(--felt); border: 10px solid var(--rim); border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5), inset 0 0 0 1px var(--felt-hi);
    padding: 22px; display: flex; flex-direction: column; gap: 14px;
}
.modal-title { font-family: var(--font-tile); font-weight: 700; font-size: 22px; text-align: center; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; }

.joker-letters { --tw: 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 10px 6px; justify-items: center; }
.joker-letters .tile { cursor: pointer; border-style: solid; }
.joker-letters .tile:hover { transform: translateY(-2px); }
.joker-letters button { padding: 0; background: none; border: none; cursor: pointer; }

.how-to-box { width: min(620px, 100%); background: var(--wood-2) var(--grain); }
.how-to-content { overflow-y: auto; padding-right: 6px; font-size: 14px; line-height: 1.55; color: #e9dfc8; -webkit-user-select: text; user-select: text; }
.how-to-content h3 { font-family: var(--font-tile); color: var(--gold); font-size: 15px; margin: 16px 0 4px; }
.how-to-content h3:first-child { margin-top: 0; }
.how-to-content p { margin: 0 0 6px; }
.how-to-content ol, .how-to-content ul { margin: 0 0 6px; padding-left: 20px; }
.how-to-content li { margin-bottom: 4px; }
.how-to-content strong { color: var(--ivory); }

.gameover-box { width: min(560px, 100%); }
.go-sub { text-align: center; font-size: 13px; color: var(--felt-text); margin-top: -8px; }
.go-rows { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.go-row {
    display: grid; grid-template-columns: 22px 40px minmax(0, 1fr) auto; gap: 10px; align-items: center;
    background: rgba(0,0,0,0.18); border-radius: 12px; padding: 8px 12px;
}
.go-row.win { background: rgba(212,166,74,0.2); box-shadow: inset 0 0 0 1px var(--brass); }
.go-rank { font-family: var(--font-tile); font-weight: 700; color: var(--felt-text); }
.go-row .avatar { width: 40px; height: 40px; font-size: 13px; border-width: 2px; }
.go-mid { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.go-name { font-weight: 600; }
.go-why { font-size: 12px; color: var(--felt-text); }
.go-left { display: flex; flex-wrap: wrap; gap: 2px; --tw: 18px; }
.go-left .tile { box-shadow: 0 1px 0 var(--ivory-edge); }
.go-left .tile .p { display: none; }
.go-scores { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.15; }
.go-hand { font-size: 11px; color: var(--felt-text); white-space: nowrap; }
.go-score { font-family: var(--font-tile); font-weight: 800; font-size: 22px; }
.go-score.pos { color: var(--ok); }
.go-score.neg { color: #f0a090; }

/* ── Orta genişlik (küçük dizüstü, yatay tablet) ──────────── */

@media (max-width: 1180px) {
    .game {
        padding: 10px 14px 12px; gap: 10px 12px;
        grid-template-columns: 170px minmax(0, 1fr) 190px;
        grid-template-rows: 44px auto minmax(0, 1fr) auto auto auto;
        grid-template-areas:
            "head   head   head"
            ".      top    ."
            "left   board  right"
            ".      pool   drop"
            "rack   rack   rack"
            "status status actions";
    }
    .seat[data-pos="left"], .seat[data-pos="right"] { width: 112px; }
    .seat[data-pos="left"]  { margin-left: 24px; }
    .seat[data-pos="right"] { margin-right: 24px; }
    .status { flex-direction: row; align-items: center; padding: 10px 14px; gap: 16px; }
    .st-sep { width: 1px; height: 40px; }
    .st-turn { flex: 0 1 260px; }
    .st-open { flex: 1; }
    .st-chips { max-height: 28px; }
    .actions { padding-top: 0; }
    .open-btn { height: 56px; }
    .hint { display: none; }
    .tool-label { display: none; }
    .tool-btn { width: 40px; padding: 0; justify-content: center; }
    .topbar { padding-right: 150px; }
}

/* ── Yatay telefon ────────────────────────────────────────── */

@media (max-height: 540px) and (orientation: landscape) {
    .game {
        padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        gap: 0 8px;
        grid-template-columns: auto minmax(0, 1fr) auto auto auto;
        grid-template-rows: 44px minmax(0, 1fr) 50px auto;
        grid-template-areas:
            "menu   seats seats seats   tools"
            "board  board board board   board"
            "status pool  drop  actions actions"
            "rack   rack  rack  rack    rack";
    }
    .felt { grid-row: 1 / 4; border-width: 6px; border-radius: 18px; box-shadow: inset 0 0 0 1px var(--felt-hi), inset 0 0 40px rgba(0,0,0,0.3); }
    .topbar { display: none; }
    .menu-btn { display: inline-flex; margin: 8px 0 0 10px; width: 34px; height: 34px; border: none; }
    .tools { grid-area: tools; margin: 8px 10px 0 0; gap: 2px; }
    .tools .icon-btn, .tool-btn { width: 34px; height: 34px; border: none; padding: 0; justify-content: center; }
    .tool-label { display: none; }

    .seats { display: flex; grid-area: seats; align-items: center; justify-content: space-around; margin-top: 8px; min-width: 0; }
    .seat, .seat[data-pos="left"], .seat[data-pos="right"], .seat[data-pos="top"] {
        flex-direction: row; width: auto; margin: 0; gap: 7px; text-align: left; --tw: 24px; min-width: 0;
    }
    .seat .avatar { width: 26px; height: 26px; font-size: 10px; border-width: 0; }
    .seat-name { font-size: 12px; }
    .seat-info { font-size: 11px; white-space: nowrap; }
    .seat-discard, .seat[data-pos="left"] .seat-discard, .seat[data-pos="right"] .seat-discard { margin: 0; flex-direction: row; gap: 4px; }
    .seat-discard .empty-slot { border-radius: 5px; }
    .take-label { font-size: 10px; }

    .board { --tw: 22px; gap: 6px 14px; padding: 2px 14px; }
    .bw { gap: 2px; padding: 3px 5px; border-radius: 8px; }
    .bw-owner { font-size: 10px; }
    .bw-tiles { gap: 2px; }
    .bw-ext .preview { --tw: 18px; }
    .ext-btn { height: 30px; font-size: 12px; padding: 0 9px; }

    .pool { margin: 0 0 8px; padding: 0 12px 0 8px; height: 40px; gap: 10px; background: rgba(0,0,0,0.22); border-radius: 10px; align-self: end; }
    .pool-stack { width: 26px; height: 32px; }
    .pool-stack i { width: 22px; height: 28px; border-radius: 5px; }
    .pool-stack i:nth-child(1) { left: 4px; top: 0; }
    .pool-stack i:nth-child(2) { left: 2px; top: 2px; }
    .pool-stack i:nth-child(3) { left: 0; top: 4px; }
    .pool-stack i:nth-child(3)::after { display: none; }
    .pool-text { flex-direction: row; align-items: baseline; gap: 4px; }
    .pool-text strong { font-family: var(--font-ui); font-size: 13px; }
    .pool-text span { font-size: 12px; }

    .drop { margin: 0 0 8px; gap: 6px; align-self: end; }
    .drop-label { display: none; }
    .drop-label-short { display: inline; }
    .drop-box { --tw: 24px; width: 32px; height: 40px; border-radius: 6px; }

    .status {
        flex-direction: row; align-items: center; gap: 8px; align-self: end;
        margin: 0 0 8px 14px; padding: 4px 10px 4px 5px; height: 40px;
        background: rgba(0,0,0,0.22); border: none; border-radius: 10px;
    }
    .status.mine { box-shadow: inset 0 0 0 1.5px var(--brass); }
    .ring { width: 30px; height: 30px; }
    .ring circle { stroke-width: 6; }
    .ring span { font-size: 8px; font-family: var(--font-ui); }
    .st-title { font-size: 13px; white-space: nowrap; }
    .st-sub, .st-bar, .st-chips { display: none; }
    .st-sep { width: 1px; height: 20px; background: rgba(255,255,255,0.15); }
    .st-open { flex-direction: row; }
    .st-open-head { gap: 6px; }
    .st-open-label { font-size: 12px; font-weight: 400; color: var(--felt-text); white-space: nowrap; }
    .st-open-num { font-size: 16px; white-space: nowrap; }
    .st-open-num small { font-size: 11px; }

    .actions { flex-direction: row; align-items: center; justify-content: flex-end; gap: 6px; padding: 0; margin: 0 14px 8px 0; align-self: end; }
    .actions .btn { height: 40px; border-radius: 10px; font-size: 12px; padding: 0 12px; }
    .open-btn { flex-direction: row; padding: 0 18px !important; }
    .open-main { font-size: 16px; }
    .open-sub { display: none; }
    .second-btn { display: none; }
    .second-btn.urgent { display: inline-flex; }
    .sort-phone { display: inline-flex; }
    #reset-jokers-btn, .hint { display: none; }

    .rack-wrap { margin-top: 6px; gap: 0; }
    .rack-bar { display: none; }
    .rack { --gap: 3px; padding: 6px 6px 4px; gap: 5px; border-radius: 12px; border-bottom-width: 5px; box-shadow: inset 0 2px 0 var(--rack-hi), 0 6px 14px rgba(0,0,0,0.45); }
    .rack-row { padding-bottom: 4px; border-bottom-width: 3px; }

    .toast { font-size: 13px; padding: 8px 12px; margin-top: 2px; }
    .modal-box { border-width: 6px; padding: 14px 16px; gap: 10px; }
    .gameover-box { width: min(760px, 100%); }
    .go-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
    .go-row { padding: 6px 10px; gap: 8px; grid-template-columns: 16px 30px minmax(0, 1fr) auto; }
    .go-row .avatar { width: 30px; height: 30px; font-size: 10px; }
    .go-left { --tw: 14px; }
    .go-score { font-size: 18px; }
    .go-sub { margin-top: -6px; }
    .modal-title { font-size: 18px; }
    .joker-letters { --tw: 34px; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px 4px; }
}

/* Küçük yatay telefon: yazıları kıs, sadece sayılar kalsın */
@media (max-height: 540px) and (orientation: landscape) and (max-width: 760px) {
    .seat-name { display: none; }
    .seats { justify-content: space-evenly; }
    .st-texts, .st-open-label { display: none; }
    .status { margin-left: 12px; padding-right: 8px; }
    .pool { padding: 0 8px 0 6px; gap: 6px; }
    #pool-label { display: none; }
    .drop-label-short { display: none; }
    .actions { margin-right: 12px; }
    .actions .btn { padding: 0 10px; }
    .open-btn { padding: 0 12px !important; }
}

/* Dik telefon: oyun ekranında yan çevir uyarısı */
@media (orientation: portrait) and (max-width: 600px) {
    .rotate {
        display: flex; position: fixed; inset: 0; z-index: 25000;
        flex-direction: column; align-items: center; justify-content: center; gap: 16px;
        background: var(--wood) var(--grain); color: var(--ivory); text-align: center; padding: 24px;
    }
    .rotate p { font-family: var(--font-tile); font-size: 18px; font-weight: 700; margin: 0; }
    .rotate svg { animation: tilt 2.4s ease-in-out infinite; }
    @keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
