/* كلمة وحدة وبس — shared look, from /images/design/web/kalmaw.png.
   Used by index.php, /mobile/kalmaw/index.php and word.php. Art cut from the design
   lives in /images/logo/kalmaw_*. Sizes are in em so each page scales a component by
   setting font-size on it (the desktop stage does it in cqw). */
:root {
  --km-navy: #071433;
  --km-navy-2: #0c2154;
  --km-line: rgba(79, 150, 255, .55);
  --km-gold-1: #ffe36a;
  --km-gold-2: #ffc21a;
  --km-gold-3: #f59a00;
  --km-ink: #1b1305;
  --km-blue: #19a4ff;
  --km-red: #ff4b3e;
  --km-text: #ffffff;
  --km-soft: rgba(255, 255, 255, .82);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: 'Cairo', sans-serif;
  color: var(--km-text);
  background: #060c24 url('/images/logo/kalmaw_bg_soft.jpg') center / cover fixed no-repeat;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── info chips (فريقان / 60 ثانية / كلمة واحدة) ── */
.km-chip {
  display: flex; align-items: center; justify-content: center; gap: .7em;
  padding: .45em 1em;
  border-radius: 1.1em;
  background: linear-gradient(180deg, rgba(14, 34, 84, .92), rgba(5, 14, 40, .92));
  border: 1.5px solid var(--km-line);
  box-shadow: 0 0 1.2em rgba(40, 120, 255, .28), inset 0 1px 0 rgba(255, 255, 255, .08);
  line-height: 1.25;
}
.km-chip svg { flex: 0 0 auto; width: 2.6em; height: 2.6em; }
.km-chip b { display: block; font-size: 1.15em; font-weight: 800; }
.km-chip small { display: block; font-size: .78em; font-weight: 600; color: var(--km-soft); }

/* ── the big yellow button ── */
.km-play {
  display: flex; align-items: center; justify-content: center; gap: .55em;
  width: 100%;
  border: none; cursor: pointer;
  font-family: 'Cairo', sans-serif; font-weight: 900; line-height: 1;
  color: var(--km-ink);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--km-gold-1) 0%, var(--km-gold-2) 52%, var(--km-gold-3) 100%);
  box-shadow:
    inset 0 .12em 0 rgba(255, 255, 255, .65),
    inset 0 -.14em 0 rgba(170, 80, 0, .45),
    0 0 0 .08em #ffcf3a,
    0 0 1.1em rgba(255, 190, 30, .75),
    0 .3em .9em rgba(0, 0, 0, .45);
  transition: transform .15s ease, filter .15s ease;
}
.km-play:hover { transform: translateY(-.06em) scale(1.02); filter: brightness(1.06); }
.km-play:active { transform: scale(.98); }
.km-play .tri {
  width: 0; height: 0;
  border-top: .42em solid transparent; border-bottom: .42em solid transparent;
  border-right: .66em solid var(--km-ink);   /* points left, as in the design (RTL) */
  border-radius: .08em;
}

/* ── the two corner pills (قواعد اللعبة / ملاحظة أو اقتراح) ── */
.km-pill {
  display: flex; align-items: center; justify-content: center; gap: .7em;
  width: 100%;
  padding: .5em 1em;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif; font-size: 1em; font-weight: 700;
  color: #fff; text-decoration: none;
  background: rgba(6, 16, 44, .88);
  border: 1.5px solid var(--km-line);
  box-shadow: 0 0 1em rgba(40, 120, 255, .25);
  transition: border-color .15s ease, transform .15s ease;
}
.km-pill svg { width: 1.5em; height: 1.5em; flex: 0 0 auto; }
.km-pill:hover { border-color: rgba(120, 180, 255, .95); transform: translateY(-1px); }

/* Main menu — the 2×2 grid icon, dark glass disc */
.km-home {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--km-gold-1);
  background: rgba(6, 16, 44, .82);
  border: 1.5px solid var(--km-line);
  box-shadow: 0 3px 14px rgba(0, 0, 0, .4);
  transition: transform .15s ease, border-color .15s ease;
}
.km-home svg { width: 22px; height: 22px; display: block; }
.km-home:hover { transform: scale(1.08); border-color: rgba(120, 180, 255, .95); }

