:root {
  --bg: #1a2160;
  --card: #fff9eb;
  --tx: #241454;
  --ac: #ffb300;
  --ok: #2bb673;
  --bad: #e5484d;
  --s1: 6px;
  --s2: 10px;
  --s3: 16px;
  --s4: 24px;
  --s5: 32px;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  font-family: "Lilita One", "Trebuchet MS", system-ui, sans-serif;
  color: var(--tx);
}

canvas#cv {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 3D Rendered Icon Helper */
.gi {
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

/* Top HUD & Control Bar */
#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 max(72px, env(safe-area-inset-right, 0px));
  max-width: 100vw;
  box-sizing: border-box;
  color: #fff;
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 20px);
  text-shadow: 0 2px 3px #0009;
  flex-wrap: wrap;
  z-index: 4;
  pointer-events: none;
}

#hud span {
  background: rgba(20, 26, 74, 0.88);
  border: 3.5px solid #241454;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  border-radius: 99px;
  padding: 6px 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.top-bar-right {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: max(14px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
}

#sb, #fb, #cfg-btn {
  width: auto !important;
  min-height: 42px !important;
  margin: 0 !important;
  font-size: clamp(12px, 1.25vw, 15px) !important;
  font-family: 'Nunito', sans-serif !important;
  font-weight: 900 !important;
  padding: 6px 14px !important;
  border-radius: 999px !important;
  border: 2.5px solid #241454 !important;
  box-shadow: 0 3px 0 #241454, inset 0 1px 0 rgba(255, 255, 255, 0.45) !important;
  gap: 6px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.12s ease, filter 0.15s ease;
}

#sb:hover, #fb:hover, #cfg-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

#sb:active, #fb:active, #cfg-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #241454 !important;
}

#mb {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Race Progress Bar & Rule Banner */
#rb, #rl {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}

#rb {
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  width: min(68vw, 900px);
  height: 34px;
  background: rgba(15, 20, 58, 0.82);
  border: 4px solid #241454;
  border-radius: 20px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

#rb:empty, #rl:empty {
  display: none;
}

#rb::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 50% / 8px 8px;
  border: 1.5px solid #fff;
}

.rd {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  color: #fff;
  font-size: 14px;
  font-style: normal;
  display: grid;
  place-items: center;
  transition: left 0.5s ease;
}

.rd.ld {
  width: 36px;
  height: 36px;
  z-index: 2;
  border-color: #ffd54f;
  box-shadow: 0 0 12px #ffd54f;
}

#rl {
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  background: rgba(20, 26, 74, 0.88);
  border: 3.5px solid #241454;
  color: #fff;
  border-radius: 99px;
  padding: 6px 20px;
  font-size: clamp(15px, 1.7vw, 20px);
  white-space: nowrap;
}

body.ifp #rl {
  top: calc(env(safe-area-inset-top, 0px) + 110px);
}

/* Overlay & Menu Containers */
#ov {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  z-index: 10;
}

.mn {
  pointer-events: auto;
  text-align: center;
  width: 100%;
  max-width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vh, 18px);
  padding: 10px 0;
  box-sizing: border-box;
}

.mn > *:first-child:last-child {
  margin: auto 0;
}

/* 3D Game Logo */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.6vw, 16px);
  transform: rotate(-2.5deg);
  margin-bottom: 4px;
  max-width: 98vw;
}

.logo span {
  font-size: clamp(38px, 9.5vw, 136px);
  line-height: 0.95;
  color: #ffd23f;
  -webkit-text-stroke: clamp(4px, 1vw, 13px) #241454;
  paint-order: stroke fill;
  text-shadow: 0 clamp(4px, 0.9vw, 10px) 0 #241454;
}

.logo .l2 {
  color: #ff5fa2;
}

.logo b {
  font-weight: 400;
  font-size: clamp(22px, 5.2vw, 72px);
  background: linear-gradient(180deg, #5ee08f, #21b25e);
  color: #fff;
  border: clamp(3px, 0.6vw, 6px) solid #241454;
  border-radius: 50%;
  width: 1.85em;
  height: 1.85em;
  display: grid;
  place-items: center;
  transform: rotate(10deg);
  text-shadow: 0 3px 0 #241454;
  box-shadow: 0 6px 0 #241454, inset 0 3px 0 #fff5;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: clamp(14px, 2.4vw, 24px);
  font-weight: 900;
  background: rgba(24, 12, 54, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 7px 22px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin-bottom: 12px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.02em;
  max-width: 92vw;
  text-align: center;
}

/* 3D Arcade Buttons */
button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 12px 20px;
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 800;
  background: linear-gradient(180deg, #ffca28, #ffb300);
  color: #2b1d00;
  cursor: pointer;
  border: 3.5px solid #241454;
  box-shadow: 0 5px 0 #241454, inset 0 3px 0 #fff6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s ease, filter 0.15s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
}

button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #241454;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.bad {
  background: linear-gradient(180deg, #ff6b6b, #e5484d);
  color: #fff;
}

button.ok {
  background: linear-gradient(180deg, #5ee08f, #2bb673);
  color: #fff;
}

.gb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 14px);
  width: min(92vw, 520px);
  min-height: clamp(56px, 8vh, 78px);
  margin: 0;
  font-size: clamp(21px, 3.4vw, 38px);
  color: #fff;
  letter-spacing: 0.04em;
  padding: 12px 28px;
  border: clamp(3.5px, 0.5vw, 5.5px) solid #241454;
  border-radius: clamp(18px, 2.5vw, 26px);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.42);
  box-shadow: 0 8px 0 #241454, inset 0 5px 0 rgba(255, 255, 255, 0.35);
  touch-action: manipulation;
}

