/* ==========================================================================
   ეზო — დომინოს სრულეკრანიანი მაგიდა („ფლეიერის“ რეჟიმი)
   ღამის თბილისის ფონზე — ხის მაგიდა სპილენძის არშიით და სპილოსძვლისფერი ქვები.
   ========================================================================== */

html, body.gx-body { height: 100%; }
body.gx-body {
  margin: 0; overflow: hidden; color: #EEF0F8;
  background:
    radial-gradient(1100px 650px at 50% 48%, rgba(70, 96, 170, .35) 0%, transparent 70%),
    radial-gradient(ellipse at 50% 120%, #2A1C34 0%, transparent 55%),
    linear-gradient(180deg, #0E1530 0%, #0A0F22 100%);
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.gx {
  height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; gap: 6px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  box-sizing: border-box; max-width: 1600px; margin: 0 auto; position: relative;
}

/* ზედა ზოლი */
.gx-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gx-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #E9ECF7; text-decoration: none !important;
  transition: background-color .15s, transform .1s; list-style: none;
}
.gx-btn::-webkit-details-marker { display: none; }
.gx-btn:hover { background: rgba(255, 255, 255, .16); }
.gx-btn:active { transform: scale(.94); }
.gx-btn .ic { width: 20px; height: 20px; }
.gx-btn[aria-pressed="false"] { color: rgba(255, 255, 255, .45); }
.gx-meta { flex: 1; text-align: center; color: rgba(238, 240, 248, .66); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gx-tools { display: flex; gap: 8px; }
.gx-menu { position: relative; }
.gx-menu-pop {
  position: absolute; right: 0; top: 50px; z-index: 30; min-width: 190px; padding: 6px; border-radius: 14px;
  background: #182040; border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
}
.gx-menu-pop button { display: block; width: 100%; text-align: start; padding: 10px 12px; border: 0; background: none; color: #EEF0F8; border-radius: 9px; font-weight: 600; }
.gx-menu-pop button:hover { background: rgba(255, 255, 255, .08); }
.gx-menu-pop .danger { color: #FF8A96; }

/* მოთამაშეები — რგოლი ავატარის გარშემო არის ტაიმერი */
.gx-seat {
  --ring: #F3C64B; --p: 0;
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 5px 8px 5px 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
  transition: border-color .25s, box-shadow .25s;
}
.gx-seat.active { border-color: rgba(243, 198, 75, .6); box-shadow: 0 0 0 3px rgba(243, 198, 75, .1), 0 0 28px rgba(243, 198, 75, .16); }
.gx-seat.low { --ring: #FF5C6C; }
.gx-ava { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; flex: none; padding: 3px; box-sizing: border-box;
  background: conic-gradient(var(--ring) calc(var(--p) * 1turn), rgba(255, 255, 255, .12) 0); }
.gx-ava > span { display: grid; }
.gx-ava .avatar { width: 40px; height: 40px; box-shadow: 0 0 0 2px #0F1733; font-size: 1rem; }
.gx-who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.gx-who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; font-size: .95rem; }
.gx-sub { font-size: .76rem; color: rgba(238, 240, 248, .7); font-variant-numeric: tabular-nums; min-height: 1em; }
.gx-seat.active .gx-sub { color: #FFD66E; font-weight: 700; }
.gx-seat.low .gx-sub { color: #FF8A96; animation: dg-pulse .5s ease-in-out infinite; }
.gx-plate {
  min-width: 46px; text-align: center; padding: 5px 10px; border-radius: 11px; flex: none;
  background: linear-gradient(180deg, #F9E39A, #C99A3A); color: #2A1A00; font-weight: 800; font-size: 1.12rem; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65), 0 3px 10px rgba(0, 0, 0, .35);
}

/* მოწინააღმდეგის ქვები (ზურგით) */
.gx-backs { display: flex; justify-content: center; align-items: flex-end; gap: 3px; min-height: 36px; padding-top: 2px; }
.gx-back {
  display: inline-block; width: 19px; height: 34px; border-radius: 4px; flex: none; transform: rotate(var(--r, 0deg));
  background:
    linear-gradient(var(--glass-1), var(--glass-1)) 4px 7px / 5px 8px no-repeat,
    linear-gradient(var(--glass-2), var(--glass-2)) 10px 7px / 5px 8px no-repeat,
    linear-gradient(var(--glass-4), var(--glass-4)) 4px 18px / 5px 8px no-repeat,
    linear-gradient(var(--glass-3), var(--glass-3)) 10px 18px / 5px 8px no-repeat,
    linear-gradient(160deg, #2A3366, #161C3A);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 3px 6px rgba(0, 0, 0, .45);
}

/* მაგიდა */
.gx-table { position: relative; min-height: 0; }
.gx-felt {
  position: absolute; inset: 0; border-radius: 28px; overflow: hidden;
  background-color: #6A4024;
  background-image:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(255, 220, 160, .26), transparent 70%),
    repeating-linear-gradient(91deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(89deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px 31px),
    repeating-radial-gradient(ellipse 140% 18% at 30% 60%, rgba(0, 0, 0, .05) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, #8C5B33 0%, #6B4225 60%, #55331B 100%);
  box-shadow:
    inset 0 0 0 9px #42250F, inset 0 0 0 11px #C99A3A, inset 0 0 0 12px rgba(0, 0, 0, .35),
    inset 0 24px 70px rgba(0, 0, 0, .45), inset 0 -18px 50px rgba(0, 0, 0, .35),
    0 30px 70px -25px rgba(0, 0, 0, .8);
}
.gx-felt::after { /* ვინიეტი */
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .28) 100%);
}
.gx-layout { position: absolute; left: 50%; top: 53%; transform-origin: center center; z-index: 1; }
.gx-layout .dt { position: absolute; }
.gx-layout .dt.spinner { box-shadow: inset 0 0 0 1px rgba(120, 98, 58, .32), 0 0 0 3px rgba(243, 198, 75, .85), 0 0 22px rgba(243, 198, 75, .45), 0 6px 12px rgba(0, 0, 0, .35); }
.gx-layout .dt.fresh { animation: dg-drop .45s cubic-bezier(.2, 1.3, .4, 1); }
.gx-layout .dt.fresh.by-opp { box-shadow: inset 0 0 0 1px rgba(120, 98, 58, .32), 0 0 0 3px rgba(255, 255, 255, .85), 0 8px 14px rgba(0, 0, 0, .35); }
.gx-slot {
  position: absolute; display: grid; place-items: center; padding: 0; cursor: pointer; z-index: 2;
  border: 2px dashed rgba(255, 236, 200, .95); border-radius: calc(var(--u) * .17); background: rgba(255, 245, 225, .18);
  color: #FFF3DA; font-weight: 800; font-size: calc(var(--u) * .62); line-height: 1;
  animation: dg-slot .9s ease-in-out infinite alternate; box-shadow: 0 0 18px rgba(255, 220, 140, .35);
}
.gx-slot-h { width: calc(var(--u) * 2); height: var(--u); }
.gx-slot-v { width: var(--u); height: calc(var(--u) * 2); }
.gx-slot:hover { background: rgba(255, 245, 225, .32); }
.gx-empty { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); color: rgba(255, 242, 220, .9); font-weight: 600; white-space: nowrap; text-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.gx-slot-first { position: static; width: 150px; height: 70px; font-size: 1rem; }

.gx-sum { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 3; padding: 4px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: #FFF0D6; background: rgba(0, 0, 0, .3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gx-sum.five { background: linear-gradient(180deg, #F9E39A, #E0B24A); color: #3A2604; box-shadow: 0 0 16px rgba(243, 198, 75, .6); }
.gx-log { position: absolute; left: 22px; top: 18px; z-index: 3; margin: 0; padding: 0; list-style: none; font-size: .76rem; line-height: 1.55; color: rgba(255, 240, 220, .6); max-width: 34%; pointer-events: none; }
.gx-log li:first-child { color: rgba(255, 244, 228, .95); font-weight: 600; }
.gx-bone { position: absolute; right: 22px; bottom: 18px; z-index: 3; display: flex; align-items: center; gap: 0; color: #FFF0D6; font-weight: 800; font-size: .95rem; }
.gx-bone .gx-back:nth-child(2) { margin-left: -12px; transform: rotate(8deg); }
.gx-bone b { margin-left: 8px; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.gx-pop { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: grid; place-items: center; }
.gx-pop-item { grid-area: 1 / 1; font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 9vw, 5.5rem); color: #FFE08A; text-shadow: 0 4px 0 #8A5A16, 0 10px 30px rgba(0, 0, 0, .55); animation: dg-popup 1.7s cubic-bezier(.2, .9, .3, 1) forwards; }
.gx-pop-item.opp { color: #FFFFFF; text-shadow: 0 4px 0 #3C3F52, 0 10px 30px rgba(0, 0, 0, .55); }

.gx-status { margin: 0; text-align: center; min-height: 1.35em; font-size: .9rem; color: rgba(238, 240, 248, .72); }
.gx-status.mine { color: #FFD66E; font-weight: 700; }

/* ქვედა ზოლი: მე, ჩემი ქვები, მოქმედებები */
.gx-bottom { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "seat hand actions"; align-items: end; gap: 14px; }
.gx-seat-me { grid-area: seat; align-self: center; }
.gx-hand { grid-area: hand; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: calc(var(--u, 36px) * .22); padding-top: 14px; min-height: 60px; }
.gx-actions { grid-area: actions; display: flex; flex-direction: column; gap: 8px; align-self: center; }
.gx-action {
  height: 46px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: linear-gradient(180deg, #F9E39A, #C99A3A); color: #2A1A00; font-weight: 800; font-size: .92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 6px 16px rgba(0, 0, 0, .4);
}
.gx-action:active { transform: translateY(1px); }
.gx-action-ghost { background: rgba(255, 255, 255, .1); color: #EEF0F8; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .3); }
.gx-htile { border: 0; background: none; padding: 0; border-radius: 6px; cursor: pointer; transition: transform .18s cubic-bezier(.3, 1.4, .5, 1), opacity .2s, filter .2s; }
.gx-htile .dt { box-shadow: inset 0 0 0 1px rgba(120, 98, 58, .32), 0 calc(var(--u) * .08) 0 #B9A97F, 0 10px 18px rgba(0, 0, 0, .45); }
.gx-htile:hover { transform: translateY(-4px); }
.gx-htile.can { transform: translateY(-10px); }
.gx-htile.can .dt { box-shadow: inset 0 0 0 1px rgba(120, 98, 58, .32), 0 calc(var(--u) * .08) 0 #B9A97F, 0 0 0 3px #F3C64B, 0 0 24px rgba(243, 198, 75, .45), 0 12px 20px rgba(0, 0, 0, .45); }
.gx-htile.dim { opacity: .5; filter: saturate(.6); }
.gx-htile.sel { transform: translateY(-18px) scale(1.04); }
.gx-htile.sel .dt { box-shadow: 0 0 0 3px #FFFFFF, 0 0 30px 6px rgba(255, 220, 140, .65), 0 14px 24px rgba(0, 0, 0, .5); }
.gx-htile.leaving { opacity: 0; transform: translateY(-60px) scale(.85); }
.gx-htile.shake { animation: dg-shake .35s; }

/* გადაფარვები */
.gx-overlay { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(6, 9, 22, .55); backdrop-filter: blur(4px); }
.gx-invite-card { width: min(400px, 100%); text-align: center; padding: 28px 22px 24px; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
.gx-invite-card h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; margin: 14px 0 6px; }
.gx-invite-card p { color: var(--ink-2); margin: 0 0 18px; }
.gx-rules { border: 0; border-radius: 20px; padding: 22px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
.gx-rules::backdrop { background: rgba(6, 9, 22, .6); backdrop-filter: blur(3px); }
.gx-rules h2 { font-family: var(--font-display); font-weight: 800; margin: 0 0 10px; }
.gx-rules ul { padding-left: 1.2em; margin: 0 0 16px; color: var(--ink-2); line-height: 1.6; }
.gx-rules li { margin-bottom: 6px; }
body.gx-body .toast { bottom: 150px; }

/* ტელეფონი (ვერტიკალური) */
@media (max-width: 760px) {
  .gx { gap: 5px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .gx-btn { width: 38px; height: 38px; }
  .gx-meta { display: none; }
  .gx-top .gx-seat { flex: 1; }
  .gx-who b { max-width: 110px; }
  .gx-ava { width: 42px; height: 42px; }
  .gx-ava .avatar { width: 35px; height: 35px; }
  .gx-plate { min-width: 40px; font-size: 1rem; padding: 4px 8px; }
  .gx-felt { border-radius: 20px; }
  .gx-log { max-width: 58%; left: 16px; top: 46px; }
  .gx-log li:not(:first-child) { display: none; }
  .gx-sum { top: 14px; }
  .gx-bone { right: 16px; bottom: 12px; }
  .gx-bottom { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "seat actions" "hand hand"; gap: 6px 10px; }
  .gx-action { height: 40px; padding: 0 14px; font-size: .85rem; }
  .gx-actions { flex-direction: row; }
  .gx-backs { min-height: 28px; }
  .gx-back { width: 15px; height: 27px; background-size: 4px 6px, 4px 6px, 4px 6px, 4px 6px, auto; background-position: 3px 6px, 8px 6px, 3px 15px, 8px 15px, 0 0; }
  .gx-bottom .gx-seat-me { justify-self: start; }
}
@media (max-width: 420px) {
  .gx-top { gap: 6px; }
  .gx-tools { gap: 5px; }
  .gx-btn { width: 36px; height: 36px; }
  .gx-btn .ic { width: 18px; height: 18px; }
  .gx-top .gx-seat { gap: 7px; padding-right: 5px; }
  .gx-top .gx-plate { min-width: 34px; padding: 3px 6px; }
}

/* ტელეფონი ჰორიზონტალურად / დაბალი ეკრანი */
@media (max-height: 520px) {
  .gx { gap: 4px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .gx-backs { min-height: 22px; }
  .gx-back { width: 13px; height: 23px; }
  .gx-status { font-size: .8rem; min-height: 1.1em; }
  .gx-bottom { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "seat hand actions"; }
  .gx-hand { padding-top: 10px; min-height: 0; flex-wrap: nowrap; overflow-x: auto; }
  .gx-actions { flex-direction: column; }
  .gx-log { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gx-slot, .gx-pop-item, .gx-layout .dt.fresh { animation: none !important; }
}

/* ───────── შეძახილები (დაგვათენდა!, აჩქარდი! …) — ყველა თამაშისთვის ───────── */
.sh-btn.pulse { color: #FFD66E; border-color: rgba(243, 198, 75, .55); animation: sh-pulse 1.6s ease-in-out infinite; }
@keyframes sh-pulse { 50% { box-shadow: 0 0 0 6px rgba(243, 198, 75, .14); } }
.sh-panel {
  position: fixed; z-index: 70; right: max(12px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 54px);
  width: min(380px, calc(100vw - 24px)); padding: 12px; border-radius: 18px; color: #EEF0F8;
  background: linear-gradient(180deg, rgba(24, 34, 58, .98), rgba(14, 20, 38, .98)); border: 1px solid rgba(243, 198, 75, .35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6); animation: sh-in .18s ease-out;
}
@keyframes sh-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.sh-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sh-head b { font-family: var(--font-display); font-size: 1.05rem; color: #FFE08A; }
.sh-x { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08); color: #EEF0F8; font-size: 1.2rem; cursor: pointer; }
.sh-to { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sh-to button { padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .18); background: none; color: #EEF0F8; font-weight: 600; font-size: .84rem; cursor: pointer; }
.sh-to button.on { background: linear-gradient(180deg, #F9E39A, #C99A3A); color: #2A1A00; border-color: transparent; }
.sh-for { margin: -2px 0 10px; color: rgba(238, 240, 248, .7); font-size: .86rem; }
.sh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sh-grid button {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .06); color: #EEF0F8; font-weight: 700; font-size: .88rem;
  transition: background .15s, transform .1s;
}
.sh-grid button span { font-size: 1.35rem; line-height: 1; }
.sh-grid button:hover { background: rgba(255, 255, 255, .12); }
.sh-grid button:active { transform: scale(.97); }
.sh-panel.cooling .sh-grid button { opacity: .45; cursor: wait; }
.sh-cool { margin: 8px 0 0; min-height: 1em; text-align: center; font-size: .78rem; color: rgba(238, 240, 248, .6); }
.sh-layer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.sh-bubble {
  position: fixed; display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border-radius: 18px; white-space: nowrap;
  background: #FFFDF7; color: #1B1E2A; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); animation: sh-pop .35s cubic-bezier(.2, 1.5, .4, 1);
}
.sh-bubble.anchored { transform: translate(-50%, -100%); }
.sh-bubble.anchored::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
.sh-bubble.anchored.below { transform: translate(-50%, 0); }
.sh-bubble.anchored.below::after { bottom: auto; top: -7px; }
.sh-bubble.banner { left: 50%; top: 18%; transform: translateX(-50%); }
.sh-emo { font-size: 1.7rem; line-height: 1; }
.sh-txt { display: flex; flex-direction: column; line-height: 1.2; }
.sh-txt b { font-family: var(--font-display); font-size: 1.05rem; }
.sh-txt small { font-size: .74rem; color: #5B6070; }
.sh-bubble.to-me { left: 50% !important; top: 34% !important; transform: translate(-50%, -50%) !important; padding: 16px 26px 16px 18px; border-radius: 24px;
  background: linear-gradient(180deg, #FFF3C4, #F3C64B); box-shadow: 0 0 0 6px rgba(243, 198, 75, .3), 0 24px 60px rgba(0, 0, 0, .55); }
.sh-bubble.to-me::after { display: none; }
.sh-bubble.to-me .sh-emo { font-size: 2.8rem; animation: sh-wiggle .5s ease-in-out 3; }
.sh-bubble.to-me .sh-txt b { font-size: 1.6rem; }
.sh-bubble.out { opacity: 0; transition: opacity .45s; }
@keyframes sh-pop { from { opacity: 0; scale: .6; } }
@keyframes sh-wiggle { 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
body.sh-shake .gx { animation: dg-shake .45s 2; }

/* ლოგო მაგიდაზე */
.gx-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(38%, 420px); max-height: 46%; object-fit: contain; opacity: .2; pointer-events: none; user-select: none; z-index: 0; }
