/* /memoryglyph/memoryglyph.css
   Premium pass: better surfaces, hierarchy, tile motion, progress bar, dialog polish.
*/

/* ============================
   MemoryGlyph theme vars
   ============================ */

:root{
  --mgAccent: var(--accent, #d6b35a);
  --mgOk: rgba(0, 255, 140, .18);
  --mgOkBorder: rgba(0, 255, 140, .48);
  --mgBad: rgba(255, 60, 60, .14);
  --mgBadBorder: rgba(255, 60, 60, .46);

  --mgCardBg: rgba(255,255,255,.03);
  --mgCardBg2: rgba(255,255,255,.02);
  --mgCardBorder: rgba(255,255,255,.10);

  --mgTileBg: rgba(255,255,255,.035);
  --mgTileBorder: rgba(255,255,255,.14);
  --mgTileInset: rgba(255,255,255,.05);

  --mgShadow: 0 14px 36px rgba(0,0,0,.30);
}

:root[data-theme="light"]{
  --mgOk: rgba(0, 160, 90, .16);
  --mgOkBorder: rgba(0, 160, 90, .40);

  --mgCardBg: rgba(255,255,255,.78);
  --mgCardBg2: rgba(255,255,255,.88);
  --mgCardBorder: rgba(11,15,20,.14);

  --mgTileBg: rgba(11,15,20,.03);
  --mgTileBorder: rgba(11,15,20,.14);
  --mgTileInset: rgba(11,15,20,.06);

  --mgShadow: 0 16px 40px rgba(0,0,0,.12);
}

/* ============================
   Page background polish
   ============================ */

.mgPage{
  position: relative;
}

.mgPage::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(214,179,90,.18), transparent 60%),
    radial-gradient(900px 500px at 95% 10%, rgba(0,255,140,.10), transparent 55%),
    radial-gradient(900px 600px at 50% 110%, rgba(140,170,255,.10), transparent 60%);
  opacity: .9;
}

:root[data-theme="light"] .mgPage::before{
  opacity: .55;
}

/* ============================
   Card spacing / layout
   ============================ */

header.wrap { padding-bottom: 6px; }
main.wrap { padding-top: 6px; }

.mgCard{
  padding: 12px 12px 12px;
  background: linear-gradient(180deg, var(--mgCardBg), var(--mgCardBg2));
  border: 1px solid var(--mgCardBorder);
  box-shadow: var(--mgShadow);
  overflow: hidden;
  position: relative;
}

.mgCard::after{
  content:"";
  position:absolute;
  inset: 0;
  pointer-events:none;
  background: radial-gradient(800px 200px at 30% 0%, rgba(255,255,255,.06), transparent 60%);
}

:root[data-theme="light"] .mgCard::after{
  background: radial-gradient(800px 220px at 30% 0%, rgba(255,255,255,.55), transparent 58%);
  opacity: .35;
}

@media (max-width:520px){
  .wrap { padding-left: 10px; padding-right: 10px; }
  .mgCard { padding: 10px 10px 10px; }
}

/* top row */
.mgTopRow{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 10px;
}

.mgMeta{ display:flex; flex-direction:column; gap:8px; min-width: 0; }
.mgRight{ display:flex; align-items:center; justify-content:flex-end; }

/* Mode pills stay one line */
.mgMeta .modeSeg{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;

  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
}
.mgMeta .modeSeg::-webkit-scrollbar{ display:none; }

:root[data-theme="light"] .mgMeta .modeSeg{
  background: rgba(11,15,20,.02);
}

