/* ====================================================================
   lobby.css — Layar lobby. Semua selector diawali #lobby / .lb- supaya
   tidak bentrok dengan style.css milik game.
   ==================================================================== */
#lobby {
  --brass: #d7b56d; --brass-d: #8c7137; --ink: #12140e; --ink2: #1d2016;
  --steel: #c9cfbf; --line: rgba(215,181,109,.38);
  --ui: clamp(46px, 13.5vh, 86px);            /* sisi tombol kotak kiri */
  position: fixed; inset: 0; z-index: 50; overflow: hidden; background: #0c0e0a;
  font-family: Bahnschrift, 'Arial Narrow', 'Roboto Condensed', 'Segoe UI', sans-serif;
  color: var(--steel); user-select: none; -webkit-user-select: none;
  transition: opacity .38s ease;
}
#lobby.leaving { opacity: 0; pointer-events: none; }
#lobby button { font-family: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#lobby button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Latar & komandan ---------- */
.lb-bg {
  position: absolute; inset: -4%; background: #0c0e0a url(../img/lobby-bg.webp) center 42% / cover no-repeat;
  filter: brightness(.78) saturate(.9); animation: lbDrift 40s ease-in-out infinite alternate;
}
@keyframes lbDrift { from { transform: scale(1) translateX(-1%); } to { transform: scale(1.06) translateX(1%); } }
.lb-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(6,7,5,.72) 100%),
    linear-gradient(to bottom, rgba(6,7,5,.55), transparent 22%, transparent 62%, rgba(6,7,5,.82));
}
.lb-cmd {
  position: absolute; left: 50%; bottom: 0; height: 94%; max-width: 92vw; object-fit: contain; object-position: bottom;
  transform: translateX(-50%); pointer-events: none; z-index: 1;
  filter: drop-shadow(0 0 28px rgba(0,0,0,.65));
  animation: lbRise .9s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes lbRise { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Atas: logo + mata uang ---------- */
.lb-top {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
  display: flex; justify-content: space-between; align-items: flex-start; z-index: 3; pointer-events: none;
}
.lb-top > * { pointer-events: auto; }
.lb-brand { display: flex; flex-direction: column; align-items: flex-start; }
.lb-logo {
  height: clamp(54px, 22vh, 140px); width: auto; display: block;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 62%, transparent 100%);
          mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 62%, transparent 100%);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.7));
}
.lb-dev {
  display: flex; align-items: center; gap: 6px; margin: -2px 0 0 clamp(14px, 5vh, 40px);
  font-size: clamp(10px, 2.6vh, 14px); letter-spacing: .14em; font-weight: 700; color: #a9ad9b;
}
.lb-fg { width: 1.7em; height: 1.7em; display: inline-grid; place-items: center; border: 1px solid #6c705e; border-radius: 3px; background: #1a1c14; }
.lb-fg svg { width: 70%; height: 70%; fill: #c9cfbf; }

.lb-currency { display: flex; align-items: center; gap: clamp(4px, 1.2vh, 10px); }
.lb-pill {
  display: flex; align-items: center; gap: 7px; height: clamp(26px, 8vh, 40px); padding: 0 0 0 10px;
  background: linear-gradient(#2a2c22, #14160f); border: 1px solid #4b4d3b; border-radius: 8px;
  font-size: clamp(11px, 3vh, 17px); font-weight: 700; color: #ecebe0; letter-spacing: .02em;
}
.lb-pill span { min-width: 4.2em; text-align: left; }
.lb-pill b { display: grid; place-items: center; align-self: stretch; width: clamp(24px, 7vh, 36px); margin-left: 2px; font-size: 1.4em; font-weight: 400; color: var(--steel); border-left: 1px solid #3c3e30; }
.lb-coin, .lb-gem { width: 1.5em; height: 1.5em; flex: none; }
.lb-coin { border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe08a, #c99416 70%); box-shadow: inset 0 0 0 2px #f3c75a, 0 0 0 1px #6b4d0a; }
.lb-gem { clip-path: polygon(50% 0, 100% 35%, 80% 100%, 20% 100%, 0 35%); }
.lb-gem-p { background: linear-gradient(135deg, #e7a6ff, #8a2bd0); }
.lb-gem-b { background: linear-gradient(135deg, #9fe3ff, #1479d6); }
.lb-gear {
  width: clamp(32px, 10.5vh, 52px); height: clamp(32px, 10.5vh, 52px); display: grid; place-items: center;
  background: linear-gradient(#2a2c22, #14160f); border: 1px solid #4b4d3b; border-radius: 10px; padding: 0;
}
.lb-gear svg { width: 62%; height: 62%; fill: #c9cfbf; }

/* ---------- Kiri: Spin / Event / Inventory ---------- */
.lb-side {
  position: absolute; z-index: 3; left: max(10px, env(safe-area-inset-left));
  top: calc(max(8px, env(safe-area-inset-top)) + clamp(54px, 22vh, 140px) + clamp(16px, 5vh, 30px));
  display: flex; flex-direction: column; gap: clamp(5px, 1.6vh, 10px);
}
.lb-sq, .lb-tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(#25271d, #12140e); border: 1px solid #4b4d3b; border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06), 0 4px 10px rgba(0,0,0,.5);
  transition: border-color .15s, transform .12s;
}
.lb-sq:active, .lb-tab:active { transform: scale(.97); }
.lb-sq:hover, .lb-tab:hover { border-color: var(--brass-d); }
.lb-sq { width: var(--ui); height: var(--ui); padding: 4px; gap: 2px; }
.lb-sq svg { flex: 1 1 0; min-height: 0; width: 62%; }
.lb-sq em, .lb-tab em { flex: none; line-height: 1.1; }
.lb-sq em, .lb-tab em { font-style: normal; font-weight: 700; letter-spacing: .08em; color: #e4e2d4; text-transform: uppercase; }
.lb-sq em { font-size: clamp(7px, 2vh, 11px); letter-spacing: .04em; }
.lb-dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: #e23a32; box-shadow: 0 0 0 2px #12140e; }

/* ---------- Bawah: 5 tombol utama ---------- */
.lb-bottom {
  position: absolute; z-index: 3; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom)); height: clamp(56px, 19vh, 108px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.28fr); gap: clamp(6px, 1.6vw, 14px);
}
.lb-tab { padding: 4px 6px; gap: 2px; background: linear-gradient(rgba(37,39,29,.94), rgba(18,20,14,.96)); }
.lb-tab svg { flex: 1 1 0; min-height: 0; width: 100%; max-width: 100px; }
.lb-tab em { font-size: clamp(9px, 2.9vh, 17px); letter-spacing: .1em; }
.lb-start {
  background: linear-gradient(#5a4a1c, #2c2410); border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.4), inset 0 0 22px rgba(215,181,109,.28), 0 0 18px rgba(215,181,109,.22), 0 4px 10px rgba(0,0,0,.5);
}
.lb-start:hover { border-color: #f1d68f; }
.lb-start em { color: var(--brass); }


/* ---------- Toast ---------- */
.lb-toast {
  position: absolute; z-index: 20; left: 50%; bottom: max(4px, env(safe-area-inset-bottom)); transform: translate(-50%, 6px); opacity: 0; pointer-events: none;
  padding: 6px 16px; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,16,11,.94);
  color: #ecebe0; font-size: clamp(12px, 3.4vh, 16px); font-weight: 700; letter-spacing: .04em; white-space: nowrap;
  transition: opacity .18s, transform .18s;
}
.lb-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Modal ---------- */
.lb-modal {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,4,.72); padding: 10px;
}
.lb-modal[hidden] { display: none; }
.lb-box {
  width: min(420px, 100%); max-height: calc(100% - 4px); display: flex; flex-direction: column;
  background: linear-gradient(#20231a, #12140e); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
}
.lb-modal.wide .lb-box { width: min(900px, 100%); height: min(100%, 560px); }
.lb-box-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 16px; border-bottom: 1px solid #34362a; flex: none; }
.lb-box-head h2 { margin: 0; font-size: clamp(15px, 4vh, 21px); color: var(--brass); letter-spacing: .06em; text-transform: uppercase; }
.lb-x { width: 32px; height: 32px; background: #1b1d15; border: 1px solid #4b4d3b; border-radius: 6px; font-size: 14px; }
.lb-x:hover { border-color: #b24a42; color: #ff9a92; }
.lb-box-body { padding: 12px 14px 14px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.note { margin: 0 0 10px; font-size: 12px; color: #9a9d8c; }
.grid { display: grid; gap: 8px; }
.g-tile { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.g-unit { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: #191b13; border: 1px solid #34362a; border-radius: 6px; padding: 10px; }
.g-tile .card { display: flex; gap: 12px; align-items: center; }
.hex { width: 44px; height: 50px; flex: none; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }
.card h3 { margin: 0; font-size: 15px; color: #ecebe0; letter-spacing: .03em; }
.card h3 small { font-size: 11px; font-weight: 400; color: #8f9280; margin-left: 4px; }
.card p { margin: 3px 0 0; font-size: 12.5px; line-height: 1.4; color: #b6b9a8; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 8px; }
.badge { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #d7b56d; color: #1b1d15; font-style: normal; font-weight: 800; font-size: 12px; flex: none; }
.badge.sq { border-radius: 5px; background: #9b7a3f; color: #fff4d8; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; width: 100%; }
.tg { font-size: 10.5px; padding: 1px 7px; border: 1px solid #4b4d3b; border-radius: 10px; color: #a9ad9b; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.st { background: #11130d; border-radius: 4px; padding: 4px 6px; display: flex; flex-direction: column; min-width: 0; }
.st.wide { grid-column: span 2; }
.st span { font-size: 10px; color: #8f9280; letter-spacing: .06em; text-transform: uppercase; }
.st b { font-size: 14px; color: #ecebe0; font-weight: 700; white-space: nowrap; }

.modes { display: grid; gap: 8px; }
.mode {
  position: relative; text-align: left; padding: 11px 14px; background: #191b13; border: 1px solid #3c3e30; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.mode b { font-size: 16px; color: #d9d8cb; letter-spacing: .03em; }
.mode small { font-size: 12px; color: #8f9280; }
.mode i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 10.5px; padding: 1px 8px; border: 1px solid #4b4d3b; border-radius: 10px; color: #8f9280; }
.mode.ready { border-color: var(--brass); background: linear-gradient(#3a3016, #1e1a0c); }
.mode.ready b { color: var(--brass); }
.mode:hover { border-color: var(--brass-d); }

/* ---------- Layar potret (HP dipegang tegak) ---------- */
@media (orientation: portrait) {
  #lobby { --ui: clamp(54px, 10vh, 80px); }
  .lb-cmd { height: auto; width: 104vw; max-width: none; bottom: 13vh; }
  .lb-logo { height: clamp(52px, 11vh, 96px); }
  .lb-top { flex-wrap: wrap; gap: 6px; }
  .lb-currency { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  .lb-pill { height: 28px; font-size: 11px; padding-left: 7px; gap: 5px; }
  .lb-pill span { min-width: 0; }
  .lb-pill b { width: 22px; }
  .lb-gear { width: 32px; height: 32px; }
  .lb-tab em { font-size: 9px; letter-spacing: .04em; }
  .lb-sq { width: 56px; height: 56px; }
  .lb-side { top: 20vh; }
  .lb-bottom { height: 14vh; min-height: 62px; }
  .lb-dev { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .lb-bg, .lb-cmd { animation: none; }
  #lobby, .lb-toast { transition: none; }
}


/* ---------- Loading screen (v8.7) ---------- */
#loading {
  position: fixed; inset: 0; z-index: 200; overflow: hidden; background: #0c0e0a;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease;
}
#loading[hidden] { display: none; }
#loading.hide { opacity: 0; pointer-events: none; }
.ld-bg {
  position: absolute; inset: -4%; background: #0c0e0a url(../img/lobby-bg.webp) center 42% / cover no-repeat;
  filter: brightness(.78) saturate(.9);
}
.ld-shade {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(6,7,5,.72) 100%),
              linear-gradient(to bottom, rgba(6,7,5,.45), transparent 25%, transparent 65%, rgba(6,7,5,.8));
}
.ld-logo {
  position: relative; max-width: 70vw; max-height: 46vh; width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.75));
  animation: ldPulse 2.4s ease-in-out infinite alternate;
}
@keyframes ldPulse { from { transform: scale(1); } to { transform: scale(1.04); } }
.ld-bar {
  position: absolute; left: 50%; bottom: max(26px, calc(env(safe-area-inset-bottom) + 18px)); transform: translateX(-50%);
  width: min(420px, 72vw); height: 6px; border-radius: 3px; overflow: hidden;
  background: rgba(0,0,0,.55); border: 1px solid rgba(215,181,109,.45);
}
.ld-bar i {
  display: block; width: 100%; height: 100%; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, #8c7137, #d7b56d);
}
