#leaderboard { flex: 0 0 auto; }
.lb-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding: 0 4px;
}
.lb-title {
  font-family: var(--naskh); font-weight: 700; font-size: 30px; color: var(--gold-2);
}
#lb-empty {
  color: var(--muted); font-size: 24px; line-height: 1.5;
  padding: 14px 16px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line);
}
#lb-rows { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
}
.lb-score {
  min-width: 92px; height: 54px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; color: #241806;
}
.lb-row.rank-1 .lb-score { background: linear-gradient(180deg, #F7E28A, #E2B84A); }
.lb-row.rank-2 .lb-score { background: linear-gradient(180deg, #E8EEF2, #B7C2C8); }
.lb-row.rank-3 .lb-score { background: linear-gradient(180deg, #E8B48A, #B87333); }
.lb-name { flex: 1; font-size: 28px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-medal {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #241806;
}
.lb-row.rank-1 .lb-medal { background: #E2B84A; }
.lb-row.rank-2 .lb-medal { background: #C5D0D6; }
.lb-row.rank-3 .lb-medal { background: #C4844A; }

#timer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 999px;
  background: rgba(6, 22, 20, 0.82); border: 1px solid var(--line);
}
#timer-bar {
  flex: 1; height: 14px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,0.08);
}
#timer-fill {
  height: 100%; width: 100%; transform-origin: right center;
  background: linear-gradient(90deg, #2F9E62, #E2B84A);
}
#timer-num {
  min-width: 72px; font-weight: 800; font-size: 40px; color: var(--gold-2);
  text-align: center; font-variant-numeric: tabular-nums;
}
#part {
  margin-inline-start: auto; color: var(--cream); font-size: 22px; font-weight: 700;
  background: rgba(226,184,74,0.12); border-radius: 999px; padding: 6px 12px;
  white-space: nowrap;
}
#part:empty { display: none; }
#conn { display: flex; align-items: center; gap: 6px; font-size: 18px; color: var(--muted); }
#conn .dot { width: 11px; height: 11px; border-radius: 50%; background: #888; }
#conn.ok .dot { background: #3CB56A; }
#conn.wait .dot { background: #E2B84A; }
#conn.down .dot { background: #C0392B; }

#welcome {
  flex: 0 0 auto; height: 0; overflow: hidden; opacity: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; border-radius: 16px;
  background: rgba(20, 48, 40, 0.92); border: 1px solid var(--line);
}
#welcome.on { height: 58px; opacity: 1; padding: 8px 14px; }
#welcome img, #welcome .ph {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #1B3A32; flex: 0 0 auto;
}
#welcome .txt { font-size: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#qcard {
  flex: 0 1 auto; min-height: 0; position: relative;
  padding: 22px 20px 18px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(18, 42, 36, 0.92), rgba(8, 24, 21, 0.88));
  border: 1px solid rgba(226,184,74,0.42);
  box-shadow: var(--glow), inset 0 1px 0 rgba(246,222,154,0.12);
}
#qcard .q-orn {
  position: absolute; inset: 10px; border-radius: 20px; pointer-events: none;
  border: 1px solid rgba(226,184,74,0.12);
}
#qmeta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
#qbadge {
  padding: 7px 16px; border-radius: 999px;
  font-weight: 800; font-size: 22px; color: #fff;
}
#qtopic {
  color: var(--gold-2); font-size: 22px; font-weight: 700;
  max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#qtopic:empty { display: none; }
#qtext {
  font-family: var(--naskh); font-weight: 700; font-size: 40px; line-height: 1.7;
  color: var(--paper); white-space: pre-wrap; overflow-wrap: anywhere;
}
#explain {
  display: none; margin-top: 12px;
  font-family: var(--naskh); font-size: 26px; line-height: 1.6;
  color: #D5EEDC; background: rgba(21, 53, 31, 0.7);
  border-radius: 16px; padding: 10px 12px;
}
#explain.on { display: block; }

#hint {
  flex: 0 0 auto; text-align: center;
  color: var(--gold-2); font-size: 24px; font-weight: 700;
}

#options { flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px;
  min-height: 82px; padding: 12px 14px; border-radius: 22px;
  background: rgba(7, 26, 22, 0.88);
  border: 1px solid rgba(226,184,74,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.opt .num {
  width: 58px; height: 58px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #F6DE9A, #C8962A);
  color: #241806; font-weight: 800; font-size: 30px;
  box-shadow: 0 4px 0 #7A5A16;
}
.opt .txt {
  flex: 1; font-family: var(--naskh); font-size: 30px; line-height: 1.5; font-weight: 600;
  color: var(--cream); overflow-wrap: anywhere;
}
#safe.reveal .opt { opacity: 0.34; }
#safe.reveal .opt.correct {
  opacity: 1; background: var(--ok-bg);
  border-color: #3CB56A;
  box-shadow: 0 0 0 1px #3CB56A, 0 0 20px rgba(60,181,106,0.22);
}
#safe.reveal .opt.correct .num { background: #3CB56A; color: #fff; box-shadow: none; }

