/* ---------- title: the CG gallery (top-left) and the leaderboard (top-right) ---------- */
/* both are quiet translucent plum plates with a gold ring, smaller than the start prompt */
#logo { top: 11.5%; }
#btnGallery, #btnBoard {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); bottom: auto; height: 50px; min-height: 50px;
  border: 2px solid rgba(255, 215, 122, 0.95) !important; border-image: none !important;
  background: radial-gradient(circle at 35% 30%, rgba(160, 62, 116, 0.82), rgba(84, 22, 60, 0.82)) !important;
  box-shadow: 0 3px 10px rgba(40, 10, 30, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #fff7ec; flex-direction: row; transform: none;
}
#btnGallery { left: calc(10px + env(safe-area-inset-left)); right: auto; gap: 8px; padding: 0 16px 0 12px; border-radius: 999px !important; font-size: 15px; }
#btnBoard { left: auto; right: calc(10px + env(safe-area-inset-right)); width: 50px; padding: 0; border-radius: 50% !important; }
#btnGallery.focus, #btnBoard.focus { transform: scale(1.07); filter: brightness(1.15) drop-shadow(0 0 6px #ffd27a); }
#btnGallery:active, #btnGallery.press, #btnBoard:active, #btnBoard.press { transform: scale(0.94); }
/* "backwards" (not "both"): once the entrance ends, .focus / :active may scale the plates again */
#title.active #btnGallery, #title.active #btnBoard { animation: cornerIn 0.4s cubic-bezier(.34,1.56,.64,1) 0.5s backwards; }
@keyframes cornerIn { from { opacity: 0; transform: translateY(-16px) scale(0.8); } to { opacity: 1; transform: none; } }
/* the title's logo, prompt and corner buttons hide while the gallery covers them */
#app:has(#gallery.active) #title > *, #app:has(#cgView.active) #title > * { visibility: hidden; }