/* Make active mode feel premium */
.mgMeta .modeSeg .seg{
  border-radius: 14px;
  padding: 8px 12px;
  min-height: 36px;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.mgMeta .modeSeg .seg.on{
  background: rgba(214,179,90,.14);
  border-color: rgba(214,179,90,.28);
  box-shadow: 0 10px 24px rgba(214,179,90,.10);
}
.mgMeta .modeSeg .seg:active{ transform: translateY(1px); }
.mgMeta .modeSeg .seg:focus-visible{
  outline: 2px solid rgba(214,179,90,.35);
  outline-offset: 2px;
}

/* Stats row stays one line */
.mgStatsRow{
  display:flex;
  align-items:flex-end;
  gap: 10px;
  flex-wrap: nowrap;
  width: 100%;
}

/* Stat tiles */
.mgStat{
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
  border-radius: 14px;
  padding: 8px 10px;
}
:root[data-theme="light"] .mgStat{
  background: rgba(255,255,255,.65);
}

.mgVal{ font-size: 18px; line-height: 1; font-weight: 900; }

/* tighter on small screens */
@media (max-width:520px){
  .mgStatsRow{ gap: 8px; }
  .mgStat{ padding: 7px 8px; border-radius: 13px; }
  .mgVal{ font-size: 16px; }
  .mgStat .muted{ font-size: 12px; }
  .mgMeta .modeSeg{ gap: 6px; padding: 5px; border-radius: 14px; }
}

/* Haptics pill */
.mgHapticRow{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 14px;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
  user-select:none;
}
:root[data-theme="light"] .mgHapticRow{
  background: rgba(255,255,255,.65);
}

.mgHapticRow .muted{ font-size: 12px; line-height: 1; }

/* switch sizing */
.mgSwitch{ transform: scale(.72); transform-origin: right center; }
@media (max-width:520px){
  .mgHapticRow{ padding: 5px 7px; border-radius: 13px; }
  .mgSwitch{ transform: scale(.62); }
}

/* ============================
   Status + progress
   ============================ */

.mgStatus{
  margin: 8px 0 8px;
  text-align: center;
  font-size: clamp(18px, 4.2vw, 24px);
  font-weight: 900;
  letter-spacing: .01em;
  opacity: .98;
}

.mgStatusBig{
  font-size: clamp(22px, 5.2vw, 34px);
  font-weight: 900;
}

.mgPop{ animation: mgPopDown 420ms ease-out both; }

@keyframes mgPopDown{
  0%   { transform: scale(1.35); opacity: .0; }
  35%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.0);  opacity: 1; }
}

.mgProg{
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
  overflow: hidden;
  margin: 0 auto 10px;
  max-width: 520px;
}
:root[data-theme="light"] .mgProg{
  background: rgba(11,15,20,.02);
}

.mgProgBar{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(214,179,90,.85), rgba(214,179,90,.45));
  box-shadow: 0 10px 18px rgba(214,179,90,.12);
  transition: width 140ms ease;
}

.msg{ min-height: 20px; text-align:center; }

/* ============================
   Grid + tiles
   ============================ */

.mgGridWrap{
  display:flex;
  justify-content:center;
  margin-top: 8px;
}

.mgGrid{
  display:grid;
  gap: 10px;
  width: min(520px, 100%);
}

.mgTile{
  border-radius: 18px;
  border: 1px solid var(--mgTileBorder);
  background: var(--mgTileBg);
  box-shadow:
    inset 0 0 0 2px var(--mgTileInset),
    0 10px 18px rgba(0,0,0,.12);

  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  user-select:none;

  aspect-ratio: 1 / 1;
  min-height: 76px;

  font-size: 32px;
  font-weight: 950;
  line-height: 1;

  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  will-change: transform;
}

:root[data-theme="light"] .mgTile{
  box-shadow:
    inset 0 0 0 2px var(--mgTileInset),
    0 10px 16px rgba(0,0,0,.08);
}

@media (hover:hover){
  .mgTile:hover{
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow:
      inset 0 0 0 2px var(--mgTileInset),
      0 14px 22px rgba(0,0,0,.16);
  }
}

.mgTile:active{ transform: scale(.98); }

.mgTile:focus-visible{
  outline: 2px solid rgba(214,179,90,.42);
  outline-offset: 3px;
}

