/* Match 3 — jewel matching puzzle. Every class and id is prefixed m3-. */
.m3 { --m3-hue: 205; position: relative; display: flex; flex-direction: column; width: 100%; color: #dfe9ff; }
.m3 *, .m3 *::before, .m3 *::after { box-sizing: border-box; }
.m3-stage {
  position: relative; display: grid; width: 100%;
  height: min(calc(100vh - 150px), 760px); min-height: 480px;
  grid-template: "bar" auto "info" auto "area" minmax(0, 1fr) "boost" auto / minmax(0, 1fr);
  gap: 6px; padding: 8px; overflow: hidden; border-radius: 14px;
  background:
    radial-gradient(90% 60% at 50% 0%, hsl(var(--m3-hue) 70% 22% / .9) 0%, transparent 70%),
    radial-gradient(70% 50% at 85% 100%, hsl(calc(var(--m3-hue) + 50) 70% 18% / .7) 0%, transparent 70%),
    linear-gradient(180deg, #0a1126 0%, #050814 100%);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  transition: background .6s;
}
.m3-wide .m3-stage {
  grid-template: "bar area" auto "info area" auto "boost area" minmax(0, 1fr) / clamp(196px, 32%, 290px) minmax(0, 1fr);
  column-gap: 10px; row-gap: 8px; padding: 10px;
}
@media (max-width: 600px) { .m3-stage { height: calc(100svh - 112px); max-height: 860px; min-height: 500px; padding: 6px; border-radius: 10px; } }
@media (orientation: landscape) and (max-height: 520px) { .m3-stage { height: calc(100svh - 70px); min-height: 290px; padding: 6px; } }
.stage.is-immersive .stage-body > .m3 { min-height: 0; }
.stage.is-immersive .m3-stage { flex: 1 1 auto; height: auto; max-height: none; min-height: 0; border-radius: 0; }
.stage.is-immersive .m3-help { display: none; }

/* ---- top bar ---- */
.m3-bar { grid-area: bar; display: flex; align-items: center; gap: 6px; min-width: 0; }
.m3-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; padding: 0 2px; }
.m3-title b { font-size: 15px; font-weight: 800; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m3-title span { font-size: 11.5px; color: #8aa3c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m3-tool {
  flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; padding: 0; cursor: pointer;
  color: #cfe3ff; background: rgba(20, 34, 70, .72); border: 1px solid #25386a; border-radius: 12px;
  font: inherit; touch-action: manipulation; transition: background .15s, transform .1s;
}
.m3-tool svg { width: 22px; height: 22px; display: block; }
.m3-tool:hover { background: rgba(34, 56, 110, .9); }
.m3-tool:active { transform: scale(.94); }
.m3-snd-off { display: none; }
.m3-tool[aria-pressed="true"] .m3-snd-on { display: none; }
.m3-tool[aria-pressed="true"] .m3-snd-off { display: inline; }
.m3-tool[aria-pressed="true"] { color: #8aa3c4; }

/* ---- goals, moves, score ---- */
.m3-info { grid-area: info; display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.m3-stat {
  flex: 0 0 auto; min-width: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 10px 5px; background: rgba(11, 19, 40, .78); border: 1px solid #1c2b4a; border-radius: 12px; line-height: 1.1;
}
.m3-k { font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; color: #8aa3c4; }
.m3-v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; }
.m3-left.m3-low .m3-v { color: #ff6b81; animation: m3-beat .7s ease-in-out infinite; }
.m3-score { min-width: 96px; }
.m3-score .m3-v { font-size: 19px; }
.m3-meter { position: relative; width: 100%; min-width: 78px; height: 6px; margin-top: 4px; border-radius: 4px; background: rgba(138, 163, 196, .22); }
.m3-meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: linear-gradient(90deg, #55d6ff, #ffd166); transition: width .35s ease-out; }
.m3-pip { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #1a2a52; border: 1.5px solid #6f86ad; transition: background .2s, border-color .2s, transform .2s; }
.m3-pip.m3-on { background: #ffd166; border-color: #fff3c4; transform: scale(1.25); box-shadow: 0 0 8px #ffd166; }
.m3-goals {
  flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px;
  padding: 4px 6px; background: rgba(11, 19, 40, .6); border: 1px solid #1c2b4a; border-radius: 12px;
}
.m3-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px 2px 4px; min-height: 34px;
  background: rgba(28, 43, 74, .7); border-radius: 18px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff;
  transition: background .25s, transform .2s;
}
.m3-chip .m3-ico { display: block; flex: 0 0 auto; }
.m3-chip small { font-size: 11px; font-weight: 600; color: #8aa3c4; }
.m3-chip.m3-done { background: rgba(53, 217, 107, .2); color: #7ff0a4; }
.m3-chip.m3-bump { transform: scale(1.12); }
.m3-note { font-size: 13px; color: #b9cbe8; text-align: center; line-height: 1.25; padding: 2px 4px; }
.m3-note b { color: #ffd166; }
.m3-heat { display: flex; align-items: center; gap: 8px; width: 100%; padding: 0 6px; }
.m3-heat b { font-size: 20px; font-weight: 800; color: #ffd166; min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.m3-heat span { position: relative; flex: 1 1 auto; height: 8px; border-radius: 5px; background: rgba(138, 163, 196, .22); overflow: hidden; }
.m3-heat i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 5px; background: linear-gradient(90deg, #ffd166, #ff6b81); }

/* ---- board ---- */
.m3-area { grid-area: area; position: relative; min-width: 0; min-height: 0; overflow: hidden; border-radius: 12px; }
.m3-area canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: pointer; }
.m3-area canvas:focus-visible { box-shadow: inset 0 0 0 2px rgba(85, 214, 255, .55); border-radius: 12px; }
.m3-toast {
  grid-area: area; align-self: start; justify-self: center; position: relative; margin: 8px 8px 0; z-index: 2; pointer-events: none;
  padding: 7px 14px; border-radius: 18px; background: rgba(8, 14, 32, .9); border: 1px solid #2a4074; color: #eaf2ff;
  font-size: 14px; font-weight: 700; text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); animation: m3-drop .28s ease-out;
}
.m3-toast[hidden] { display: none; }

/* ---- boosters ---- */
.m3-boost { grid-area: boost; display: flex; gap: 6px; min-width: 0; }
.m3-boost[hidden] { display: none; }
.m3-bst {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 4px 8px; cursor: pointer; color: #dfe9ff; font: inherit; font-size: 13px; font-weight: 700;
  background: rgba(20, 34, 70, .78); border: 1px solid #25386a; border-radius: 12px; touch-action: manipulation; transition: background .15s, transform .1s, opacity .2s;
}
.m3-bst[hidden] { display: none; }
.m3-bst:hover { background: rgba(34, 56, 110, .92); }
.m3-bst:active { transform: scale(.96); }
.m3-bst:disabled { opacity: .42; cursor: default; }
.m3-bst.m3-armed { background: rgba(255, 209, 102, .22); border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255, 209, 102, .35); }
.m3-bst-i { display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; }
.m3-bst-i svg { width: 24px; height: 24px; display: block; }
.m3-bst-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m3-bst-n { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; background: #55d6ff; color: #04121f; font-size: 12px; font-weight: 800; }
.m3-bst:disabled .m3-bst-n { background: #55657f; color: #0b1328; }
.m3-wide .m3-info { flex-direction: column; }
.m3-wide .m3-stat { flex-direction: row; justify-content: space-between; gap: 10px; padding: 8px 14px; flex-wrap: wrap; }
.m3-wide .m3-goals { padding: 10px 8px; min-height: 58px; order: -1; }
.m3-wide .m3-boost { flex-wrap: wrap; align-self: end; }
.m3-wide .m3-bst { flex: 1 1 calc(50% - 3px); justify-content: flex-start; min-height: 48px; }
.m3-wide .m3-bst-t { flex: 1 1 auto; text-align: left; }
@media (max-width: 430px) {
  .m3-bst { flex-direction: column; gap: 1px; padding: 4px 2px 3px; font-size: 11px; min-height: 52px; }
  .m3-bst-n { position: absolute; top: 3px; right: 4px; min-width: 18px; height: 18px; font-size: 11px; }
  .m3-stat { min-width: 62px; padding: 4px 6px 5px; }
  .m3-score { min-width: 84px; }
}

/* ---- panels ---- */
.m3-overlay {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 10px;
  background: rgba(4, 6, 15, .74); animation: m3-fade .2s ease-out;
}
.m3-overlay[hidden] { display: none; }
.m3-overlay.m3-ov-soft { background: rgba(4, 6, 15, .5); }
.m3-overlay.m3-ov-solid { background: rgba(5, 8, 20, .97); }
.m3-panel {
  width: 100%; max-width: 430px; max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 18px 18px 16px;
  background: linear-gradient(180deg, rgba(16, 27, 58, .97), rgba(9, 15, 34, .98)); border: 1px solid #2a4074; border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(85, 214, 255, .06) inset; text-align: center; animation: m3-rise .26s cubic-bezier(.2, .9, .3, 1.2);
  -webkit-overflow-scrolling: touch;
}
.m3-panel.m3-p-wide { max-width: 560px; }
.m3-panel h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: .2px; color: #fff; }
.m3-panel h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: #8aa3c4; }
.m3-panel p { margin: 6px 0; font-size: 14.5px; line-height: 1.45; color: #c6d6f2; }
.m3-lead { color: #8aa3c4 !important; font-size: 13.5px !important; }
.m3-logo { display: flex; justify-content: center; gap: 2px; margin: 0 0 6px; }
.m3-logo .m3-ico { animation: m3-bob 2.6s ease-in-out infinite; }
.m3-logo .m3-ico:nth-child(2) { animation-delay: .2s; } .m3-logo .m3-ico:nth-child(3) { animation-delay: .4s; }
.m3-logo .m3-ico:nth-child(4) { animation-delay: .6s; } .m3-logo .m3-ico:nth-child(5) { animation-delay: .8s; }
.m3-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 9px 18px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 800; color: #dfe9ff; background: rgba(28, 43, 84, .9); border: 1px solid #33508f; border-radius: 13px;
  touch-action: manipulation; transition: background .15s, transform .1s, box-shadow .15s;
}
.m3-btn:hover { background: rgba(40, 62, 120, .95); }
.m3-btn:active { transform: scale(.97); }
.m3-btn:disabled { opacity: .45; cursor: default; }
.m3-btn.m3-go {
  color: #04121f; border-color: #b9f0ff; background: linear-gradient(180deg, #8fe6ff, #36b9f0);
  box-shadow: 0 6px 22px rgba(85, 214, 255, .35); font-size: 17px; min-height: 54px;
}
.m3-btn.m3-go:hover { background: linear-gradient(180deg, #b0eeff, #55c8f8); }
.m3-btn.m3-go small { display: block; font-size: 12px; font-weight: 700; opacity: .75; }
.m3-btn.m3-big { width: 100%; flex-direction: column; gap: 0; line-height: 1.2; }
.m3-btn .m3-ico { flex: 0 0 auto; }
.m3-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.m3-row .m3-btn { flex: 1 1 0; min-width: 96px; }
.m3-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.m3-mode { flex-direction: column; gap: 1px; padding: 8px 4px; min-height: 66px; line-height: 1.2; }
.m3-mode small { font-size: 11px; font-weight: 600; color: #8aa3c4; white-space: nowrap; }
.m3-mode [data-rg-daily] { font-size: 11px; font-weight: 600; color: #ffd166; }
.m3-mode [data-rg-daily]:empty { display: none; }
.m3-tally { display: flex; justify-content: center; gap: 14px; margin: 10px 0 0; font-size: 13px; color: #8aa3c4; }
.m3-tally b { color: #ffd166; font-variant-numeric: tabular-nums; }
.m3-stars { display: flex; justify-content: center; gap: 6px; margin: 8px 0 4px; }
.m3-stars .m3-ico { animation: m3-star .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.m3-stars .m3-ico:nth-child(2) { animation-delay: .22s; margin-top: -8px; } .m3-stars .m3-ico:nth-child(3) { animation-delay: .44s; }
.m3-big-n { font-size: 34px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.1; }
.m3-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 6px 0 2px; font-size: 13.5px; color: #8aa3c4; }
.m3-facts b { color: #dfe9ff; font-variant-numeric: tabular-nums; }
.m3-badge { display: inline-block; margin: 6px 0 2px; padding: 4px 12px; border-radius: 14px; background: rgba(255, 209, 102, .16); border: 1px solid rgba(255, 209, 102, .5); color: #ffd166; font-size: 13.5px; font-weight: 700; }
.m3-gift { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 0; padding: 7px 10px; border-radius: 12px; background: rgba(85, 214, 255, .1); border: 1px dashed rgba(85, 214, 255, .5); font-size: 13.5px; color: #cfeeff; }
.m3-gift svg { width: 22px; height: 22px; flex: 0 0 auto; }

/* ---- level map ---- */
.m3-map { text-align: left; }
.m3-ch { margin: 0 0 12px; padding: 10px 10px 12px; border-radius: 14px; background: hsl(var(--h) 55% 16% / .55); border: 1px solid hsl(var(--h) 60% 40% / .4); }
.m3-ch-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.m3-ch-h b { font-size: 15px; color: #fff; } .m3-ch-h span { font-size: 12.5px; color: #ffd166; font-variant-numeric: tabular-nums; }
.m3-lvs { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 6px; }
.m3-lv {
  position: relative; min-height: 50px; padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 800; color: #fff; background: rgba(20, 34, 70, .85); border: 1px solid #33508f; border-radius: 12px; touch-action: manipulation;
}
.m3-lv:hover { background: rgba(40, 62, 120, .95); }
.m3-lv i { font-style: normal; font-size: 10px; letter-spacing: 1px; color: #445a86; line-height: 1; }
.m3-lv i b { color: #ffd166; font-weight: 400; }
.m3-lv.m3-cur { border-color: #8fe6ff; box-shadow: 0 0 0 2px rgba(85, 214, 255, .4), 0 0 14px rgba(85, 214, 255, .35); }
.m3-lv:disabled { cursor: default; color: #5b6f96; background: rgba(12, 20, 42, .7); border-color: #1c2b4a; }
.m3-close { position: sticky; top: 0; z-index: 2; float: right; margin: -6px -6px 0 8px; }

/* ---- how to play ---- */
.m3-how { text-align: left; }
.m3-how ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 7px; }
.m3-how li { display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.38; color: #c6d6f2; }
.m3-how li > span:first-child { flex: 0 0 auto; display: flex; gap: 1px; min-width: 40px; justify-content: center; }
.m3-how li b { color: #fff; }
.m3-gems { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 4px 0; }
.m3-gems span { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: #8aa3c4; }
.m3-card-ico { display: flex; justify-content: center; gap: 4px; margin: 2px 0 8px; }

.m3-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.m3 button:focus-visible { outline: 2px solid #55d6ff; outline-offset: 2px; }

@keyframes m3-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m3-rise { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes m3-drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes m3-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
@keyframes m3-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes m3-star { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .m3 *, .m3 *::before, .m3 *::after { animation: none !important; transition: none !important; }
}

/* inline line icons inside panels */
.m3-how li > span:first-child { flex: 0 0 76px; min-width: 0; }
.m3-how [data-svg] { display: grid; place-items: center; width: 32px; height: 32px; color: #ffd166; }
.m3-how [data-svg] svg { width: 26px; height: 26px; display: block; }
.m3-how h3 { margin: 14px 0 6px; font-size: 15px; color: #fff; }
.m3-how p { margin: 6px 0; font-size: 14px; line-height: 1.45; color: #c6d6f2; }
.m3-gift [data-svg] { display: grid; place-items: center; color: #ffd166; }
.m3-svg-big { display: grid; place-items: center; width: 58px; height: 58px; color: #55d6ff; }
.m3-svg-big svg { width: 54px; height: 54px; display: block; }
.m3-help .hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .m3-help .hint-kb { display: none; } .m3-help .hint-touch { display: inline; } }

/* ---- refinements after the first screenshot pass ---- */
/* the close button floats without taking any width, so text beside it keeps the full line */
.m3-close { margin: -6px -6px 0 -38px; width: 44px; min-height: 44px; padding: 0; background: #1b2c58; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
.m3-map, .m3-how { container-type: inline-size; }
.m3-lvs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@container (min-width: 440px) { .m3-lvs { grid-template-columns: repeat(10, minmax(0, 1fr)); } .m3-lv { min-height: 46px; } }
@container (max-width: 380px) { .m3-how li { gap: 8px; font-size: 13.5px; } }
.m3-wide .m3-bst { padding: 4px 7px; gap: 5px; }
.m3-wide .m3-bst-i { width: 22px; }
.m3-wide .m3-bst-t { font-size: 12.5px; }
.m3-toast-side .m3-toast { grid-area: boost; justify-self: stretch; margin: 6px 0 0; border-radius: 14px; }
/* a narrow side column (a phone on its side): booster labels go under their icons */
.m3-boost { container-type: inline-size; }
@container (max-width: 250px) {
  .m3-wide .m3-bst { flex-direction: column; justify-content: center; gap: 1px; padding: 4px 2px 3px; min-height: 46px; }
  .m3-wide .m3-bst-t { flex: 0 0 auto; text-align: center; font-size: 11px; }
  .m3-wide .m3-bst-n { position: absolute; top: 3px; right: 4px; min-width: 18px; height: 18px; font-size: 11px; }
}
.m3-close + h2 { min-height: 42px; line-height: 42px; margin-bottom: 2px; white-space: nowrap; }
/* the line under the heading clears the close button's corner on a narrow sheet */
.m3-close + h2 + .m3-lead { margin-top: 10px; }
/* a very short side column (a small phone on its side): one row of icon-only boosters, tighter boxes */
.m3-short .m3-stage { row-gap: 5px; }
.m3-short .m3-title b, .m3-slim .m3-title b { font-size: 13px; white-space: normal; line-height: 1.05; }
.m3-short .m3-title span, .m3-slim .m3-title span { display: none; }
.m3-short .m3-goals { min-height: 44px; padding: 4px 6px; }
.m3-short .m3-stat { padding: 4px 12px; }
.m3-short .m3-boost { flex-wrap: nowrap; gap: 5px; }
.m3-short .m3-bst { flex: 1 1 0; min-height: 44px; }
.m3-short .m3-bst-t { display: none; }
