/* Jewel Match (jewels.js), on top of hanzo.css: the board, the jewels and their effects. */
.jm { --jm-size: max(300px, min(calc(100vh - 230px), 640px)); }
.jm__game { display: grid; grid-template-columns: min(calc(100% - 358px), var(--jm-size)) minmax(340px, 420px); gap: 18px; justify-content: center; align-items: start; }
.jm__boardwrap { position: relative; width: 100%; }
.jm__board { position: relative; width: 100%; aspect-ratio: 1; border: 1px solid var(--hz-line); border-radius: 12px; overflow: hidden; touch-action: none; user-select: none;
    background-color: #0b0a08; background-image: linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px); background-size: 12.5% 12.5%; }
.jm__board .jm__cell { position: absolute; left: calc(var(--x) * 12.5%); top: calc(var(--y) * 12.5%); width: 12.5%; height: 12.5%; transition: transform .15s ease-out, opacity .2s; cursor: grab; }
.jm__cell { display: flex; align-items: center; justify-content: center; box-sizing: border-box; border-radius: 10px; }
.jm__cell img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .7)); transition: transform .2s; }
.jm__board .jm__cell:hover img { transform: scale(1.1); }
.jm__cell.is-picked { background: rgba(231, 190, 106, .18); box-shadow: inset 0 0 0 2px var(--gold); }
.jm__cell.is-charged { background: radial-gradient(circle, rgba(255, 220, 140, .35), rgba(255, 220, 140, 0) 68%); }
.jm__cell.is-charged::after { content: ""; position: absolute; inset: 8%; border-radius: 50%; border: 2px dashed rgba(255, 228, 150, .8); animation: jm-spin 4s linear infinite; pointer-events: none; }
.jm__cell.is-charged img { animation: jm-glow 1.4s ease-in-out infinite; }
.jm__cell.is-pop { transition: transform .22s ease-in, opacity .22s ease-in; transform: scale(1.35) !important; opacity: 0; }
.jm__cell.is-beam { background: rgba(255, 240, 190, .45); }
.jm__cell.is-firing { background: rgba(255, 240, 190, .8); box-shadow: 0 0 22px rgba(255, 220, 140, .9); }
.jm__cell.is-shake { animation: jm-shake .3s; }
.jm__cell.is-shuffle { animation: jm-shuffle .4s ease-out; }
.jm__board .jm__cell[style*="translateY"] { transition: none; }
@keyframes jm-spin { to { transform: rotate(360deg); } }
@keyframes jm-glow { 50% { filter: drop-shadow(0 0 8px rgba(255, 225, 140, .95)); } }
@keyframes jm-shake { 25% { transform: translateX(-8%); } 75% { transform: translateX(8%); } }
@keyframes jm-shuffle { from { transform: rotate(-160deg) scale(.3); opacity: 0; } }