.mgTile.disabled{
  opacity: .62;
  cursor: default;
  transform: none !important;
  filter: none !important;
}

/* Flash (premium pulse) */
.mgTile.flash{
  background: var(--mgOk);
  border-color: var(--mgOkBorder);
  box-shadow:
    inset 0 0 0 2px rgba(0,255,140,.18),
    0 0 0 6px rgba(0,255,140,.10),
    0 14px 22px rgba(0,0,0,.16);
  animation: mgPulse 240ms ease-out both;
}

@keyframes mgPulse{
  0% { transform: scale(1.00); }
  55%{ transform: scale(1.04); }
  100%{ transform: scale(1.00); }
}

/* Wrong (shake + red glow) */
.mgTile.wrong{
  background: var(--mgBad);
  border-color: var(--mgBadBorder);
  box-shadow:
    inset 0 0 0 2px rgba(255,60,60,.12),
    0 0 0 6px rgba(255,60,60,.10),
    0 14px 22px rgba(0,0,0,.16);
}

.mgTile.shake{
  animation: mgShake 260ms ease-in-out both;
}

@keyframes mgShake{
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* small screens */
@media (max-width:520px){
  .mgGrid{ gap: 8px; }
  .mgTile{ border-radius: 16px; font-size: 30px; min-height: 66px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .mgTile, .mgProgBar, .mgPop{ transition:none !important; animation:none !important; }
}

/* ============================
   Controls
   ============================ */

.mgControls{
  margin-top: 12px;
  display:flex;
  gap:8px;
  justify-content:center;
  flex-wrap:wrap;
}

.mgBtn{
  min-width: 112px;
  height: 42px;
  border-radius: 14px;
  font-size: 15px;
  padding: 0 14px;
  font-weight: 800;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.03);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
:root[data-theme="light"] .mgBtn{
  background: rgba(255,255,255,.70);
}

.mgBtn:active{ transform: translateY(1px); }
.mgBtn:focus-visible{ outline: 2px solid rgba(214,179,90,.35); outline-offset: 2px; }

.mgBtn.primary{
  border-color: rgba(214,179,90,.28);
  background: linear-gradient(180deg, rgba(214,179,90,.22), rgba(214,179,90,.12));
  box-shadow: 0 14px 26px rgba(214,179,90,.10);
}
@media (hover:hover){
  .mgBtn.primary:hover{ filter: brightness(1.03); box-shadow: 0 16px 32px rgba(214,179,90,.14); }
  .mgBtn:hover{ background: rgba(255,255,255,.06); }
  :root[data-theme="light"] .mgBtn:hover{ background: rgba(255,255,255,.90); }
}

.mgBtn.ghost{ opacity: .95; }
.mgBtn:disabled{ opacity:.55; cursor:not-allowed; }

@media (max-width:520px){
  .mgBtn{ min-width: 100px; height: 40px; border-radius: 13px; }
}

.mgMiniRow{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-size: 13px;
}

.mgLinkBtn{
  border: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
}
.mgLinkBtn:hover{ background: rgba(255,255,255,.04); }
:root[data-theme="light"] .mgLinkBtn:hover{ background: rgba(11,15,20,.04); }

/* ============================
   Learn/about cards minor polish
   ============================ */

.mgLearnCard{ margin-top:14px; }
.mgAboutCard{ margin-top:14px; }

.mgLearnTitle{
  margin:0;
}

.mgCtaBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.03);
  text-decoration:none;
  color: inherit;
  font-weight: 800;
}
:root[data-theme="light"] .mgCtaBtn{
  background: rgba(255,255,255,.70);
}
.mgCtaBtn.primary{
  border-color: rgba(214,179,90,.28);
  background: linear-gradient(180deg, rgba(214,179,90,.22), rgba(214,179,90,.12));
}
@media (hover:hover){
  .mgCtaBtn:hover{ background: rgba(255,255,255,.06); }
  :root[data-theme="light"] .mgCtaBtn:hover{ background: rgba(255,255,255,.92); }
}