.gb:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

.gb:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #241454, inset 0 4px 0 rgba(255, 255, 255, 0.25);
}

.gb.s {
  width: 100%;
  min-height: clamp(52px, 6.5vh, 64px);
  font-size: clamp(18px, 2.2vw, 28px);
  padding: 10px 20px;
  border-width: 4px;
  border-radius: 18px;
  gap: 10px;
  box-shadow: 0 5px 0 #241454, inset 0 4px 0 rgba(255, 255, 255, 0.32);
}

.g-a { background: linear-gradient(180deg, #5ee08f, #1fa855); }
.g-b { background: linear-gradient(180deg, #ffb347, #f56a00); }
.g-c { background: linear-gradient(180deg, #5fb4ff, #2568c9); }
.g-d { background: linear-gradient(180deg, #c58bff, #7c3aed); }
.gb.alt {
  background: linear-gradient(180deg, #cfd8dc, #90a4ae);
  color: #241454;
  text-shadow: none;
}

.bk {
  background: rgba(20, 26, 74, 0.94);
  border: 3.5px solid #241454;
  box-shadow: 0 4px 0 #241454;
  border-radius: 99px;
  color: #fff;
  font-size: clamp(14px, 1.4vw, 17px);
  padding: 8px 24px;
  min-height: 42px;
  margin: 14px auto 6px;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  z-index: 5;
}

/* Main Menu Actions Stack (Juicy Arcade Buttons) */
.menu-action-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 16px);
  width: min(92vw, 490px);
  margin: 4px auto 0;
}

.menu-action-stack.single-btn {
  width: min(92vw, 540px);
  margin: 16px auto 0;
}

.menu-action-btn {
  width: 100% !important;
  min-height: clamp(64px, 8.5vh, 78px) !important;
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  align-items: center !important;
  gap: clamp(12px, 2vw, 20px) !important;
  padding: 8px clamp(16px, 2.2vw, 24px) !important;
  border: clamp(3.5px, 0.4vw, 5px) solid #241454 !important;
  border-radius: clamp(18px, 2.5vw, 24px) !important;
  text-align: left !important;
  box-shadow: 0 7px 0 #241454, 0 12px 24px rgba(0, 0, 0, 0.28), inset 0 3px 0 rgba(255, 255, 255, 0.4) !important;
  transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.2), filter 0.15s ease, box-shadow 0.15s ease !important;
  cursor: pointer !important;
  position: relative !important;
  overflow: hidden !important;
  touch-action: manipulation !important;
}

.menu-action-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0));
  border-radius: inherit;
  pointer-events: none;
}

.menu-action-btn:hover {
  transform: translateY(-3px) scale(1.02) !important;
  filter: brightness(1.06) !important;
  box-shadow: 0 9px 0 #241454, 0 16px 28px rgba(0, 0, 0, 0.32) !important;
}

.menu-action-btn:active {
  transform: translateY(4px) !important;
  box-shadow: 0 3px 0 #241454, inset 0 3px 0 rgba(0, 0, 0, 0.2) !important;
}

.menu-action-btn.ifp-hero-btn {
  min-height: clamp(80px, 11vh, 96px) !important;
  background: linear-gradient(180deg, #10b981 0%, #059669 48%, #047857 100%) !important;
  border: clamp(4px, 0.45vw, 5.5px) solid #022c22 !important;
  border-radius: clamp(22px, 2.8vw, 30px) !important;
  box-shadow: 0 9px 0 #022c22, 0 18px 36px rgba(4, 120, 87, 0.45), inset 0 3px 0 rgba(255, 255, 255, 0.5) !important;
  gap: clamp(14px, 2.2vw, 24px) !important;
  padding: 10px clamp(20px, 2.6vw, 30px) !important;
}

.menu-action-btn.ifp-hero-btn:hover {
  transform: translateY(-4px) scale(1.025) !important;
  box-shadow: 0 12px 0 #022c22, 0 22px 42px rgba(4, 120, 87, 0.55), inset 0 3px 0 rgba(255, 255, 255, 0.6) !important;
  filter: brightness(1.08) !important;
}

.menu-action-btn.ifp-hero-btn:active {
  transform: translateY(4px) !important;
  box-shadow: 0 3px 0 #022c22, inset 0 3px 0 rgba(0, 0, 0, 0.25) !important;
}

.menu-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.32));
  flex-shrink: 0;
}

.menu-btn-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-btn-title {
  font-family: 'Lilita One', cursive, sans-serif;
  font-size: clamp(22px, 3.2vw, 30px);
  color: #ffffff;
  letter-spacing: 0.03em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.42);
  line-height: 1.05;
}