/* a little framed picture */
.galIcon { position: relative; width: 24px; height: 19px; flex: 0 0 auto; border-radius: 3px; overflow: hidden;
  background: linear-gradient(170deg, #ffe9f3, #f6b3cd); box-shadow: 0 0 0 2px #ffd27a; }
.galIcon::before { content: ""; position: absolute; left: 1px; bottom: -1px; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 11px solid #d9578f; }
.galIcon::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: #ffc94d; }
/* a gold cup with handles on a stand */
#btnBoard .trophy { position: relative; display: block; width: 18px; height: 15px; margin-top: -7px; border-radius: 2px 2px 9px 9px;
  background: linear-gradient(#fff4c2, #f2c24e); box-shadow: none; }
#btnBoard .trophy::before { content: ""; position: absolute; left: -6px; right: -6px; top: 1px; height: 8px; border: 3px solid #f2c24e; border-top: 0; border-radius: 0 0 8px 8px; }
#btnBoard .trophy::after { content: ""; position: absolute; left: 3px; right: 3px; top: 15px; height: 9px;
  background: linear-gradient(#f2c24e, #c8953a); clip-path: polygon(36% 0, 64% 0, 64% 45%, 100% 45%, 100% 100%, 0 100%, 0 45%, 36% 45%); }

/* ---------- CG gallery ---------- */
#gallery { z-index: 45; background: rgba(28, 8, 24, 0.72); }
#gallery.active { animation: galFade 0.2s ease-out; }
@keyframes galFade { from { opacity: 0; } to { opacity: 1; } }
.galBox { position: absolute; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; padding: 14px 12px 12px; animation: popIn 0.28s cubic-bezier(.34,1.56,.64,1); }
.galBox .sheetTitle { margin-bottom: 6px; font-size: 22px; letter-spacing: 0.04em; }
.galHead { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-bottom: 4px; }
.galProg { padding: 3px 16px; border-radius: 999px; font-size: 16px; font-weight: 900; color: #fff; line-height: 1.35;
  background: linear-gradient(#e776a6, #b8457a); box-shadow: 0 0 0 2px #fff3c0, 0 2px 4px rgba(80, 20, 50, 0.3);
  text-shadow: 0 1px 0 var(--plum), 1px 0 0 var(--plum), -1px 0 0 var(--plum), 0 -1px 0 var(--plum); }
.galBar { width: 70%; height: 8px; border-radius: 6px; background: rgba(110, 37, 82, 0.18); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2); }
.galBar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #ffb3cf, #ffd27a); transition: width 0.5s ease-out; }
.galHint { font-size: 12px; font-weight: 800; color: #9a5d80; text-align: center; margin: 2px 0 8px; }
/* rows are max-content: the tiles clip their overflow, so "auto" rows would shrink to fit the box */
.galGrid { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: max-content;
  gap: 8px; align-content: start; padding: 4px 3px 10px; scrollbar-width: none; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.galGrid::-webkit-scrollbar { display: none; }
/* each tile is a 2:3 portrait card: its height comes from the spacer (padding-top 150% of its width) */
.galTile { position: relative; display: block; width: 100%; height: auto; padding: 0; margin: 0; overflow: hidden; cursor: pointer;
  border: 2px solid var(--gold); border-radius: 10px; outline: none; font-family: var(--font);
  background: linear-gradient(165deg, #5a1d45, #23081b); box-shadow: 0 3px 6px rgba(60, 20, 50, 0.3);
  transition: transform 90ms ease-out, filter 120ms ease-out, box-shadow 120ms; animation: popIn 0.3s cubic-bezier(.34,1.56,.64,1) backwards; }
.galTile::before { content: ""; display: block; width: 100%; padding-top: 150%; }
.galTile img { pointer-events: none; -webkit-user-drag: none; }
.galTile img.th { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.galTile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 4px 5px; font-size: 12px; font-weight: 900; line-height: 1.25; color: #fff;
  text-align: center; background: linear-gradient(transparent, rgba(40, 8, 30, 0.88) 55%); text-shadow: 0 1px 2px #000; }
.galTile.locked { border-color: rgba(200, 149, 58, 0.6); }
.galTile img.sil { position: absolute; left: 50%; bottom: -2%; height: 96%; width: auto; max-width: none; transform: translateX(-50%);
  filter: brightness(0); opacity: 0.6; }
.galTile img.sil.wide { height: 78%; transform: translateX(-46%); }
.galTile .lock { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px 5px;
  text-align: center; background: radial-gradient(ellipse at 50% 45%, rgba(40, 8, 30, 0.15), rgba(40, 8, 30, 0.55)); }
.galTile .lockIcon { position: relative; flex: 0 0 auto; width: 22px; height: 17px; margin-top: 10px; border-radius: 4px; background: linear-gradient(#ffe9a8, #e0a83e);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.galTile .lockIcon::before { content: ""; position: absolute; left: 4px; right: 4px; top: -11px; height: 13px; border: 3px solid #f0c66a; border-bottom: 0; border-radius: 9px 9px 0 0; }
.galTile .lockIcon::after { content: ""; position: absolute; left: 50%; top: 5px; width: 4px; height: 6px; margin-left: -2px; border-radius: 2px; background: #6e2552; }
.galTile .cond { font-size: 12px; font-weight: 800; line-height: 1.3; color: #ffe6f1; overflow-wrap: anywhere;
  text-shadow: 0 1px 2px #000, 0 0 5px #000, 0 0 2px #000; }
.galTile.focus { transform: scale(1.05); filter: brightness(1.12); box-shadow: 0 0 0 3px #fff, 0 0 14px 3px #ffd27a; z-index: 1; }
.galTile:active { transform: scale(0.96); }
.galTile.shake { animation: galShake 0.32s ease-out; }
@keyframes galShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 60% { transform: translateX(5px); } }
.galClose { display: flex; margin: 10px auto 0; min-width: 150px; flex: 0 0 auto; }

/* ---------- full-screen viewer (opaque: the grid never shows through the letterbox) ---------- */
#cgView { z-index: 46; background: radial-gradient(ellipse at 50% 42%, #2c1024 0%, #160911 70%, #10060c 100%); touch-action: none; }
#cgView.active { animation: galFade 0.22s ease-out; }
#cgImg { position: absolute; left: 0; top: calc(66px + env(safe-area-inset-top)); width: 100%;
  height: calc(100% - 152px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); object-fit: contain;
  transition: opacity 0.14s ease, transform 0.22s ease-out; pointer-events: none; }
#cgView.bare #cgImg { top: 0; height: 100%; }
#cgImg.outL { opacity: 0; transform: translateX(-40px); }
#cgImg.outR { opacity: 0; transform: translateX(40px); }
#cgImg.fromR { opacity: 0; transform: translateX(40px); transition: none; }
#cgImg.fromL { opacity: 0; transform: translateX(-40px); transition: none; }
.cgArrow, #cgClose { border: 2px solid rgba(255, 215, 122, 0.95) !important; border-image: none !important;
  background: radial-gradient(circle at 35% 30%, rgba(160, 62, 116, 0.86), rgba(84, 22, 60, 0.86)) !important; color: #fff7ec; transition: opacity 0.2s, transform 90ms; }
.cgArrow { position: absolute; top: 50%; width: 52px; height: 52px; min-height: 52px; margin-top: -26px; padding: 0; border-radius: 50% !important; font-size: 20px; }
#cgPrev { left: calc(8px + env(safe-area-inset-left)); }
#cgNext { right: calc(8px + env(safe-area-inset-right)); }
#cgClose { position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); min-width: 100px; height: 48px; border-radius: 999px !important; }
.cgArrow.focus, #cgClose.focus { filter: brightness(1.15) drop-shadow(0 0 6px #ffd27a); transform: scale(1.07); }
.cgCap { position: absolute; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); padding: 8px 12px; border-radius: 14px; text-align: center; color: #fff;
  background: rgba(60, 14, 44, 0.78); box-shadow: 0 0 0 2px rgba(255, 215, 122, 0.7); transition: opacity 0.2s; pointer-events: none; }
.cgCap .cgn { font-size: 16px; font-weight: 900; line-height: 1.3; text-shadow: 0 1px 0 var(--plum), 1px 0 0 var(--plum), -1px 0 0 var(--plum), 0 -1px 0 var(--plum); }
.cgCap .cgc { margin-top: 2px; font-size: 14px; font-weight: 900; color: #ffd27a; }
#cgView.bare .cgArrow, #cgView.bare .cgCap, #cgView.bare #cgClose { opacity: 0; pointer-events: none; }