/* ── rules modal ── */
.km-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 22, .78);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.km-modal-box {
  position: relative;
  width: 100%; max-width: 560px; max-height: calc(calc(var(--dvh, 1dvh) * 100) - 32px); overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #0f2560, #07123a);
  border: 2px solid var(--km-line);
  box-shadow: 0 0 40px rgba(40, 120, 255, .35), 0 20px 50px rgba(0, 0, 0, .6);
  text-align: right;
}
.km-modal-box h2 {
  text-align: center; font-size: 24px; font-weight: 900; margin-bottom: 12px;
  color: var(--km-gold-1);
}
.km-modal-box ol { padding-right: 22px; line-height: 1.95; font-size: 15px; color: var(--km-soft); }
.km-modal-box li::marker { color: var(--km-gold-2); font-weight: 800; }
.km-modal-close {
  position: absolute; top: 12px; left: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--km-line); background: rgba(0, 0, 0, .3);
  color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.km-modal-ok { font-size: 20px; padding: 12px 0; margin-top: 18px; }

/* ═════════ lobby / join ═════════
   Used by lobby.php (both trees), player.php and word.php. Same navy-and-gold
   palette as the landing page; sizes here are in px because these screens are
   lists, not a scaled stage. */

.km-lobby { width: 100%; margin: 0 auto; display: grid; gap: 14px; align-items: start; }
.km-col   { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.km-panel {
  border-radius: 20px; padding: 14px;
  background: linear-gradient(180deg, rgba(14, 40, 100, .72), rgba(5, 14, 40, .8));
  border: 1.5px solid var(--km-line);
  box-shadow: 0 12px 28px rgba(0, 4, 24, .45), inset 0 1px 0 rgba(255, 255, 255, .07);
}
.km-panel-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; font-weight: 900; margin-bottom: 10px; }
.km-sub { font-size: 13px; font-weight: 700; color: var(--km-soft); }
.km-name { font-size: 22px; font-weight: 900; margin-bottom: 16px; }

/* the logo banner at the top of the lobby */
.km-hero { position: relative; text-align: center; }
.km-hero img { width: 100%; max-width: 420px; display: block; margin: 0 auto; filter: drop-shadow(0 8px 20px rgba(0,0,0,.45)); }