.menu-btn-sub {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(12px, 1.35vw, 15px);
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.01em;
}

/* Game Modal Frame (.bd & #ov .card) */
.bd, #ov .card {
  pointer-events: auto;
  background: #fff9eb;
  color: #241454;
  border: clamp(3.5px, 0.4vw, 5px) solid #241454;
  border-radius: clamp(20px, 2.5vw, 28px);
  box-shadow: 0 8px 0 #241454, 0 18px 40px rgba(0, 0, 0, 0.42);
  padding: clamp(20px, 2.4vw, 30px) clamp(16px, 2.2vw, 26px) clamp(16px, 1.8vw, 22px);
  width: min(95vw, 680px);
  margin: 18px auto 10px;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 16px);
  text-align: left;
  animation: sl 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  box-sizing: border-box;
  position: relative;
}

/* Landscape 2-Grid Setup & Lobby Board - Pas, Proporsional & Rapi */
.bd.bd-land {
  width: min(96vw, 1200px);
  max-height: min(90vh, 740px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ffb347 rgba(36, 20, 84, 0.1);
  margin: 16px auto 10px;
  padding: clamp(20px, 2vh, 26px) clamp(16px, 1.8vw, 24px) 14px;
  gap: clamp(8px, 1.2vh, 14px);
  display: flex;
  flex-direction: column;
}

.modal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  position: relative;
  margin-top: -6px;
  margin-bottom: 2px;
}

.modal-header-bar > h2 {
  margin: 0 !important;
}

.modal-close-pill {
  background: #fff;
  border: 2.5px solid #241454;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 17px;
  font-weight: 900;
  color: #241454;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 0 #241454;
  transition: transform 0.1s, background 0.15s, color 0.15s;
  flex-shrink: 0;
  margin-left: auto;
}

.modal-close-pill:hover {
  background: #ff6b6b;
  color: #fff;
  transform: scale(1.08);
}

.modal-footer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding-top: 4px;
  margin-top: auto;
}

.bk-inline {
  background: rgba(20, 26, 74, 0.95);
  border: 3px solid #241454;
  box-shadow: 0 4px 0 #241454;
  border-radius: 99px;
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(13px, 1.3vw, 16px);
  font-weight: 800;
  padding: 8px 24px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  touch-action: manipulation;
}

.bk-inline:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.bk-inline:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #241454;
}

.bd.bd-land::-webkit-scrollbar {
  width: 8px;
}
.bd.bd-land::-webkit-scrollbar-track {
  background: rgba(36, 20, 84, 0.08);
  border-radius: 99px;
}
.bd.bd-land::-webkit-scrollbar-thumb {
  background: #ffb347;
  border-radius: 99px;
  border: 2px solid #241454;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(10px, 1.4vw, 18px);
  align-items: stretch;
  width: 100%;
}

@media (max-width: 1024px) {
  .setup-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .bd.bd-land {
    width: min(96vw, 720px);
    max-height: none;
    margin: 20px auto 12px;
  }
}
  }
}

#ov .card {
  text-align: center;
  align-items: center;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bd > h2, .modal-ribbon {
  align-self: center;
  margin: -48px auto 4px !important;
  width: fit-content;
  max-width: 90vw;
  font-weight: 400;
  background: linear-gradient(180deg, #ff70a6, #f73b82);
  color: #fff;
  border: clamp(3px, 0.4vw, 4.5px) solid #241454;
  border-radius: 18px;
  padding: 6px clamp(18px, 2.5vw, 32px);
  font-size: clamp(18px, 2.2vw, 28px);
  text-shadow: 0 3px 0 #241454;
  box-shadow: 0 5px 0 #241454, inset 0 3px 0 #fff5;
  transform: rotate(-1.2deg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  box-sizing: border-box;
  z-index: 2;
}

/* Section Cards Inside Setup */
.ed-card {
  background: #ffffff;
  border: 3.5px solid #241454;
  border-radius: 20px;
  padding: clamp(10px, 1.4vh, 16px) clamp(12px, 1.4vw, 18px);
  box-shadow: 0 5px 0 rgba(36, 20, 84, 0.12);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 10px);
  height: 100%;
  box-sizing: border-box;
}

.ed-title {
  font-size: clamp(16px, 1.6vw, 20px);
  color: #241454;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 2.5px dashed rgba(36, 20, 84, 0.16);
}

.step-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffb347, #f56a00);
  color: #fff;
  border: 2.5px solid #241454;
  box-shadow: 0 2.5px 0 #241454;
  display: inline-grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  flex-shrink: 0;
}

/* Tahap 1: 3D Character Selection Grid & Cards */
.char-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1.4vw, 14px);
  flex: 1;
}

.char-card {
  border: clamp(2.5px, 0.4vw, 3.5px) solid #241454;
  border-radius: clamp(14px, 2vw, 20px);
  padding: clamp(8px, 1.2vw, 14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: clamp(4px, 0.8vh, 8px);
  box-shadow: 0 4px 0 rgba(36, 20, 84, 0.14);
  transition: background-color 0.2s ease, transform 0.15s ease;
  min-width: 0;
}

.char-card.single {
  max-width: 420px;
  margin: auto;
  width: 100%;
  padding: 18px 20px;
  gap: 12px;
}

.char-card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: "Nunito", sans-serif;
  font-size: 16px;
  font-weight: 900;
  color: #241454;
}

