/* The loading screen (loading-screen.md, Felt and dice): the whole viewport while the socket connects or reconnects, above
   every screen and sheet, catching every tap. Always the green felt, never the player's own. A column at most 420 px wide:
   the logo near the top, two dice tumbling in the middle, then the status, its line, the bar and a tip at the bottom.
   Shown and hidden by public/js/loading.js; every class starts with ld, clear of the table's .die, .bar and .tip. */
.ldscreen { --ld-logo: 64px; --ld-die: 96px; --ld-jump: 110px; --ld-top: 70px; --ld-bottom: 34px;
  position: fixed; inset: 0; z-index: 40; display: none; overflow: hidden; box-sizing: border-box; color: #fff; outline: none; overscroll-behavior: contain; touch-action: none; -webkit-user-select: none; user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: repeating-radial-gradient(circle at 50% 42%, rgba(255,255,255,.035) 0 2px, transparent 2px 7px), radial-gradient(circle at 50% 42%, #2A9A58 0%, #14703F 45%, #0B3D22 100%), #0B3D22; }
.ldscreen.show { display: block; } /* (display: none otherwise, so nothing animates while it is hidden) */
.ldscreen.out { opacity: 0; transition: opacity .2s ease; }
.ldcol { box-sizing: border-box; height: 100%; max-width: 420px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; }

/* the lobby's marker logo (.logo in lobby.css) at this screen's size, both lines centred and turned together */
.ldscreen .ldlogo { flex: 0 0 auto; margin-top: var(--ld-top); font-size: var(--ld-logo); line-height: .92; transform: rotate(-4deg); }
.ldscreen .ldlogo .l1, .ldscreen .ldlogo .l2 { transform: none; }

/* the dice: the stage takes the room between the logo and the status, the dice four fifths of the way down it (the jump
   goes up into the rest). Where the stage is short (a small phone, with the waking line and Back to the lobby up), the
   dice keep their place over the status and the jump is only as high as the stage has room for, never over the logo. */
.ldstage { flex: 1 1 0; min-height: 0; container-type: size; display: flex; flex-direction: column; justify-content: flex-end; }
.ldstage::before { content: ""; flex: 4 1 0; } .ldstage::after { content: ""; flex: 1 1 0; }
.lddice { flex: 0 0 auto; display: flex; justify-content: center; gap: calc(var(--ld-die) * .6); padding: var(--ld-jump) 0 14px; }
.ldd { position: relative; width: var(--ld-die); height: var(--ld-die); }
.lddie { --ld-up: min(var(--ld-jump), 100cqh - var(--ld-die) - 44px); position: relative; box-sizing: border-box; width: 100%; height: 100%; border-radius: calc(var(--ld-die) * .23); background: #FBFBF7; border: 5px solid var(--ink2);
  box-shadow: inset -6px -7px 0 #E6E6DE, 0 6px 0 var(--ink2); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; padding: 13%;
  animation: ldt1 1.6s cubic-bezier(.3,.6,.4,1) infinite; }
.lddie i { width: 79%; aspect-ratio: 1; border-radius: 50%; background: var(--ink2); }
.lddie.f5 i:nth-child(3), .lddie.f3 i:nth-child(2) { width: 87%; } /* (the middle pip a touch bigger) */
.lddie.f5 i:nth-child(1) { grid-area: 1 / 1; } .lddie.f5 i:nth-child(2) { grid-area: 1 / 3; } .lddie.f5 i:nth-child(3) { grid-area: 2 / 2; } .lddie.f5 i:nth-child(4) { grid-area: 3 / 1; } .lddie.f5 i:nth-child(5) { grid-area: 3 / 3; }
.lddie.f3 i:nth-child(1) { grid-area: 1 / 1; } .lddie.f3 i:nth-child(2) { grid-area: 2 / 2; } .lddie.f3 i:nth-child(3) { grid-area: 3 / 3; }
.ldsh { position: absolute; left: 10%; right: 10%; top: calc(100% + 2px); height: 12px; border-radius: 50%; background: rgba(0,0,0,.25); animation: ldsh 1.6s cubic-bezier(.3,.6,.4,1) infinite; }
.ldd + .ldd .lddie, .ldd + .ldd .ldsh { animation-delay: .2s; } /* (the second die a beat behind the first) */
/* up about 110 px while turning 200°, down to 360°, a small second bounce, then a rest */
@keyframes ldt1 {
  0% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(calc(var(--ld-up) * -1)) rotate(200deg); }
  55% { transform: translateY(0) rotate(360deg); }
  65% { transform: translateY(calc(var(--ld-up) * -.12)) rotate(360deg); }
  75%, 100% { transform: translateY(0) rotate(360deg); }
}
/* the shadow shrinks and pales while its die is up */
@keyframes ldsh {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(.5); opacity: .45; }
  55% { transform: scale(1); opacity: 1; }
  65% { transform: scale(.88); opacity: .85; }
  75%, 100% { transform: scale(1); opacity: 1; }
}

