/* ChaoGames UI layer */
:root {
  --cg-navy: #002a50;
  --cg-blue: #009cff;
  --cg-blue-dark: #0084d8;
  --cg-ink: #082643;
  --cg-muted: #5b7891;
}
.cg-wrap { width: 100%; max-width: 1031px; margin: 0 auto 18px; }
@media (min-width: 768px) { .cg-wrap { margin-bottom: 22px; } }

.cg-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b1220;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px -18px rgba(0, 42, 80, 0.55);
}
.cg-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cg-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0b1220; z-index: 2; }
.cg-launch {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(8, 38, 67, 0.05), rgba(8, 38, 67, 0.45)); border: 0; cursor: pointer;
}
.cg-launch span {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: var(--cg-navy); font-family: var(--font-baloo), system-ui, sans-serif;
  font-weight: 800; font-size: clamp(14px, 2vw, 19px); padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 12px 26px -10px rgba(0, 42, 80, 0.6); transition: transform 0.15s ease;
}
.cg-launch:hover span { transform: scale(1.04); }
.cg-launch svg { width: 20px; height: 20px; }
.cg-loading {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center;
  color: #cfe6f7; font: 600 14px/1.4 var(--font-poppins), system-ui, sans-serif; letter-spacing: 0.04em;
}
.cg-loading::after {
  content: ""; width: 26px; height: 26px; margin-left: 12px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: var(--cg-blue); animation: cg-spin 0.8s linear infinite;
}
@keyframes cg-spin { to { transform: rotate(360deg); } }

/* control bar */
.cg-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--cg-navy); color: #fff; border-radius: 14px; margin-top: 10px;
  padding: 10px 12px; box-shadow: 0 12px 28px -16px rgba(0, 42, 80, 0.7);
}
.cg-bar__title { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-left: 4px; }
.cg-bar__name { font-family: var(--font-baloo), system-ui, sans-serif; font-weight: 800; font-size: clamp(15px, 2.1vw, 19px); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-bar__by { font-size: 12px; color: #a9c8e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.cg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 38px; height: 38px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff; transition: background 0.15s ease, transform 0.15s ease;
}
.cg-btn:hover { background: rgba(255, 255, 255, 0.26); }
.cg-btn:active { transform: scale(0.94); }
.cg-btn svg { width: 18px; height: 18px; }
.cg-btn.is-on { background: var(--cg-blue); }
.cg-btn--wide { width: auto; padding: 0 14px; font-weight: 700; font-size: 13px; }

/* bigger mode (not the real Fullscreen API) */
.cg-shell.cg-big {
  position: fixed; inset: 0; z-index: 99990; width: 100vw; height: 100vh; max-width: none;
  aspect-ratio: auto; border-radius: 0; box-shadow: none;
}
.cg-shell.cg-big .cg-launch { display: none; }
.cg-shell.cg-big .cg-exit {
  position: absolute; top: 14px; right: 14px; z-index: 99999; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.6); color: #fff; border: 0; border-radius: 999px; padding: 9px 15px;
  font: 700 13px var(--font-poppins), system-ui, sans-serif; cursor: pointer;
}
.cg-exit { display: none; }
body.cg-big-open { overflow: hidden; }