.jm__pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 12px; }
.jm__pop { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 20px; color: #ffe39a; text-shadow: 0 2px 6px #000, 0 0 10px rgba(0, 0, 0, .8); white-space: nowrap; animation: jm-float 1.1s ease-out forwards; }
.jm__pop.is-double { color: #ff8be0; font-size: 24px; }
.jm__pop.is-life { color: #7dff9a; }
.jm__pop.is-chaos { color: #ffb34a; font-size: 26px; }
@keyframes jm-float { from { opacity: 0; transform: translate(-50%, -20%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } to { opacity: 0; transform: translate(-50%, -160%); } }
.jm__banner { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); padding: 14px 26px; border-radius: 14px; border: 1px solid var(--gold); background: rgba(14, 12, 9, .92); color: #ffe39a; font-size: 26px; font-weight: 800; white-space: nowrap; animation: jm-banner 1.6s ease-out forwards; }
@keyframes jm-banner { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; } }

.jm__moves { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.jm__moves b { font-size: 34px; color: #8fd0ff; }
.jm__moves small { color: var(--muted); font-size: 12px; margin-top: 4px; }
.jm__moves.is-low b { color: var(--red); }
.jm__powers { display: flex; flex-direction: column; gap: 8px; }
.jm__power { display: flex; gap: 10px; align-items: center; }
.jm__power .jm__cell { position: relative; width: 40px; height: 40px; flex: none; }
.jm__power > div { display: flex; flex-direction: column; font-size: 13px; }
.jm__power b { color: var(--text); }

/* start menu: a dim field of jewels behind it */
.jm__demo { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); opacity: .3; }
.jm__demo img { width: 70%; height: 70%; margin: auto; object-fit: contain; }
.jm__howpic { gap: 4px; }
.jm__howpic img { width: 26px; height: 26px; object-fit: contain; }
.jm__howpic img.is-moving { transform: translateY(-10px); }
.jm__howpic .jm__cell { position: relative; width: 38px; height: 38px; }
.jm__howpic .jm__cell img { width: 30px; height: 30px; }
.jm__howbig { font-size: 28px; color: #8fd0ff; }

@media (max-width: 900px) {
    .jm__game { grid-template-columns: 1fr; }
    .jm__boardwrap { max-width: 640px; margin: 0 auto; }
}

/* each kind its own tile colour, so look-alike jewels (three pink, two yellow) read apart at a glance */
.jm__k0 { --jm-c: 140, 110, 255; }
.jm__k1 { --jm-c: 255, 45, 85; }
.jm__k2 { --jm-c: 46, 204, 113; }
.jm__k3 { --jm-c: 255, 176, 32; }
.jm__k4 { --jm-c: 0, 170, 255; }
.jm__k5 { --jm-c: 220, 230, 240; }
.jm__board .jm__cell::before, .jm__power .jm__cell::before { content: ""; position: absolute; inset: 6%; border-radius: 22%; pointer-events: none;
    background: radial-gradient(circle at 50% 40%, rgba(var(--jm-c), .38), rgba(var(--jm-c), .1) 70%); box-shadow: inset 0 0 0 1px rgba(var(--jm-c), .35); }
.jm__cell img { position: relative; }

/* power tooltip: a card like an item tooltip in the game */
.hanzo__itemtip.jm__tip { width: 280px; max-width: 280px; padding: 12px 14px; gap: 8px; border-color: rgba(231, 190, 106, .45); background: linear-gradient(180deg, #1d1810, #110e0a); box-shadow: 0 8px 24px rgba(0, 0, 0, .6); }
.jm__tiphead { display: flex; align-items: center; gap: 10px; }
.jm__tiphead .jm__cell { position: relative; width: 44px; height: 44px; flex: none; }
.jm__tiphead .jm__cell::before { content: ""; position: absolute; inset: 6%; border-radius: 22%; background: radial-gradient(circle at 50% 40%, rgba(var(--jm-c), .38), rgba(var(--jm-c), .1) 70%); box-shadow: inset 0 0 0 1px rgba(var(--jm-c), .35); }
.jm__tiphead b { color: #ffe39a; font-size: 15px; }
.jm__tiphow { color: var(--muted); font-size: 12px; line-height: 1.4; border-top: 1px solid var(--hz-line); padding-top: 8px; }
.jm__power { cursor: help; }

/* the game's haul: jewels gathered of each kind, the best chain, powers fired */
.jm__haul { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.jm__haulcell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 8px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid var(--hz-line); }
.jm__haulcell .jm__cell { position: relative; width: 40px; height: 40px; }
.jm__haulcell .jm__cell::before { content: ""; position: absolute; inset: 6%; border-radius: 22%; background: radial-gradient(circle at 50% 40%, rgba(var(--jm-c), .38), rgba(var(--jm-c), .1) 70%); box-shadow: inset 0 0 0 1px rgba(var(--jm-c), .35); }
.jm__haulcell b { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.jm__haulstats { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--hz-line); color: var(--muted); font-size: 13px; }
.jm__haulstats b { color: #ffe39a; font-size: 16px; margin-left: 4px; }
.hanzo__itemtip.jm__tip { transform: none; }

/* the side panel is exactly as tall as the board: powers in two columns, the haul card takes what is left */
@media (min-width: 901px) {
    .jm__game { align-items: stretch; }
    .jm__boardwrap { align-self: start; }
    .jm .hanzo__right { min-height: var(--jm-board-h, 0px); }
    .jm__powers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
    .jm__power { align-items: flex-start; }
    .jm__power > div { font-size: 12px; }
    .jm .hanzo__right > .hanzo__card:last-child { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
    .jm__haul { flex: 1; align-content: center; }
}