/* the status, its line (or the green pill when reconnecting), the bar, the tip and, after a long wait, the way out */
.ldfoot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: var(--ld-bottom); }
.ldmsg { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 16px; min-height: 85px; } /* (room for the pill either way, so the dice don't move when Connecting turns into Reconnecting) */
.ldword { display: flex; align-items: center; white-space: nowrap; font: 28px/28px var(--marker); color: #fff; transform: rotate(-2deg);
  text-shadow: -3px -3px 0 var(--ink2), 3px -3px 0 var(--ink2), -3px 3px 0 var(--ink2), 3px 3px 0 var(--ink2), 0 -3px 0 var(--ink2), 0 3px 0 var(--ink2), -3px 0 0 var(--ink2), 3px 0 0 var(--ink2), 0 5px 0 var(--ink2); }
.lddots { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; padding-top: 12px; }
.lddots i { width: 5px; height: 5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px var(--ink2); animation: lddot 1.2s ease-in-out infinite; }
.lddots i:nth-child(2) { animation-delay: .2s; } .lddots i:nth-child(3) { animation-delay: .4s; }
@keyframes lddot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-7px); opacity: 1; } }
.ldsafe { display: none; font: 15px/19px var(--lilita); color: var(--ink2); background: #7ED957; border: 3px solid var(--ink2); border-radius: 999px; box-shadow: 0 3px 0 var(--ink2); padding: 8px 14px; white-space: nowrap; }
.ldscreen[data-kind="reconnect"] .ldsafe { display: block; }
.ldline { font: 800 14px/19px var(--nunito); color: #D6F2E0; text-align: center; max-width: 320px; text-wrap: balance; }
.ldline:empty { display: none; }
.ldbar { box-sizing: content-box; height: 26px; border: 4px solid var(--ink2); border-radius: 999px; background: #06281A; box-shadow: 0 4px 0 var(--ink2); overflow: hidden; }
.ldfill { width: 6%; height: 100%; border-radius: 999px; box-shadow: inset 0 3px 0 rgba(255,255,255,.35);
  background: repeating-linear-gradient(-45deg, #FFD23F 0 14px, #F2B90F 14px 28px) 0 0 / 39.598px 39.598px; /* (a tile two stripes square, so the scroll is seamless) */
  animation: ldfill 3.2s ease-in-out infinite, ldstripes .9s linear infinite; }
@keyframes ldfill { 0% { width: 6%; } 75% { width: 88%; } 100% { width: 96%; } } /* (a loop, never a real percentage: how long a connection takes can't be known) */
@keyframes ldstripes { to { background-position: 39.598px 0; } }
.ldtip { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px 15px; background: #FFF4D6; border: 4px solid var(--ink2); border-radius: 20px; box-shadow: 0 6px 0 var(--ink2); }
.ldbadge { flex: 0 0 auto; padding: 4px 9px 4px 10px; border-radius: 999px; background: var(--ink2); color: var(--lob-yellow); font: 14px/14px var(--lilita); letter-spacing: .08em; }
.ldtips { flex: 1 1 auto; min-width: 0; display: grid; } /* every tip in the one cell: the card is as tall as the longest, so a new tip never moves the screen */
.ldtips p { grid-area: 1 / 1; margin: 0; font: 800 14px/19px var(--nunito); color: #3C3020; text-wrap: pretty; opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility .35s; }
.ldtips p.on { opacity: 1; visibility: visible; }
.ldback { display: none; align-self: center; min-height: 40px; margin: -10px 0 -14px; padding: 0 14px; background: none; border: 0; box-shadow: none; color: #fff; font: 800 15px/1 var(--nunito); text-decoration: underline; text-underline-offset: 3px; }
.ldscreen.long .ldback { display: block; }

@media (max-height: 739.98px) { .ldscreen { --ld-logo: 52px; --ld-die: 80px; --ld-jump: 90px; --ld-top: 40px; --ld-bottom: 28px; } }
@media (max-height: 639.98px) {
  .ldscreen { --ld-logo: 44px; --ld-die: 68px; --ld-jump: 72px; --ld-top: 24px; --ld-bottom: 20px; }
  .ldfoot, .ldmsg { gap: 12px; } .ldmsg { min-height: 81px; }
  .ldtip { padding: 12px 14px; } .ldtips p { font-size: 13px; line-height: 17px; }
}
/* reduced motion: the dice rest at a tilt, the dots and the stripes hold still, the fill eases slowly to and fro */
@media (prefers-reduced-motion: reduce) {
  .lddie, .ldsh, .lddots i { animation: none; }
  .lddie { transform: rotate(-8deg); } .ldd + .ldd .lddie { transform: rotate(7deg); }
  .lddots i { opacity: .8; }
  .ldfill { animation: ldease 6s ease-in-out infinite alternate; }
}
@keyframes ldease { from { width: 18%; } to { width: 82%; } }
/* the same under Reduce motion in Settings (body.rm) */
body.rm .lddie, body.rm .ldsh, body.rm .lddots i { animation: none; }
body.rm .lddie { transform: rotate(-8deg); } body.rm .ldd + .ldd .lddie { transform: rotate(7deg); }
body.rm .lddots i { opacity: .8; }
body.rm .ldfill { animation: ldease 6s ease-in-out infinite alternate; }

/* At a table, a reconnect's first 3 s: the Reconnecting pill at the top centre, under the top bar (on the opponent's card) and inside the safe
   area, over a clear layer that takes every tap (the table stays in sight). The full screen above replaces it after 3 s. */
.ldshield { position: fixed; inset: 0; z-index: 40; display: none; background: transparent; touch-action: none; -webkit-user-select: none; user-select: none; }
.ldshield.show { display: block; }
.ldshield.out { opacity: 0; transition: opacity .15s ease; }
.ldpill { position: absolute; top: calc(env(safe-area-inset-top) + 78px); left: 50%; transform: translateX(-50%); box-sizing: border-box; max-width: calc(100% - 32px); width: max-content;
  display: flex; align-items: center; gap: 8px; padding: 7px 16px 7px 12px; background: #0B3D22; color: #fff; border: 3px solid var(--ink2); border-radius: 999px; box-shadow: 0 4px 0 var(--ink2);
  font: 15px/19px var(--lilita); text-align: center; text-wrap: balance; }
.ldshield.off .ldpill { border-radius: 22px; } /* (the offline line can take two lines on a small phone) */
.ldpdie { flex: 0 0 auto; box-sizing: border-box; width: 16px; height: 16px; border-radius: 4px; background: #FBFBF7; border: 2px solid var(--ink2); padding: 1px;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; animation: ldpspin 2.4s linear infinite; }
.ldpdie i { width: 3px; height: 3px; border-radius: 50%; background: var(--ink2); }
.ldpdie i:nth-child(1) { grid-area: 1 / 1; } .ldpdie i:nth-child(2) { grid-area: 2 / 2; } .ldpdie i:nth-child(3) { grid-area: 3 / 3; }
@keyframes ldpspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ldpdie { animation: none; transform: rotate(-8deg); } }
body.rm .ldpdie { animation: none; transform: rotate(-8deg); }
