:root { --bg: #062018; --panel: #0b3328; --ink: #f4edda; --dim: #b9b6a3; --gold: #d8b260; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, sans-serif; }
h1, h2 { margin: 0; color: var(--gold); letter-spacing: .06em; }
ul { list-style: none; margin: 0; padding: 0; }
button, input, select { font: inherit; border-radius: 10px; border: 1px solid #d8b26066; padding: 10px 14px; background: #0004; color: var(--ink); }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button.primary { background: var(--gold); color: #1d1606; font-weight: 700; }
label { display: grid; gap: 6px; text-align: left; }
select option { color: #000; }
.muted { color: var(--dim); font-size: 14px; margin: 0; }
.error { color: #ffb4a8; margin: 0; min-height: 1.4em; }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { width: min(360px, 100%); display: grid; gap: 16px; padding: 28px; background: var(--panel); border: 1px solid #d8b26044; border-radius: 18px; text-align: center; }
.card.wide { width: min(460px, 100%); }
#code { text-transform: uppercase; letter-spacing: .3em; min-width: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#host-controls { display: grid; gap: 12px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seats li { padding: 14px 8px; border-radius: 12px; border: 1px dashed #d8b26055; overflow-wrap: anywhere; }
.seats li.taken { border-style: solid; background: #0003; }
.seats li small { display: block; font-weight: 700; }
.seats li.team-0, .players li.team-0 { box-shadow: inset 4px 0 #2f6fd6; }
.seats li.team-1, .players li.team-1 { box-shadow: inset 4px 0 #c23a3a; }
.team-form { display: flex; align-items: end; gap: 8px; }
.team-form[hidden] { display: none; }
.team-form label { flex: 1; }
.partner { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0 auto 4px; padding: 4px 10px; width: fit-content; max-width: 100%; border-radius: 10px; background: #fffdf8f2; color: #3b2314; border: 1px solid #d9a636; font-size: 13px; font-weight: 600; }
.partner[hidden] { display: none; }
.partner i { display: block; width: 44px; line-height: 0; }
.partner svg { width: 100%; height: auto; }

.table { max-width: 960px; margin: 0 auto; padding: 12px; display: grid; gap: 10px; }
.table header { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.tools { display: flex; gap: 8px; margin-left: auto; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.players li { padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 2px solid transparent; overflow-wrap: anywhere; }
.players li.turn { border-color: var(--gold); }
.players small { display: block; color: var(--dim); }
#stage { position: relative; height: clamp(300px, 44vh, 440px); overflow: hidden; border-radius: 18px; background: radial-gradient(#0f4a37, #041a13); border: 1px solid #d8b26044; }
#chain { position: absolute; left: 50%; top: 50%; transform-origin: center; }
#chain .piece { position: absolute; width: 64px; height: 32px; filter: drop-shadow(0 2px 3px #000a); }

/* Süfrə dizaynları: butalı haşiyə, mərkəzi tikmə, parça fonu və yanlarda saçaq. */
#rug[data-design="qarabag"] { --field: url(/carpets/qarabag-field.svg); --medallion: url(/carpets/qarabag-medallion.svg); --border: url(/carpets/qarabag-border.svg); }
#rug[data-design="quba"] { --field: url(/carpets/quba-field.svg); --medallion: url(/carpets/quba-medallion.svg); --border: url(/carpets/quba-border.svg); }
#rug[data-design="shirvan"] { --field: url(/carpets/shirvan-field.svg); --medallion: url(/carpets/shirvan-medallion.svg); --border: url(/carpets/shirvan-border.svg); }
#rug:not([data-design="felt"]) { padding: 0 12px; background: repeating-linear-gradient(#e6d3a8 0 2px, transparent 2px 6px); }
#rug:not([data-design="felt"]) #stage {
  border: 22px solid transparent;
  border-image: var(--border) 30 round;
  border-radius: 0;
  background: var(--medallion) center / min(86%, 480px) 82% no-repeat, var(--field) center / 40px;
}
@media (max-width: 500px) {
  #rug:not([data-design="felt"]) { padding: 0 7px; }
  #rug:not([data-design="felt"]) #stage { border-width: 14px; }
}
#chain svg, .hand svg { display: block; width: 100%; height: 100%; }
#status { margin: 0; text-align: center; font-weight: 600; min-height: 1.4em; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 44px; }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 52px; }
.hand button { width: 88px; height: 48px; padding: 2px; border-color: transparent; background: none; }
.hand button.playable { border-color: var(--gold); transform: translateY(-4px); }
.hand button.selected { background: var(--gold); }
.log { color: var(--dim); font-size: 13px; text-align: center; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: max-content; max-width: 90vw; padding: 10px 16px; border-radius: 10px; background: #7d2b21; }

.gender { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 0; padding: 0; margin: 0; }
.gender legend { padding: 0 0 6px; width: 100%; }
.gender label { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 1px solid #d8b26066; border-radius: 10px; cursor: pointer; }
.gender input { accent-color: var(--gold); padding: 0; margin: 0; }
.gender label:has(input:checked) { border-color: var(--gold); background: #d8b26033; }

#scene { position: relative; height: clamp(340px, 58vh, 580px); overflow: hidden; border-radius: 18px; border: 1px solid #d8b26044; background: linear-gradient(#241a14, #0c0907); }
#scene canvas { display: block; }
.tag { position: absolute; left: 0; top: 0; padding: 3px 10px; border-radius: 999px; background: #000b; font-size: 13px; white-space: nowrap; pointer-events: none; }
.tag.turn { background: var(--gold); color: #1d1606; font-weight: 700; }
@media (max-width: 500px) { #scene { height: min(58vh, 108vw); min-height: 300px; } }

#chain .piece.back { transform: rotate(var(--turn)); }
#chain .piece.back.mixing { animation: mix .9s linear infinite; }
@keyframes mix {
  0% { transform: rotate(var(--turn)) translate(0, 0); }
  25% { transform: rotate(calc(var(--turn) + 90deg)) translate(26px, 8px); }
  50% { transform: rotate(calc(var(--turn) + 180deg)) translate(-6px, 28px); }
  75% { transform: rotate(calc(var(--turn) + 270deg)) translate(-28px, -10px); }
  100% { transform: rotate(calc(var(--turn) + 360deg)) translate(0, 0); }
}
.tag.waiter { background: #6e1f1ccc; }
.tag.pot { background: #7a3b12dd; }
.tag.pot.empty { background: #b3261e; font-weight: 700; }

.wallet { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid #d8b26044; }
.wallet .balance { display: flex; align-items: center; gap: 8px; font-size: 18px; color: var(--gold); }
.manat { width: 22px; height: 22px; }
.wallet .notes { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.wallet .notes img { width: 68px; height: 34px; border-radius: 3px; box-shadow: 0 2px 5px #0008; }

#rug.shake { animation: shake .35s ease-out; }
@keyframes shake { 20% { transform: translate(-6px, 4px); } 45% { transform: translate(5px, -3px); } 70% { transform: translate(-3px, 2px); } }

.menu { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: #000a; }
.menu-card { width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 18px; border-radius: 18px; background: var(--panel); border: 1px solid #d8b26066; }
.menu-card header { display: flex; align-items: center; gap: 12px; }
.menu-card header span { margin-left: auto; color: var(--gold); font-weight: 700; }
.menu-card h3 { margin: 16px 0 8px; color: var(--gold); font-size: 16px; }
.menu-list { display: grid; gap: 8px; }
.menu-list li { display: grid; grid-template-columns: 52px 1fr auto auto; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: #0003; }
.menu-list img { width: 52px; height: 42px; }
.menu-list .tea-icon { font-size: 30px; text-align: center; }
.menu-list button { padding: 8px 10px; }
#toast { z-index: 20; }

/* Adi (2D) görünüşdə örtüklər yoxmuş kimi davranır. */
.hud-top, .hud-bottom { display: contents; }

/* ---------- Oyunçu kartı və əlavə düymələr (2D və 3D üçün) ---------- */
.info { display: grid; line-height: 1.25; }
.info small { color: var(--dim); font-size: 12px; }
.info small b { color: var(--ink); letter-spacing: .08em; }
.players li { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; align-items: center; }
.players .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .points { grid-row: span 2; font-size: 24px; color: var(--gold); font-variant-numeric: tabular-nums; }
.extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#camera.active { background: var(--gold); }

/* ---------- Tam ekran: 3D otaq bütün pəncərəni tutur ----------
   Yuxarıda solda oyun məlumatı və pul, ortada xal lövhəsi, sağda alətlər.
   Aşağıda ortada gediş və daşlar, sağda çay və menyu. */
body.immersive { overflow: hidden; }
.table.immersive { position: fixed; inset: 0; max-width: none; margin: 0; padding: 0; display: block; z-index: 1; }
.immersive #scene { position: absolute; inset: 0; height: auto; min-height: 0; border: 0; border-radius: 0; }
.immersive .log { display: none; }
.immersive .hud-top, .immersive .hud-bottom { position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none; }
.immersive .hud-top > *, .immersive .hud-top header > *, .immersive .hud-bottom > * { pointer-events: auto; }

/* örtüklərin hamısı eyni "şüşə" lövhədir */
.immersive :is(.info, .tools, .wallet, .players li, .extras, .hand) {
  background: #0c1712d9; border: 1px solid #d8b26033; border-radius: 14px;
  backdrop-filter: blur(8px); box-shadow: 0 6px 18px #0006;
}

.immersive .hud-top {
  top: 0; display: grid; gap: 8px; padding: 10px 12px; align-items: start;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "info players tools" "wallet players .";
}
.immersive .hud-top header { display: contents; }
.immersive .info { grid-area: info; justify-self: start; padding: 7px 14px; }
.immersive .wallet { grid-area: wallet; justify-self: start; padding: 5px 14px; }
.immersive .wallet .notes { display: none; }
.immersive .wallet .balance { font-size: 15px; }
.immersive .manat { width: 17px; height: 17px; }

.immersive .tools { grid-area: tools; justify-self: end; align-items: center; gap: 2px; margin: 0; padding: 4px; }
.immersive .tools button, .immersive .tools select { height: 34px; min-width: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; font-size: 14px; }
.immersive .tools button:hover, .immersive .tools select:hover { background: #ffffff1a; }
.immersive .tools #camera.active { background: var(--gold); }
.immersive .tools .leave { color: #ffb4a8; }

.immersive .players { grid-area: players; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.immersive .players li { min-width: 128px; padding: 6px 14px; font-size: 13px; border-width: 2px; }
.immersive .players li.turn { border-color: var(--gold); background: #2b2410eb; }
.immersive .players small { font-size: 11px; }

.immersive .hud-bottom { bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px 10px; }
.immersive #status { pointer-events: none; padding: 4px 16px; border-radius: 999px; background: #0c1712d9; font-size: 14px; }
.immersive .actions { min-height: 0; gap: 8px; }
.immersive .actions:empty { display: none; }
.immersive .actions button { padding: 8px 18px; background: #0c1712; }
.immersive .actions button.primary { background: var(--gold); box-shadow: 0 4px 14px #d8b26055; }
.immersive .hand { min-height: 0; gap: 6px; padding: 8px 12px; max-width: 100%; }
.immersive .hand:empty { display: none; }
.immersive .hand button { width: 76px; height: 42px; }

.immersive .extras { position: absolute; right: 12px; bottom: 10px; flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; min-width: 156px; }
.immersive .extras:empty { display: none; }
.immersive .extras button { padding: 7px 12px; border: 0; background: transparent; text-align: left; font-size: 14px; }
.immersive .extras button:hover:not(:disabled) { background: #ffffff1a; }
body.immersive #toast { bottom: auto; top: 130px; }

/* dar pəncərə: sağdakı panel daşların üstünə, sətir şəklinə keçir */
@media (max-width: 1000px) {
  .immersive .extras { position: static; flex-direction: row; justify-content: center; min-width: 0; }
  .immersive .extras button { padding: 5px 9px; font-size: 13px; }
}
@media (max-width: 760px) {
  .immersive .hud-top { padding: 6px; gap: 5px; grid-template-columns: 1fr auto; grid-template-areas: "info wallet" "tools tools" "players players"; }
  .immersive .wallet { justify-self: end; align-self: center; }
  .immersive .tools { justify-self: stretch; justify-content: space-between; }
  .immersive .tools button, .immersive .tools select { min-width: 32px; padding: 0 7px; font-size: 13px; }
  .immersive .players { flex-wrap: nowrap; overflow-x: auto; justify-content: stretch; }
  .immersive .players li { flex: 1; min-width: 0; padding: 4px 8px; column-gap: 6px; font-size: 12px; }
  .immersive .players .points { font-size: 18px; }
  .immersive .hud-bottom { padding: 0 6px 6px; gap: 5px; }
  .immersive .hand { justify-content: center; }
  .immersive .hand button { width: 58px; height: 33px; }
}

/* Giriş addımları */
.step { display: grid; gap: 14px; }
.step h2 { font-size: 18px; }
.step input, .step select { width: 100%; }

/* ---------- Giriş və lobbi: ağ fon, rəngli Azərbaycan naxışları ---------- */
.screen {
  --ink: #3b2314; --dim: #7a5c49; --line: #e5cf9b;
  position: relative; color: var(--ink); color-scheme: light;
  padding: 62px 16px;
  background: url(/art/pattern.svg) center top / 160px repeat, #fff;
}
.screen::before, .screen::after { /* yuxarı və aşağıda xalça haşiyəsi */
  content: ""; position: absolute; left: 0; right: 0; height: 30px;
  background: url(/art/band.svg) center / auto 30px repeat-x;
}
.screen::before { top: 0; }
.screen::after { bottom: 0; }

.screen .card, .screen .card.wide {
  position: relative; gap: 14px; padding: 0 28px 26px; overflow: hidden;
  background: #fffdf8; border: 3px solid #d9a636; border-radius: 22px;
  box-shadow: 0 0 0 6px #fff, 0 0 0 8px #8e1f24, 0 18px 50px #5a2a1040;
}
.screen .card::before { /* şəbəkə tağı */
  content: ""; display: block; margin: 0 -28px; aspect-ratio: 3 / 1;
  background: url(/art/arch.svg) center bottom / 100% 100% no-repeat;
}
.screen h1, .screen h2 { color: #8e1f24; font-family: Georgia, "Times New Roman", serif; }
.screen h1 { font-size: 34px; }
.screen label, .screen legend { color: var(--ink); font-weight: 600; }
.screen input, .screen select { background: #fff; color: var(--ink); border: 2px solid var(--line); font-weight: 400; }
.screen input:focus-visible, .screen select:focus-visible, .screen button:focus-visible { outline: 3px solid #1f5fa8; outline-offset: 2px; }
.screen button { background: #fff; color: var(--ink); border: 2px solid var(--line); font-weight: 700; transition: transform .12s, filter .12s; }
.screen button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }

.screen .gender label { border: 2px solid var(--line); background: #fff; }
.screen .gender label:has(input:checked) { border-color: #1f5fa8; background: #eaf2fc; }
.screen .gender input { accent-color: #1f5fa8; }

/* hər yolun öz rəngi: qırmızı, göy, yaşıl */
.screen button.primary, .screen #open-create { background: linear-gradient(#cf453a, #a92b27); border-color: #8e1f24; color: #fff; }
.screen #open-bot, .screen #bot { background: linear-gradient(#2f74c4, #1c548f); border-color: #174a80; color: #fff; }
.screen #open-join, .screen #join { background: linear-gradient(#2a9a69, #1b6f4a); border-color: #155c3d; color: #fff; }
.screen #open-create::before { content: "✦  "; color: #ffd978; }
.screen #open-bot::before { content: "✦  "; color: #ffd978; }
.screen #open-join::before { content: "✦  "; color: #ffd978; }
.screen .error { color: #b3261e; }
.screen .error:empty { display: none; }

.screen .seats li { border-color: #d9a636; background: #fff; }
.screen .seats li.taken { background: #fdf1d6; }
.screen .muted b { color: #8e1f24; letter-spacing: .12em; }

@media (max-height: 760px) {
  .screen .card::before { aspect-ratio: 4 / 1; }
  .screen { padding: 46px 16px; }
}

/* ---------- Oyun ekranının ağ lövhələri (giriş səhifəsi ilə eyni üslub) ---------- */
html:has(body.immersive), body.immersive { background: #fff; }
.table.immersive { --ink: #3b2314; --dim: #7a5c49; --gold: #8e1f24; color: var(--ink); color-scheme: light; }

.immersive :is(.info, .tools, .wallet, .players li, .extras, .hand) {
  background: #fffdf8f2; border: 2px solid #d9a636; box-shadow: 0 6px 18px #3a1a0840;
}
.immersive .players li.turn { border-color: #8e1f24; background: #fdf0cf; box-shadow: 0 0 0 2px #d9a636, 0 6px 18px #3a1a0840; }
.immersive #status { background: #fffdf8f2; border: 2px solid #d9a636; color: var(--ink); text-shadow: none; }

.immersive .tools button, .immersive .tools select { color: var(--ink); }
.immersive .tools button:hover, .immersive .tools select:hover,
.immersive .extras button:hover:not(:disabled) { background: #f6e7c2; }
.immersive .tools #camera.active { background: #f0cd78; }
.immersive .tools .leave { color: #b3261e; font-weight: 700; }
.immersive .extras button { color: var(--ink); font-weight: 600; }

.immersive .actions button { background: #fffdf8; border: 2px solid #d9a636; color: var(--ink); font-weight: 700; box-shadow: 0 4px 14px #3a1a0840; }
.immersive .actions button.primary { background: linear-gradient(#cf453a, #a92b27); border-color: #8e1f24; color: #fff; }

/* ağ lövhədə daşların konturu seçilsin */
.immersive .hand button svg { filter: drop-shadow(0 1px 2px #3a1a0866); }
.immersive .hand button.playable { border: 2px solid #1f7a57; background: #e4f3ec; }
.immersive .hand button.selected { background: #f0cd78; }

#scene .tag { background: #fffdf8f2; color: #3b2314; border: 1px solid #d9a636; font-weight: 600; }
#scene .tag.turn { background: #8e1f24; color: #fff; border-color: #fff; }
#scene .tag.waiter { background: #fdf0cf; }
#scene .tag.speaking, .players li.speaking { box-shadow: 0 0 0 3px #2fae6b, 0 0 14px #2fae6b; }
#scene .tag.speaking::before { content: '🎙️ '; }
#scene .tag.pot.empty { background: #b3261e; color: #fff; }

/* menyu pəncərəsi də ağdır */
.menu-card { --ink: #3b2314; --dim: #7a5c49; --gold: #8e1f24; color: var(--ink); background: #fffdf8; border: 3px solid #d9a636; color-scheme: light; }
.menu-card button { background: #fff; border: 2px solid #d9a636; color: var(--ink); font-weight: 600; }
.menu-list li { background: #faf1dc; }
.menu-who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.menu-who button { padding: 6px 12px; }
.menu-who button.chosen { background: #8e1f24; border-color: #8e1f24; color: #fff; }
/* oynaya bilməyən daşların rəqəmləri də ağ fonda oxunmalıdır */
.immersive .hand button:disabled { opacity: 1; }
.immersive .hand button:disabled svg { filter: brightness(.86) drop-shadow(0 1px 2px #3a1a0877); }

/* reklamla pul qazanmaq */
.wallet #earn { padding: 4px 10px; border-radius: 10px; border: 2px solid #155c3d; background: linear-gradient(#2a9a69, #1b6f4a); color: #fff; font-size: 13px; font-weight: 700; }
.immersive .wallet { display: flex; align-items: center; gap: 10px; }
.ad { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: #000d; }
.ad-card { width: min(380px, 100%); display: grid; gap: 12px; padding: 24px; text-align: center; border-radius: 20px; background: #fffdf8; color: #3b2314; border: 3px solid #d9a636; }
.ad-card small { color: #7a5c49; text-transform: uppercase; letter-spacing: .2em; }
.ad-card h2 { color: #8e1f24; margin: 0; }
.ad-card p { margin: 0; }
.ad-bar { height: 10px; border-radius: 99px; background: #f0e2bd; overflow: hidden; }
.ad-bar i { display: block; height: 100%; width: 0; background: #1f7a57; transition: width .2s linear; }
.ad-card button { background: #fff; color: #3b2314; border: 2px solid #d9a636; }

/* komanda rəngi tam ekran lövhəsində də görünsün */
.immersive .players li.team-0 { border-left: 6px solid #2f6fd6; }
.immersive .players li.team-1 { border-left: 6px solid #c23a3a; }

/* ---------- Nərd taxtası ---------- */
.hand:empty { display: none !important; }
.nard { width: min(720px, 100%); margin: 0 auto; aspect-ratio: 582 / 430; }
.immersive .nard { position: fixed; z-index: 2; left: 12px; right: 12px; top: 130px; bottom: 120px; width: auto; aspect-ratio: auto; pointer-events: none; }
.nard[hidden] { display: none; }
.nard svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 10px 18px #0008); touch-action: manipulation; }
.immersive .nard svg > * { pointer-events: auto; }
.nard .wood { fill: #5a3018; stroke: #d9a636; stroke-width: 3; }
.nard .field { fill: #e9cf9f; }
.nard .bar { fill: #6e3c1e; }
.nard .point.odd { fill: #8e1f24; }
.nard .point.even { fill: #2c5a4a; }
.nard .stone.p0 { fill: #fdf6e3; stroke: #8a7350; stroke-width: 1.5; }
.nard .stone.p1 { fill: #2b1a12; stroke: #c9a15a; stroke-width: 1.5; }
.nard .ring { fill: none; stroke-width: 1.5; }
.nard .ring.p0 { stroke: #c9b184; }
.nard .ring.p1 { stroke: #6b4a30; }
.nard .count { text-anchor: middle; font: 700 15px sans-serif; fill: #2b1a12; }
.nard .count.p1 { fill: #fdf6e3; }
.nard .die rect { fill: #fffdf6; stroke: #3b2314; stroke-width: 2; }
.nard .die .pip { fill: #8e1f24; }
.nard .die.used { opacity: .35; }
.nard .hit { fill: transparent; stroke: transparent; stroke-width: 3; }
.nard .hit.source { stroke: #f2c14e; stroke-dasharray: 5 5; cursor: pointer; }
.nard .hit.selected { stroke: #1f6fd6; fill: #1f6fd61f; cursor: pointer; }
.nard .hit.target { stroke: #1d9a55; fill: #1d9a5540; cursor: pointer; }
.nard .hit.tray { stroke: #d9a63688; }
.nard .hit.tray.target { stroke: #1d9a55; }

/* ---------- Pul qabı: dəri cüzdan, ağzından əskinaslar görünür ----------
   Qatlar (arxadan önə): arxa dəri (::before) → əskinaslar → ön cib (::after) → yazı. */
#wallet { position: relative; isolation: isolate; display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; width: fit-content; min-width: 214px; min-height: 80px; padding: 30px 20px 10px 16px; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; color: #f6dfa4; }
#wallet[hidden] { display: none; }
#wallet::before, #wallet::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; }
#wallet::before { z-index: -3; top: 14px; border-radius: 12px 12px 14px 14px; background: linear-gradient(#4a2410, #351707); box-shadow: 0 6px 14px #0007; }
#wallet::after { z-index: -1; top: 25px; border-radius: 5px 5px 14px 14px;
  background:
    radial-gradient(circle at 22% 30%, #ffffff17, transparent 55%),
    repeating-radial-gradient(circle at 30% 40%, #0000 0 2px, #00000012 2px 3px),
    linear-gradient(165deg, #94532a, #6d3617 55%, #52260e);
  box-shadow: inset 0 1px 0 #ffd9a055, inset 0 -3px 6px #0006, 0 -2px 4px #0005;
  /* tikiş */
  outline: 1.5px dashed #e8bd76b0; outline-offset: -5px; }

#wallet .notes { position: absolute; z-index: -2; left: 14px; right: 14px; top: 0; height: 48px; display: block; margin: 0; pointer-events: none; }
#wallet .notes img { position: absolute; top: 3px; width: 82px; height: 41px; border-radius: 3px; box-shadow: 0 -1px 4px #0006; transform-origin: 50% 100%; }
#wallet .notes img:nth-child(1) { left: 6px; transform: rotate(-5deg); }
#wallet .notes img:nth-child(2) { left: 46px; transform: rotate(3deg); top: 1px; }
#wallet .notes img:nth-child(3) { left: 86px; transform: rotate(-2deg); top: 5px; }
#wallet .notes img:nth-child(4) { left: 112px; transform: rotate(6deg); top: 2px; }

#wallet .balance { display: flex; align-items: center; gap: 6px; font-size: 17px; color: #f8dc95; text-shadow: 0 -1px 0 #0009, 0 1px 0 #ffdca022; white-space: nowrap; }
#wallet .manat { width: 18px; height: 18px; }
/* düymə cüzdanın qızılı bağlayıcısı kimi sağ tərəfdədir */
#wallet #earn { margin-left: auto; padding: 5px 11px; border-radius: 999px; border: 2px solid #8a621c; background: linear-gradient(#ffe39a, #d9a636 55%, #b8851f); color: #3b2008; font-size: 13px; font-weight: 800; white-space: nowrap; box-shadow: 0 2px 4px #0007, inset 0 1px 0 #fff8; }
#wallet #earn:hover:not(:disabled) { filter: brightness(1.08); }
#wallet #earn:disabled { opacity: .65; }

/* ---------- Pauza ---------- */
#pause-open { width: 38px; height: 34px; padding: 0; border: 0; background: transparent; font-size: 18px; font-weight: 700; }
#pause { z-index: 20; }
.pause-card { width: min(320px, 100%); display: grid; gap: 10px; text-align: center; }
.pause-card h2 { margin: 0; }
.pause-card p { margin: 0; }
.pause-card button { padding: 11px; font-size: 15px; }
.pause-card button[hidden] { display: none; }
.pause-card .resume { background: #8e1f24; border-color: #8e1f24; color: #fff; }
.pause-card .danger { color: #a52a22; }
.pause-card label { display: grid; gap: 4px; text-align: left; }
@media (max-width: 700px) { .immersive .hud-top { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "info wallet wallet" "players players tools"; } .immersive .tools { justify-self: end; align-self: center; } }
.pause-card select { background: #fff; color: #3b2314; border: 2px solid #d9a636; padding: 9px; }

/* ---------- Telefon: oyun üfüqi ---------- */
html.rotated { overflow: hidden; }
/* çevrilmiş body içindəki "fixed" elementlər də onunla birlikdə çevrilir */
body.rotated { position: fixed; top: 0; left: 0; width: var(--stage-w); height: var(--stage-h); min-height: 0; overflow: hidden; transform-origin: top left; transform: translateX(var(--stage-h)) rotate(90deg); }
body.phone { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
body.phone button, body.phone #scene { touch-action: manipulation; }

/* alçaq ekran üçün yığcam örtüklər (en və hündürlük sorğularından asılı deyil) */
body.phone.immersive .hud-top { padding: 4px 6px; gap: 4px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "info players tools" "wallet . ."; }
body.phone.immersive .info { padding: 3px 9px; font-size: 12px; max-width: 190px; }
body.phone.immersive .info small { font-size: 9px; }
body.phone.immersive .players { flex-wrap: nowrap; justify-content: center; gap: 4px; overflow-x: auto; }
body.phone.immersive .players li { flex: 0 1 140px; min-width: 0; padding: 2px 7px; column-gap: 6px; font-size: 11px; }
body.phone.immersive .players small { font-size: 9px; }
body.phone.immersive .players .points { font-size: 17px; }
body.phone.immersive .tools { justify-self: end; align-self: start; }
body.phone #wallet { zoom: .72; justify-self: start; align-self: start; }
body.phone.immersive .hud-bottom { gap: 3px; padding: 0 150px 4px; }
body.phone.immersive #status { padding: 2px 10px; font-size: 11px; text-align: center; }
body.phone.immersive .actions button { padding: 7px 12px; font-size: 13px; }
body.phone.immersive .hand { flex-wrap: wrap; justify-content: center; gap: 4px; padding: 4px 6px; }
body.phone.immersive .hand button { width: 50px; height: 29px; }
body.phone.immersive .partner { margin: 0; padding: 2px 6px; font-size: 10px; }
body.phone.immersive .partner i { width: 28px; }
body.phone.immersive .extras { position: absolute; right: 6px; bottom: 4px; flex-direction: column; align-items: stretch; justify-content: center; min-width: 0; width: 138px; gap: 0; padding: 4px; }
body.phone.immersive .extras:empty { display: none; }
body.phone.immersive .extras button { padding: 6px 8px; font-size: 12px; text-align: left; }
body.phone.immersive #toast { bottom: auto; top: 56px; max-width: 70%; font-size: 13px; }

/* pəncərələr çevrilmiş ekranın hündürlüyünə sığır (vh burada dik ekrana görədir) */
body.phone .menu { padding: 8px; }
body.phone .menu-card { max-height: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; }
body.phone .menu { grid-template-rows: minmax(0, 1fr); }
body.phone .pause-card { width: min(480px, 100%); max-height: 100%; align-self: center; grid-template-columns: 1fr 1fr; gap: 7px; }
body.phone .pause-card :is(h2, p, .resume) { grid-column: 1 / -1; }
body.phone .pause-card button { padding: 8px; font-size: 14px; }
body.phone .menu-list { grid-template-columns: 1fr 1fr; }
body.phone .menu-list li { grid-template-columns: 40px minmax(0, 1fr) auto; font-size: 13px; }
body.phone .menu-list li { grid-template-areas: "pic name order" "pic price order"; row-gap: 0; }
body.phone .menu-list li > :nth-child(1) { grid-area: pic; }
body.phone .menu-list li > :nth-child(2) { grid-area: name; }
body.phone .menu-list li > :nth-child(3) { grid-area: price; }
body.phone .menu-list li > :nth-child(4) { grid-area: order; }
body.phone .menu-list img { width: 40px; height: 32px; }

/* ---------- Pul kisəsi aşağıda solda ---------- */
.immersive #wallet { position: absolute; left: 12px; bottom: 10px; }
/* orta enli pəncərə: kisə kiçilir, ortadakı daşlar ona dəyməsin deyə yer saxlanır */
@media (min-width: 761px) and (max-width: 1100px) {
  body:not(.phone) .immersive #wallet { zoom: .8; left: 8px; }
  body:not(.phone) .immersive .hud-bottom { padding-left: 190px; padding-right: 190px; }
  body:not(.phone) .immersive .hand button { width: 56px; height: 32px; }
}
/* dar pəncərə: kisə örtüyün axınında, solda durur */
@media (max-width: 760px) {
  body:not(.phone) .immersive #wallet { position: relative; left: 0; bottom: 0; align-self: flex-start; zoom: .85; }
}
body.phone.immersive #wallet { left: 5px; bottom: 4px; zoom: .64; }

/* ---------- Lobbidə komanda seçimi ---------- */
.team-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.screen .team-pick button { display: grid; gap: 2px; padding: 10px 6px; overflow-wrap: anywhere; border-width: 2px; border-top-width: 6px; }
.screen .team-pick button.team-0 { border-color: #2f6fd6; }
.screen .team-pick button.team-1 { border-color: #c23a3a; }
.screen .team-pick button.chosen { opacity: 1; background: #fdf1d6; }
.team-pick small { font-weight: 400; font-size: 12px; }
#team-choose .team-pick button { display: grid; gap: 3px; border-width: 2px; border-top-width: 6px; overflow-wrap: anywhere; }
#team-choose .team-pick button.team-0 { border-color: #2f6fd6; }
#team-choose .team-pick button.team-1 { border-color: #c23a3a; }
#team-choose { color-scheme: light; }
#team-choose p { color: #7a5c49; }
body.phone .pause-card .team-pick { grid-column: 1 / -1; }