.mgAboutLinks{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* ============================
   Help + Share dialogs (premium)
   ============================ */

.mgHelpDlg,
.mgShareDlg{
  padding: 0;
  border: 0;
  background: transparent;
  width: fit-content;
  max-width: calc(100vw - 24px);
  margin: auto;
}

.mgHelpDlg::backdrop,
.mgShareDlg::backdrop{ background: rgba(0,0,0,.55); }
:root[data-theme="light"] .mgHelpDlg::backdrop,
:root[data-theme="light"] .mgShareDlg::backdrop{ background: rgba(0,0,0,.30); }

.mgHelp,
.mgShare{
  padding: 12px 12px 12px;
  max-width: 560px;
  border: 1px solid var(--mgCardBorder);
  background: linear-gradient(180deg, var(--mgCardBg), var(--mgCardBg2));
  box-shadow: var(--mgShadow);
  border-radius: 16px;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.mgHelpScroll{
  max-height: 70vh;
  overflow: auto;
  padding-right: 2px;
}

.mgHelpBox{
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
  border-radius: 12px;
  padding: 9px 10px;
  margin: 8px 0;
}
:root[data-theme="light"] .mgHelpBox{
  background: rgba(255,255,255,.60);
}

.mgHelpKicker{
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .78;
  margin-bottom: 6px;
}

.mgHelpList{ margin: 0; padding-left: 18px; }
.mgHelpList li{ margin: 5px 0; }

.mgHelpActions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
  margin-top: 8px;
}

/* Share */
.mgShareTA{
  width:100%;
  resize:vertical;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--mgCardBorder);
  background: rgba(255,255,255,.02);
}
:root[data-theme="light"] .mgShareTA{
  background: rgba(255,255,255,.80);
}

.mgShareActions{
  display:flex;
  gap:10px;
  margin-top:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

/* ============================
   GLOBAL MENU (Glyphverse) — keep your existing styles
   (unchanged from your last pass, just preserved)
   ============================ */

:root{
  --gvMenuBg: rgba(255,255,255,.06);
  --gvMenuBorder: rgba(255,255,255,.10);
  --gvMenuShadow: 0 18px 50px rgba(0,0,0,.45);

  --gvItemBg: rgba(255,255,255,.05);
  --gvItemBgHover: rgba(255,255,255,.08);
  --gvItemBorder: rgba(255,255,255,.10);
}

:root[data-theme="light"]{
  --gvMenuBg: rgba(255,255,255,.92);
  --gvMenuBorder: rgba(11,15,20,.14);
  --gvMenuShadow: 0 16px 40px rgba(0,0,0,.18);

  --gvItemBg: rgba(255,255,255,.78);
  --gvItemBgHover: rgba(255,255,255,.92);
  --gvItemBorder: rgba(11,15,20,.14);
}

.gvMenuDlg{
  border: 0;
  padding: 0;
  background: transparent;
  width: min(760px, 94vw);
  color: inherit;
}

.gvMenuDlg::backdrop{ background: rgba(0,0,0,.55); }
:root[data-theme="light"] .gvMenuDlg::backdrop{ background: rgba(0,0,0,.28); }

.gvMenu{
  background: var(--gvMenuBg);
  border: 1px solid var(--gvMenuBorder);
  border-radius: 16px;
  box-shadow: var(--gvMenuShadow);
  overflow: auto;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  max-height: 80vh;
}

:root[data-theme="light"] .gvMenu{
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
}

.gvMenuTop{
  position: sticky;
  top: 0;
  z-index: 2;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gvMenuBorder);
  background: inherit;
}

.gvMenuTitle{
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .85;
}