.char-col-pill {
  color: #fff;
  padding: 3px 12px;
  border-radius: 99px;
  border: 2.5px solid #241454;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 0 2px 0 rgba(36, 20, 84, 0.22);
}

.char-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.char-arrow {
  width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  border-radius: 12px !important;
  border: 3px solid #241454 !important;
  background: #fff !important;
  color: #241454 !important;
  font-size: 16px !important;
  box-shadow: 0 3px 0 #241454 !important;
  flex-shrink: 0;
}

.char-arrow:hover {
  background: #ffe066 !important;
}

.char-avatar-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.char-avatar-img {
  width: clamp(64px, 14vw, 102px);
  height: clamp(64px, 14vw, 102px);
  object-fit: contain;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.3));
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  pointer-events: none;
}

.char-card.single .char-avatar-img {
  width: clamp(96px, 20vw, 135px);
  height: clamp(96px, 20vw, 135px);
}

.char-model-label {
  margin-top: -6px;
  color: #fff;
  border: 2.5px solid #241454;
  border-radius: 10px;
  padding: 3px 12px;
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 0 #241454;
  white-space: nowrap;
}

.char-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  justify-items: center;
  align-items: center;
  width: fit-content;
  max-width: 160px;
  margin: 3px auto 5px;
  padding: 2px 0;
}

.char-card.single .char-swatches {
  grid-template-columns: repeat(8, 1fr);
  max-width: 300px;
  gap: 8px;
}

.char-dot {
  width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 2.5px solid #241454 !important;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28) !important;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.char-dot:hover {
  transform: scale(1.18);
}

.char-dot.active {
  transform: scale(1.22);
  border: 2.5px solid #241454 !important;
  outline: 2.5px solid #ffffff;
  box-shadow: 0 0 0 4.5px #241454 !important;
}

.char-inp {
  width: 100% !important;
  min-height: clamp(38px, 5vh, 46px) !important;
  height: auto !important;
  padding: 6px 10px !important;
  font-size: clamp(14px, 1.6vw, 17px) !important;
  font-weight: 800 !important;
  border: 3px solid #241454 !important;
  border-radius: 12px !important;
  text-align: center;
  background: #fff !important;
  box-sizing: border-box;
}

/* Form Controls */
.ifg, .rw2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.4vw, 14px);
  align-items: end;
}

.bd input, .bd select, .bd textarea {
  width: 100%;
  margin: 0;
  min-height: clamp(38px, 4.4vh, 46px);
  border: 3px solid #241454;
  border-radius: 12px;
  background: #fff;
  color: #241454;
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(13px, 1.25vw, 15px);
  padding: 6px 12px;
  box-sizing: border-box;
}

.bd select {
  cursor: pointer;
}

.bd input.cd {
  font-family: "Lilita One", sans-serif;
  font-size: clamp(32px, 5vw, 50px);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  min-height: 58px;
}

.bd label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: clamp(12px, 1.15vw, 14px);
  font-weight: 900;
  color: #3b2866;
}

.setup-form-grid {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 10px);
  width: 100%;
}

/* Host / Guru Card in "BUAT RUANG" */
.host-role-card {
  background: #f7f3ff;
  border: 3px solid #241454;
  border-radius: 16px;
  padding: clamp(10px, 1.4vh, 14px) clamp(12px, 1.4vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 0 rgba(36, 20, 84, 0.1);
  margin-top: 2px;
}

.host-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.host-role-badge {
  background: linear-gradient(180deg, #ffb347, #f56a00);
  color: #fff;
  border: 2.5px solid #241454;
  border-radius: 99px;
  padding: 3px 10px;
  font-family: "Nunito", sans-serif;
  font-size: clamp(11.5px, 1.1vw, 13px);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 0 #241454;
}

.host-quota-badge {
  background: linear-gradient(180deg, #2bb673, #1e8751);
  color: #fff;
  border: 2.5px solid #241454;
  border-radius: 99px;
  padding: 3px 10px;
  font-family: "Nunito", sans-serif;
  font-size: clamp(11.5px, 1.1vw, 13px);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 0 #241454;
}

.host-info-desc {
  font-family: "Nunito", sans-serif;
  font-size: clamp(11.5px, 1.1vw, 13px);
  font-weight: 700;
  color: #3b2866;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.host-info-desc p {
  margin: 0;
}

.host-cam-note {
  background: #ffffff;
  border: 2px dashed #8b4de0;
  border-radius: 10px;
  padding: 6px 10px;
  color: #4a228a;
  font-size: clamp(11px, 1vw, 12px);
  font-weight: 800;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.35;
}

.setup-field-hint {
  font-size: 13px;
  color: #5a4980;
  font-weight: 700;
  margin-top: 2px;
}

/* Quick Topic Chips Grid */
.chip-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 540px) {
  .chip-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .ifg {
    grid-template-columns: 1fr;
  }
}

.chip {
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 16px !important;
  font-weight: 900 !important;
  background: #f5f2ff !important;
  color: #241454 !important;
  border: 3px solid #241454 !important;
  border-radius: 13px !important;
  padding: 10px 12px !important;
  min-height: 46px !important;
  box-shadow: 0 3px 0 #241454 !important;
  cursor: pointer;
  text-align: center;
}

.chip:hover {
  background: #ffe066 !important;
  transform: translateY(-1px);
}

/* Status Box & Question Deck */
.status-box {
  background: #f5f2ff;
  border: 3.5px solid #241454;
  border-radius: 15px;
  padding: 12px 16px;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: #241454;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.status-box.ready {
  background: #d3f5e2;
  color: #0d6832;
  border-color: #1b8a4b;
}

.status-box.status-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #f59e0b;
}

.ai-btn-row {
  display: flex;
  width: 100%;
}

.ai-btn-row #aib {
  width: 100% !important;
  min-height: clamp(54px, 7vh, 64px) !important;
  font-size: clamp(16px, 1.8vw, 20px) !important;
}