#brand {
  flex: 0 0 auto; margin-top: auto;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 6px;
}
#brand::before {
  content: ''; width: 120px; height: 1px; margin-bottom: 8px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
#brand .logo { width: 52px; height: 52px; }
#brand .name { font-family: var(--naskh); font-weight: 700; font-size: 34px; color: var(--gold-2); }
#brand .tag { font-size: 20px; color: var(--muted); }

#safe.fit-compact #qtext { font-size: 32px; line-height: 1.55; }
#safe.fit-compact .opt { min-height: 68px; padding: 10px 12px; }
#safe.fit-compact .opt .txt { font-size: 26px; }
#safe.fit-compact .opt .num { width: 50px; height: 50px; font-size: 26px; }
#safe.fit-compact #hint { font-size: 21px; }
#safe.fit-compact .lb-name { font-size: 24px; }
#safe.fit-tight #qtext { font-size: 27px; line-height: 1.45; }
#safe.fit-tight .opt { min-height: 58px; padding: 8px 10px; gap: 8px; }
#safe.fit-tight .opt .txt { font-size: 23px; }
#safe.fit-tight .opt .num { width: 42px; height: 42px; font-size: 22px; }
#safe.fit-tight #hint { font-size: 19px; }
#safe.fit-tight #welcome.on { height: 48px; }
#safe.fit-tight #qcard { padding: 14px; }

#toast {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -24px);
  min-width: 360px; max-width: 760px; padding: 12px 22px; border-radius: 999px;
  background: rgba(47, 148, 86, 0.94); color: #fff; font-weight: 800; font-size: 30px;
  text-align: center; opacity: 0; pointer-events: none; z-index: 8;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#fastest {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -10px);
  width: 740px; padding: 24px 22px; border-radius: 28px; text-align: center;
  background: linear-gradient(180deg, #3C2C10, #1A1307);
  border: 2px solid #E2B84A; box-shadow: 0 0 30px rgba(226,184,74,0.28);
  opacity: 0; pointer-events: none; z-index: 9;
}
#fastest.on { opacity: 1; transform: translate(-50%, 0); }
#fastest .bless { font-family: var(--naskh); font-size: 30px; color: var(--gold-2); line-height: 1.65; margin-bottom: 12px; }
#fastest .who { display: flex; align-items: center; justify-content: center; gap: 12px; }
#fastest img, #fastest .ph { width: 72px; height: 72px; border-radius: 50%; background: #2A210C; object-fit: cover; }
#fastest .nm { font-size: 34px; font-weight: 800; }
#fastest .pts { font-size: 26px; color: var(--gold); }

#screens { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.screen {
  position: absolute; top: var(--m-top); right: var(--m-right); bottom: var(--m-bottom); left: var(--m-left);
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px; text-align: center;
  background: rgba(4, 17, 15, 0.78); border-radius: 28px; padding: 28px;
}
.screen.on { display: flex; }
.screen h2 { font-family: var(--naskh); font-size: 46px; color: var(--gold-2); line-height: 1.4; }
.screen p { font-size: 26px; color: var(--muted); line-height: 1.6; max-width: 720px; }
#ended-top { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

#guides { position: absolute; inset: 0; pointer-events: none; z-index: 20; display: none; }
body.guides #guides { display: block; }
.g-top, .g-bot, .g-left, .g-right { position: absolute; background: rgba(220, 50, 50, 0.22); }
.g-top { top: 0; left: 0; right: 0; height: var(--m-top); }
.g-bot { bottom: 0; left: 0; right: 0; height: var(--m-bottom); }
.g-left { top: var(--m-top); bottom: var(--m-bottom); left: 0; width: var(--m-left); }
.g-right { top: var(--m-top); bottom: var(--m-bottom); right: 0; width: var(--m-right); }
.g-lab {
  position: absolute; font-size: 20px; font-weight: 800; color: #ffd0d0;
  background: rgba(80,0,0,0.45); padding: 4px 8px; border-radius: 8px;
}
.g-top .g-lab { top: 16px; left: 50%; transform: translateX(-50%); }
.g-bot .g-lab { bottom: 16px; left: 50%; transform: translateX(-50%); }
.g-left .g-lab { top: 40%; right: 8px; writing-mode: vertical-rl; }
.g-right .g-lab { top: 40%; left: 6px; writing-mode: vertical-rl; }

#corner-btns {
  position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; z-index: 30;
  opacity: 0; transition: opacity 0.3s;
}
body.show-ui #corner-btns, body.debug-open #corner-btns { opacity: 1; }
.btn {
  font-family: var(--ui); font-weight: 700; font-size: 20px; color: var(--cream);
  background: rgba(8,28,24,0.92); border: 1px solid rgba(226,184,74,0.4);
  border-radius: 12px; padding: 8px 12px; cursor: pointer;
}
.btn.sm { font-size: 18px; padding: 6px 10px; }
#audio-hint { display: none; font-size: 16px; color: var(--gold-2); align-self: center; }
body.need-audio #audio-hint { display: block; }
