/* lock: a steel padlock on teal. Dials and tries light up green, yellow or grey, like Wordle. */
.gamecard.lock {
  --teal: #0E7C74;
  --deep: #0A5F59;
  --ok: #22C55E;
  --near: #FACC15;
  --no: #33413F;
  container-type: size;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  color: #FFFFFF;
  background: radial-gradient(70% 70% at 30% 40%, rgba(255, 255, 255, 0.12), transparent 70%), var(--teal);
}

/* ---------- the padlock ---------- */
.lock-stage { position: relative; display: grid; place-items: center; padding: 40px; }
.padlock { position: relative; display: flex; flex-direction: column; align-items: center; width: min(100%, 420px); }
.shackle {
  position: relative;
  z-index: 0;
  width: 60%;
  aspect-ratio: 1 / 0.8;
  margin-bottom: -18%;
  border: clamp(20px, 3.4vw, 30px) solid #C3CED8;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.5);
  transition: transform 520ms cubic-bezier(.2,.9,.3,1.4);
  transform-origin: 85% 100%;
}
.lock-body {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 34px 28px 26px;
  border-radius: 34px;
  background: linear-gradient(to bottom, #F1F5F8 0 78%, #D5DEE5 78%);
  box-shadow: 0 30px 50px -24px rgba(0, 30, 28, 0.6), inset 0 4px 0 rgba(255, 255, 255, 0.8);
}
.padlock.open .shackle { transform: translateY(-26%) rotate(-14deg); }
.padlock.shut { animation: shake 420ms cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 15%, 55% { transform: translateX(-10px) rotate(-2deg); } 35%, 75% { transform: translateX(10px) rotate(2deg); } }

.dials { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 10px; perspective: 600px; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 6px; border-radius: 18px; outline: none; cursor: ns-resize; touch-action: none; user-select: none; }
.turn { display: grid; place-items: center; width: 100%; height: 30px; border: 0; border-radius: 10px; background: rgba(30, 50, 70, 0.08); color: #4A5A68; font: inherit; font-size: 12px; cursor: pointer; transition: background-color 150ms ease, transform 120ms ease; }
.turn:hover { background: rgba(30, 50, 70, 0.16); }
.turn:active { transform: scale(0.94); }
.wheel { position: relative; width: 100%; height: clamp(76px, 9vw, 104px); overflow: hidden; border-radius: 14px; background: #14211F; box-shadow: inset 0 10px 14px rgba(0, 0, 0, 0.4), inset 0 -10px 14px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(30, 50, 70, 0.18); transition: background-color 200ms ease; }
.strip { display: flex; flex-direction: column; height: 1000%; transition: transform 220ms cubic-bezier(.2,.8,.2,1); }
.strip span { display: grid; place-items: center; height: 10%; color: #FFFFFF; font-size: clamp(40px, 5vw, 58px); font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.dial.focus .wheel { box-shadow: inset 0 10px 14px rgba(0, 0, 0, 0.4), inset 0 -10px 14px rgba(0, 0, 0, 0.4), 0 0 0 4px var(--teal); }
/* The colours, once a try is in */
.dial.ok .wheel { background: var(--ok); }
.dial.near .wheel { background: var(--near); }
.dial.near .strip span { color: #3A2A00; }
.dial.no .wheel { background: #6B7A80; }
.dial.ok .wheel, .dial.near .wheel, .dial.no .wheel { box-shadow: inset 0 8px 12px rgba(0, 0, 0, 0.18), inset 0 -8px 12px rgba(0, 0, 0, 0.18); }
.dial.flip .wheel { animation: flip 440ms ease both; }
/* Locked dials: no arrows, a small padlock on top, and a click into place */
.dial.locked { cursor: default; }
.dial.locked .turn { font-size: 0; background: transparent; pointer-events: none; }
.dial.locked .turn.up::before { content: ""; width: 16px; height: 16px; background: #15803D; -webkit-mask: var(--lock-i) center / contain no-repeat; mask: var(--lock-i) center / contain no-repeat; }
.dials { --lock-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 7V5.2a3 3 0 0 1 6 0V7' fill='none' stroke='black' stroke-width='1.8'/%3E%3Crect x='3.2' y='7' width='9.6' height='7' rx='2'/%3E%3C/svg%3E"); }
.dial.snap .wheel { animation: snap 380ms cubic-bezier(.2,.9,.3,1.5); }
.dial.snap .turn.up::before { animation: snap 380ms cubic-bezier(.2,.9,.3,1.5); }
@keyframes snap { 0% { transform: scale(1); } 40% { transform: scale(0.9); } 100% { transform: scale(1); } }
@keyframes flip { 0% { transform: rotateX(0); background: #14211F; } 50% { transform: rotateX(90deg); background: #14211F; } 100% { transform: rotateX(0); } }
.lock-msg { min-height: 1.4em; margin: 18px 0 0; color: #4A5A68; font-size: 16px; font-weight: 800; text-align: center; letter-spacing: -0.02em; }
.padlock.open .lock-msg { color: #15803D; }

/* ---------- the side ---------- */
.side { position: relative; min-width: 0; }
.panel { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 44px 48px 44px 8px; overflow-y: auto; }
.kicker { margin: 0; font-size: 15px; font-weight: 700; opacity: 0.8; }
.title { margin: 4px 0 14px; font-size: clamp(72px, 9cqw, 120px); font-weight: 800; line-height: 0.85; letter-spacing: -0.07em; }
.lede { max-width: 32ch; margin: 0 0 20px; font-size: 19px; font-weight: 500; line-height: 1.45; }
/* The colour key: a quiet list with hairlines, like the steps in window and sort */
.legend { display: grid; max-width: 340px; margin: 4px 0 24px; padding: 0; list-style: none; border-top: 1px solid rgba(255, 255, 255, 0.16); }
.legend li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.16); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.legend i { width: 20px; height: 20px; border-radius: 6px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.lock .chip { background: rgba(255, 255, 255, 0.16); }
.lock .chip.hot { background: #FFFFFF; color: var(--teal); }
.lock .chip.gold { background: var(--near); color: #3A2A00; }
.chips:not(:empty) { margin-bottom: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.actions .pill { min-height: 56px; padding: 0 28px; }
.lock .pill.white { --edge: var(--deep); color: var(--teal); }

.hud { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.ask { margin: 0; font-size: clamp(30px, 3.4cqw, 44px); font-weight: 800; line-height: 1; letter-spacing: -0.05em; }
.left { margin: 0; font-size: 15px; font-weight: 700; opacity: 0.8; }

/* ---------- the tries so far, with the keypad beside them ---------- */
.board { display: flex; align-items: stretch; gap: 22px; max-width: 460px; margin-bottom: 18px; }
.grid { --t: clamp(34px, 5.8cqh, 52px); display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.grid li { display: grid; grid-template-columns: repeat(4, var(--t)); gap: 6px; }
.grid b { display: grid; place-items: center; height: var(--t); border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 10px; font-size: calc(var(--t) * 0.5); font-weight: 800; font-variant-numeric: tabular-nums; }
.grid li.next b { border-color: rgba(255, 255, 255, 0.5); }
.grid b.ok, .grid b.near, .grid b.no, .legend i { border: 0; }
.grid .ok, .legend .ok { background: var(--ok); }
.grid .near, .legend .near { background: var(--near); color: #3A2A00; }
.grid .no, .legend .no { background: var(--no); }
.grid li.new b { animation: pop 320ms cubic-bezier(.2,.9,.3,1.4) both; }
.grid li.new b:nth-child(2) { animation-delay: 60ms; }
.grid li.new b:nth-child(3) { animation-delay: 120ms; }
.grid li.new b:nth-child(4) { animation-delay: 180ms; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.grid.small { --t: 34px; margin-bottom: 20px; }
.grid.small b { border-radius: 8px; }

/* ---------- the keypad: 1-9, then 0 and back, as tall as the grid ---------- */
.pad { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 6px; min-width: 150px; max-width: 230px; }
.key { min-height: 0; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.18); color: #FFFFFF; font: inherit; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color 200ms ease, transform 100ms ease; }
.key:hover { background: rgba(255, 255, 255, 0.28); }
.key:active { transform: scale(0.94); }
.key.zero { grid-column: span 2; }
.key.back { font-size: 18px; }
.key.ok { background: var(--ok); }
.key.near { background: var(--near); color: #3A2A00; }
.key.no { background: var(--no); color: rgba(255, 255, 255, 0.5); }

.big { margin: 6px 0 0; font-size: clamp(72px, 9cqw, 112px); font-weight: 800; line-height: 0.85; letter-spacing: -0.07em; }
.line { margin: 14px 0 18px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

@media (prefers-reduced-motion: no-preference) {
  .panel.enter > * { animation: rise 600ms cubic-bezier(.2,.8,.2,1) both; }
  .panel.enter > :nth-child(2) { animation-delay: 60ms; }
  .panel.enter > :nth-child(3) { animation-delay: 120ms; }
  .panel.enter > :nth-child(n+4) { animation-delay: 180ms; }
}
@media (prefers-reduced-motion: reduce) {
  .dial.flip .wheel, .dial.snap .wheel, .dial.snap .turn.up::before, .grid li.new b { animation: none; }
}
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }

/* ---------- phones: lock on top, tries and pad below ---------- */
@media (max-width: 760px) {
  .gamecard.lock { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .lock-stage { padding: 26px 18px 0; }
  .padlock { width: min(100%, 290px); }
  .shackle { width: 54%; border-width: 18px; }
  .lock-body { padding: 16px 14px 10px; border-radius: 24px; }
  .wheel { height: clamp(48px, 8cqh, 64px); }
  .strip span { font-size: clamp(30px, 5cqh, 38px); }
  .turn { height: 22px; }
  .lock-msg { margin-top: 6px; font-size: 14px; }
  .panel { position: absolute; padding: 12px 18px 16px; justify-content: flex-start; }
  #intro { justify-content: flex-end; }
  #play { align-items: center; }
  .title { font-size: 64px; }
  .lede { font-size: 16px; margin-bottom: 14px; }
  .legend { margin-bottom: 16px; }
  .legend li { font-size: 14px; }
  .legend i { width: 20px; height: 20px; }
  .hud { margin-bottom: 8px; }
  .ask { font-size: 22px; }
  .left { font-size: 13px; }
  .board { width: 100%; max-width: 380px; gap: 12px; margin-bottom: 12px; }
  .grid { --t: clamp(24px, 4.3cqh, 36px); gap: 4px; }
  .grid li { gap: 4px; }
  .grid b { border-radius: 7px; }
  .grid.small { --t: 24px; margin-bottom: 14px; }
  .grid.small b { border-radius: 6px; }
  .line { margin: 10px 0 14px; font-size: 17px; }
  .pad { max-width: none; gap: 5px; }
  #play .actions { width: 100%; }
  .actions .pill { flex: 1; min-height: 52px; }
  .big { font-size: 64px; }
}

/* Very short phones (Android with bigger system text or the three-button bar): a flatter shackle and less padding,
   so the keypad and the button fit under the padlock */
@media (max-width: 760px) and (max-height: 660px) {
  .lock-stage { padding-top: 12px; }
  .shackle { aspect-ratio: 1 / 0.66; }
  .lock-body { padding: 12px 12px 8px; }
  .turn { height: 18px; }
  .lock-msg { margin-top: 4px; font-size: 13px; }
  .panel { padding: 10px 18px 12px; }
  .hud { margin-bottom: 6px; }
  .board { margin-bottom: 10px; }
  .actions .pill { min-height: 48px; }
}
@media (max-width: 760px) and (max-height: 580px) {
  .lock-stage { padding-top: 8px; }
  .padlock { width: min(100%, 260px); }
  .wheel { height: 42px; }
  .strip span { font-size: 28px; }
  .grid { --t: 21px; }
}
/* If the text is still too big (very large system text), the panel scrolls but the button stays on screen */
@media (max-width: 760px) {
  #play .actions { position: sticky; bottom: 0; z-index: 3; }
  /* The result: Share right under the score, the tries below it (six rows of them don't fit above the button) */
  #over .grid.small { order: 1; margin-bottom: 0; }
  #over .actions { margin: 0 0 16px; }
}