.btn-chip {
  background: #ede9fe;
  color: #5b21b6;
  border: 2px solid #7c3aed;
  border-radius: 99px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s;
  touch-action: manipulation;
}

.btn-chip:hover {
  background: #ddd6fe;
}

.btn-chip.alt {
  background: #f1f5f9;
  color: #334155;
  border-color: #64748b;
}

/* In-Game Custom Modal & Toast System */
#toast-container {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.game-toast {
  background: rgba(20, 14, 46, 0.94);
  color: #fff;
  border: 3px solid #7c3aed;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  padding: 10px 22px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(13px, 1.3vw, 16px);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: opacity 0.3s, transform 0.3s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.game-toast.success { border-color: #21b25e; }
.game-toast.warning { border-color: #f59e0b; }
.game-toast.error   { border-color: #ef4444; }
.game-toast.hide    { opacity: 0; transform: translateY(12px); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 30, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.18s ease;
}

.dialog-card {
  position: relative;
  background: #fff9eb;
  border: 4px solid #241454;
  border-radius: 24px;
  box-shadow: 0 10px 0 #241454, 0 20px 45px rgba(0, 0, 0, 0.45);
  width: min(94vw, 480px);
  padding: 32px 22px 20px;
  text-align: center;
  animation: dialogPop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  box-sizing: border-box;
}

.dialog-ribbon {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(-1deg);
  background: linear-gradient(180deg, #ff70a6, #f73b82);
  color: #fff;
  border: 3.5px solid #241454;
  border-radius: 14px;
  padding: 5px 20px;
  font-family: 'Lilita One', cursive, sans-serif;
  font-size: clamp(16px, 2vw, 20px);
  box-shadow: 0 4px 0 #241454, inset 0 2px 0 rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.dialog-ribbon.ribbon-warn {
  background: linear-gradient(180deg, #ffb347, #f56a00);
}

.dialog-ribbon.ribbon-bad {
  background: linear-gradient(180deg, #ff6b6b, #e5484d);
}

.dialog-body {
  margin: 10px 0 18px;
}

.dialog-msg {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 1.4vw, 17px);
  color: #241454;
  line-height: 1.5;
  margin: 0;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes dialogPop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.q-deck {
  max-height: 180px;
  overflow-y: auto;
  background: #f7f4eb;
  border: 3px solid #241454;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: "Nunito", system-ui, sans-serif;
}

.q-round-hdr {
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 8px;
  color: #fff;
  background: #241454;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-item {
  background: #fff;
  border: 2.5px solid #241454;
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.q-item-top {
  font-size: 15px;
  font-weight: 800;
  color: #1a2160;
  display: flex;
  gap: 8px;
}

.q-num {
  background: #ffb300;
  color: #2b1d00;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 13px;
  font-weight: 900;
  height: fit-content;
}

.q-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.q-opt {
  font-size: 13px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
}

.q-opt.ok {
  background: #d3f5e2;
  color: #0d6832;
  border: 1.5px solid #2bb673;
}

.q-opt.w {
  background: #f1f1f5;
  color: #555;
  border: 1.5px solid #ddd;
}

/* Lobby, Results & Podium */
.code {
  font-size: clamp(44px, 7.5vw, 84px);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #f56a00;
  background: #fff;
  border: 4.5px solid #241454;
  border-radius: 20px;
  padding: 6px 24px;
  box-shadow: 0 6px 0 #241454;
}

.pl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

.pl i {
  font-style: normal;
  font-family: "Nunito", sans-serif;
  font-size: 18px;
  font-weight: 900;
  background: #fff;
  border: 3.5px solid #241454;
  border-radius: 99px;
  padding: 7px 20px;
  box-shadow: 0 3px 0 rgba(36, 20, 84, 0.15);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rs {
  width: 100%;
  max-height: 44vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rs div {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 16px;
  border: 3.5px solid #241454;
  text-align: left;
  font-family: "Nunito", sans-serif;
  font-size: 18px;
  font-weight: 800;
}

.rs .ok {
  background: #d3f5e2;
  color: #0d6832;
}

.rs .no {
  background: #ffe3e3;
  color: #9b1c1c;
}

.rs i, .rs u {
  font-style: normal;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
}

.pd {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  margin: 10px 0 6px;
  width: 100%;
}

.pd div {
  width: min(28vw, 175px);
  border: 4.5px solid #241454;
  border-radius: 18px 18px 8px 8px;
  padding: 12px 10px;
  font-size: 18px;
  font-weight: 800;
  color: #241454;
  box-shadow: 0 6px 0 #241454, inset 0 4px 0 #fff6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

/* Gameplay Question Cards (#qp) */
#qp {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
}

#qp .card {
  width: 100%;
  max-width: min(94vw, 860px);
  background: #fff9eb;
  color: #241454;
  border: clamp(3.5px, 0.5vw, 4.5px) solid #241454;
  border-radius: clamp(16px, 2.5vw, 24px);
  padding: clamp(12px, 2vw, 20px) clamp(14px, 2.4vw, 24px);
  box-shadow: 0 8px 0 #241454;
  box-sizing: border-box;
}

.q {
  font-size: clamp(18px, 3.2vw, 38px);
  font-weight: 800;
  text-align: center;
  margin-bottom: clamp(8px, 1.6vh, 14px);
  line-height: 1.25;
}

.o {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1.4vw, 12px);
}

body.ifp #qp {
  height: clamp(230px, 38vh, 420px);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  align-items: stretch;
}

body.ifp #qp > div {
  height: 100%;
  grid-template-rows: minmax(0, 1fr);
}

.ic, .ic *, #qp .card, #qp button {
  font-family: "Nunito", "Trebuchet MS", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.ic {
  background: #141a4a !important;
  color: #fff !important;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 8px;
  padding: clamp(6px, 1.2vw, 12px) !important;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
  border-radius: clamp(14px, 2vw, 20px) !important;
}

.ic b {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  opacity: 0.92;
  padding-bottom: 4px;
  border-bottom: 2px solid #ffffff22;
  font-size: clamp(12px, min(1.7vw, 2.6vh), 22px);
  font-weight: 800;
}

.iq {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0;
  min-height: 0;
  font-size: clamp(15px, min(2.2vw, 3.6vh), 34px);
  font-weight: 800;
  line-height: 1.18;
  color: #fff;
  text-wrap: balance;
}

.ic .o {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.ib {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  min-height: 0;
  padding: 4px 8px !important;
  border-radius: 12px !important;
  font-size: clamp(13px, min(1.6vw, 2.9vh), 26px) !important;
  font-weight: 900;
  line-height: 1.12;
  color: #2b1d00;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}

@supports (container-type: size) {
  .ic { container-type: size; }
  .ic b { font-size: clamp(12px, 5cqw, 22px); }
  .iq { font-size: clamp(15px, min(8.2cqw, 9.8cqh), 42px); }
  .ib { font-size: clamp(13px, min(6.2cqw, 8.4cqh), 30px) !important; }
  #qp > .card:not(.ic) { container-type: inline-size; }
  #qp .q { font-size: clamp(18px, 6cqw, 42px); }
  #qp .o button { font-size: clamp(15px, 4.4cqw, 30px); }
}

@keyframes sl {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
}

.shake {
  animation: sh 0.4s;
}

@keyframes sh {
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* =========================================================================
   RESPONSIVE DESIGN BREAKPOINTS: IFP (Large Touchscreen), Desktop, & Mobile
   ========================================================================= */

/* IFP (Interactive Flat Panel / 1080p, 2K, 4K Touchscreens in Classrooms) */
@media (min-width: 1400px) and (min-height: 780px) {
  #hud {
    font-size: 18px;
    gap: 14px;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
  }
  #hud span {
    padding: 6px 18px;
    font-size: 18px;
  }
  #sb, #fb {
    min-height: 48px !important;
    font-size: 16px !important;
    padding: 6px 16px !important;
    border-radius: 16px !important;
  }
  .bd.bd-land {
    max-width: 1320px;
    max-height: calc(100vh - 84px);
    padding: 16px 26px 14px;
    gap: 10px;
  }
  .setup-grid {
    gap: 16px;
  }
  .ed-card {
    padding: 14px 18px;
    border-radius: 20px;
    gap: 8px;
  }
  .ed-title {
    font-size: 20px;
  }
  .step-badge {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .bd input, .bd select, .bd textarea {
    min-height: 42px;
    font-size: 16px;
    padding: 6px 12px;
    border-radius: 12px;
  }
  .bd label {
    font-size: 14px;
    gap: 3px;
  }
  .setup-field-hint {
    font-size: 12px;
  }
  .gb.s {
    min-height: 50px;
    font-size: 22px;
  }
  .status-box {
    font-size: 15px;
    padding: 8px 14px;
  }
  .bk {
    min-height: 40px;
    font-size: 15px;
    padding: 6px 20px;
    margin: 4px auto 10px;
  }
  body.ifp #qp {
    height: 38vh;
    max-height: 420px;
  }
  .ic {
    padding: 14px !important;
    border-radius: 22px !important;
  }
  .ic b {
    font-size: 20px;
  }
  .iq {
    font-size: 26px;
  }
  .ib {
    font-size: 22px !important;
    min-height: 54px !important;
  }
}

/* Mobile Devices (Portrait & Compact Viewports) */
@media (max-width: 600px) {
  #hud {
    padding: 0 54px;
    gap: 6px;
    font-size: 12px;
  }
  #hud span {
    padding: 4px 10px;
    font-size: 12px;
    border-width: 2.5px;
  }
  #sb, #fb {
    min-height: 38px !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    border-radius: 12px !important;
    border-width: 3px !important;
  }
  #sb span, #fb span {
    font-size: 11.5px;
  }
  .bd {
    margin: 18px auto 12px;
    padding: 18px 12px 14px;
    border-radius: 18px;
    border-width: 3.5px;
  }
  .bd.bd-land {
    padding: 18px 12px 14px;
    gap: 14px;
  }
  .modal-ribbon, .bd > h2 {
    font-size: 19px !important;
    padding: 5px 16px !important;
    margin: -42px auto 2px !important;
    border-radius: 14px !important;
    border-width: 3.5px !important;
  }
  .ed-card {
    padding: 14px 10px;
    border-radius: 16px;
    border-width: 3px;
    gap: 12px;
  }
  .ed-title {
    font-size: 17px;
    gap: 8px;
  }
  .step-badge {
    width: 28px;
    height: 28px;
    font-size: 15px;
    border-radius: 8px;
    border-width: 2.5px;
  }
  .ifg, .rw2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .bd input, .bd select, .bd textarea {
    min-height: 46px;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 12px;
    border-width: 3px;
  }
  .bd label {
    font-size: 13.5px;
    gap: 4px;
  }
  .setup-field-hint {
    font-size: 11.5px;
  }
  .gb.s {
    min-height: 50px;
    font-size: 17px;
    border-radius: 15px;
    padding: 8px 14px;
  }
  .status-box {
    font-size: 14px;
    padding: 9px 12px;
    border-radius: 12px;
    border-width: 2.5px;
  }
  .q {
    font-size: 18px;
    margin-bottom: 8px;
  }
  .o {
    gap: 8px;
  }
  .o button {
    min-height: 48px;
    font-size: 15px !important;
    padding: 6px 10px !important;
    border-radius: 12px !important;
  }
  .rs div {
    grid-template-columns: 32px 1fr auto auto;
    gap: 6px;
    font-size: 13.5px;
    padding: 6px 10px;
    border-radius: 12px;
    border-width: 2.5px;
  }
  .pd div {
    width: clamp(75px, 25vw, 105px);
    font-size: 13px;
    padding: 6px 4px;
    border-radius: 12px 12px 6px 6px;
  }
}