.gvMenuX{
  border: 1px solid var(--gvItemBorder);
  background: var(--gvItemBg);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.gvMenuX:hover{ background: var(--gvItemBgHover); }

.gvMenuGrid{
  display:grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 10px;
  padding: 10px;
  align-items: start;
}

.gvCol{ min-width: 0; }

.gvCol:first-child{
  padding-right: 8px;
  border-right: 1px solid var(--gvMenuBorder);
}

.gvSection{ margin-bottom: 10px; }
.gvSection:last-child{ margin-bottom: 0; }

.gvSectionTitle{
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .70;
  margin: 0 0 8px;
}

.gvWelcome{
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--gvItemBorder);
  background: var(--gvItemBg);
  border-radius: 14px;
}

.gvWelcomeTitle{
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 2px;
}
.gvWelcomeSub{
  font-size: 12px;
  line-height: 1.2;
  opacity: .85;
}

.gvRow,
.gvLink,
.gvGameLink{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid var(--gvItemBorder);
  background: var(--gvItemBg);
  text-decoration: none;
  color: inherit;
  min-height: 38px;
}

.gvRow{ justify-content: space-between; }
.gvRowLeft{ display:flex; align-items:center; gap:10px; min-width:0; }

.gvLink:hover,
.gvGameLink:hover{ background: var(--gvItemBgHover); }

.gvIcon{
  width: 18px;
  display:inline-flex;
  justify-content:center;
  opacity: .95;
  flex: 0 0 auto;
}

.gvText{
  font-size: 13px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.gvGameGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width:900px){
  .gvGameGrid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.gvActive{
  outline: 2px solid rgba(255,255,255,.18);
  outline-offset: 0;
}
:root[data-theme="light"] .gvActive{
  outline-color: rgba(11,15,20,.18);
}

.gvSwitch{ transform: scale(.90); transform-origin: right center; }

@media (max-width:520px){
  .gvMenuDlg{ width: 98vw; }
  .gvMenu{ max-height: 88vh; border-radius: 14px; }
  .gvMenuGrid{ gap: 8px; padding: 8px; }
  .gvCol:first-child{ padding-right: 6px; }

  .gvSectionTitle{ font-size: 10px; margin: 0 0 6px; letter-spacing: .18em; }

  .gvWelcome{ padding: 8px 8px; border-radius: 12px; }
  .gvWelcomeTitle{ font-size: 12px; }
  .gvWelcomeSub{ font-size: 11px; }

  .gvRow, .gvLink, .gvGameLink{
    padding: 8px 8px;
    border-radius: 12px;
    min-height: 34px;
    gap: 8px;
  }

  .gvText{ font-size: 12px; }
  .gvIcon{ width: 16px; }
  .gvSwitch{ transform: scale(.85); }
}

/* Center the dialog on desktop */
#menuDlg.gvMenuDlg[open]{
  position: fixed;
  inset: 0;
  margin: auto;
}

.menuBtn{
  position:relative;
  border-radius:12px;
}

@media (prefers-reduced-motion: no-preference){
  .menuBtn.attn::before{
    content:"";
    position:absolute;
    inset:-2px;
    border-radius:inherit;
    padding:2px;
    background: conic-gradient(from 0deg,
      transparent 0 70%,
      var(--accent, #d6b35a) 78%,
      transparent 86% 100%);
    -webkit-mask:
      linear-gradient(#000 0 0) content-box,
      linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: spin 3.5s linear infinite;
    opacity:.7;
    pointer-events:none;
  }

  @keyframes spin{ to{ transform: rotate(360deg); } }

  .menuBtn:hover::before,
  .menuBtn:focus-visible::before{ opacity:0; animation:none; }
}

/* Light-mode: make flash MUCH more visible */
:root[data-theme="light"] .mgTile.flash{
  background: rgba(0, 170, 90, .34);          /* stronger fill */
  border-color: rgba(0, 170, 90, .92);        /* punchier edge */
  box-shadow:
    inset 0 0 0 2px rgba(0,170,90,.22),
    0 0 0 8px rgba(0,170,90,.22),             /* bigger ring */
    0 14px 22px rgba(0,0,0,.10);
  filter: saturate(1.25) contrast(1.05);
}

