/* Hiko Games shared mini-game design system.
   Account accent color from :root --accent (neutral gray by default).
   Keep mini-game pages compact, playable first, without promotional banners. */
.hg{--game-accent:var(--accent,#a8a8ae);--game-soft:color-mix(in srgb,var(--game-accent) 66%,white);--game-low:color-mix(in srgb,var(--game-accent) 36%,#303139);--game-bg:#27282e;--game-border:color-mix(in srgb,var(--game-accent) 25%,#393a42);margin:0 auto 28px;max-width:1120px;color:#f2f0ec}
.hg *{box-sizing:border-box}
.hg button{font:inherit;cursor:pointer}
.hg button:disabled{opacity:.38;cursor:not-allowed}
.hg button:focus-visible{outline:3px solid var(--game-accent);outline-offset:3px}
.hg-header{margin:0 auto 16px;max-width:100%}
.hg-topline{display:flex;align-items:center;justify-content:space-between;gap:12px}
.hg-back{color:#f4f2ed!important;background:#292a30!important;border:1px solid var(--game-border)!important;border-radius:999px!important;padding:10px 17px!important;font-size:13px!important;font-weight:550!important}
.hg-category{font-size:12px;letter-spacing:.03em;color:#bbb7b2}
.hg-header h1{text-align:center;font-weight:760;font-size:clamp(32px,4.7vw,52px);letter-spacing:-.025em;line-height:1.15;margin:13px auto 8px;color:#f2f0ec}
.hg-subtitle{text-align:center;color:#bbb9b7;font-size:14px;margin:0 0 20px;line-height:1.45}
.hg-columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,270px);gap:18px;align-items:start}
.hg-play{display:flex;flex-direction:column;align-items:center;gap:12px;min-width:0;border:1px solid var(--game-border);border-radius:20px;padding:20px 15px;background:linear-gradient(155deg,#292a30,#222329);box-shadow:0 15px 45px #0004}
.hg-main{width:100%;display:grid;place-items:center;min-width:0}
.hg-message{min-height:22px;text-align:center;color:var(--game-soft);font-size:13px;line-height:1.5}
.hg-controls{max-width:430px;width:100%}
.hg-side{display:grid;gap:12px;min-width:0}
.hg-stats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.hg-stat,.hg-panel{background:var(--game-bg);border:1px solid var(--game-border);border-radius:15px;padding:15px}
.hg-stat{min-height:79px}
.hg-stat-title{display:block;color:#bcb9b6;font-size:10px;letter-spacing:.08em;text-transform:uppercase;margin-bottom:7px}
.hg-stat-value{display:block;color:var(--game-soft);font-size:clamp(18px,2.2vw,25px);font-weight:650;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.hg-panel h2{font-size:14px;font-weight:650;margin:0 0 12px;color:#f3f0eb}
.hg-details{display:grid;gap:10px}
.hg-help{font-size:13px;color:#c1bdba;line-height:1.6;margin:4px 0}
.hg-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.hg-actions button:only-child{grid-column:1/-1}
.hg-primary,.hg-button{min-height:43px;border-radius:12px!important;border:1px solid var(--game-border)!important;padding:10px 11px!important;font-size:13px!important;font-weight:700!important}
.hg-primary{color:#191a1d!important;background:linear-gradient(135deg,var(--game-accent),var(--game-soft))!important;border-color:var(--game-soft)!important}
.hg-button{background:#35363d!important;color:#f3f0eb!important}
.hg-footnote{font-size:11px;color:#aaa6a2;line-height:1.55;margin:2px 0}
.hg-touch{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:12px auto 0}
.hg-touch-btn{min-height:48px;border-radius:12px!important;border:1px solid var(--game-border)!important;background:#34353c!important;color:var(--game-soft)!important;padding:9px!important;font-size:21px!important}
.hg-touch-btn:active{background:var(--game-low)!important}
.hg-snake-board{--cell:clamp(14px,2.25vw,25px);display:grid;grid-template-columns:repeat(16,var(--cell));grid-template-rows:repeat(16,var(--cell));gap:2px;padding:10px;background:#121317;border:1px solid var(--game-border);border-radius:14px;touch-action:none}
.hg-snake-cell{background:linear-gradient(140deg,#24252b,#1e1f24);border-radius:3px}
.hg-snake-body{background:var(--game-accent);box-shadow:inset 1px 1px 1px #fff7,inset -2px -2px 2px #0005}
.hg-snake-head{background:var(--game-soft);box-shadow:inset 2px 1px 1px #fff7,0 0 10px color-mix(in srgb,var(--game-accent) 42%,transparent)}
.hg-snake-food{background:#f2f1ed;border-radius:50%;box-shadow:0 0 12px color-mix(in srgb,var(--game-accent) 70%,white);transform:scale(.72)}
.hg-merge-board{--cell:clamp(66px,8.2vw,92px);display:grid;grid-template-columns:repeat(4,var(--cell));grid-template-rows:repeat(4,var(--cell));gap:8px;padding:12px;background:#17181e;border:1px solid var(--game-border);border-radius:17px;touch-action:none}
.hg-merge-cell{display:grid;place-items:center;background:#2d2e34;border-radius:9px;color:#18191d;font-size:clamp(18px,2.1vw,30px);font-weight:800;font-variant-numeric:tabular-nums}
.hg-merge-filled{background:linear-gradient(135deg,var(--game-soft),var(--game-accent));box-shadow:inset 2px 2px 2px #fff7,0 2px 12px color-mix(in srgb,var(--game-accent) 18%,transparent)}
.hg-merge-cell[data-value="4"],.hg-merge-cell[data-value="16"],.hg-merge-cell[data-value="64"],.hg-merge-cell[data-value="256"],.hg-merge-cell[data-value="1024"]{background:linear-gradient(135deg,var(--game-accent),var(--game-low));color:#f2f0ed}
.hg-merge-cell[data-value="128"],.hg-merge-cell[data-value="512"],.hg-merge-cell[data-value="2048"]{background:linear-gradient(140deg,#f6f5f1,var(--game-soft));box-shadow:0 0 17px color-mix(in srgb,var(--game-accent) 40%,transparent)}
.hg-merge-cell[data-value="4096"],.hg-merge-cell[data-value="8192"]{font-size:20px}
/* Hiko Match: five exact legacy HU accent colors. Background remains anthracite. */
.hg-match-board{--cell:clamp(36px,4.2vw,51px);--match-gap:5px;display:grid;grid-template-columns:repeat(8,var(--cell));grid-template-rows:repeat(8,var(--cell));gap:var(--match-gap);padding:10px;background:#17181e;border:1px solid var(--game-border);border-radius:16px;touch-action:manipulation;isolation:isolate}
.hg-match-cell{position:relative!important;background:#34353e!important;color:#f7f6f3!important;border:1px solid #ffffff26!important;border-radius:8px!important;display:grid;place-items:center;line-height:1!important;font-size:clamp(24px,3vw,35px)!important;padding:0!important;user-select:none;-webkit-user-select:none;overflow:visible!important;isolation:auto}
.hg-match-cell:disabled{opacity:1!important;cursor:default!important}
.hg-match-glyph{display:inline-flex;align-items:center;justify-content:center;position:relative;z-index:2;line-height:1;color:var(--tile-color,#b9b9b5);font-family:Arial,sans-serif;font-size:1em;font-weight:750;text-shadow:0 1px 2px #0009,0 0 8px color-mix(in srgb,var(--tile-color,#b9b9b5) 38%,transparent);will-change:transform}
.hg-match-cell .hg-match-glyph{transition:filter .12s ease}
.hg-match-picked{outline:3px solid var(--game-soft)!important;background:var(--game-low)!important;box-shadow:0 0 12px var(--game-accent)}
.hg-match-power{filter:drop-shadow(0 0 4px var(--tile-color))}
.hg-match-power-mark{position:absolute;right:-6px;bottom:-4px;min-width:16px;height:16px;display:grid;place-items:center;z-index:5;border-radius:5px;border:1px solid #e5e0d8;background:#25262b;color:#fff;font:800 12px/1 Arial,sans-serif;box-shadow:0 1px 4px #0009;text-shadow:none}
.hg-match-power-bomb .hg-match-power-mark{background:#c6a0a8;color:#1c1821}
.hg-match-power-row .hg-match-power-mark,.hg-match-power-column .hg-match-power-mark{background:#8faabd;color:#1a1d24}
.hg-match-clearing{z-index:8!important;border-color:var(--tile-color,#e6d7be)!important}
.hg-match-clearing .hg-match-glyph{animation:hu-match-clear .24s cubic-bezier(.2,.75,.3,1) both}
.hg-match-falling{animation:hu-match-fall .4s cubic-bezier(.16,.78,.32,1.12) both}
.hg-match-new{animation-name:hu-match-fall-new}
@keyframes hu-match-clear{0%{transform:scale(1);filter:brightness(1)}45%{transform:scale(1.32);filter:brightness(1.8) drop-shadow(0 0 11px var(--tile-color,#fff))}100%{transform:scale(.05);filter:brightness(2.2);opacity:0}}
@keyframes hu-match-fall{0%{transform:translateY(var(--fall-offset,0px)) scale(.92);opacity:.8}77%{transform:translateY(3px) scale(1.03);opacity:1}100%{transform:translateY(0) scale(1);opacity:1}}
@keyframes hu-match-fall-new{0%{transform:translateY(var(--fall-offset,0px)) scale(.85);opacity:.1}77%{transform:translateY(4px) scale(1.04);opacity:1}100%{transform:translateY(0) scale(1);opacity:1}}
/* The moving rainbow HU star, built directly in CSS, no GIF or extra media files. */
.hg-match-power-rainbow{font-family:Georgia,serif;font-size:1.24em;font-weight:900;background-image:linear-gradient(105deg,#b9b9b5 0%,#8faabd 13%,#91aa98 29%,#c6a0a8 45%,#bba678 62%,#a9a0bb 78%,#b9b9b5 100%);background-size:350% 100%;background-clip:text;-webkit-background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent!important;text-shadow:none;filter:drop-shadow(0 0 5px #dfd6ea);animation:hu-match-rainbow 3.2s linear infinite,hu-match-star-pulse 2.4s ease-in-out infinite alternate}
.hg-match-power-rainbow:after{content:"✧";position:absolute;top:-.3em;right:-.23em;color:#f7f5ec;-webkit-text-fill-color:#f7f5ec;font:700 .36em Arial,sans-serif;animation:hu-match-twinkle 1.2s ease-in-out infinite alternate}
@keyframes hu-match-rainbow{0%{background-position:0% 50%}100%{background-position:100% 50%}}
@keyframes hu-match-star-pulse{0%{transform:rotate(-9deg) scale(.94);filter:drop-shadow(0 0 4px #acb8d9)}100%{transform:rotate(9deg) scale(1.13);filter:drop-shadow(0 0 11px #efceac)}}
@keyframes hu-match-twinkle{from{opacity:.3;transform:scale(.7)}to{opacity:1;transform:scale(1.2)}}
.hg-match-legend{display:flex;align-items:center;justify-content:center;gap:9px;flex-wrap:wrap;padding:4px 0 5px}
.hg-match-swatch{display:grid;place-items:center;width:37px;height:36px;border-radius:9px;background:#31323a;border:1px solid #ffffff21;font-size:26px;line-height:1}
.hg-target{display:flex;align-items:center;gap:11px}
.hg-target-symbol{color:var(--tile-color,#b9b9b5);font-size:35px;font-weight:800;line-height:1;text-shadow:0 0 10px color-mix(in srgb,var(--tile-color,#b9b9b5) 42%,transparent)}
.hg-target-count{font-size:13px;color:#f4eee5;line-height:1.4}
.hg-hearts{font-size:13px;line-height:1.6;margin:4px 0;color:var(--game-soft)}
@media(max-width:650px){.hg-match-board{--match-gap:3px}.hg-match-cell{font-size:clamp(20px,6.6vw,32px)!important}.hg-match-swatch{width:33px;height:32px;font-size:23px}}

/* Cascades announce their freshly generated power-ups without losing the fall animation. */
.hg-match-created{animation:hu-match-power-created .54s ease-out both;z-index:3!important}
@keyframes hu-match-power-created{
  0%{box-shadow:0 0 0 0 transparent;border-color:#ffffff26}
  38%{box-shadow:0 0 0 3px var(--game-soft),0 0 16px 7px color-mix(in srgb,var(--game-accent) 36%,transparent);border-color:var(--game-soft)}
  100%{box-shadow:0 0 0 0 transparent;border-color:#ffffff26}
}
/* Level success occurs only once the final swap and falling cascades are finished. */
.hg-main:has(.hg-match-board){position:relative;isolation:isolate}
.hg-match-level-win{position:absolute;z-index:15;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;
  border:1px solid color-mix(in srgb,var(--game-accent) 70%,white);
  border-radius:17px;background:radial-gradient(circle at 50% 40%,#36313bdc,#18191bea 75%);
  text-align:center;pointer-events:none;color:#f5f2ed;padding:20px;box-shadow:inset 0 0 45px color-mix(in srgb,var(--game-accent) 22%,transparent)}
.hg-match-level-win[hidden]{display:none!important}
.hg-match-level-win h2{font-size:clamp(22px,3.2vw,36px);font-weight:750;margin:0}
.hg-match-level-win p{color:#e9dfcc;font-size:14px;margin:0}
.hg-match-win-spark{font-family:Georgia,serif;font-size:clamp(56px,7vw,96px);line-height:1;
  background-image:linear-gradient(104deg,#8faabd,#91aa98,#c6a0a8,#bba678,#a9a0bb,#8faabd);
  background-size:250% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;
  filter:drop-shadow(0 0 12px color-mix(in srgb,var(--game-accent) 60%,transparent))}
.hg-level-win-visible{animation:hu-match-win-appear 1.9s ease-in-out forwards}
.hg-level-win-visible .hg-match-win-spark{animation:hu-match-win-spark 1.9s ease-out,hu-match-rainbow 2.3s linear infinite}
@keyframes hu-match-win-appear{0%{opacity:0;transform:scale(.96)}17%{opacity:1;transform:scale(1)}78%{opacity:1}100%{opacity:0}}
@keyframes hu-match-win-spark{0%{transform:scale(.25) rotate(-45deg);opacity:.1}35%{transform:scale(1.12) rotate(8deg);opacity:1}70%{transform:scale(.98)}100%{transform:scale(1)}}
@media(prefers-reduced-motion:reduce){.hg-level-win-visible,.hg-level-win-visible .hg-match-win-spark,.hg-match-created{animation:none!important}.hg-match-level-win{opacity:1}}

@media(prefers-reduced-motion:reduce){.hg-match-power-rainbow,.hg-match-power-rainbow:after,.hg-match-clearing .hg-match-glyph,.hg-match-falling{animation:none!important}.hg-match-power-rainbow{background-size:100% 100%}}
.hg-logic-modes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:0 auto 12px}
.hg-mode{font-size:11px!important;line-height:1.3!important;padding:8px 4px!important;border-radius:10px!important;border:1px solid var(--game-border)!important;color:#dfdcda!important;background:#34343b!important}
.hg-mode-selected{background:var(--game-accent)!important;color:#191a1d!important;border-color:var(--game-soft)!important}
.hg-logic-board{--cell:clamp(49px,5.8vw,70px);display:grid;grid-template-columns:repeat(var(--logic-size),var(--cell));grid-template-rows:repeat(var(--logic-size),var(--cell));gap:6px;padding:11px;margin:auto;background:#16171b;border:1px solid var(--game-border);border-radius:16px}
.hg-logic-tile{position:relative!important;padding:0!important;border:1px solid var(--game-border)!important;background:#31323a!important;border-radius:10px!important;color:var(--game-soft)!important;overflow:hidden}
.hg-logic-blank{opacity:.3;cursor:default!important}
.hg-pipe{position:absolute;display:block;background:var(--game-accent);box-shadow:0 0 7px color-mix(in srgb,var(--game-accent) 40%,transparent)}
.hg-pipe-n,.hg-pipe-s{width:13%;height:50%;left:43.5%}
.hg-pipe-n{top:0}.hg-pipe-s{bottom:0}
.hg-pipe-e,.hg-pipe-w{height:13%;width:50%;top:43.5%}
.hg-pipe-e{right:0}.hg-pipe-w{left:0}
.hg-pipe-center{position:absolute;width:18%;height:18%;left:41%;top:41%;border-radius:50%;background:var(--game-soft)}
.hg-logic-marker{z-index:2;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:15px;color:#15161a;background:var(--game-soft);width:25px;height:25px;border-radius:50%;display:grid;place-items:center}
.hg-logic-start,.hg-logic-end{box-shadow:inset 0 0 0 2px var(--game-accent)}
@media(max-width:1050px){.hg-columns{grid-template-columns:1fr}.hg-side{grid-template-columns:repeat(2,minmax(0,1fr))}.hg-stats{grid-column:1/-1}.hg-actions{grid-column:1/-1}.hg-footnote{grid-column:1/-1}.hg-snake-board{--cell:clamp(17px,2.7vw,27px)}.hg-match-board{--cell:clamp(32px,5vw,48px)}}
@media(max-width:650px){.hg-header{margin-bottom:9px}.hg-header h1{font-size:31px;margin-top:8px}.hg-subtitle{font-size:12px;margin-bottom:12px}.hg-category{font-size:11px}.hg-play{padding:12px 6px}.hg-columns{gap:10px}.hg-side{grid-template-columns:1fr}.hg-stats{grid-column:auto}.hg-actions{grid-column:auto}.hg-footnote{grid-column:auto}.hg-snake-board{--cell:clamp(14px,4.55vw,21px);gap:1px;padding:7px}.hg-merge-board{--cell:clamp(57px,17.2vw,75px);gap:5px;padding:7px}.hg-match-board{--cell:clamp(29px,8.2vw,41px);gap:3px;padding:6px}.hg-logic-board{--cell:clamp(37px,10.4vw,54px);gap:4px;padding:6px}.hg-mode{font-size:10px!important}.hg-touch-btn{min-height:43px}}
@media(prefers-reduced-motion:reduce){.hg button{transition:none}}

/* Snake: discrete grid rules with smooth visual interpolation on a separate layer. */
.hg-snake-board{position:relative;overflow:hidden}
.hg-snake-overlay{position:absolute;inset:0;pointer-events:none;z-index:2}
.hg-snake-segment{position:absolute;top:0;left:0;border-radius:4px;background:var(--game-accent);
 box-shadow:inset 1px 1px 1px #ffffff7b,inset -2px -2px 2px #0005;
 will-change:transform;pointer-events:none;contain:paint}
.hg-snake-segment-head{background:var(--game-soft);border-radius:5px;
 box-shadow:inset 2px 1px 1px #ffffff91,0 0 10px color-mix(in srgb,var(--game-accent) 42%,transparent)}
/* Merge: two tiles move into the same cell before the new value pops into place. */
.hg-merge-board{position:relative;isolation:isolate}
.hg-merge-fly-layer{position:absolute;inset:0;z-index:6;pointer-events:none}
.hg-merge-fly{position:absolute;display:grid;place-items:center;border-radius:9px;
 background:linear-gradient(135deg,var(--game-soft),var(--game-accent));color:#19191d;
 font-weight:800;font-size:clamp(18px,2.1vw,30px);font-variant-numeric:tabular-nums;
 box-shadow:inset 2px 2px 2px #fff7,0 2px 12px color-mix(in srgb,var(--game-accent) 18%,transparent);
 will-change:transform}
.hg-merge-fly[data-value="4"],.hg-merge-fly[data-value="16"],.hg-merge-fly[data-value="64"],
.hg-merge-fly[data-value="256"],.hg-merge-fly[data-value="1024"]{background:linear-gradient(135deg,var(--game-accent),var(--game-low));color:#f2f0ed}
.hg-merge-board.is-moving .hg-merge-cell.hg-merge-filled{visibility:hidden}
/* Keep high-value tiles visually stable; no repeated outer glow when they move. */
.hg-merge-cell[data-value="128"],.hg-merge-cell[data-value="512"],.hg-merge-cell[data-value="2048"]{
 background:linear-gradient(140deg,#f6f5f1,var(--game-soft));box-shadow:inset 2px 2px 2px #ffffff70;filter:none}
.hg-merge-fly[data-value="128"],.hg-merge-fly[data-value="512"],.hg-merge-fly[data-value="2048"]{
 background:linear-gradient(140deg,#f6f5f1,var(--game-soft));color:#18191d;
 box-shadow:inset 2px 2px 2px #ffffff70}

.hg-merge-pop{animation:hg-merge-pop .29s cubic-bezier(.19,.85,.26,1.3)}
.hg-merge-spawn{animation:hg-merge-spawn .24s ease-out}
@keyframes hg-merge-pop{0%{transform:scale(.76);filter:brightness(1.8)}
 52%{transform:scale(1.15);filter:brightness(1.25);box-shadow:0 0 22px var(--game-accent)}
 100%{transform:scale(1);filter:brightness(1)}}
@keyframes hg-merge-spawn{0%{transform:scale(.4);opacity:0}
 65%{transform:scale(1.08);opacity:1}100%{transform:scale(1);opacity:1}}
@media(prefers-reduced-motion:reduce){.hg-merge-pop,.hg-merge-spawn{animation:none!important}}


/* Safari touch controls for two distinct interactions:
 * Match: one-finger swipe swaps cells. Only this board captures touch panning.
 * Logic: manipulation suppresses double-tap smart zoom while retaining pinch
 * zoom and normal document scrolling outside the puzzle.
 */
.hg-match-board,.hg-match-cell{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
.hg-logic-board,.hg-logic-tile{touch-action:manipulation;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
.hg-logic-tile{cursor:pointer}

/* Match shows one actual goal, not a repeated counter and a second card.
 * Wide screens: side panel. Narrow screens: same DOM card under the grid,
 * replacing the decorative color legend. No duplicated accessible content. */
.hg-match-stats .hg-stat:last-child{grid-column:1/-1}
.hg-match-objective .hg-target{gap:12px}
.hg-match-objective .hg-target-count{font-variant-numeric:tabular-nums}
@media(max-width:700px){
 .hg-match-legend{display:none}
 .hg-controls:has(.hg-match-objective){max-width:100%;margin:0;display:block}
 .hg-controls .hg-match-objective{width:100%;padding:11px 14px;border-radius:12px;
  background:color-mix(in srgb,var(--game-accent) 10%,#26272d);
  border:1px solid color-mix(in srgb,var(--game-accent) 40%,#484950)}
 .hg-controls .hg-match-objective h2{font-size:12px;color:var(--game-soft);
  margin:0 0 6px}
 .hg-controls .hg-match-objective .hg-target{justify-content:center;gap:13px}
 .hg-controls .hg-match-objective .hg-target-symbol{font-size:34px}
 .hg-controls .hg-match-objective .hg-target-count{font-size:14px;font-weight:650}
}