/* Mobile Landscape (e.g. 640x360 - 920x420) */
@media (max-height: 520px) {
  #ov {
    align-items: flex-start;
  }
  .mn {
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
    gap: 8px;
  }
  .bd {
    margin-top: 36px;
    margin-bottom: 24px;
  }
  .modal-ribbon, .bd > h2 {
    margin-top: -46px !important;
  }
  body.ifp #qp {
    height: 46vh;
  }
}

/* =========================================================================
   QUIZIZZ-STYLE LOBBY & FIREBASE CONFIG STYLING
   ========================================================================= */

/* Top Info Bar in Host Lobby */
.lobby-host-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #ffffff;
  border: 3px solid #241454;
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: 0 4px 0 rgba(36, 20, 84, 0.1);
}

.lobby-code-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #ffca28, #ffb300);
  border: 3px solid #241454;
  border-radius: 14px;
  padding: 4px 14px;
  box-shadow: 0 3px 0 #241454;
  color: #241454;
}

.lobby-code-badge small {
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.lobby-code-badge b {
  font-family: "Lilita One", sans-serif;
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: 0.16em;
  color: #241454;
}

.copy-pill-btn {
  background: #f0ebff !important;
  color: #4a228a !important;
  border: 2.5px solid #241454 !important;
  border-radius: 12px !important;
  font-size: 13px !important;
  font-weight: 900 !important;
  padding: 6px 12px !important;
  min-height: 36px !important;
  box-shadow: 0 2.5px 0 #241454 !important;
  cursor: pointer;
}

.copy-pill-btn:hover {
  background: #ffd54f !important;
}

.lobby-instructions {
  font-family: "Nunito", sans-serif;
  font-size: clamp(12px, 1.25vw, 14px);
  font-weight: 700;
  color: #3b2866;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lobby-instructions b {
  color: #d9480f;
}

.lobby-status-tag {
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 99px;
  border: 2px solid #241454;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.lobby-status-tag.online {
  background: #2bb673;
  color: #fff;
}
.lobby-status-tag.local {
  background: #ffb300;
  color: #241454;
}

/* Two-column layout in Host Lobby */
.lobby-split-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(10px, 1.4vw, 16px);
  align-items: stretch;
  width: 100%;
}

