/* EwrekaGames — Snake (assets/js/solo/yilan.js). Loaded only on the Snake pages (bo_game_css). */

/* The solo shell's puzzle-only parts (clock, best time, hint/mistakes, new/restart, share, daily link, status line)
   have no meaning for an arcade game: the game shows its own score, best and controls inside the board. */
#soloMain[data-game="yilan"] .solo-clock,
#soloMain[data-game="yilan"] .solo-stats,
#soloMain[data-game="yilan"] .solo-opts,
#soloMain[data-game="yilan"] .solo-card .actions,
#soloMain[data-game="yilan"] #btnShare,
#soloMain[data-game="yilan"] .daily-link,
#soloMain[data-game="yilan"] #status,
#soloMain[data-game="yilan"] #soloPad { display: none; }
#soloMain[data-game="yilan"] .solo-stage { gap: 8px; }

.yl {
  --yl-frame: #1e2636; --yl-frame-d: #0f1522;
  --s: 0px; --pb: 56px;
  width: 100%; display: grid; grid-template-columns: auto; justify-content: center; justify-items: center; gap: 10px;
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] .yl { --yl-frame: #46536b; --yl-frame-d: #0a0d13; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .yl { --yl-frame: #46536b; --yl-frame-d: #0a0d13; } }

/* score bar: fixed height, numbers in fixed-width cells (a growing score never moves anything) */
.yl-hud { width: var(--s); max-width: 100%; height: 46px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 46px; gap: 8px; touch-action: manipulation; }
.yl.row { grid-template-columns: auto auto; grid-template-rows: auto 1fr; column-gap: 14px; row-gap: 10px; align-items: start; }
.yl.row .yl-field { grid-row: 1 / 3; grid-column: 1; }
.yl.row .yl-hud { grid-column: 2; grid-row: 1; width: calc(var(--pb) * 3 + 12px); height: auto; grid-template-columns: 1fr; gap: 4px; }
.yl.row .yl-stat { flex-direction: row; align-items: center; justify-content: space-between; height: 28px; padding: 0 10px; gap: 8px; }
.yl.row .yl-stat .yl-num { font-size: 16px; }
.yl.row .yl-hbtn { display: none; }
.yl.row .yl-pad { grid-column: 2; grid-row: 2; align-self: start; }
.yl-stat { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.yl-stat small { font-size: 11px; font-weight: 600; color: var(--ink-3); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yl-stat .yl-num { font-size: 18px; font-weight: 800; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.yl-stat:first-child .yl-num { color: var(--brand); }
.yl-hbtn { width: 46px; height: 46px; padding: 0; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); box-shadow: var(--press); cursor: pointer; }
.yl-hbtn svg { width: 22px; height: 22px; }
.yl-hbtn:active:not(:disabled) { box-shadow: none; background: var(--surface-2); }
.yl-hbtn:disabled { opacity: .4; cursor: default; }
.yl-hbtn:focus-visible, .yl-pb:focus-visible, .yl-seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }


/* the field: size set once in px by the script; the frame is a shadow (no layout) */
.yl-field { position: relative; flex: none; border-radius: 10px; background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--yl-frame), 0 7px 0 4px var(--yl-frame-d); margin: 4px 4px 10px; touch-action: none; cursor: default; }
/* before a run and after it the page scrolls over the field like over any other part of the page (landscape phones:
   the field and the pad fill the middle of the screen); swipes steer only while a run is on (playing / paused) */
.yl[data-ph="ready"] .yl-field, .yl[data-ph="over"] .yl-field { touch-action: manipulation; }
.yl-field.wrap { box-shadow: 0 0 0 4px var(--blue), 0 7px 0 4px var(--blue-press); }
.yl-canvas { display: block; border-radius: 10px; }

/* overlays (ready / paused / game over) sit on top of the field and never resize it */
.yl-ov { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 10px; border-radius: 10px;
  background: rgba(23, 32, 51, .18); overflow: hidden; animation: yl-in .2s var(--ease); }
:root[data-theme="dark"] .yl-ov { background: rgba(0, 0, 0, .3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .yl-ov { background: rgba(0, 0, 0, .3); } }
.yl-ov.hidden { display: none; }
@keyframes yl-in { from { opacity: 0; } to { opacity: 1; } }
.yl-box { width: 100%; max-width: 320px; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 14px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.yl-box h2 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.15; color: var(--ink); }
.yl-sub { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); line-height: 1.35; }
.yl-final { display: flex; align-items: baseline; gap: 6px; }
.yl-final b { font-size: 38px; font-weight: 800; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.yl-final small { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.yl-best { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.yl-best.new { color: var(--good); font-size: 15px; }
.yl-top { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 220px; display: grid; gap: 2px; font-size: 13px; }
.yl-top li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 8px; color: var(--ink-2); }
.yl-top li b { text-align: left; color: var(--ink); font-variant-numeric: tabular-nums; }
.yl-top li small { color: var(--ink-3); font-size: 11px; }
.yl-top li.me { background: var(--brand-soft); }
.yl-top li.me b { color: var(--brand); }
.yl-walls { display: grid; grid-template-columns: auto auto; align-items: center; justify-content: center; column-gap: 10px; row-gap: 3px; }
.yl-wl { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.yl-wh { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }
.yl-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.yl-seg button { min-width: 64px; height: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.yl-seg button.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 0 var(--line-2), 0 0 0 1px var(--line); }
.yl-box .btn { min-height: 44px; }
.yl-box .btn.big { height: 48px; min-width: 170px; font-size: 16px; padding: 0 22px; }
.yl-box .btn .yl-bi { display: inline-grid; width: 18px; height: 18px; }
.yl-box .btn .yl-bi:empty { display: none; }
.yl-box .btn .yl-bi svg { width: 18px; height: 18px; }
.yl.small .yl-box { gap: 6px; padding: 12px 10px; }
.yl.small .yl-sub { font-size: 12.5px; }
.yl.small .yl-best { font-size: 12.5px; }
.yl.small .yl-best.new { font-size: 14px; }
.yl.small .yl-box h2 { font-size: 19px; }
.yl.small .yl-final b { font-size: 30px; }
.yl.small .yl-wh { display: none; }
.yl.small .yl-box .btn.big { height: 44px; min-width: 150px; font-size: 15px; }
/* tightest fields (under 280 px: phone held sideways, 320 px phones): every overlay must fit without clipping */
.yl.tiny .yl-ov { padding: 6px; }
.yl.tiny .yl-box { gap: 5px; padding: 9px 8px; border-radius: 14px; }
.yl.tiny .yl-box h2 { font-size: 17px; }
.yl.tiny .yl-sub { font-size: 12px; line-height: 1.3; }
.yl.tiny .yl-final { flex-wrap: wrap; justify-content: center; column-gap: 6px; row-gap: 0; }
.yl.tiny .yl-final b { font-size: 24px; }
.yl.tiny .yl-final small { font-size: 12px; }
.yl.tiny .yl-final .yl-best { font-size: 12px; margin-left: 4px; }
.yl.tiny .yl-final .yl-best.new { font-size: 13px; }
.yl.tiny .yl-wl { font-size: 12px; }
.yl.tiny .yl-seg { padding: 2px; gap: 2px; }
.yl.tiny .yl-walls { column-gap: 8px; }
.yl.tiny .yl-seg button { min-width: 50px; padding: 0 8px; font-size: 12.5px; }
.yl.tiny .yl-box .btn.big { padding: 0 14px; font-size: 15px; }
/* smallest fields (under 240 px: 320 px tall phones held sideways): the game-over heading gives way to its reason */
.yl.micro .yl-box { gap: 4px; padding: 7px 6px; }
.yl.micro .yl-box h2.yl-h-over { display: none; }
.yl.tiny .yl-box .btn { min-height: 44px; }
.yl.tiny .yl-box .btn.big { height: 44px; min-width: 140px; }

/* direction pad (touch screens): below the field, or beside it on a phone held sideways */
.yl-pad { display: none; }
.yl.pad .yl-pad { display: grid; grid-template-columns: repeat(3, var(--pb)); grid-template-rows: repeat(3, var(--pb)); gap: 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.yl-pb { width: var(--pb); height: var(--pb); padding: 0; display: inline-grid; place-items: center; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  box-shadow: var(--press); cursor: pointer; touch-action: none; transition: background .12s, color .12s; }
.yl-pb svg { width: 30px; height: 30px; transition: transform .08s; }
.yl-pb.on, .yl-pb:active { background: var(--brand-soft); color: var(--brand); box-shadow: 0 1px 0 var(--line-2); }
.yl-pb.on svg, .yl-pb:active svg { transform: translateY(2px); }
.yl-u { grid-area: 1 / 2; } .yl-l { grid-area: 2 / 1; } .yl-pc { grid-area: 2 / 2; } .yl-r { grid-area: 2 / 3; } .yl-d { grid-area: 3 / 2; }
.yl-r svg { rotate: 90deg; } .yl-d svg { rotate: 180deg; } .yl-l svg { rotate: -90deg; }
.yl-pc { border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.yl-pc svg { width: 22px; height: 22px; }
.yl-pc:disabled { opacity: .45; }

.yl-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .yl-ov { animation: none; }
  .yl-pb svg { transition: none; }
}
