/* Jerzyk: lock screen, intro cards and the minimal HUD. */
:root {
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ink: #f5f5f7;
  --spring: cubic-bezier(0.2, 1.3, 0.35, 1);
  --out: cubic-bezier(0.22, 1, 0.36, 1);
  --err: #ff453a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body {
  color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; touch-action: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#vig {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 120% 100% at 50% 46%, rgba(0,0,0,0) 52%, rgba(0,0,0,.42) 100%);
}
#scrim { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; z-index: 2; transition: opacity 1.4s ease; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 30; }
#flash.on { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }

#lock, #intro { position: fixed; inset: 0; z-index: 10; display: none; }
#lock.on, #intro.on { display: block; }

#lock { background: #000; transition: opacity .9s ease; }
#lock.leave { opacity: 0; pointer-events: none; }
.lock-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  transition: transform 1s var(--out), filter 1s ease, opacity .8s ease;
}
#lock.leave .lock-inner { transform: scale(1.06); filter: blur(14px); opacity: 0; }
.greet { font-size: clamp(15px, 2.3vmin + 6px, 22px); font-weight: 500; letter-spacing: .01em; color: rgba(245,245,247,.62); min-height: 1.3em; }
.name { font-size: clamp(64px, 17vmin, 148px); font-weight: 700; letter-spacing: -.035em; line-height: 1; margin-top: .06em; min-height: 1em; }
.ch { display: inline-block; opacity: 0; filter: blur(14px); transform: translateY(.18em) scale(.96); transition: opacity .9s ease, filter 1s ease, transform 1.1s var(--spring); white-space: pre; }
.ch.on { opacity: 1; filter: blur(0); transform: none; }

.slots { display: flex; align-items: flex-end; justify-content: center; gap: clamp(7px, 1.7vmin, 12px); margin-top: clamp(34px, 7vmin, 64px); height: clamp(50px, 9vmin, 66px); }
.slot { position: relative; width: clamp(25px, 5.6vmin, 40px); height: 100%; }
.slot .d {
  position: absolute; left: 0; right: 0; bottom: 12px; text-align: center;
  font-size: clamp(30px, 6.4vmin, 44px); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
  opacity: 0; filter: blur(10px); transform: translateY(10px) scale(.9);
  transition: opacity .28s ease, filter .32s ease, transform .5s var(--spring);
}
.slot.has .d { opacity: 1; filter: blur(0); transform: none; }
.slot .l {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--ink);
  transform: scaleX(0); transform-origin: left center; opacity: .34;
  transition: transform .7s var(--out), opacity .3s ease, background-color .25s ease;
}
.slots.drawn .slot .l { transform: scaleX(1); }
.slot.has .l { opacity: .9; }
.slot.cur .l { animation: cur 1.1s ease-in-out infinite; }
@keyframes cur { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.slash {
  width: clamp(10px, 2.2vmin, 16px); height: 100%; position: relative; opacity: 0; filter: blur(6px);
  transition: opacity .7s ease, filter .7s ease;
}
.slash::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 2px; height: 62%; border-radius: 2px;
  background: rgba(245,245,247,.45); transform: translateX(-50%) rotate(18deg); transform-origin: bottom center;
}
.slots.drawn .slash { opacity: 1; filter: blur(0); }
.slots.bad { animation: shake .46s cubic-bezier(.36,.07,.19,.97); }
.slots.bad .slot .l { background: var(--err); opacity: 1; animation: none; }
.slots.bad .slot .d { color: var(--err); }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); } }
.slots.good .slot .l { opacity: 1; animation: none; }
.slots.good .slot .d { transition-delay: 0s; }
.fmt { margin-top: 14px; font-size: 12px; letter-spacing: .08em; color: rgba(245,245,247,.42); opacity: 0; transition: opacity 1s ease; height: 1.2em; }
.fmt.on { opacity: 1; }

.pad { display: none; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 2.2vmin, 16px) clamp(18px, 5vmin, 28px); margin-top: clamp(22px, 5vmin, 44px); }
.touch .pad { display: grid; }
.pad button {
  width: clamp(58px, 15.5vmin, 76px); height: clamp(58px, 15.5vmin, 76px); border-radius: 50%;
  background: rgba(255,255,255,.09); font-size: clamp(24px, 6.2vmin, 31px); font-weight: 400; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(.82); filter: blur(6px);
  transition: opacity .5s ease, transform .6s var(--spring), filter .5s ease, background-color .18s ease;
}
.pad.on button { opacity: 1; transform: none; filter: blur(0); }
.pad button:active, .pad button.hit { background: rgba(255,255,255,.3); transition-duration: 0s; }
.pad button.ghost { background: none; }
.pad button.empty { visibility: hidden; }
@media (max-height: 560px) and (orientation: landscape) {
  .lock-inner { flex-direction: row; flex-wrap: wrap; align-content: center; column-gap: 6vw; }
  .greet, .name { flex-basis: 100%; text-align: center; }
  .name { font-size: clamp(40px, 13vmin, 70px); }
  .slots { margin-top: 18px; }
  .fmt { display: none; }
  .pad { margin-top: 14px; grid-template-columns: repeat(6, 1fr); gap: 8px 10px; }
  .pad button { width: 46px; height: 46px; font-size: 21px; }
  .pad button.empty { display: none; }
}

