/* Snug Table Mexican Train: açık sayfa, yeşil çuha masa, trenler satır satır, renkli sayılı taşlar */
:root { --bg: #f6f1e7; --card: #fffdf8; --text: #1d140c; --muted: #6b5a45; --line: rgba(29, 20, 12, .12); --green: #1f8f42; --cw: 76px; --step: 40px; --tw: 64px; color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
a { color: #1f5fb3; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 12px 28px; }
.wrap > .site-bar { padding-left: 4px; padding-right: 4px; }

/* Üst çubuk */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 12px 4px 10px; }
.title h1 { margin: 0; font-size: 28px; line-height: 1.1; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.tool { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(29, 20, 12, .2); background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.tool:hover:not(:disabled) { background: #f1ebdf; }
.tool:disabled { opacity: .45; cursor: default; }
.tool.busy { opacity: .6; cursor: progress; }
.tool-green { background: var(--green); border-color: var(--green); color: #fff; }
.tool-green:hover:not(:disabled) { background: #23a04b; }

/* Masa: üstte kuzey, ortada batı - el - doğu, altta sen */
.felt { position: relative; display: grid; grid-template-columns: minmax(70px, 1fr) minmax(0, 2.2fr) minmax(70px, 1fr); grid-template-rows: auto auto minmax(200px, 1fr) auto;
  grid-template-areas: "n-seat n-seat n-seat" ". n-opp ." "w trick e" "s s s"; gap: 6px; padding: 10px 10px 8px; border-radius: 18px;
  background: radial-gradient(ellipse 80% 70% at 50% 40%, #2c8a5a 0%, #1f6a44 55%, #154a30 100%); box-shadow: inset 0 0 70px rgba(0, 0, 0, .35), 0 8px 24px rgba(40, 25, 10, .18); }
.seat-n { grid-area: n-seat; justify-self: center; }
.opp-n { grid-area: n-opp; justify-self: center; }
.seat-w, .opp-w { grid-area: w; }
.seat-e, .opp-e { grid-area: e; }
.seat-w, .seat-e { align-self: start; justify-self: center; z-index: 2; }
.opp-w, .opp-e { align-self: center; justify-self: center; }
.seat-s { grid-area: s; justify-self: center; }
.trick { grid-area: trick; position: relative; justify-self: center; align-self: center; width: calc(var(--tw) * 3.1); height: calc(var(--tw) * 2.75); }

.seat { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .28); color: #f2efe4; font-size: 14px; font-weight: 700; white-space: nowrap; transition: box-shadow .2s, background .2s; }
.seat b { font-size: 16px; }
.seat .hp { color: #ffb3a7; font-weight: 800; }
.seat .hp.zero { color: rgba(242, 239, 228, .55); font-weight: 600; }
.seat.turn { background: rgba(241, 199, 91, .92); color: #2a1a05; box-shadow: 0 0 0 3px rgba(241, 199, 91, .35); }
.seat.turn .hp { color: #9a2414; }
.seat.won { animation: seatWon .9s; }
@keyframes seatWon { 30% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .45); } }

/* Rakip elleri: kapalı kartlar */
.opp { display: flex; }
.opp-n { flex-direction: row; }
.opp-w, .opp-e { flex-direction: column; }
.back-card { width: 30px; height: 42px; border-radius: 4px; background: linear-gradient(135deg, #7a4a24, #4a2a12); border: 1px solid #2a1308; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); flex: none; }
.opp-n .back-card + .back-card { margin-left: -20px; }
.opp-w .back-card + .back-card, .opp-e .back-card + .back-card { margin-top: -34px; }

/* Kart */
.pc { position: relative; width: var(--cw); height: calc(var(--cw) * 1.4); flex: none; border-radius: calc(var(--cw) * .1); background: linear-gradient(180deg, #ffffff, #f4efe3);
  border: 1px solid rgba(80, 60, 30, .35); box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 2px 5px rgba(0, 0, 0, .28); color: #1d140c;
  font: 800 calc(var(--cw) * .3) system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding: 0; text-align: left; }
.pc.red { color: #c0392b; }
.pc b { position: absolute; left: 7%; top: 3%; line-height: 1; letter-spacing: -.04em; }
.pc i { position: absolute; left: 8%; top: 27%; font-style: normal; font-size: .78em; line-height: 1; }
.pc em { position: absolute; left: 50%; top: 60%; transform: translate(-50%, -50%); font-style: normal; font-size: 1.9em; line-height: 1; opacity: .92; }
.pc.pts::after { content: ""; position: absolute; right: 7%; top: 6%; width: 7px; height: 7px; border-radius: 50%; background: #c0392b; opacity: .0; }

/* Elin: kartlar üst üste biner; oynanabilenler parlak, diğerleri soluk */
.hand { display: flex; justify-content: center; align-items: flex-end; min-height: calc(var(--cw) * 1.4 + 22px); margin: 10px 0 0; padding: 14px 0 4px; }
.hand .pc { cursor: pointer; transition: transform .16s cubic-bezier(.3, .7, .4, 1), box-shadow .15s, filter .15s; }
.hand .pc + .pc { margin-left: calc(var(--step) - var(--cw)); }
.hand .pc.legal:hover, .hand .pc.focus { transform: translateY(-12px); box-shadow: 0 10px 18px rgba(0, 0, 0, .3); z-index: 2; }
.hand .pc.dim { filter: brightness(.8) saturate(.7); cursor: not-allowed; }
.hand .pc.sel { transform: translateY(-20px); box-shadow: 0 0 0 3px var(--green), 0 10px 18px rgba(0, 0, 0, .3); }
.hand .pc.got { box-shadow: 0 0 0 3px #f1c75b, 0 0 14px rgba(241, 199, 91, .8); }
.hand .pc.hint { box-shadow: 0 0 0 3px #f1c75b, 0 0 18px 4px rgba(241, 199, 91, .75); transform: translateY(-14px); }
.hand .pc.nope { animation: nope .3s; }
@keyframes nope { 25% { translate: -5px 0; } 75% { translate: 5px 0; } }

/* Ortadaki el */
.tslot { position: absolute; width: var(--tw); height: calc(var(--tw) * 1.4); }
.tslot .pc { --cw: var(--tw); }
.t0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.t2 { left: 50%; top: 0; transform: translateX(-50%); }
.t1 { left: 0; top: 50%; transform: translateY(-50%); }
.t3 { right: 0; top: 50%; transform: translateY(-50%); }
.tslot .pc { animation: .32s cubic-bezier(.3, .7, .4, 1) both; }
.t0 .pc { animation-name: inS; } .t1 .pc { animation-name: inW; } .t2 .pc { animation-name: inN; } .t3 .pc { animation-name: inE; }
@keyframes inS { from { transform: translateY(120px) rotate(6deg); opacity: 0; } }
@keyframes inN { from { transform: translateY(-120px) rotate(-6deg); opacity: 0; } }
@keyframes inW { from { transform: translateX(-120px) rotate(-8deg); opacity: 0; } }
@keyframes inE { from { transform: translateX(120px) rotate(8deg); opacity: 0; } }
.tslot .pc.win { box-shadow: 0 0 0 3px #f1c75b, 0 4px 12px rgba(0, 0, 0, .35); }
.trick.go .pc { transition: transform .45s ease-in, opacity .45s ease-in; opacity: 0; }
.trick.go-0 .pc { transform: translateY(160px) scale(.5); } .trick.go-2 .pc { transform: translateY(-160px) scale(.5); }
.trick.go-1 .pc { transform: translateX(-200px) scale(.5); } .trick.go-3 .pc { transform: translateX(200px) scale(.5); }
.center-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; padding: 10px 16px; border-radius: 14px; background: rgba(20, 12, 6, .78); color: #fff8e6; font-weight: 700; text-align: center; max-width: 80%; }

/* Durum satırı ve koç */
.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; margin: 10px 4px 0; min-height: 40px; font-weight: 700; text-align: center; }
.coach-line { margin: 6px auto 0; max-width: 680px; padding: 8px 12px; border-radius: 12px; background: #fff3cf; border: 1px solid rgba(138, 98, 36, .3); color: #4a3310; font-size: 14px; text-align: center; }
.coach-line.good { background: #e3f6e8; border-color: rgba(31, 143, 66, .35); color: #17532b; }
.keys { margin: 12px 4px 0; color: var(--muted); font-size: 13px; text-align: center; }
kbd { padding: 0 5px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); background: #fff; font: 600 12px ui-monospace, Consolas, monospace; }

/* Pencereler */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(20, 12, 6, .55); }
.modal-card { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; border-radius: 18px; background: var(--card); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.modal-card.wide { width: min(560px, 100%); }
.modal-card h2 { margin: 0 0 10px; font-size: 22px; }
.modal-card h3 { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #8a6224; }
fieldset { margin: 0 0 12px; padding: 0; border: 0; }
legend { margin-bottom: 4px; font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: #8a6224; }
fieldset label { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; }
fieldset label:has(input:checked) { border-color: var(--green); background: #e3f6e8; }
fieldset small, .check small { display: block; margin-left: 24px; font-weight: 500; color: var(--muted); }
.check { display: block; margin: 8px 0; font-weight: 600; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid rgba(29, 20, 12, .2); background: #fff; font-weight: 700; cursor: pointer; }
.btn:hover { background: #f1ebdf; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #23a04b; }
.score-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.score-table th, .score-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table thead th { font-size: 13px; color: var(--muted); }
.score-table tfoot td { font-weight: 800; border-top: 2px solid rgba(29, 20, 12, .3); }
.score-table .lead { background: #e3f6e8; }
.score-table .moon { color: #8a6224; font-weight: 800; }
.big-line { font-size: 18px; margin: 4px 0 8px; }
.coach-box { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: #fff3cf; border: 1px solid rgba(138, 98, 36, .3); color: #4a3310; font-size: 15px; line-height: 1.45; }
.coach-box p { margin: 4px 0; }
.hint-text { color: var(--muted); font-size: 14px; }

.about { margin-top: 32px; padding: 22px 4px 0; border-top: 1px solid var(--line); }
.about-inner { max-width: 720px; }

/* Görünüm seçenekleri */
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches legend { width: 100%; }
.swatches label { display: flex; align-items: center; gap: 8px; flex: 1 1 110px; margin: 0; }
.swatches input { position: absolute; opacity: 0; }
.swatches label:has(input:focus-visible) { outline: 3px solid var(--green); outline-offset: 2px; }
.sw { width: 26px; height: 34px; flex: none; border-radius: 5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.felt-green { background: #1f6a44; } .felt-blue { background: #1f4f74; } .felt-wood { background: repeating-linear-gradient(92deg, #7a4f2c 0 4px, #6a4424 4px 8px); }
html[data-felt="blue"] .felt { background: radial-gradient(ellipse 80% 70% at 50% 40%, #2f6f9a 0%, #1f4f74 55%, #14344f 100%); }
html[data-felt="wood"] .felt { background: radial-gradient(ellipse 80% 70% at 50% 35%, rgba(255, 220, 170, .18), transparent 70%), repeating-linear-gradient(92deg, #7a4f2c 0 6px, #714828 6px 13px, #7f5530 13px 21px); }
html.big-cards .pc { font-size: calc(var(--cw) * .36); }
html.big-cards .pc i { top: 31%; font-size: .8em; }
html.big-cards .pc em { font-size: 1.5em; top: 66%; }

@media (max-width: 640px) {
  .wrap { padding: 0 6px 24px; }
  .bar { margin: 8px 2px; gap: 6px 10px; }
  .title h1 { font-size: 22px; }
  .tools { margin-left: 0; width: 100%; }
  .tool { flex: 1 1 auto; min-height: 40px; padding: 6px 8px; font-size: 13px; }
  #btnSettings { flex: 0 0 auto; } #btnSettings .tl { display: none; }
  .felt { padding: 8px 4px 6px; border-radius: 12px; grid-template-columns: 54px minmax(0, 1fr) 54px; grid-template-rows: auto auto minmax(170px, 1fr) auto; }
  .seat { padding: 3px 8px; font-size: 12px; gap: 5px; }
  .seat b { font-size: 14px; }
  .seat-w, .seat-e { flex-direction: column; gap: 0; border-radius: 12px; padding: 4px 6px; }
  .back-card { width: 20px; height: 28px; }
  .opp-n .back-card + .back-card { margin-left: -15px; }
  .opp-w .back-card + .back-card, .opp-e .back-card + .back-card { margin-top: -24px; }
  .keys { display: none; }
}
@media (prefers-reduced-motion: reduce) { .pc, .tslot .pc, .trick.go .pc { animation: none !important; transition: none !important; } }
@media (prefers-contrast: more) { .pc { border: 2px solid #000; } .pc.red { color: #a00; } }


/* Mexican Train: merkez (engine), trenler satır satır, renkli sayılı taşlar */
.mfelt { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 260px; grid-template: none; }
.hub-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hub, .bone { display: flex; align-items: center; gap: 8px; }
.mini { color: rgba(242, 239, 228, .85); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini b { color: #fff8e6; }
.bone-pile { width: 22px; height: 38px; border-radius: 5px; background: linear-gradient(135deg, #f4efe3, #d9cfb8); box-shadow: 3px 3px 0 #c7bca2, 6px 6px 0 #b3a88e; }
.pend-note { padding: 6px 12px; border-radius: 10px; background: #f1c75b; color: #2a1a05; font-weight: 700; font-size: 14px; text-align: center; }
.trains { display: flex; flex-direction: column; gap: 6px; }
.trow { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 4px 6px; border-radius: 12px; background: rgba(0, 0, 0, .16); transition: background .15s, box-shadow .15s; }
.trow.mex { background: rgba(255, 255, 255, .1); }
.trow.mine { background: rgba(47, 189, 90, .2); }
.trow.turn .tlab b { color: #ffe08a; }
.trow.open .tlab { color: #ffd2c8; }
.trow.can { cursor: pointer; box-shadow: 0 0 0 3px #f1c75b, 0 0 14px rgba(241, 199, 91, .55); }
.trow.can .tend { background: #f1c75b; color: #2a1a05; border-color: #f1c75b; animation: pulse 1.2s ease-in-out infinite; }
.trow.pend { box-shadow: 0 0 0 3px #e2574c; }
.trow.hint { box-shadow: 0 0 0 3px #f1c75b, 0 0 20px 4px rgba(241, 199, 91, .8); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(241, 199, 91, .35); } }
.tlab { display: flex; flex-direction: column; width: 130px; flex: none; color: #f2efe4; line-height: 1.15; }
.tlab b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlab small { font-size: 12px; opacity: .8; }
.mark { font-size: 13px; }
.tline { display: flex; align-items: center; gap: 3px; min-width: 0; flex: 1; overflow: hidden; }
.more { padding: 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, .3); color: #fff8e6; font-size: 12px; font-weight: 700; }
.tend { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .25); color: #fff8e6; font-weight: 800; font-size: 15px; padding: 0; cursor: inherit; }

/* Taş: iki yarım, renkli sayı (renk tek ipucu değil, sayı her zaman yazılı) */
.tile { display: inline-flex; flex: none; align-items: stretch; height: 34px; border-radius: 7px; background: linear-gradient(180deg, #fffdf8, #f1ebdc); border: 1px solid rgba(80, 60, 30, .45);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3); padding: 0; font: 800 15px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #1d140c; }
.tile .h { display: grid; place-items: center; width: 28px; }
.tile .h + .h { border-left: 2px solid rgba(80, 60, 30, .35); }
.tile.dbl { box-shadow: 0 0 0 2px rgba(241, 199, 91, .7), 0 2px 4px rgba(0, 0, 0, .3); }
.tile.small { height: 30px; font-size: 14px; }
.tile.small .h { width: 26px; }
.tile.last { box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, .4); }
.tile.engine { height: 40px; font-size: 18px; } .tile.engine .h { width: 34px; }
.v0 { color: #6b5a45; } .v1 { color: #1f6fb3; } .v2 { color: #1f8f42; } .v3 { color: #c0392b; } .v4 { color: #7b3fa0; } .v5 { color: #a35a00; } .v6 { color: #0f7a7a; }
.v7 { color: #b0261a; } .v8 { color: #1d4f91; } .v9 { color: #5a7d00; } .v10 { color: #8e2b6b; } .v11 { color: #2f5d50; } .v12 { color: #1d140c; }
.tend.v0, .tend.v1, .tend.v2, .tend.v3, .tend.v4, .tend.v5, .tend.v6, .tend.v7, .tend.v8, .tend.v9, .tend.v10, .tend.v11, .tend.v12 { color: #fff8e6; }

/* El */
.plan-line { margin: 8px auto 0; max-width: 760px; padding: 8px 12px; border-radius: 12px; background: #e9f3ea; border: 1px solid rgba(31, 143, 66, .3); font-size: 14px; text-align: center; color: #17532b; }
.mhand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 6px; margin: 12px 0 0; padding: 12px 0 4px; min-height: 64px; }
.tile.big { position: relative; height: 46px; font-size: 19px; cursor: pointer; transition: transform .15s, box-shadow .15s, filter .15s; }
.tile.big .h { width: 36px; }
.tile.big.legal:hover, .tile.big.focus { transform: translateY(-6px); }
.tile.big.dim { filter: brightness(.92) saturate(.75); cursor: not-allowed; }
.tile.big.sel { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--green), 0 8px 14px rgba(0, 0, 0, .3); }
.tile.big.hint { box-shadow: 0 0 0 3px #f1c75b, 0 0 16px 4px rgba(241, 199, 91, .75); transform: translateY(-8px); }
.tile.big.got { box-shadow: 0 0 0 3px #f1c75b; }
.tile.big.nope { animation: nope .3s; }
.ptag { position: absolute; left: 50%; top: -11px; transform: translateX(-50%); min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--green); color: #fff; font-size: 11px; font-weight: 800; line-height: 17px; }
.ptag.spare { background: #8a6224; font-weight: 700; }
html.big-tiles .tile.big { height: 56px; font-size: 24px; } html.big-tiles .tile.big .h { width: 44px; }
html.big-tiles .tile.small { height: 36px; font-size: 17px; } html.big-tiles .tile.small .h { width: 32px; }

.fair-badge { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 1px 10px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 700; color: #17532b; background: #e3f6e8; border: 1px solid rgba(31, 143, 66, .35); vertical-align: middle; }
.fair-badge.open { background: #fff3cf; color: #6a4a0c; border-color: rgba(138, 98, 36, .35); }
.fair-badge.verified { background: #1f8f42; color: #fff; }
.fair-badge.failed { background: #fbe2de; color: #8a1c10; }
.fair-result { margin: 10px 0; padding: 10px 12px; border-radius: 10px; font-weight: 700; }
.fair-result.ok { background: #e3f6e8; color: #17532b; } .fair-result.fail { background: #fbe2de; color: #8a1c10; }
.fair-details summary { cursor: pointer; font-weight: 700; margin-top: 8px; }
.fair-body dt { font-weight: 700; margin-top: 6px; font-size: 13px; }
.fair-body dd { margin: 0; font: 12px/1.4 ui-monospace, Consolas, monospace; word-break: break-all; }
.inline-select { display: flex !important; align-items: center; gap: 8px; }
.inline-select select { min-height: 36px; padding: 4px 8px; border-radius: 8px; border: 1px solid #b9a98c; background: #fff; font: inherit; }
.score-table td, .score-table th { padding: 5px 6px; }

@media (max-width: 640px) {
  .mfelt { padding: 6px; }
  .tlab { width: 74px; }
  .tlab b { font-size: 13px; }
  .tile.small { height: 28px; font-size: 13px; } .tile.small .h { width: 22px; }
  .tend { width: 30px; height: 30px; font-size: 14px; }
  .tile.big { height: 42px; font-size: 17px; } .tile.big .h { width: 30px; }
  .score-table { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .trow.can .tend, .tile.big { animation: none !important; transition: none !important; } }