/* the join card: code on one side, QR on the other */
.km-code-card {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 20px; color: var(--km-ink);
  background: linear-gradient(180deg, #fff6d8 0%, #ffd873 100%);
  border: 2px solid #fff; box-shadow: 0 14px 30px rgba(0, 4, 24, .45), inset 0 -3px 0 rgba(120, 70, 0, .14);
}
.km-code-card .info { flex: 1; min-width: 0; text-align: center; }
.km-code-card .lbl  { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 900; }
.km-code-card .lbl svg { width: 16px; height: 16px; }
.km-code-card .hint { margin-top: 6px; font-size: 12px; font-weight: 800; color: #7a5200; }
.km-code-pill {
  display: block; width: 100%; margin-top: 6px; padding: 4px 10px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #0c2154, #051233); color: var(--km-gold-1);
  direction: ltr; font-family: 'Cairo', sans-serif; font-size: clamp(26px, calc(var(--dvw, 1vw) * 7), 34px); font-weight: 900; letter-spacing: 2px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5);
}
.km-qr { flex: none; background: #fff; border-radius: 14px; padding: 6px; line-height: 0; text-align: center; cursor: pointer; border: none;
  box-shadow: 0 6px 14px rgba(0, 4, 24, .3); }
.km-qr img  { width: 112px; height: 112px; display: block; image-rendering: pixelated; }
.km-qr span { display: block; line-height: 1.4; margin-top: 2px; font-size: 11px; font-weight: 800; color: var(--km-ink); }

/* player rows */
.km-list { display: flex; flex-direction: column; gap: 6px; }
.km-lrow {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 60, 140, .45), rgba(8, 26, 76, .6));
  border: 1.5px solid var(--km-line);
}
.km-lrow .nm    { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.km-lrow .crown { font-size: 18px; line-height: 1; flex: none; }
.km-lrow .away  { font-size: 12px; font-weight: 800; color: var(--km-soft); flex: none; }
.km-av { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid rgba(255,255,255,.85); background: #0c2154; }
.km-kebab { width: 30px; height: 30px; border: none; background: none; color: rgba(255,255,255,.8); cursor: pointer; flex: none;
  border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.km-kebab svg { width: 20px; height: 20px; }
.km-kebab:hover { background: rgba(255, 255, 255, .08); }

.km-status { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--km-soft); }
.km-spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px dotted rgba(255,255,255,.7); animation: km-spin 1.6s linear infinite; flex: none; }
@keyframes km-spin { to { transform: rotate(360deg); } }

/* secondary buttons — the gold .km-play stays the one primary action */
.km-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 8px 16px;
  border: none; border-radius: 16px; cursor: pointer; text-decoration: none; color: #fff;
  font-family: 'Cairo', sans-serif; font-size: 17px; font-weight: 900; transition: transform .12s, filter .15s;
}
.km-btn svg { width: 22px; height: 22px; flex: none; }
.km-btn:active { transform: translateY(2px); }
.km-btn .sub { display: block; font-size: 12px; font-weight: 800; opacity: .78; line-height: 1.1; }
.km-btn-green { background: linear-gradient(180deg, #3ddc7d, #17a352); box-shadow: 0 5px 0 #0c6b35, inset 0 2px 0 rgba(255,255,255,.35); }
.km-btn-blue  { background: linear-gradient(180deg, #4fb0ff, #1f78e6); box-shadow: 0 5px 0 #0e4fa8, inset 0 2px 0 rgba(255,255,255,.35); }
.km-btn-red   { background: linear-gradient(180deg, #fc5b74, #e8143f); box-shadow: 0 5px 0 #9c0b2b, inset 0 2px 0 rgba(255,255,255,.35); }
.km-btn-navy  { background: linear-gradient(180deg, #123f8f, #0a2a6a); border: 1.5px solid var(--km-line); box-shadow: 0 5px 0 #031a48; }

/* name + avatar, on the join page and in the host modal */
.km-field {
  width: 100%; padding: 13px; border-radius: 14px; border: 1.5px solid var(--km-line);
  background: rgba(4, 12, 38, .7); color: #fff; outline: none;
  font-family: 'Cairo', sans-serif; font-size: 19px; font-weight: 800; text-align: center;
}
.km-field::placeholder { color: rgba(255, 255, 255, .35); }
.km-field:focus { border-color: var(--km-gold-1); box-shadow: 0 0 0 3px rgba(255, 227, 106, .18); }
.km-avpick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0; }
@media (max-width: 420px) { .km-avpick { grid-template-columns: repeat(4, 1fr); } }
.km-avpick button { padding: 0; border-radius: 50%; overflow: hidden; line-height: 0; aspect-ratio: 1; cursor: pointer;
  background: #0c2154; border: 3px solid rgba(255, 255, 255, .14); transition: transform .15s; }
.km-avpick img { width: 100%; height: 100%; object-fit: cover; }
.km-avpick .sel { border-color: var(--km-gold-1); transform: scale(1.08); box-shadow: 0 0 0 3px rgba(255, 227, 106, .25); }
.km-err { color: #ffb3bd; font-weight: 800; font-size: 14px; margin-bottom: 10px; }

.km-modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.km-toast {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1100;
  background: #051233; border: 1.5px solid var(--km-line); padding: 8px 18px; border-radius: 999px; font-weight: 800; font-size: 14px;
}

/* the QR sheet */
.km-share-qr { background: #fff; border-radius: 18px; padding: 14px; color: var(--km-ink); margin: 14px 0; }
.km-share-qr img  { width: min(calc(var(--dvw, 1vw) * 62), 240px); height: min(calc(var(--dvw, 1vw) * 62), 240px); display: block; margin: 0 auto; image-rendering: pixelated; }
.km-share-qr b    { display: block; direction: ltr; font-size: 30px; font-weight: 900; letter-spacing: 2px; line-height: 1.2; margin-top: 6px; }
.km-share-qr span { font-size: 13px; font-weight: 800; color: #7a5200; }
.km-share-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.km-share-acts > * { display: flex; flex-direction: column; align-items: center; gap: 6px; border: none; background: none; color: #fff;
  cursor: pointer; font-family: 'Cairo', sans-serif; font-size: 12px; font-weight: 800; text-decoration: none; }
.km-share-acts i { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #13449a, #0a2a6a); border: 1.5px solid var(--km-line); }
.km-share-acts i svg { width: 24px; height: 24px; }
.km-share-acts .wa i { background: linear-gradient(180deg, #3ddc7d, #17a352); border-color: #8ff0b5; }