@media (max-width: 960px) {
  .lobby-split-grid {
    grid-template-columns: 1fr;
  }
}

/* Live Student Roster Panel */
.student-roster-pane {
  background: #ffffff;
  border: 3.5px solid #241454;
  border-radius: 20px;
  padding: clamp(12px, 1.6vh, 18px) clamp(12px, 1.6vw, 18px);
  box-shadow: 0 5px 0 rgba(36, 20, 84, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  box-sizing: border-box;
}

.student-roster-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 2.5px dashed rgba(36, 20, 84, 0.16);
  font-family: "Lilita One", sans-serif;
  font-size: clamp(17px, 1.8vw, 21px);
  color: #241454;
}

.student-count-pill {
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 900;
  background: #e0f2fe;
  color: #0369a1;
  border: 2px solid #241454;
  border-radius: 99px;
  padding: 3px 10px;
}

.student-list-container {
  flex: 1;
  min-height: 200px;
  max-height: 380px;
  overflow-y: auto;
  background: #fbf9f4;
  border: 2.5px solid #241454;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  width: 100%;
}

.student-card {
  background: #ffffff;
  border: 2.5px solid #241454;
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2.5px 0 rgba(36, 20, 84, 0.12);
  position: relative;
  animation: sl 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(36, 20, 84, 0.18);
}

