/* الشاشة */
body { overflow: hidden; background: radial-gradient(circle at 50% 30%, #1d2350, #0b0d1e 70%); }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
.view {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5vh 2vw 5vh; gap: 2vh;
  background: radial-gradient(circle at 50% 30%, #1d2350, #0b0d1e 75%);
}
.view.over-game { background: rgba(10, 12, 30, .86); }
.title { font-size: clamp(30px, 4.4vw, 66px); font-weight: 900; text-shadow: 0 4px 0 rgba(0,0,0,.35); line-height: 1.2; }
.small-btn {
  font-size: 18px; font-weight: 700; padding: 6px 16px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff;
}
.big-btn {
  font-size: 30px; font-weight: 900; padding: 12px 46px; border: 0; border-radius: 18px;
  background: linear-gradient(#4ade80, #16a34a); color: #fff; box-shadow: 0 6px 0 #0d6b30;
}
.big-btn.secondary { background: linear-gradient(#64748b, #334155); box-shadow: 0 6px 0 #1e293b; }
.hint { opacity: .7; font-size: 18px; }

/* ---------- اللوبي ---------- */
.lobby-stage { display: flex; align-items: center; justify-content: center; gap: 2.5vw; width: 100%; flex: 1; min-height: 0; }
.slots { display: grid; grid-template-rows: repeat(4, 1fr); gap: 1.4vh; height: 100%; max-height: 72vh; width: min(22vw, 300px); }
.slot {
  display: flex; align-items: center; gap: 12px; padding: 6px 14px;
  border-radius: 20px; border: 2px dashed rgba(255,255,255,.18);
  background: rgba(255,255,255,.04); min-height: 0;
}
.slot canvas { flex: none; }
.slot .info { display: flex; flex-direction: column; min-width: 0; }
.slot .label { font-size: clamp(16px, 1.6vw, 24px); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .st { font-size: clamp(13px, 1.2vw, 18px); font-weight: 700; opacity: .85; }
.slot.ready { border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.slot.ready .st { color: #4ade80; opacity: 1; }
.slot.choosing { border: 2px dashed var(--c); }
.slot.choosing canvas { opacity: .4; }
.slot.choosing .st { color: #fbbf24; }
.slot.empty .ph {
  width: 64px; height: 64px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.25); flex: none;
}
.slot.empty .label { opacity: .4; font-weight: 400; }
.slot.off { filter: grayscale(.8); opacity: .6; }
.center-card {
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12);
  border-radius: 26px; padding: 2.4vh 2vw; display: flex; flex-direction: column; align-items: center; gap: 1vh;
}
.qr { background: #fff; padding: 12px; border-radius: 16px; line-height: 0; }
.qr img { width: min(34vh, 26vw); height: auto; display: block; image-rendering: pixelated; }
.code-label { font-size: 18px; opacity: .7; }
.room-code { font-size: clamp(44px, 6.5vw, 96px); font-weight: 900; letter-spacing: 10px; direction: ltr; color: #ffd84d; line-height: 1; }
.join-url { direction: ltr; font-size: 14px; opacity: .75; word-break: break-all; text-align: center; max-width: 34vw; }
.host-status { font-size: 15px; opacity: .8; }
.ready-bar {
  font-size: clamp(18px, 1.9vw, 28px); font-weight: 900; padding: 10px 30px; border-radius: 16px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.15); text-align: center;
}
.ready-bar.go { background: #16a34a; border-color: #4ade80; }
.countdown {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  font-size: 34vh; font-weight: 900; color: #fff; background: rgba(0,0,0,.45);
  text-shadow: 0 10px 0 rgba(0,0,0,.35);
}
.countdown span { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(1.8); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: .9; } }

/* ---------- الترتيب ---------- */
.rank-list { list-style: none; width: min(820px, 90vw); display: flex; flex-direction: column; gap: .7vh; }
.rank-list li {
  display: flex; align-items: center; gap: 14px; font-size: clamp(18px, 3vh, 26px); font-weight: 700;
  background: rgba(255,255,255,.07); border-radius: 14px; padding: .25vh 18px;
}
.rank-list li canvas { width: 5.5vh !important; height: 5.5vh !important; }
.rank-list .place { width: 46px; text-align: center; font-size: 30px; }
.rank-list .name { flex: 1; }
.rank-list .score { font-size: 30px; font-weight: 900; color: #ffd84d; }

.mini-join {
  position: fixed; top: 10px; left: 10px; z-index: 5; background: rgba(0,0,0,.5);
  border-radius: 12px; padding: 8px; font-size: 16px; text-align: center;
}
.mini-join #mini-qr { background: #fff; padding: 4px; border-radius: 6px; line-height: 0; margin-bottom: 4px; }
.mini-join #mini-qr img { width: 90px; height: 90px; image-rendering: pixelated; }

.sub-title { font-size: clamp(18px, 2vw, 30px); opacity: .75; font-weight: 700; }
.corner-btn { position: fixed; top: 14px; right: 14px; z-index: 12; }
.rank-list canvas { flex: none; }
.rank-list .pts { font-size: 22px; font-weight: 900; color: #4ade80; min-width: 60px; text-align: center; }
.rank-list .tot { font-size: 22px; font-weight: 700; opacity: .8; min-width: 80px; text-align: center; }
.rank-list .head { background: transparent; font-size: 16px; opacity: .6; padding: 0 18px; }

/* ---------- اختيار الألعاب ---------- */
.menu-top { display: flex; gap: 2.5vw; }
.menu-item {
  font-family: inherit; color: #fff; border: 4px solid transparent; border-radius: 24px; cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.menu-item.focus { border-color: #ffd84d; transform: scale(1.06); box-shadow: 0 0 0 6px rgba(255,216,77,.25), 0 10px 30px rgba(0,0,0,.4); }
.menu-item.mode {
  font-size: clamp(30px, 3.6vw, 56px); font-weight: 900; padding: 1.4vh 3.5vw; display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.menu-item.mode small { font-size: clamp(14px, 1.3vw, 20px); font-weight: 700; opacity: .85; }
.menu-item.play { background: linear-gradient(#4ade80, #15803d); box-shadow: 0 8px 0 #0d6b30; }
.menu-item.all { background: linear-gradient(#60a5fa, #1d4ed8); box-shadow: 0 8px 0 #1e3a8a; }
.cards { display: flex; flex-wrap: wrap; gap: 1.6vw; justify-content: center; max-width: 92vw; }
.card {
  background: rgba(255,255,255,.07); padding: 10px; width: clamp(180px, 17vw, 270px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.card canvas { width: 100%; aspect-ratio: 16 / 10; border-radius: 14px; background: #141a3a; display: block; }
.card .nm { font-size: clamp(18px, 1.6vw, 26px); font-weight: 900; }
.card .tag { font-size: 14px; opacity: .7; }

/* ---------- الشرح ---------- */
.ex-body { display: flex; gap: 3vw; align-items: center; justify-content: center; width: 100%; }
.demo { width: min(48vw, 78vh); aspect-ratio: 16 / 10; border-radius: 20px; background: #141a3a; border: 3px solid rgba(255,255,255,.15); }
.ex-rules { list-style: none; display: flex; flex-direction: column; gap: 1.4vh; max-width: 36vw; }
.ex-rules li { font-size: clamp(18px, 1.9vw, 30px); font-weight: 700; background: rgba(255,255,255,.07); border-radius: 14px; padding: 8px 16px; }
.ex-rules li::before { content: '• '; color: #ffd84d; }
.avatars { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.avatars .av { position: relative; display: flex; flex-direction: column; align-items: center; font-size: 15px; font-weight: 700; opacity: .45; }
.avatars .av.ok { opacity: 1; }
.avatars .av.ok::after { content: '✓'; position: absolute; top: 0; left: 4px; background: #16a34a; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 14px; }

#v-between { gap: 1.2vh; }
#v-between .title { font-size: clamp(26px, 5vh, 52px); }

/* ---------- النتيجة النهائية ---------- */
#v-final { gap: 1.5vh; }
.final-stage { display: flex; align-items: flex-end; justify-content: center; gap: 2.5vw; width: 100%; flex: 1; min-height: 0; padding-bottom: 2vh; }
.side-panel {
  width: min(24vw, 340px); align-self: center; list-style: none;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12); border-radius: 20px; padding: 1.4vh 1vw;
  display: flex; flex-direction: column; gap: .8vh;
}
.side-panel h3 { font-size: clamp(18px, 2.4vh, 26px); text-align: center; margin-bottom: .5vh; }
.side-panel .row { display: flex; align-items: center; gap: 10px; font-size: clamp(15px, 2.3vh, 22px); font-weight: 700; transition: opacity .3s, transform .3s; }
.side-panel .row .nm { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-panel .row .pl { width: 34px; text-align: center; opacity: .8; }
.side-panel .row .pt { color: #ffd84d; font-weight: 900; }
.side-panel .row.hide { opacity: 0; transform: translateY(10px); }
.side-panel .row canvas { flex: none; width: 4.6vh !important; height: 4.6vh !important; }
.final-rest:empty { visibility: hidden; }
.replay-panel { visibility: hidden; }
.replay-panel.show { visibility: visible; animation: slidein .5s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
.replay-panel .st { font-size: .9em; }
.replay-panel .st.wait { opacity: .6; }
.replay-panel .st.yes { color: #4ade80; }
.replay-panel .row.left .nm { text-decoration: line-through; color: #f87171; }
.replay-panel .st.no { color: #f87171; }
.podium { display: flex; align-items: flex-end; gap: 1.2vw; height: 100%; }
.pod { display: flex; flex-direction: column; align-items: center; width: min(14vw, 200px); }
.pod .who { display: flex; flex-direction: column; align-items: center; transition: opacity .4s; }
.pod .who canvas { width: 15vh !important; height: 15vh !important; }
.pod .nm { font-size: clamp(16px, 2.6vh, 28px); font-weight: 900; text-align: center; }
.pod .pt { font-size: clamp(16px, 2.4vh, 26px); font-weight: 900; color: #ffd84d; }
.pod .col {
  width: 100%; border-radius: 14px 14px 0 0; display: flex; align-items: flex-start; justify-content: center;
  font-size: 6vh; font-weight: 900; padding-top: 1vh; color: rgba(255,255,255,.9);
  box-shadow: inset 0 -10px 0 rgba(0,0,0,.2);
}
.pod.p1 .col { height: 30vh; background: linear-gradient(#fde047, #ca8a04); }
.pod.p2 .col { height: 21vh; background: linear-gradient(#e5e7eb, #9ca3af); }
.pod.p3 .col { height: 15vh; background: linear-gradient(#fdba74, #c2410c); }
.pod .who.hide { opacity: 0; }
.pod .mystery { font-size: 13vh; font-weight: 900; color: #ffd84d; line-height: 15vh; height: 15vh; text-shadow: 0 6px 0 rgba(0,0,0,.3); }
.pod .who.boom { animation: boom 1.1s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes boom { 0% { transform: scale(.2); opacity: 0; } 60% { transform: scale(1.35); opacity: 1; } 100% { transform: scale(1); } }
.pod.empty { visibility: hidden; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 25; pointer-events: none; }