/* toast */
.cg-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 24px); z-index: 99999;
  background: var(--cg-navy); color: #fff; padding: 11px 18px; border-radius: 999px;
  font: 600 13px var(--font-poppins), system-ui, sans-serif; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; box-shadow: 0 16px 34px -14px rgba(0, 42, 80, 0.8);
}
.cg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* modal */
.cg-overlay {
  position: fixed; inset: 0; z-index: 99995; background: rgba(6, 26, 46, 0.55);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.cg-overlay[hidden] { display: none; }
.cg-panel {
  width: 100%; max-width: 460px; max-height: 86vh; overflow: auto; background: #fff; color: var(--cg-ink);
  border-radius: 20px; padding: 20px; box-shadow: 0 30px 70px -30px rgba(0, 42, 80, 0.8);
  font-family: var(--font-poppins), system-ui, sans-serif;
}
.cg-panel--wide { max-width: 720px; }
.cg-panel h3 { font-family: var(--font-baloo), system-ui, sans-serif; font-weight: 800; font-size: 22px; margin: 0 0 4px; color: var(--cg-navy); }
.cg-panel p.cg-sub { margin: 0 0 16px; color: var(--cg-muted); font-size: 13px; }
.cg-x { float: right; border: 0; background: #eef6fc; color: var(--cg-navy); width: 32px; height: 32px; border-radius: 999px; cursor: pointer; font-size: 17px; line-height: 1; }
.cg-x:hover { background: #dcecf8; }
.cg-field { display: block; margin-bottom: 12px; }
.cg-field span { display: block; font-size: 12px; font-weight: 700; color: var(--cg-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.cg-field input {
  width: 100%; border: 1.5px solid #d7e8f5; border-radius: 12px; padding: 11px 13px; font: 500 14px var(--font-poppins), system-ui, sans-serif;
  color: var(--cg-ink); background: #f8fcff; outline: none;
}
.cg-field input:focus { border-color: var(--cg-blue); background: #fff; }
.cg-primary {
  width: 100%; border: 0; border-radius: 999px; padding: 13px 18px; cursor: pointer; margin-top: 4px;
  background: var(--cg-navy); color: #fff; font: 800 15px var(--font-baloo), system-ui, sans-serif;
}
.cg-primary:hover { background: #01406e; }
.cg-primary[disabled] { opacity: 0.6; cursor: default; }
.cg-switch { margin-top: 14px; text-align: center; font-size: 13px; color: var(--cg-muted); }
.cg-switch button { border: 0; background: none; color: var(--cg-blue); font-weight: 700; cursor: pointer; padding: 0 3px; }
.cg-err { color: #d43c3c; font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* search */
.cg-searchbox { display: flex; gap: 8px; margin-bottom: 14px; }
.cg-searchbox input {
  flex: 1; border: 1.5px solid #d7e8f5; border-radius: 999px; padding: 12px 18px; font: 500 15px var(--font-poppins), system-ui, sans-serif;
  background: #f8fcff; outline: none; color: var(--cg-ink);
}
.cg-searchbox input:focus { border-color: var(--cg-blue); background: #fff; }
.cg-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.cg-result { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--cg-ink); }
.cg-result img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 13px; background: #eaf4fb; }
.cg-result span { font: 700 12px/1.25 var(--font-baloo), system-ui, sans-serif; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cg-empty { color: var(--cg-muted); font-size: 13px; padding: 14px 2px; }

/* profile */
.cg-who { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cg-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--cg-blue), var(--cg-navy));
  color: #fff; display: flex; align-items: center; justify-content: center; font: 800 22px var(--font-baloo), system-ui, sans-serif;
}
.cg-who b { display: block; font: 800 18px var(--font-baloo), system-ui, sans-serif; color: var(--cg-navy); }
.cg-who small { color: var(--cg-muted); font-size: 12px; }
.cg-stats { display: flex; gap: 8px; margin-bottom: 16px; }
.cg-stat { flex: 1; background: #f2f9ff; border-radius: 14px; padding: 10px; text-align: center; }
.cg-stat b { display: block; font: 800 20px var(--font-baloo), system-ui, sans-serif; color: var(--cg-navy); }
.cg-stat span { font-size: 11px; color: var(--cg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cg-section-title { font: 800 14px var(--font-baloo), system-ui, sans-serif; color: var(--cg-navy); margin: 4px 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.cg-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.cg-row a { flex: 0 0 auto; width: 78px; text-decoration: none; color: var(--cg-ink); }
.cg-row img { width: 78px; height: 78px; border-radius: 12px; object-fit: cover; background: #eaf4fb; }
.cg-row span { display: block; font: 700 11px/1.2 var(--font-baloo), system-ui, sans-serif; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cg-linkrow { display: flex; gap: 10px; margin-top: 6px; }
.cg-ghost { flex: 1; border: 1.5px solid #d7e8f5; background: #fff; color: var(--cg-navy); border-radius: 999px; padding: 10px; font: 700 13px var(--font-poppins), system-ui, sans-serif; cursor: pointer; }
.cg-ghost:hover { border-color: var(--cg-blue); color: var(--cg-blue); }
.cg-switcher { position: absolute; z-index: 99996; background: #fff; border-radius: 16px; padding: 8px; box-shadow: 0 22px 50px -20px rgba(0, 42, 80, 0.7); min-width: 170px; }
.cg-switcher a { display: block; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--cg-ink); font: 600 14px var(--font-poppins), system-ui, sans-serif; }
.cg-switcher a:hover, .cg-switcher a.is-on { background: #eef7fe; color: var(--cg-blue); }
@media (max-width: 640px) {
  .cg-bar { padding: 8px 10px; }
  .cg-btn { width: 34px; height: 34px; }
  .cg-btn--wide span { display: none; }
  .cg-btn--wide { width: 34px; padding: 0; }
}
