/* Cool Math Cool Games – Play Next. Rows reuse the theme's classes; these rules only add what the theme does not have. */

/* The plugin's wrappers take no room of their own, so the rows sit in the theme's layout like its own rows. */
.cmg-rows, .cmg-personal { display: contents; }
.cmg-head .arrowcommon, [data-cmg-scroll] { cursor: pointer; }

/* Rows and games taken out by the no-repeat rule (kept in the page, so the script can bring them back). */
.cmg-off, .cmg-dup, .cmg-move[hidden] { display: none !important; }

/* "Play next" button beside the game's full-screen button */
.cmg-next-btn {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 0 0; padding: 7px 14px;
  border-radius: 999px; background: linear-gradient(135deg, #ffc809, #ffaa00); color: #290838 !important;
  font-weight: 800; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); -webkit-user-select: none; user-select: none; vertical-align: middle;
}
.cmg-next-btn:hover { filter: brightness(1.06); }
.cmg-next-btn:focus-visible { outline: 3px solid #7964ca; outline-offset: 2px; }
@media (max-width: 600px) { .cmg-next-btn { margin: 0 8px 0 0; padding: 6px 10px; font-size: 12px; } }

/* "Play next" screen over the game */
.cmg-ov {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 50; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; padding: 12px;
  background: rgba(41, 8, 56, .88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  container-type: size; font-family: inherit; color: #fff; animation: cmg-fade .25s ease-out;
}
.cmg-ov[hidden] { display: none; }
.cmg-ov * { box-sizing: border-box; }
.cmg-ov-box {
  position: relative; width: 100%; max-width: 760px; max-width: min(760px, calc((100cqh - 150px) * 1.76 + 20px));
  max-height: 100%; display: flex; flex-direction: column; gap: 12px; overflow: auto; scrollbar-width: none;
}
.cmg-ov-head { text-align: center; padding: 0 44px; }
.cmg-ov-title { font-size: 28px; font-weight: 800; line-height: 1.15; }
.cmg-ov-sub { font-size: 15px; opacity: .85; margin-top: 3px; }
.cmg-ov-x {
  position: absolute; top: 0; right: 0; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 24px; line-height: 36px; cursor: pointer;
}
.cmg-ov-x:hover { background: rgba(255, 255, 255, .28); }
.cmg-ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cmg-ov-card {
  position: relative; display: block; overflow: hidden; border-radius: 12px; background: #50136c; color: #fff !important;
  text-decoration: none !important; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: transform .15s;
}
.cmg-ov-card:hover, .cmg-ov-card:focus-visible { transform: scale(1.03); outline: 3px solid #ffc809; outline-offset: 0; }
.cmg-ov-img { display: block; aspect-ratio: 250 / 142; }
.cmg-ov-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cmg-ov-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 12px; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(0deg, rgba(0, 0, 0, .82), transparent);
}
.cmg-ov-big { grid-column: span 2; grid-row: span 2; }
.cmg-ov-big .cmg-ov-img { aspect-ratio: auto; height: 100%; }
.cmg-ov-big .cmg-ov-name { font-size: 18px; padding: 34px 12px 10px; }
.cmg-ov-play {
  position: absolute; top: 10px; left: 10px; padding: 6px 12px; border-radius: 999px; background: #ffc809; color: #290838;
  font-size: 13px; font-weight: 800; line-height: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.cmg-ov-keep {
  align-self: center; padding: 7px 18px; border: 2px solid rgba(255, 255, 255, .6); border-radius: 999px;
  background: transparent; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
}
.cmg-ov-keep:hover { background: rgba(255, 255, 255, .12); }
@keyframes cmg-fade { from { opacity: 0; } to { opacity: 1; } }

/* Short game frames (phones, small windows): one swipeable strip */
@container (max-height: 400px) {
  .cmg-ov-box { max-width: 100%; gap: 8px; }
  .cmg-ov-grid { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 2px; }
  .cmg-ov-card { flex: 0 0 auto; width: min(190px, 40cqw); scroll-snap-align: start; }
  .cmg-ov-big { width: min(240px, 52cqw); }
  .cmg-ov-big .cmg-ov-img { aspect-ratio: 250 / 142; height: auto; }
  .cmg-ov-big .cmg-ov-name { font-size: 13px; padding: 18px 8px 6px; }
  .cmg-ov-title { font-size: 20px; }
  .cmg-ov-sub { font-size: 13px; }
}
@container (max-height: 300px) {
  .cmg-ov { padding: 8px; }
  .cmg-ov-title { font-size: 16px; }
  .cmg-ov-sub { display: none; }
  .cmg-ov-x { width: 28px; height: 28px; font-size: 20px; line-height: 28px; }
  .cmg-ov-card { width: min(150px, 40cqw); }
  .cmg-ov-big { width: min(170px, 46cqw); }
  .cmg-ov-play { top: 6px; left: 6px; padding: 4px 8px; font-size: 11px; }
  .cmg-ov-keep { padding: 4px 12px; font-size: 12px; }
}
