/* OKEY — table styling. Felt-green table, gold accents, CSS-drawn ivory tiles. */
:root{
  --felt:#0b6a3a; --felt2:#0a5e34; --felt-dark:#074026;
  --gold:#e8c14a; --gold-2:#f4d97a;
  --ink:#0d1b12; --paper:#f6f4ec;
  --red:#c8324a; --blue:#1f4f9c; --ok:#2f9e5a;
  --line:rgba(255,255,255,.16);
  --shadow:0 6px 18px rgba(0,0,0,.35);
  --tile-w:46px; --tile-h:62px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:"Segoe UI",system-ui,Roboto,Arial,sans-serif;
  background:radial-gradient(120% 80% at 50% 0%, #12813f 0%, var(--felt) 40%, var(--felt-dark) 100%) fixed;
  color:#eafff0; min-height:100vh; -webkit-tap-highlight-color:transparent;
}
h1,h2{margin:0}
button{font-family:inherit}

/* -------------------------------------------------------------- topbar */
#topbar{
  position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; background:rgba(4,40,22,.85); backdrop-filter:blur(6px); border-bottom:1px solid var(--line);
}
.brand{font-size:22px; font-weight:800; cursor:pointer; color:var(--gold-2); letter-spacing:.5px}
.brand span{color:#fff}
.top-right{display:flex; gap:8px; align-items:center}
.icon-btn{background:transparent; border:1px solid var(--line); color:#fff; border-radius:8px; padding:5px 9px; cursor:pointer; font-size:15px}
.lang{background:#0a5230; color:#fff; border:1px solid var(--line); border-radius:8px; padding:5px 8px}

/* -------------------------------------------------------------- screens */
.screen{max-width:960px; margin:0 auto; padding:16px}
.hidden{display:none !important}

/* --------------------------------------------------------------- hero */
.hero{text-align:center; padding:18px 0 6px}
.hero h1{font-size:52px; font-weight:900; color:var(--gold-2); text-shadow:0 3px 0 rgba(0,0,0,.25)}
.hero .suit{font-size:26px; display:block; letter-spacing:4px; margin-top:2px}
.tagline{opacity:.85; margin-top:6px}

/* --------------------------------------------------- name / create bars */
.namebar,.createbox{
  display:flex; gap:10px; align-items:center; justify-content:center;
  background:rgba(0,0,0,.18); border:1px solid var(--line); border-radius:12px;
  padding:12px; margin:12px auto; max-width:560px; flex-wrap:wrap;
}
.namebar label{font-weight:700}
input[type=text]{background:#f6f4ec; color:#173; border:none; border-radius:9px; padding:11px 12px; font-size:16px; min-width:180px}
input[type=text]:focus{outline:2px solid var(--gold)}
.btn{
  border:none; border-radius:10px; padding:11px 16px; font-size:15px; font-weight:700; cursor:pointer;
  background:#125e37; color:#eafff0; box-shadow:var(--shadow); transition:transform .05s, filter .15s;
}
.btn:hover{filter:brightness(1.08)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.45; cursor:not-allowed; filter:none}
.btn.primary{background:linear-gradient(180deg,var(--gold-2),var(--gold)); color:#4a3403}
.btn.gold{background:linear-gradient(180deg,#ffd98a,#e8a53a); color:#4a2f03}
.btn.danger{background:linear-gradient(180deg,#e0596c,var(--red)); color:#fff}
.btn.ghost{background:rgba(255,255,255,.08); border:1px solid var(--line)}
.btn.small{padding:8px 12px; font-size:14px}
.btn.big{padding:14px 26px; font-size:18px}

/* ------------------------------------------------------------- tables */
.tables h2{margin:14px 4px 8px; font-size:18px; color:var(--gold-2)}
.room-list{display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:12px}
.room-tile{background:rgba(0,0,0,.22); border:1px solid var(--line); border-left:5px solid var(--gold); border-radius:12px; padding:12px; position:relative}
.room-tile.playing{border-left-color:var(--red)}
.room-tile .rt-name{font-weight:800; font-size:17px}
.room-tile .rt-code{font-family:monospace; opacity:.7; font-size:12px}
.room-tile .rt-host{opacity:.85; font-size:13px; margin:4px 0}
.room-tile .badge{display:inline-block; font-size:11px; font-weight:800; padding:2px 8px; border-radius:20px; margin-left:6px; background:var(--ok); color:#fff}
.room-tile .badge.playing{background:var(--red)}
.chips{display:flex; flex-wrap:wrap; gap:5px; margin:6px 0}
.chip{background:rgba(255,255,255,.14); border-radius:20px; padding:2px 9px; font-size:12px}
.rt-actions{display:flex; gap:8px; margin-top:8px; align-items:center}
.rt-remove{margin-left:auto; font-size:11px; opacity:.6; cursor:pointer; background:none; border:none; color:#ffd; text-decoration:underline}
.no-tables{opacity:.75; padding:10px}

/* --------------------------------------------------------------- room */
.room-head{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:8px}
.room-title{font-size:20px; font-weight:800}
.room-title .code{font-family:monospace; font-size:13px; opacity:.7; margin-left:6px; background:rgba(0,0,0,.25); padding:2px 8px; border-radius:8px}
.room-actions{display:flex; gap:8px; flex-wrap:wrap}

/* lobby */
.lobby-card{background:rgba(0,0,0,.2); border:1px solid var(--line); border-radius:14px; padding:20px; text-align:center; max-width:520px; margin:20px auto}
.lobby-msg{font-size:18px; margin-bottom:12px; opacity:.95}
.seat-list{display:flex; flex-direction:column; gap:8px; margin:14px 0}
.seat-row{display:flex; align-items:center; gap:10px; background:rgba(255,255,255,.07); border-radius:10px; padding:9px 12px}
.seat-row .who{font-weight:700}
.seat-row .tag{font-size:11px; background:var(--gold); color:#4a3403; padding:1px 8px; border-radius:20px; font-weight:800}
.seat-row .tag.you{background:#fff; color:#124}
.seat-row .tag.bot{background:#3a6ea5; color:#fff}
.seat-row .kick{margin-left:auto; background:none; border:none; color:#ffb; cursor:pointer; font-size:12px; text-decoration:underline}
.hint{opacity:.8; font-size:13px; margin-top:8px}

/* -------------------------------------------------------- CSS TILES */
.tile{
  position:relative; width:var(--tile-w); height:var(--tile-h); border-radius:8px;
  background:linear-gradient(160deg,#fbf7ea,#efe7cf); border:1px solid #cdbf99;
  box-shadow:0 2px 5px rgba(0,0,0,.4), inset 0 2px 2px rgba(255,255,255,.7);
  display:flex; align-items:center; justify-content:center; flex:0 0 auto;
  color:var(--tc,#333); user-select:none; -webkit-user-select:none;
}
.tile .face{position:relative; width:100%; height:100%; display:flex; align-items:center; justify-content:center}
/* the round's okey (wild) tile is shown upside-down so you notice you're holding it */
.tile.wild .face{transform:rotate(180deg)}
.tile .num{font-size:26px; font-weight:900; line-height:1; letter-spacing:-1px; text-shadow:0 1px 0 rgba(0,0,0,.08)}
.tile .dot{position:absolute; bottom:6px; left:50%; transform:translateX(-50%); width:7px; height:7px; border-radius:50%; background:var(--tc,#333); opacity:.85}
.tile.small{--tile-w:30px; --tile-h:40px}
.tile.small .num{font-size:17px}
.tile.small .dot{width:5px; height:5px; bottom:4px}
.tile.joker{color:#7a1030}
.tile.joker .jk{font-size:26px; line-height:1}
.tile.small.joker .jk{font-size:16px}
.tile.wild::after{content:"★"; position:absolute; top:2px; right:4px; font-size:10px; color:var(--gold); text-shadow:0 1px 1px rgba(0,0,0,.5)}
.tile.selected{transform:translateY(-12px); box-shadow:0 10px 16px rgba(0,0,0,.5); outline:3px solid var(--gold); z-index:5}
.tile.back{
  background:repeating-linear-gradient(45deg,#0a4a8a,#0a4a8a 5px,#0d59a6 5px,#0d59a6 10px);
  border:1px solid #063; box-shadow:0 2px 5px rgba(0,0,0,.45), inset 0 0 0 3px rgba(255,255,255,.12);
}
.tile.takeable{outline:2px solid rgba(232,193,74,.6)}
.tile.clickable{cursor:pointer}
.tile.clickable:hover{outline:3px solid var(--gold)}

/* ------------------------------------------------------------- game */
.opp-bar{display:flex; align-items:stretch; gap:10px; justify-content:center; flex-wrap:wrap; padding:8px; margin-bottom:6px}
.opp-chip{display:flex; flex-direction:column; gap:5px; background:rgba(0,0,0,.25); border:1px solid var(--line); border-radius:12px; padding:8px 12px; min-width:120px}
.opp-chip.turn{border-color:var(--gold); box-shadow:0 0 0 2px rgba(232,193,74,.5)}
.opp-chip.left{border-color:rgba(120,200,255,.6)}
.opp-chip.me-chip{border-color:rgba(232,193,74,.4)}
.opp-chip .ohead{display:flex; align-items:center; justify-content:space-between; gap:8px}
.opp-chip .oname{font-weight:800}
.opp-chip .oscore{color:var(--gold-2); font-weight:800}
.opp-chip .ocards{display:flex; align-items:center}
.opp-chip .ocards .mini{width:12px; height:18px; margin-left:-6px; border-radius:2px;
  background:repeating-linear-gradient(45deg,#0a4a8a,#0a4a8a 3px,#0d59a6 3px,#0d59a6 6px); box-shadow:0 1px 2px rgba(0,0,0,.4)}
.opp-chip .ocards .mini:first-child{margin-left:0}
.opp-chip .ocount{font-size:11px; opacity:.8; margin-left:6px}
.opp-chip .odisc{min-height:40px; display:flex; align-items:center}

.table-center{display:flex; gap:14px; align-items:flex-start; justify-content:center; flex-wrap:wrap; padding:12px; background:rgba(0,0,0,.12); border-radius:16px; border:1px solid var(--line)}
.pile{text-align:center}
.pile-tile{width:var(--tile-w); height:var(--tile-h); border-radius:8px; display:flex; align-items:center; justify-content:center}
.pile-tile.back{background:repeating-linear-gradient(45deg,#0a4a8a,#0a4a8a 5px,#0d59a6 5px,#0d59a6 10px); border:1px solid #063; box-shadow:var(--shadow)}
.pile-tile.empty{background:rgba(255,255,255,.06); border:2px dashed var(--line)}
.pile-tile.clickable{cursor:pointer}
.pile-tile.clickable:hover{outline:3px solid var(--gold)}
.take-pile{width:var(--tile-w); height:var(--tile-h); display:flex; align-items:center; justify-content:center}
.pile-lbl{font-size:11px; opacity:.85; margin-top:4px}

/* turn banner */
.turn-banner{text-align:center; font-weight:800; font-size:15px; padding:8px; margin:8px 0; border-radius:10px}
.turn-banner.mine{background:linear-gradient(180deg,var(--gold-2),var(--gold)); color:#4a3403}
.turn-banner.theirs{background:rgba(0,0,0,.25); color:#dfe}

/* action bar */
.action-bar{display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin:8px 0}
.finish-hint{text-align:center; font-size:13px; color:var(--gold-2); margin:2px 0 6px}

/* rack (istaka) */
.hand-wrap{margin-top:10px}
.hand-head{display:flex; justify-content:flex-start; align-items:center; gap:12px; font-size:13px; opacity:.95; margin-bottom:6px; padding:0 4px; flex-wrap:wrap}
.hand-info{opacity:.8}
.my-disc-wrap{margin-left:auto; display:flex; align-items:center; gap:6px}
.my-disc-wrap .mini-lbl{opacity:.7; font-size:11px}
.my-disc{display:flex; align-items:center; min-height:40px}
.sort-btn{background:rgba(255,255,255,.1); border:1px solid var(--line); color:#eafff0; border-radius:8px; padding:4px 10px; font-size:12px; font-weight:700; cursor:pointer}
.sort-btn:hover{background:rgba(255,255,255,.18)}
.hand-area{padding:10px; background:linear-gradient(180deg,#5b3d1e,#3f2a14); border-radius:14px; border:1px solid rgba(0,0,0,.3);
  box-shadow:inset 0 3px 10px rgba(0,0,0,.5); min-height:calc(2*var(--tile-h) + 26px)}
.hand-area.rack{overflow-x:hidden}
.rack-grid{display:grid; grid-template-columns:repeat(var(--cols), 1fr); gap:5px; width:100%}
.rack-slot{aspect-ratio:46/62; border-radius:8px; background:rgba(0,0,0,.18); border:1px solid rgba(0,0,0,.25); box-shadow:inset 0 2px 4px rgba(0,0,0,.4)}
.rack-slot.hover{border:2px solid var(--gold); background:rgba(232,193,74,.25)}
.rack-slot .tile{width:100%; height:100%; cursor:grab; touch-action:none; -webkit-user-drag:none}
.rack-slot .tile .num{font-size:min(6vw,26px)}
.tile.drag-source{opacity:.35}
.tile.drag-float{position:fixed; z-index:1000; pointer-events:none; box-shadow:0 14px 26px rgba(0,0,0,.6); outline:3px solid var(--gold)}

/* freshly drawn tile: deal-in + a lingering gold shine */
@keyframes dealIn{ from{ transform:translateY(-46px) scale(.5); opacity:0 } to{ transform:none; opacity:1 } }
@keyframes shinesweep{ 0%,100%{ box-shadow:0 2px 6px rgba(0,0,0,.4) } 50%{ box-shadow:0 0 22px 8px rgba(244,217,122,.95), 0 2px 6px rgba(0,0,0,.4) } }
.tile.justdrawn{ animation:dealIn .35s ease-out, shinesweep 1.05s ease-in-out 3; outline:3px solid var(--gold); z-index:6 }

/* over view */
.over-view{position:fixed; inset:0; background:rgba(2,20,10,.78); display:flex; align-items:center; justify-content:center; z-index:30; padding:16px}
.over-card{background:linear-gradient(180deg,#0d7a44,#075330); border:2px solid var(--gold); border-radius:16px; padding:22px; max-width:460px; width:100%; text-align:center; box-shadow:var(--shadow)}
.over-card h2{font-size:26px; color:var(--gold-2); margin-bottom:12px}
.over-body{margin:10px 0}
.res-row{display:flex; justify-content:space-between; padding:8px 10px; border-radius:8px; background:rgba(255,255,255,.08); margin:6px 0}
.res-row.win{background:rgba(47,158,90,.35); border:1px solid var(--ok)}
.res-row .rn{font-weight:800}
.res-row .rg{opacity:.9}
.res-row .rt{color:var(--gold-2); font-weight:800}
.over-actions{display:flex; gap:10px; justify-content:center; margin-top:14px; flex-wrap:wrap}

/* chat */
.chat-box{max-width:960px; margin:14px auto 0; background:rgba(0,0,0,.18); border:1px solid var(--line); border-radius:12px; padding:10px}
.chat-head{font-size:12px; color:var(--gold-2); font-weight:700; margin-bottom:6px; display:flex; align-items:center; gap:8px}
.chat-badge{background:var(--red); color:#fff; font-size:11px; font-weight:800; min-width:18px; height:18px; border-radius:9px; padding:0 5px; display:inline-flex; align-items:center; justify-content:center; animation:badgePop .25s ease-out}
@keyframes badgePop{ from{ transform:scale(.4); opacity:0 } to{ transform:scale(1); opacity:1 } }
.chat-input-row{display:flex; gap:8px; margin-bottom:8px}
.chat-input-row input{flex:1; min-width:0}
.chat-area{max-height:150px; overflow-y:auto; display:flex; flex-direction:column; gap:4px; padding-right:4px}
.chat-msg{font-size:13px; padding:4px 8px; border-radius:8px; background:rgba(255,255,255,.06); word-break:break-word}
.chat-msg.me{background:rgba(232,193,74,.15); border:1px solid rgba(232,193,74,.35)}
.chat-msg .chat-name{font-weight:800; color:var(--gold-2)}

/* log */
.log-box{max-width:960px; margin:14px auto 30px; background:rgba(0,0,0,.18); border:1px solid var(--line); border-radius:12px; padding:10px}
.log-title{font-size:12px; color:var(--gold-2); font-weight:700; margin-bottom:6px}
.log-area{font-size:13px; max-height:120px; overflow-y:auto; display:flex; flex-direction:column-reverse}
.log-area .li{padding:3px 4px; border-bottom:1px solid rgba(255,255,255,.06); opacity:.9}

/* toast */
#toast{position:fixed; left:50%; bottom:26px; transform:translateX(-50%) translateY(20px); background:#1b1b1b; color:#fff; padding:11px 18px; border-radius:10px; font-size:14px; opacity:0; pointer-events:none; transition:.25s; z-index:50; box-shadow:var(--shadow); max-width:90%}
#toast.show{opacity:1; transform:translateX(-50%) translateY(0)}

@media(max-width:560px){
  :root{--tile-w:38px; --tile-h:52px}
  .hero h1{font-size:40px}
  .tile .num{font-size:22px}
}