#intro { pointer-events: auto; }
#card {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; padding: 0 7vw;
  font-size: clamp(34px, 8.4vmin, 88px); font-weight: 700; letter-spacing: -.03em; line-height: 1.04;
  text-shadow: 0 2px 44px rgba(0,0,0,.8), 0 1px 4px rgba(0,0,0,.45);
}
#card.sign { font-size: clamp(22px, 4.6vmin, 40px); font-weight: 500; letter-spacing: -.01em; color: rgba(245,245,247,.86); }
#card .w { display: inline-block; white-space: pre; opacity: 0; filter: blur(16px); transform: translateY(.22em); transition: opacity .7s ease, filter .8s ease, transform 1s var(--spring); }
#card .w.on { opacity: 1; filter: blur(0); transform: none; }
#card .w.off { opacity: 0; filter: blur(14px); transform: translateY(-.12em); transition: opacity .5s ease, filter .5s ease, transform .6s ease; }
#skip {
  position: absolute; right: calc(18px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); padding: 10px 14px;
  font-size: 13px; letter-spacing: .02em; color: rgba(245,245,247,.5); opacity: 0; transition: opacity .8s ease;
}
#intro.on #skip { opacity: 1; }

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .9s ease; }
#hud.on { opacity: 1; }
#hud > * { pointer-events: auto; }

#slider {
  position: absolute; right: calc(6px + var(--safe-r)); top: 50%; transform: translateY(-50%);
  width: 58px; height: min(46vh, 300px); display: flex; flex-direction: column; align-items: center; gap: 10px;
  touch-action: none; cursor: ns-resize; opacity: 0; transition: opacity .5s ease; pointer-events: none;
}
#slider.on { opacity: 1; pointer-events: auto; }
#slider .cap { font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,.72); text-shadow: 0 1px 6px rgba(0,0,0,.6); }
#slider .track { position: relative; flex: 1; width: 4px; border-radius: 4px; background: rgba(255,255,255,.28); box-shadow: 0 0 0 .5px rgba(0,0,0,.25); }
#slider .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; border-radius: 4px; background: #fff; }
#slider .knob {
  position: absolute; left: 50%; bottom: 30%; width: 28px; height: 28px; margin: 0 0 -14px -14px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.45), 0 0 0 .5px rgba(0,0,0,.2);
  transition: transform .25s var(--spring);
}
#slider.drag .knob { transform: scale(1.18); }

#menuBtn, #tableBtn, #menu {
  background: rgba(22,22,24,.82); box-shadow: 0 0 0 .5px rgba(255,255,255,.1), 0 8px 28px rgba(0,0,0,.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
}
#menuBtn {
  position: absolute; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: transform .3s var(--spring), background-color .2s;
}
#menuBtn svg { fill: #fff; }
#menuBtn:active { transform: scale(.9); }
#menu {
  position: absolute; top: calc(64px + var(--safe-t)); right: calc(14px + var(--safe-r)); width: 232px; padding: 6px; border-radius: 16px;
  opacity: 0; transform: translateY(-8px) scale(.96); transform-origin: top right; filter: blur(8px); pointer-events: none !important;
  transition: opacity .22s ease, transform .4s var(--spring), filter .25s ease;
}
#menu.on { opacity: 1; transform: none; filter: blur(0); pointer-events: auto !important; }
#menu > button {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px; border-radius: 11px;
  font-size: 14.5px; font-weight: 500; text-align: left; transition: background-color .15s;
}
#menu > button:active { background: rgba(255,255,255,.1); }
@media (hover: hover) { #menu > button:hover { background: rgba(255,255,255,.07); } }
#menu > button svg { flex: none; opacity: .86; }
#menu em { font-style: normal; font-size: 11.5px; color: rgba(255,255,255,.4); margin-left: 6px; }
#menu .bar { position: absolute; left: 0; bottom: 0; top: 0; width: 100%; background: rgba(255,69,58,.3); transform: scaleX(0); transform-origin: left; }
#menu .hold.holding .bar { transform: scaleX(1); transition: transform .9s linear; }
#menu button.off .waves { display: none; }
.seg { display: flex; gap: 3px; margin: 4px 6px 6px; padding: 3px; border-radius: 10px; background: rgba(255,255,255,.07); }
.seg button { flex: 1; padding: 7px 0; border-radius: 8px; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.62); transition: background-color .2s, color .2s; }
.seg button.on { background: rgba(255,255,255,.18); color: #fff; }

#tableBtn {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translate(-50%, 16px) scale(.94);
  display: flex; align-items: center; gap: 8px; padding: 11px 17px 11px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 600;
  opacity: 0; pointer-events: none !important; filter: blur(6px);
  transition: opacity .3s ease, transform .5s var(--spring), filter .3s ease;
}
#tableBtn.on { opacity: 1; transform: translate(-50%, 0); filter: blur(0); pointer-events: auto !important; }
#tableBtn:active { transform: translate(-50%, 0) scale(.94); }

#hint {
  position: absolute; left: 0; right: 0; top: calc(22px + var(--safe-t)); text-align: center; padding: 0 70px;
  font-size: 15px; font-weight: 600; letter-spacing: -.005em; color: #fff; text-shadow: 0 1px 14px rgba(0,0,0,.6);
  opacity: 0; filter: blur(8px); transform: translateY(-6px); pointer-events: none !important;
  transition: opacity .6s ease, filter .6s ease, transform .8s var(--spring);
}
#hint.on { opacity: 1; filter: blur(0); transform: none; }

@media (prefers-reduced-motion: reduce) {
  .ch, #card .w, .slot .d { filter: none !important; transform: none !important; }
}

#menu button[hidden] { display: none; }
