.mj { --text: #dfe9ff; --muted: #8aa3c4; --line: #1c2b4a; --panel: #0b1328; --accent: #55d6ff; --warm: #ffd166;
  position: relative; margin: 0 auto; padding: 6px 4px 10px; color: var(--text); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mj [hidden] { display: none !important; }
.mj-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mj-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- controls ---------- */
.mj-top { display: flex; justify-content: space-between; align-items: center; gap: 8px 10px; flex-wrap: wrap; margin: 0 0 8px; }
.mj-opts { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.mj-opts label { display: flex; align-items: center; gap: 6px; }
.mj-opts select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; height: 40px; font-size: 14px; font-weight: 600; touch-action: manipulation; }
.mj-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.mj-btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; padding: 0 14px; font: inherit; font-weight: 700; font-size: 13.5px; white-space: nowrap; cursor: pointer; touch-action: manipulation; transition: border-color .15s, background-color .15s, transform .08s; }
@media (hover: hover) { .mj-btn:hover:not(:disabled) { border-color: var(--accent); } }
.mj-btn:active:not(:disabled) { transform: translateY(1px); }
.mj-btn:disabled { opacity: 0.4; cursor: default; }
.mj-btn:focus-visible, .mj-ibtn:focus-visible, .mj-opts select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mj-btn.mj-busy { opacity: 0.7; cursor: progress; }
.mj-btn-primary { background: var(--warm); color: #1a1200; border-color: var(--warm); }
@media (hover: hover) { .mj-btn-primary:hover:not(:disabled) { background: #ffe08a; border-color: #ffe08a; } }
.mj-ibtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: #c9d7ef; cursor: pointer; padding: 0; touch-action: manipulation; }
@media (hover: hover) { .mj-ibtn:hover { border-color: var(--accent); color: #fff; } }
.mj-ibtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mj-bar { display: flex; justify-content: center; gap: 6px 22px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.mj-bar b { color: #fff; font-size: 15px; font-weight: 800; margin-left: 3px; display: inline-block; min-width: 2ch; }
.mj-k { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 700; }

/* ---------- board ---------- */
.mj-wrap { position: relative; display: flex; align-items: center; justify-content: center; min-height: 120px; border-radius: 14px;
  background: radial-gradient(120% 90% at 50% 40%, #12305a 0%, #0a1a36 55%, #060d1f 100%); box-shadow: inset 0 0 0 1px #1c2b4a; overflow: hidden; }
.mj-board { position: relative; flex: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
.mj-tile { position: absolute; width: var(--w); height: var(--h); border-radius: var(--r); cursor: pointer; touch-action: none;
  background: linear-gradient(150deg, #fffdf7 0%, #f7f0de 55%, #ece1c6 100%);
  box-shadow: inset 0 0 0 1px rgba(122, 98, 52, 0.28), inset -1px -1px 0 1px rgba(255, 255, 255, 0.55),
    calc(var(--d) * 0.34) calc(var(--d) * 0.34) 0 #e4d7b5, calc(var(--d) * 0.6) calc(var(--d) * 0.6) 0 #cfbf95,
    calc(var(--d) * 0.82) calc(var(--d) * 0.82) 0 #2f8265, var(--d) var(--d) 0 #1d5d47,
    calc(var(--d) * 1.3) calc(var(--d) * 1.6) calc(var(--d) * 2.2) rgba(0, 0, 0, 0.55); }
.mj-tile svg { position: absolute; inset: 4% 5% 4% 4%; width: 91%; height: 92%; display: block; pointer-events: none; }
.mj-tile::before, .mj-tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.mj-tile::after { background: rgba(48, 34, 6, 0.2); opacity: 0; transition: opacity .2s ease; }
.mj-tile.blocked::after { opacity: 1; }
.mj-nodim .mj-tile.blocked::after { opacity: 0; }
.mj-tile.blocked { cursor: default; }
@media (hover: hover) { .mj-tile.free:hover { background: linear-gradient(150deg, #ffffff 0%, #fbf6e8 55%, #f2e8cf 100%); } }
.mj-tile.sel { background: linear-gradient(150deg, #fff6cf 0%, #ffe48f 60%, #f8cf5e 100%); transform: translate(-1px, -2px); }
.mj-tile.sel::before { box-shadow: inset 0 0 0 2px #d18a00, 0 0 0 2px rgba(255, 209, 102, 0.95), 0 0 14px 3px rgba(255, 209, 102, 0.55); }
.mj-tile.hint::before { box-shadow: inset 0 0 0 2px #1aa4d6, 0 0 0 2px rgba(85, 214, 255, 0.95), 0 0 16px 4px rgba(85, 214, 255, 0.55); animation: mj-pulse 0.8s ease-in-out infinite alternate; }
.mj-tile:focus { outline: none; }
.mj-tile:focus-visible::before { box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px #04060f; }
.mj-tile.sel:focus-visible::before { box-shadow: inset 0 0 0 2px #d18a00, 0 0 0 3px var(--accent), 0 0 12px 3px rgba(255, 209, 102, 0.55); }
.mj-tile.gone { visibility: hidden; pointer-events: none; }
.mj-small .mj-tile { box-shadow: inset 0 0 0 1px rgba(122, 98, 52, 0.3), calc(var(--d) * 0.5) calc(var(--d) * 0.5) 0 #d8c99f, var(--d) var(--d) 0 #1d5d47, calc(var(--d) + 1px) calc(var(--d) + 1px) calc(var(--d) * 1.2) rgba(0, 0, 0, 0.5); }
.mj-small .mj-tile svg { inset: 3%; width: 94%; height: 94%; }
.mj-ghost { pointer-events: none; z-index: 5; animation: mj-out .3s ease-in forwards; }
.mj-back { animation: mj-in .24s ease-out; }
.mj-shake { animation: mj-shake .3s; }
.mj-flip { animation: mj-flip .38s ease-in-out; }
@keyframes mj-out { 0% { opacity: 1; transform: translate(-1px, -2px); } 100% { opacity: 0; transform: translate(0, -14%) scale(1.14); } }
@keyframes mj-in { from { opacity: 0; transform: scale(1.12); } }
@keyframes mj-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes mj-flip { 0%, 100% { transform: none; } 45%, 55% { transform: scaleX(0.08); } }
@keyframes mj-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.mj-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; z-index: 8; }
.mj-fx.on { display: block; }
.mj-toast { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -6px); max-width: calc(100% - 24px); background: #f4f7fb; color: #0b1328; font-weight: 750; font-size: 13.5px; padding: 8px 15px; border-radius: 999px; pointer-events: none; opacity: 0; z-index: 9; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.mj-toast.show { animation: mj-toast var(--t, 1.7s) ease forwards; }
@keyframes mj-toast { 0% { opacity: 0; transform: translate(-50%, -6px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -4px); } }

/* ---------- sheets ---------- */
.mj-scrim { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 4, 10, 0.62); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: mj-fade .2s ease; }
.mj-sheet { position: relative; width: 100%; max-width: 440px; max-height: min(88vh, 720px); max-height: min(88dvh, 720px); overflow: auto; overscroll-behavior: contain; background: #0d1630; border: 1px solid #22345a; border-radius: 18px; padding: 22px 20px 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); color: var(--text); animation: mj-sheet .26s cubic-bezier(.2, .8, .2, 1); }
.mj-sheet:focus { outline: none; }
.mj-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.08); color: #c9d7ef; font-size: 22px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.mj-x:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.mj-sheet-title { margin: 0 44px 6px 0; font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.mj-sub { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.mj-fine { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; }
.mj-res { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; margin: 16px 0 0; text-align: center; }
.mj-res4 { grid-template-columns: repeat(4, 1fr); }
.mj-res div { display: flex; flex-direction: column; gap: 2px; background: #0a1226; border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; }
.mj-res b { font-size: 22px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.mj-res span { font-size: 11.5px; color: var(--muted); }
.mj-badge { margin: 12px auto 0; width: max-content; font-size: 12.5px; font-weight: 800; padding: 4px 11px; border-radius: 999px; background: rgba(255, 209, 102, 0.16); color: var(--warm); }
.mj-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.mj-actions .mj-btn { flex: 1 1 0; min-width: max-content; min-height: 44px; }
.mj-actions .mj-btn-primary { flex-basis: 100%; }
.mj-table { width: 100%; border-collapse: collapse; margin: 16px 0 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.mj-table th, .mj-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.mj-table th:first-child { text-align: left; font-weight: 700; color: #fff; }
.mj-table thead th { color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.mj-set { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.mj-set span { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.mj-set b { color: #fff; font-size: 15px; } .mj-set small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.mj-set input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mj-set i { flex: none; width: 46px; height: 28px; border-radius: 14px; background: #2b3448; position: relative; transition: background-color .15s; }
.mj-set i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.mj-set input:checked + i { background: #2ec27e; } .mj-set input:checked + i::after { left: 21px; }
.mj-set input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.mj-list { margin: 12px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.5; color: var(--text); }
.mj-list li { margin: 0 0 7px; }
@keyframes mj-fade { from { opacity: 0; } }
@keyframes mj-sheet { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
@media (max-width: 520px) {
  .mj-scrim { align-items: flex-end; padding: 0; }
  .mj-sheet { max-width: none; border-radius: 20px 20px 0 0; border-bottom: 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .mj *, .mj-scrim, .mj-sheet { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ---------- phones (page view) ---------- */
@media (max-width: 560px) {
  .mj { padding: 4px 0 8px; }
  .mj-top { justify-content: center; }
  .mj-tools { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .mj-btn { padding: 0 4px; }
  .mj-opts { width: 100%; }
  .mj-opts label { flex: 1 1 auto; }
  .mj-opts select { flex: 1 1 auto; min-width: 0; }
}

/* ---------- full screen (.mj-fit, set by game.js inside the site's immersive stage) ---------- */
.mj.mj-fit { height: 100%; max-width: none; margin: 0; padding: 6px 2px 6px; display: flex; flex-direction: column; overflow: hidden; }
.mj-fit .mj-top { flex: none; justify-content: center; margin: 0 0 6px; }
.mj-fit .mj-bar { flex: none; margin: 0 0 6px; }
.mj-fit .mj-wrap { flex: 1 1 auto; min-height: 0; height: auto; }
/* landscape: board on the left, controls in a column on the right */
.mj.mj-land { display: grid; grid-template-columns: minmax(0, 1fr) 184px; grid-template-rows: auto auto minmax(0, 1fr); gap: 8px 10px; padding: 6px; }
.mj-land .mj-wrap { grid-column: 1; grid-row: 1 / -1; }
.mj-land .mj-top { grid-column: 2; grid-row: 1; flex-direction: column; align-items: stretch; margin: 0; }
.mj-land .mj-opts { width: 100%; flex-wrap: wrap; }
.mj-land .mj-opts label { flex: 1 1 100%; min-width: 0; font-size: 0; gap: 0; }
.mj-land .mj-ibtn { flex: 1 1 0; width: auto; }
.mj-land .mj-opts select { flex: 1 1 auto; min-width: 0; width: 100%; }
.mj-land .mj-tools { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.mj-land .mj-btn { padding: 0 6px; }
.mj-land .mj-bar { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.mj-land .mj-stat { display: flex; justify-content: space-between; align-items: baseline; }