.student-avatar-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: grid;
  place-items: center;
  font-family: "Lilita One", sans-serif;
  font-size: 15px;
  border: 2px solid #241454;
  flex-shrink: 0;
}

.student-name {
  font-family: "Nunito", sans-serif;
  font-size: 13.5px;
  font-weight: 800;
  color: #241454;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: left;
}

.kick-btn {
  width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: #e5484d !important;
  color: #fff !important;
  border: 1.5px solid #241454 !important;
  font-size: 11px !important;
  box-shadow: 0 1.5px 0 #241454 !important;
  display: inline-grid !important;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.kick-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.lobby-empty-radar {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 14px;
  text-align: center;
}

.radar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  border: 3px solid #0284c7;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 6px rgba(2, 132, 199, 0.16);
  animation: radar-pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes radar-pulse {
  0% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.4); transform: scale(0.96); }
  70% { box-shadow: 0 0 0 14px rgba(2, 132, 199, 0); transform: scale(1.04); }
  100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); transform: scale(0.96); }
}

.empty-txt-bold {
  font-family: "Lilita One", sans-serif;
  font-size: 19px;
  color: #241454;
}

.empty-txt-sub {
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  color: #55447a;
  max-width: 320px;
  line-height: 1.4;
}

/* Student Waiting Room (Student Device) */
.student-lobby-box {
  background: #ffffff;
  border: 3.5px solid #241454;
  border-radius: 22px;
  padding: 16px 20px;
  box-shadow: 0 5px 0 rgba(36, 20, 84, 0.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

.student-badge-tag {
  background: linear-gradient(180deg, #ffd54f, #ffb300);
  border: 2.5px solid #241454;
  border-radius: 99px;
  padding: 5px 16px;
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  font-weight: 900;
  color: #241454;
  align-self: center;
  box-shadow: 0 2.5px 0 #241454;
}

.student-hero-banner {
  border: 3px solid #241454;
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(36, 20, 84, 0.1);
}

.student-hero-banner img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.25));
}

.student-hero-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
}

.student-hero-name {
  font-family: "Lilita One", sans-serif;
  font-size: 22px;
  color: #241454;
}

.student-hero-pill {
  color: #fff;
  border: 2px solid #241454;
  border-radius: 99px;
  padding: 2px 10px;
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 0 rgba(36, 20, 84, 0.18);
}

.student-wait-alert {
  background: #eef2ff;
  border: 2.5px solid #6366f1;
  border-radius: 14px;
  padding: 10px 14px;
  color: #312e81;
  font-family: "Nunito", sans-serif;
  font-size: 13.5px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.classmates-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.classmates-label {
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #4a3672;
}

/* Firebase Config Dialog */
.fb-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 58, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  box-sizing: border-box;
}

.fb-dialog-box {
  background: #fff9eb;
  border: 4px solid #241454;
  border-radius: 24px;
  box-shadow: 0 10px 0 #241454, 0 20px 45px rgba(0, 0, 0, 0.5);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  box-sizing: border-box;
  animation: sl 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.fb-dialog-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2.5px dashed rgba(36, 20, 84, 0.2);
  padding-bottom: 8px;
}

.fb-dialog-title {
  font-size: 20px;
  color: #241454;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.fb-close-btn {
  background: #ffffff !important;
  color: #241454 !important;
  border: 2px solid #241454 !important;
  border-radius: 50% !important;
  width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  font-size: 14px !important;
  box-shadow: 0 2px 0 #241454 !important;
  cursor: pointer;
}

.fb-dialog-desc {
  font-family: "Nunito", sans-serif;
  font-size: 13.5px;
  color: #4a3672;
  line-height: 1.45;
}

.fb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-family: "Nunito", sans-serif;
  font-size: 12.5px;
  font-weight: 900;
  border: 2px solid #241454;
  width: fit-content;
}

.fb-status-pill.active {
  background: #dcfce7;
  color: #15803d;
  border-color: #15803d;
}

.fb-status-pill.fallback {
  background: #fef3c7;
  color: #b45309;
  border-color: #b45309;
}

