/* Okey.TR v4 — original responsive Okey table/lobby layout inspired by a classic 4-seat card room.
   Independent of third-party web resources. Loaded AFTER existing UI styles. */
:root { --v4-wood:#b17b47; --v4-brass:#e4c77b; --v4-felt:#0d503a; --v4-felt-dark:#073427; }
#game { background:#06120e; }
#game .gamebar { height:auto; min-height:58px; padding:8px clamp(12px,2vw,24px); gap:12px; flex-wrap:wrap; background:linear-gradient(180deg,#101b17,#091510); border-bottom:1px solid #4b5d3f; }
#game .gamebar #roomTitle { margin-right:auto; font-size:16px; color:#f2db9d; overflow:hidden; max-width:30vw; text-overflow:ellipsis; white-space:nowrap; }
#game .gamebar button { border:1px solid #43634e; padding:8px 12px; background:#143526; border-radius:8px; min-height:34px; font-size:13px; font-weight:650; }
#game .gamebar button:hover { background:#285d40; }
#game .gamebar-actions { display:flex; gap:7px; flex-wrap:wrap; align-items:center; }
#game .gamebar .table-view-btn { background:#283726; border-color:#847044; }
#game .table { width:100%; max-width:1600px; min-height:0; margin:0 auto; padding:12px; display:grid !important; grid-template-columns:minmax(0,1fr) minmax(258px,295px); grid-template-areas:"felt side" "rack side"; gap:12px 14px; align-items:start; border:0; background:radial-gradient(ellipse at 50% 10%,#144532,#07170f 86%); }
#game .felt-stage { grid-area:felt; min-width:0; width:100%; height:clamp(420px,55dvh,610px); position:relative; isolation:isolate; overflow:hidden; border:8px solid #193f2c; border-radius:27px; background:radial-gradient(ellipse at center,#116648 0%,#0b533c 41%,#093a2b 77%,#082b21 100%); box-shadow:inset 0 0 0 2px #d1b56d60,inset 0 0 52px #021b13,0 18px 36px #0007; }
#game .felt-stage::before { content:""; position:absolute; inset:0; border-radius:20px; pointer-events:none; background:repeating-linear-gradient(145deg,#fff0 0px,#fff0 3px,#ffffff04 4px,#fff0 7px); opacity:.9; }
#game .felt-stage::after { content:""; position:absolute; inset:10px; border:1px solid #c4b36c40; border-radius:19px; pointer-events:none; }
#game .felt-kicker { z-index:5; pointer-events:none; position:absolute; left:17px; top:14px; display:flex; align-items:center; gap:8px; font-size:10px; letter-spacing:.12em; font-weight:800; color:#cce0cb; background:#061d16b8; padding:8px 10px; border-radius:999px; }
#game .felt-live-dot { display:inline-block; width:7px; height:7px; border-radius:50%; background:#30e49a; box-shadow:0 0 0 3px #30e49a27; }
#game .felt-mode { color:#efd188; margin-left:5px; }
/* The previous rack stylesheet positions this relative to .table; v4 confines it to .felt-stage. */
#game .felt-stage .opponents { position:absolute!important; inset:0!important; width:100%!important; height:100%!important; display:block!important; z-index:3!important; margin:0!important; padding:0!important; pointer-events:none; }
#game .felt-stage .opponents .opp { display:flex!important; flex-direction:column; justify-content:center; align-items:center; gap:3px; position:absolute!important; padding:8px 10px!important; border:1px solid #a8c2a97c; border-radius:13px; background:linear-gradient(160deg,#091d19ec,#123d2ced); box-shadow:0 8px 21px #0007; pointer-events:auto; transform:none; min-width:0!important; }
#game .felt-stage .opponents .opp.active { border-color:#f2cb77; box-shadow:0 0 0 1px #e8c579,0 0 24px #ddad3859; }
#game .felt-stage .opponents .opp.seat-top { left:50%; right:auto; top:15px; width:clamp(140px,25%,230px); transform:translateX(-50%); }
#game .felt-stage .opponents .opp.seat-left { top:41%; left:16px; right:auto; width:clamp(120px,18%,180px); }
#game .felt-stage .opponents .opp.seat-right { top:41%; right:16px; left:auto; width:clamp(120px,18%,180px); }
#game .felt-stage .opponents .opp-name { color:#f5f2db; font-size:13px; font-weight:750; text-shadow:0 1px #000; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#game .felt-stage .opponents .opp small { color:#b9d4bd; font-size:10px; }
#game .felt-stage .opponents .opp-tiles { transform:none!important; margin:1px 0!important; flex-wrap:nowrap!important; height:23px; max-height:24px; max-width:90%; width:auto; justify-content:center; overflow:hidden; }
#game .felt-stage .opponents .opp-tiles .tile-back { width:12px; min-width:8px; flex:0 0 9px; height:22px; margin:0 -2px 0 0; }
#game .felt-stage .opponents .seat-top::after,
#game .felt-stage .opponents .seat-left::after,
#game .felt-stage .opponents .seat-right::after { content:""; position:absolute; background:repeating-linear-gradient(90deg,#98603a 0,#d19b64 4px,#85502e 8px); box-shadow:inset 0 1px #e9c99888,0 3px 9px #0009; border:1px solid #422c18; }
#game .felt-stage .opponents .seat-top::after { bottom:-11px; left:18%; width:64%; height:7px; border-radius:4px; transform:rotate(180deg); }
#game .felt-stage .opponents .seat-left::after { right:-11px; top:15%; width:7px; height:70%; border-radius:4px; }
#game .felt-stage .opponents .seat-right::after { left:-11px; top:15%; width:7px; height:70%; border-radius:4px; }
/* Center engine: supports existing click targets and 101 grouping. */
#game .felt-stage .center { position:absolute!important; inset:0; width:100%; height:100%; min-height:0!important; padding:110px 20% 60px!important; margin:0; display:grid!important; grid-template-columns:minmax(80px,110px) minmax(75px,100px); grid-template-rows:auto auto auto; align-content:center; justify-content:center; justify-items:center; align-items:center; gap:12px 20px; pointer-events:none; }
#game .felt-stage .center > * { pointer-events:auto; }
#game .felt-stage .indicator { grid-column:1; grid-row:1; display:flex; flex-direction:column; gap:5px; align-items:center; justify-content:center; min-width:100px; font-size:11px; font-weight:650; border:1px solid #bdac6850; background:#061b16d9; padding:9px; border-radius:12px; color:#f1dfae; }
#game .felt-stage .indicator span { margin:0; display:block; }
#game .felt-stage .indicator .indicator-tile { width:47px; height:65px; object-fit:contain; }
#game .felt-stage .pile { grid-column:2; grid-row:1; display:flex; flex-direction:column; align-items:center; justify-content:center; min-width:91px; min-height:103px; border-radius:12px; border:1px solid #c7ad6c50; padding:8px; background:#061b16d9; cursor:pointer; }
#game .felt-stage .draw-stack { width:65px; height:65px; }
#game .felt-stage .pile img { width:58px; height:64px; border-radius:5px; }
#game .felt-stage .pile small { font-size:11px; font-weight:700; }
#game .felt-stage .groups { grid-column:1 / -1; grid-row:2; min-height:1px; max-height:70px; overflow:auto; }
#game .felt-stage #turnText { grid-column:1 / -1; grid-row:3; padding:9px 15px; border-radius:30px; border:1px solid #c3d3a165; background:#04251bdf; color:#fff7cc; font-size:13px; font-weight:800; white-space:nowrap; }
#game .self-seat-tag { z-index:2; position:absolute; bottom:15px; left:50%; transform:translateX(-50%); background:#06281d; padding:6px 12px; border-radius:999px; border:1px solid #b99e5978; font-weight:700; color:#e9d595; font-size:11px; white-space:nowrap; }
/* Last discard is placed near the appropriate player's seat, not as a static list. */
#game .felt-stage .recent-discards { z-index:2!important; width:100%!important; max-width:none!important; height:100%!important; position:absolute!important; inset:0; margin:0!important; padding:0!important; pointer-events:none!important; }
#game .recent-discards .discard-title { display:none; }
#game .recent-discards .discard-cards { position:absolute; inset:0; display:block; }
#game .recent-discards .discard-card { display:flex; align-items:center; gap:4px; flex-direction:column; justify-content:center; position:absolute; min-width:55px; max-width:78px; margin:0; padding:4px; border-radius:10px; background:#051811da; border:1px solid #54765e; color:#fff; box-shadow:0 7px 12px #0004; }
#game .recent-discards .discard-card small { margin:0; font-size:9px; font-weight:700; color:#ecdca7; max-width:66px; }
#game .recent-discards .discard-tile { height:46px; }
#game .recent-discards .discard-tile img { height:44px; width:31px; }
#game .recent-discards .discard-card.seat-top { top:24%; left:50%; transform:translateX(-50%); }
#game .recent-discards .discard-card.seat-left { top:58%; left:24%; }
#game .recent-discards .discard-card.seat-right { top:58%; right:24%; }
#game .recent-discards .discard-card.seat-bottom { bottom:13%; right:18%; }
/* Sidebar — like a compact game-room board, but Okey.TR original assets. */
#game .table-extras { grid-area:side; position:relative; z-index:4; min-width:0; width:100%; margin:0; padding:0; display:flex!important; flex-direction:column; gap:12px; }
#game .table-extras .game-score-panel, #game .table-extras .table-chat-panel { min-width:0; background:linear-gradient(180deg,#10251c,#081810); border:1px solid #426a4c; border-radius:13px; padding:12px; box-shadow:0 10px 22px #0006; }
#game .table-extras .extra-heading { font-size:14px; font-weight:750; margin-bottom:10px; color:#f5dfaa; }
#game .game-score-grid { grid-template-columns:1fr; gap:7px; }
#game .game-score { display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:auto auto; gap:2px 5px; align-items:center; padding:10px; background:#13382a; border-color:#3e674c; border-radius:8px; }
#game .game-score strong { font-size:12px; grid-column:1; }
#game .game-score span { font-size:14px; grid-column:2; grid-row:1; }
#game .game-score small { grid-column:1 / -1; font-size:10px; }
#game .game-score.is-me { box-shadow:inset 3px 0 #e2bc6b; }
#game .table-chat-messages { min-height:170px; max-height:300px; height:clamp(170px,28vh,290px); background:#061811; border:1px solid #2a4b34; padding:11px; }
#game .table-chat-form { display:flex; flex-direction:row; gap:6px; padding:0; margin-top:9px; }
#game .table-chat-form input { min-width:0; height:38px; padding:8px 9px; }
#game .table-chat-form button { min-height:38px; background:#178251; }
/* Wood rack and actions. The actual source tile images are kept unchanged. */
#game .rack-area { grid-area:rack; width:100%; min-width:0; max-width:none!important; margin:0!important; padding:11px 10px 13px!important; background:linear-gradient(180deg,#182d21,#101e16); border:1px solid #456343; border-radius:18px; box-shadow:0 12px 25px #0008; }
#game .rack-frame { height:184px!important; position:relative; isolation:isolate; border-radius:12px!important; border:5px solid #43301d!important; background:repeating-linear-gradient(88deg,#b77d48 0px,#c58b55 13px,#af7442 26px,#d19c63 35px,#af7542 47px)!important; box-shadow:inset 0 0 0 2px #e9bb7866,inset 0 17px 25px #38201255,0 8px 13px #0009!important; overflow:hidden!important; }
#game .rack-frame::before { position:absolute; inset:7px 9px 9px; z-index:0; border-radius:3px!important; border:0!important; background:linear-gradient(180deg,#dfb27b40 0,#65401d15 45%,#332112a6 48%,#3e271ca6 51%,#e2b78022 54%,#8e552518 100%)!important; box-shadow:inset 0 1px 9px #522b1899!important; pointer-events:none; }
#game .rack-frame::after { height:6px!important; bottom:0!important; left:4px!important; right:4px!important; border-radius:2px!important; background:linear-gradient(180deg,#7b4a2d,#3e2414)!important; }
#game .rack-image { display:none!important; }
#game .rack-slot { position:absolute; z-index:2; inset:10px 13px 12px!important; height:auto!important; width:auto!important; display:block!important; }
#game .rack-slot #hand { width:100%; height:100%!important; min-height:0!important; overflow:visible!important; padding:0!important; display:block!important; }
#game .two-row-rack { grid-template-columns:repeat(15,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(0,1fr)); height:100%; gap:3px; }
#game .two-row-rack .rack-cell { border:1px solid #6d462a29!important; background:#0000000d!important; border-radius:3px; transition:box-shadow .12s, transform .12s; padding:0; }
#game .two-row-rack .rack-cell.occupied { background:transparent!important; border-color:transparent!important; }
#game .two-row-rack .rack-cell.selected { outline:3px solid #ffec9b; z-index:4; box-shadow:0 0 12px #e7a44f; }
#game .two-row-rack .rack-cell img { width:100%; height:100%; object-fit:contain; filter:drop-shadow(0 2px 2px #000a); }
#game .rack-mode { margin:6px 0 5px; font-size:10px; color:#d3c39a; }
#game .rack-tools { justify-content:center; margin:8px 0 9px; gap:7px; }
#game #rackTools button { display:inline-flex!important; min-width:105px; padding:8px 13px; background:#294b36; border:1px solid #a58a53; color:#fff0cd; border-radius:9px; font-size:12px; }
#game #rackTools span { flex:1 1 100%; width:auto; text-align:center; color:#a9c5b1; font-size:10px; }
#game .rack-area .controls button { min-height:39px; min-width:95px; flex:0 1 auto; padding:8px 15px; border-radius:10px; background:#18432f; border:1px solid #50765c; font-weight:650; font-size:13px; }
#game .rack-area .controls #discardBtn:not(:disabled) { background:#168459; border-color:#28be78; }
#game .rack-area .controls button:disabled { opacity:.42; cursor:not-allowed; }
#game .voicepanel { display:none!important; }
/* Lobby: room grid + connected users + chat, inspired by the structure of established card rooms. */
#lobby .layout { max-width:1530px; display:grid; grid-template-columns:175px minmax(0,1fr); gap:13px; margin:16px auto; }
#lobby .side { border-radius:15px; padding:11px; }
#lobby .lobby-main { display:grid; grid-template-columns:minmax(0,1fr) minmax(205px,270px); grid-template-areas:'welcome welcome' 'rooms users' 'chat users' 'leader leader'; align-items:start; gap:14px; }
#lobby .welcome { grid-area:welcome; }
#lobby .grid2 { display:contents; }
#lobby .grid2 > .card:first-child { grid-area:users; min-height:470px; }
#lobby .grid2 > .card:nth-child(2) { grid-area:chat; }
#lobby .lobby-main > .card:last-child { grid-area:rooms; }
#lobby .home-leader { grid-area:leader; }
#lobby .rooms { grid-template-columns:repeat(auto-fill,minmax(205px,1fr)); gap:8px; }
#lobby .room { min-height:130px; background:linear-gradient(165deg,#153d2c,#0a2118); border:1px solid #3d694b; }
#lobby .room:nth-child(2n) { background:linear-gradient(165deg,#213e29,#10251d); }
#lobby .room button { background:#177a50; border:1px solid #38a873; font-weight:700; }
#lobby .grid2 .chat { height:190px; }
#lobby #onlineList { max-height:620px; }
@media(max-width:1050px){
 #game .table { grid-template-columns:minmax(0,1fr) 242px; gap:10px; padding:10px; }
 #game .felt-stage { height:480px; }
 #game .felt-stage .center { padding:110px 18% 45px!important; }
 #game .felt-stage .opponents .opp.seat-left { left:8px; width:120px; }
 #game .felt-stage .opponents .opp.seat-right { right:8px; width:120px; }
 #game .recent-discards .discard-card.seat-left { left:19%; }
 #game .recent-discards .discard-card.seat-right { right:19%; }
 #game .rack-frame { height:158px!important; }
 #game .gamebar button { padding:7px 9px; }
 #lobby .layout { grid-template-columns:135px minmax(0,1fr); }
 #lobby .lobby-main { grid-template-columns:minmax(0,1fr) 220px; }
}
@media(max-width:760px){
 #game .gamebar { top:64px; }
 #game .gamebar #roomTitle { max-width:100%; }
 #game .gamebar-actions { width:100%; justify-content:space-between; }
 #game .gamebar-actions button { flex:1; min-width:0; font-size:11px; padding:8px 5px; }
 #game .table { display:flex!important; flex-direction:column; gap:10px; padding:7px; }
 #game .felt-stage { width:100%; height:clamp(400px,112vw,540px); border-width:5px; border-radius:18px; flex:none; }
 #game .felt-kicker { display:none; }
 #game .felt-stage .opponents .opp.seat-top { top:12px; width:clamp(120px,36%,190px); }
 #game .felt-stage .opponents .opp.seat-left { left:5px; top:42%; width:clamp(89px,23%,125px); }
 #game .felt-stage .opponents .opp.seat-right { right:5px; top:42%; width:clamp(89px,23%,125px); }
 #game .felt-stage .opponents .opp { padding:6px 3px!important; }
 #game .felt-stage .opponents .opp-name { font-size:11px; }
 #game .felt-stage .opponents .opp small { font-size:9px; }
 #game .felt-stage .opponents .opp-tiles { height:18px; }
 #game .felt-stage .opponents .opp-tiles .tile-back { height:18px; width:10px; flex-basis:7px; }
 #game .felt-stage .center { padding:108px 25% 48px!important; gap:8px 8px; grid-template-columns:minmax(64px,95px) minmax(59px,78px); }
 #game .felt-stage .indicator { min-width:0; font-size:10px; padding:6px; }
 #game .felt-stage .pile { min-width:0; padding:6px; }
 #game .felt-stage .indicator .indicator-tile { width:35px; height:47px; }
 #game .felt-stage .pile img { width:43px; height:49px; }
 #game .felt-stage .draw-stack { width:51px; height:54px; }
 #game .felt-stage #turnText { font-size:11px; padding:7px 9px; }
 #game .recent-discards .discard-card { min-width:42px; max-width:59px; gap:0; padding:3px 2px; }
 #game .recent-discards .discard-card.seat-top { top:26%; }
 #game .recent-discards .discard-card.seat-left { top:67%; left:8%; }
 #game .recent-discards .discard-card.seat-right { top:67%; right:8%; }
 #game .recent-discards .discard-card.seat-bottom { bottom:11%; right:19%; }
 #game .recent-discards .discard-tile { height:32px; }
 #game .recent-discards .discard-tile img { height:31px; width:22px; }
 #game .recent-discards .discard-card small { font-size:8px; max-width:50px; }
 #game .rack-area { width:100%; padding:8px 6px 11px!important; order:2; }
 #game .rack-frame { height:clamp(124px,34vw,170px)!important; }
 #game .rack-slot { inset:7px 5px 9px!important; }
 #game .two-row-rack { gap:1px; }
 #game .two-row-rack .rack-cell { border-radius:1px; }
 #game .two-row-rack .rack-cell.selected img { transform:translateY(-4px) scale(1.15); transform-origin:center bottom; }
 #game .rack-tools { margin:7px 0; }
 #game #rackTools button { min-width:0; font-size:11px; padding:7px 9px; }
 #game .rack-area .controls button { min-width:0; padding:8px 10px; font-size:12px; }
 #game .table-extras { width:100%; order:3; display:grid!important; grid-template-columns:1fr; gap:10px; }
 #game .game-score-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 #game .game-score { padding:7px; }
 #game .table-chat-messages { height:140px; min-height:140px; }
 #lobby .layout { grid-template-columns:1fr; }
 #lobby .side { min-height:0; }
 #lobby .lobby-main { grid-template-columns:1fr; grid-template-areas:'welcome' 'rooms' 'users' 'chat' 'leader'; }
 #lobby .grid2 > .card:first-child { min-height:0; }
 #lobby #onlineList { max-height:260px; }
 #lobby .welcome { padding:17px; }
 #lobby .welcome h2 { font-size:22px; }
}
@media(max-width:390px){
 #game .felt-stage { height:410px; }
 #game .felt-stage .opponents .opp.seat-left, #game .felt-stage .opponents .opp.seat-right { width:84px; }
 #game .felt-stage .center { padding:100px 24% 52px!important; }
 #game .rack-frame { height:126px!important; }
 #game .rack-area .controls button { font-size:10px; padding:8px 7px; }
 #game .gamebar-actions button { font-size:10px; }
}
@media(prefers-reduced-motion:reduce) { #game *,#lobby * { transition:none!important; animation:none!important; } }
