#own-game { min-height: 800px; overflow: visible; background: radial-gradient(90% 70% at 50% 28%, #1a4170, #0a1a2e); border: 3px solid #d9a441; box-shadow: 0 0 0 4px #10264a, 0 16px 44px rgba(0, 110, 220, 0.2); scroll-margin-top: 8px; }

.zj { --size: clamp(44px, 12.4vw, 54px); --key: clamp(46px, 13vw, 56px); position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 794px; padding: 10px 8px 18px; }

/* Top bar */
.zj-hud { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.zj-logo { margin-right: auto; color: #ffc454; font-size: 1.5rem; font-style: italic; font-weight: 900; letter-spacing: -0.02em; text-transform: uppercase; text-shadow: 0 2px 0 #a15c00, 0 4px 0 #4d2b00; transform: rotate(-3deg); }
.zj-chip { padding: 4px 10px; background: rgba(4, 12, 24, 0.55); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px; color: #fff; font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
.zj-sound { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; background: rgba(4, 12, 24, 0.55); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; font-size: 0.95rem; cursor: pointer; }

.zj-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.zj-left, .zj-right { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }

/* The board is the panel of the finished wall: you lay tiles into it */
.zj-panel { padding: 8px; background: #efe6d3; border: 7px solid #1c3fae; border-radius: 6px; box-shadow: inset 0 0 0 3px #d9a441, 0 10px 26px rgba(0, 0, 0, 0.5); }
.zj-board { display: grid; gap: 5px; }
.zj-row { display: grid; grid-template-columns: repeat(4, var(--size)); gap: 5px; }
.zj-cell { position: relative; display: grid; width: var(--size); height: var(--size); background: #d6c9ae; border-radius: 4px; box-shadow: inset 0 2px 5px rgba(90, 70, 40, 0.45); }
.zj-cell .zj-tile { width: 100%; height: 100%; border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.zj-cell .zj-drop { animation: zj-set 0.16s ease-out; }
@keyframes zj-set { from { transform: scale(1.3); } }

/* Real zellij, cut from photographs: see the credits on the game page. */
.zj-tile { display: block; padding: 0; background-color: #2a343e; background-image: url(/assets/img/zellij-tiles.jpg); background-size: 500% 400%; border: 0; border-radius: 7px; }
.zj-t0, .zj-t5, .zj-t10, .zj-t15 { background-position-x: 0; }
.zj-t1, .zj-t6, .zj-t11, .zj-t16 { background-position-x: 25%; }
.zj-t2, .zj-t7, .zj-t12, .zj-t17 { background-position-x: 50%; }
.zj-t3, .zj-t8, .zj-t13, .zj-t18 { background-position-x: 75%; }
.zj-t4, .zj-t9, .zj-t14, .zj-t19 { background-position-x: 100%; }
.zj-f0 { --fam: #6da6ff; background-position-y: 0; }
.zj-f1 { --fam: #45c9a0; background-position-y: 33.333%; }
.zj-f2 { --fam: #ffb054; background-position-y: 66.667%; }
.zj-f3 { --fam: #d5dde5; background-position-y: 100%; }

/* Every mark has a symbol as well as a colour, so it reads without colour vision. */
.zj-m0 .zj-tile { filter: saturate(0.25) brightness(0.5); }
.zj-m1, .zj-m2, .zj-m3 { z-index: 1; outline: 4px solid var(--mark); outline-offset: -1px; }
.zj-m0 { --mark: #4b5664; }
.zj-m1 { --mark: #ffc454; }
.zj-m2 { --mark: #45dd9b; }
.zj-m3 { --mark: #6da6ff; }
.zj-m0::after, .zj-m1::after, .zj-m2::after, .zj-m3::after { position: absolute; right: -4px; bottom: -4px; z-index: 1; display: grid; place-items: center; width: 19px; height: 19px; background: var(--mark); border-radius: 50%; color: #071018; font: 900 0.72rem/1 var(--font); }
.zj-m0::after { content: "×"; color: #fff; }
.zj-m1::after { content: "?"; }
.zj-m2::after { content: "✓"; }
.zj-m3::after { content: "≈"; }

.zj-reveal .zj-cell { animation: zj-flip 0.42s ease both; }
.zj-reveal .zj-cell:nth-child(2) { animation-delay: 0.07s; }
.zj-reveal .zj-cell:nth-child(3) { animation-delay: 0.14s; }
.zj-reveal .zj-cell:nth-child(4) { animation-delay: 0.21s; }
@keyframes zj-flip { 50% { transform: rotateX(90deg); } }
.zj-win .zj-cell { animation: zj-hop 0.5s ease; }
.zj-win .zj-cell:nth-child(2) { animation-delay: 0.08s; }
.zj-win .zj-cell:nth-child(3) { animation-delay: 0.16s; }
.zj-win .zj-cell:nth-child(4) { animation-delay: 0.24s; }
@keyframes zj-hop { 40% { transform: translateY(-11px); } }


.zj-gems { display: flex; gap: 6px; }
.zj-gems i { width: 12px; height: 12px; background: #ffc454; box-shadow: 0 0 8px rgba(255, 196, 84, 0.8); transform: rotate(45deg); }
.zj-gems .zj-used { background: #33465c; box-shadow: none; }

.zj-msg { min-height: 1.4em; color: #dbe7f3; font-size: 0.92rem; font-weight: 650; line-height: 1.4; text-align: center; }

/* Tile tray */
.zj-play, .zj-end { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.zj-keys { display: grid; grid-template-columns: 44px repeat(5, var(--key)); gap: 6px 4px; align-items: center; }
.zj-fam { color: var(--fam); font-size: 0.72rem; font-weight: 800; background: none; }
.zj-keys .zj-tile { width: var(--key); height: calc(var(--key) * 0.84); box-shadow: inset 0 -3px 0 var(--fam), 0 3px 0 rgba(0, 0, 0, 0.55); cursor: pointer; transition: transform 0.08s; }
.zj-keys .zj-tile:hover:not(:disabled) { transform: translateY(-2px); }
.zj-keys .zj-tile:active:not(:disabled) { box-shadow: inset 0 -3px 0 var(--fam); transform: translateY(3px); }
.zj-keys .zj-tile:disabled { cursor: default; opacity: 0.4; }
.zj-keys .zj-k-out { filter: saturate(0.15) brightness(0.42); }
.zj-keys .zj-k-near { outline: 3px solid #ffc454; outline-offset: 1px; }
.zj-keys .zj-k-in { outline: 3px solid #45dd9b; outline-offset: 1px; }

/* Game buttons */
.zj-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.zj-go { min-width: 170px; padding: 12px 24px 10px; background: linear-gradient(#ffd97d, #f5a623); border: 0; border-bottom: 6px solid #a96400; border-radius: 14px; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4); color: #3a2300; font: italic 900 1.2rem/1.1 var(--font); text-transform: uppercase; cursor: pointer; }
.zj-go:hover:not(:disabled) { filter: brightness(1.07); }
.zj-go:active:not(:disabled) { border-bottom-width: 2px; transform: translateY(4px); }
.zj-go:disabled { background: #33465c; border-bottom-color: #1f2c3b; box-shadow: none; color: #8fa0b2; cursor: default; }
.zj-pulse { animation: zj-beat 1.3s ease-in-out infinite; }
@keyframes zj-beat { 50% { transform: scale(1.05); } }
.zj-alt { min-height: 44px; padding: 8px 16px; background: rgba(4, 12, 24, 0.5); border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 12px; color: #fff; font: 800 0.95rem/1.1 var(--font); cursor: pointer; }
.zj-alt:disabled { cursor: default; opacity: 0.4; }
.zj-small { min-height: 42px; font-size: 0.86rem; }
.zj-wa, .zj-x { display: grid; place-items: center; min-height: 42px; padding: 8px 14px; border-radius: 12px; font-size: 0.9rem; font-weight: 800; text-decoration: none; }
.zj-wa { background: #25d366; box-shadow: 0 4px 0 #128c4b; color: #05321a; }
.zj-x { background: #000; box-shadow: 0 4px 0 #3a4552; color: #fff; }

/* End of the game */
.zj-banner { text-align: center; }
.zj-banner h2 { font-size: clamp(2.1rem, 10vw, 2.9rem); font-style: italic; font-weight: 900; letter-spacing: -0.02em; line-height: 1.05; text-transform: uppercase; }
.zj-banner p { margin-top: 6px; color: #fff; font-weight: 700; }
.zj-won h2 { color: #ffc454; text-shadow: 0 3px 0 #a15c00, 0 6px 0 #4d2b00, 0 0 30px rgba(255, 196, 84, 0.55); transform: rotate(-2deg); animation: zj-land 0.6s cubic-bezier(0.2, 1.5, 0.4, 1); }
.zj-lost h2 { color: #ff9db8; text-shadow: 0 3px 0 #8a2346, 0 6px 0 #4a0f24; transform: rotate(-1deg); }
@keyframes zj-land { 0% { transform: scale(2.2) rotate(-8deg); } }

.zj-solution { display: flex; justify-content: center; gap: 7px; margin-top: 10px; }
.zj-solution[hidden] { display: none; }
.zj-stats { display: grid; grid-template-columns: repeat(4, 1fr); width: min(100%, 320px); overflow: hidden; background: #0a1420; border: 4px solid #33465c; border-radius: 14px; box-shadow: 0 5px 0 #0a1420; color: #9fb0c2; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-align: center; text-transform: uppercase; }
.zj-stats span { padding: 7px 2px 6px; }
.zj-stats strong { display: block; color: #7fffd0; font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0; line-height: 1.15; }

.zj-card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }

/* The wall, presented as the prize */
.zj-reward { position: relative; width: min(100%, 300px); margin-top: 16px; padding: 10px; background: linear-gradient(145deg, #ffe39a, #d9a441 45%, #8a5a0a); border-radius: 12px; box-shadow: 0 0 0 3px #4d2b00, 0 0 40px rgba(255, 196, 84, 0.45), 0 18px 34px rgba(0, 0, 0, 0.55); }
.zj-reward canvas { display: block; width: 100%; height: auto; border-radius: 4px; }
.zj-reward::after { position: absolute; inset: 10px; border-radius: 4px; background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.38) 50%, transparent 65%) no-repeat; background-size: 250% 100%; content: ""; pointer-events: none; animation: zj-shine 4.5s ease-in-out infinite; }
@keyframes zj-shine { 0%, 55% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
.zj-ribbon { position: absolute; top: -17px; left: 50%; z-index: 1; padding: 6px 30px; background: #c0392b; clip-path: polygon(0 0, 100% 0, 92% 50%, 100% 100%, 0 100%, 8% 50%); color: #fff; font-size: 0.92rem; font-style: italic; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; transform: translateX(-50%); white-space: nowrap; filter: drop-shadow(0 3px 0 #6e1a12); }

.zj-tools { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.zj-plate { display: flex; align-items: center; gap: 8px; width: min(100%, 260px); padding: 4px 12px; background: linear-gradient(#f5ecd9, #e2d4b6); border: 3px solid #d9a441; border-radius: 12px; box-shadow: 0 4px 0 #8a5a0a; }
.zj-plate input { flex: 1; min-width: 0; min-height: 36px; padding: 0; background: none; border: 0; color: #2b2118; font: 800 1rem/1.2 var(--font); }
.zj-plate input::placeholder { color: #7d705d; font-weight: 650; }
.zj-plate input:focus { outline: none; }
.zj-plate:focus-within { box-shadow: 0 4px 0 #8a5a0a, 0 0 0 3px var(--accent); }

.zj-switch { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; color: #dbe7f3; font-size: 0.92rem; font-weight: 750; cursor: pointer; }
.zj-switch input { position: absolute; opacity: 0; }
.zj-knob { position: relative; width: 48px; height: 26px; background: #33465c; border-radius: 999px; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5); transition: background 0.15s; }
.zj-knob::after { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4); content: ""; transition: transform 0.15s; }
.zj-switch input:checked + .zj-knob { background: #45dd9b; }
.zj-switch input:checked + .zj-knob::after { transform: translateX(22px); }
.zj-switch input:focus-visible + .zj-knob { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sharing: one big button, as game reward screens do */
.zj-share { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; margin-top: 4px; }
.zj-call { color: #ffc454; font-size: 0.98rem; font-style: italic; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
.zj-cta { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: min(100%, 300px); padding: 15px 22px 13px; font-size: 1.3rem; animation: zj-beat 1.6s ease-in-out infinite; }
.zj-cta[hidden] { display: none; }
.zj-cta svg { flex: none; }
.zj-done, .zj-done:hover { background: linear-gradient(#8ff5bf, #2ec27e); border-bottom-color: #0d7a46; color: #04301b; animation: none; }
.zj-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 8px; background: none; border: 0; color: #dbe7f3; font: 800 0.92rem/1 var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.zj-link svg { width: 18px; height: 18px; }
.zj-hint { color: #9fb0c2; font-size: 0.8rem; font-weight: 650; }

/* Countdown */
.zj-timer { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #9fb0c2; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.zj-timer[hidden] { display: none; }
.zj-timer strong { padding: 4px 14px; background: #0a1420; border: 3px solid #33465c; border-radius: 10px; color: #ff6b5e; font: 900 1.45rem/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; text-shadow: 0 0 10px rgba(255, 107, 94, 0.7); }


/* Start screen */
.zj-start { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 18px; background: radial-gradient(90% 70% at 50% 30%, #1f4d84, #0a1a2e); border-radius: var(--radius); text-align: center; }
.zj-start[hidden] { display: none; }
.zj-big { color: #ffc454; font-size: clamp(3.4rem, 16vw, 5rem); font-style: italic; font-weight: 900; letter-spacing: -0.02em; line-height: 1; text-transform: uppercase; text-shadow: 0 4px 0 #a15c00, 0 8px 0 #4d2b00, 0 14px 24px rgba(0, 0, 0, 0.55); transform: rotate(-3deg); }
.zj-tag { color: #fff; font-size: 1rem; font-weight: 750; }
.zj-legend { display: grid; gap: 8px; margin: 4px 0; padding: 12px 14px; background: rgba(4, 12, 24, 0.5); border-radius: 14px; color: #eaf1f8; font-size: 0.92rem; font-weight: 650; list-style: none; text-align: left; }
.zj-legend li { display: flex; align-items: center; gap: 12px; }
.zj-legend .zj-cell { flex: none; width: 34px; height: 34px; }
.zj-legend .zj-cell::after { width: 16px; height: 16px; font-size: 0.62rem; }

/* Real tiles falling on a win */
.zj-rain { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.zj-rain .zj-tile { position: absolute; top: -50px; width: 38px; height: 38px; animation: zj-fall linear both; }
@keyframes zj-fall { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(980px) rotate(460deg); } }

.zj-toast { position: fixed; left: 50%; bottom: 22px; z-index: 40; max-width: calc(100% - 32px); padding: 11px 18px; background: #0a1420; border: 2px solid #ffc454; border-radius: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.95rem; font-weight: 700; text-align: center; transform: translateX(-50%); }
.zj-toast[hidden] { display: none; }

@media (max-width: 345px) {
  .zj { --key: 48px; }
  .zj-keys { grid-template-columns: repeat(5, var(--key)); }
  .zj-fam { display: none; }
}

@media (min-width: 760px) {
  #own-game { min-height: 610px; }
  .zj { --size: 62px; --key: 60px; min-height: 604px; padding: 14px 18px 20px; }
  .zj-body { flex-direction: row; align-items: flex-start; justify-content: center; gap: 36px; }
  .zj-left, .zj-right { width: auto; }
  .zj-right { width: 380px; padding-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .zj-reveal .zj-cell, .zj-win .zj-cell, .zj-won h2, .zj-pulse, .zj-cell .zj-drop, .zj-reward::after, .zj-cta { animation: none; }
  .zj-rain { display: none; }
}
