/* Gate Builder */
.gb { position: relative; width: 100%; height: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(6px, 2dvh, 16px); padding: 4px 12px; font-family: var(--read); color: var(--ink); }
.gb-say { margin: 0; font-family: var(--display); font-size: clamp(1rem, 3.4dvh, 1.4rem); min-height: 1.3em; text-align: center; }
.gb-say.gb-word { font-family: var(--read); font-weight: 700; letter-spacing: .06em; font-size: clamp(1.4rem, 6dvh, 2.4rem); color: var(--go-dark); animation: gb-pop .5s ease-out; }

.gb-top { display: flex; align-items: center; gap: clamp(8px, 2vw, 18px); max-width: 100%; }
.gb-cue { flex: none; width: clamp(64px, 17dvh, 104px); height: clamp(64px, 17dvh, 104px); min-width: 56px; padding: 4px; border: 4px solid var(--ink); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; font-family: var(--read); font-weight: 700; font-size: clamp(1.1rem, 4dvh, 1.8rem); color: var(--ink); overflow: hidden; }
.gb-cue:active { box-shadow: var(--shadow-press); transform: translateY(2px); }
.gb-cue img { width: 100%; height: 100%; object-fit: contain; }
.gb-cue.gb-show { width: auto; min-width: 104px; padding: 4px 14px; border-color: var(--gold-dark); background: #fff3c4; }
.gb-cue-word { white-space: nowrap; }

.gb-track { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gb-slots { display: flex; flex-wrap: nowrap; justify-content: center; gap: clamp(4px, 1vw, 10px); padding: 8px 10px; border-radius: 16px; background: var(--asphalt); border: 3px solid var(--asphalt-edge); }
.gb-slot { box-sizing: border-box; min-width: calc(40px + var(--n, 1) * .5em); height: clamp(52px, 11dvh, 68px); padding: 0 6px; display: grid; place-items: center; border: 3px dashed var(--lane); border-radius: 12px; font-size: clamp(1.5rem, 5.5dvh, 2.2rem); font-weight: 700; color: var(--ink); }
.gb-slot.gb-filled { border-style: solid; border-color: var(--gold); background: var(--paper); animation: gb-pop .3s ease-out; }
.gb-complete .gb-slot.gb-filled { border-color: var(--go); background: #e5f7ea; }

.gb-road { position: relative; height: 30px; border-bottom: 4px dashed var(--lane); }
.gb-car { position: absolute; left: 0; bottom: -2px; width: 86px; height: 26px; line-height: 0; transition: transform .35s ease-out; transform: translateX(0); }
.gb-car svg { display: block; width: 100%; height: 100%; }

.gb-gates { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(6px, 1.4vw, 14px); max-width: 100%; }
.gb-gate { box-sizing: border-box; min-width: max(56px, calc(36px + var(--n, 1) * .55em)); min-height: 56px; height: clamp(56px, 13dvh, 76px); padding: 6px 14px 0; border: 3px solid var(--ink); border-top: 10px solid var(--red); border-image: none; border-radius: 12px; background: var(--paper); box-shadow: var(--shadow), inset 0 6px 0 -2px rgba(255, 255, 255, .8); font-family: var(--read); font-weight: 700; font-size: clamp(1.4rem, 5.2dvh, 2.1rem); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.gb-gate:active { box-shadow: var(--shadow-press); transform: translateY(2px); }
.gb-gate.gb-used { visibility: hidden; pointer-events: none; }
.gb-gate.gb-wobble { animation: gb-wobble .4s ease-out; }
.gb-gate.gb-hint { border-color: var(--go-dark); border-top-color: var(--go); animation: gb-glow 1s ease-in-out infinite; }
.gb-ghost { position: absolute; margin: 0; z-index: 5; pointer-events: none; display: grid; place-items: center; }

@keyframes gb-wobble { 25% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }
@keyframes gb-pop { 50% { transform: scale(1.1); } }
@keyframes gb-glow { 50% { box-shadow: 0 0 0 8px rgba(35, 160, 80, .45), var(--shadow); transform: scale(1.06); } }

@media (max-height: 400px) {
  .gb { gap: 4px; padding-top: 0; padding-bottom: 0; }
  .gb-say { font-size: 1rem; }
  .gb-cue { width: 60px; height: 60px; min-width: 56px; }
  .gb-slots { padding: 4px 8px; }
  .gb-slot { height: 52px; }
  .gb-road { height: 24px; }
  .gb-car { width: 66px; height: 20px; }
  .gb-gate { height: 56px; min-height: 56px; font-size: 1.5rem; padding-top: 2px; }
}
/* Calm mode (grown-ups' screen) */
body.calm .gb-car { transition: none; }
body.calm .gb-gate.gb-hint, body.calm .gb-say.gb-word { animation: none; }


/* The cue button when there's no picture: a big icon with a word under it, so it reads as a button */
.gb-cue-word { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gb-cue-icon { font-size: clamp(2rem, 7vmin, 3rem); line-height: 1; }
.gb-cue-word small { font-family: var(--display); font-size: .95rem; color: var(--ink); }
.gb-cue small { font-size: clamp(.72rem, 2.6dvh, 1rem); white-space: nowrap; }

/* Bigger gates and cue for small fingers, using the empty space on a tablet. The speaker
   badge on the picture shows it can be tapped to hear the word again. */
.gb-cue { position: relative; width: clamp(76px, 21dvh, 132px); height: clamp(76px, 21dvh, 132px); overflow: visible; }
.gb-cue img { border-radius: 14px; }
.gb-cue-badge { position: absolute; right: -10px; bottom: -10px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); font-size: 1.1rem; line-height: 1; }
.gb-slot { height: clamp(58px, 13dvh, 84px); font-size: clamp(1.7rem, 6.4dvh, 2.7rem); min-width: calc(48px + var(--n, 1) * .55em); }
.gb-gate { min-height: 64px; height: clamp(64px, 16dvh, 96px); min-width: max(68px, calc(44px + var(--n, 1) * .6em)); font-size: clamp(1.7rem, 6.4dvh, 2.6rem); padding: 6px 18px 0; }
.gb-car { width: 104px; height: 32px; }
.gb-road { height: 36px; }
@media (max-height: 430px) {
  .gb-cue { width: 64px; height: 64px; }
  .gb-cue-badge { width: 28px; height: 28px; font-size: .85rem; right: -6px; bottom: -6px; }
  .gb-slot { height: 48px; font-size: 1.5rem; }
  .gb-gate { height: 54px; min-height: 54px; font-size: 1.5rem; }
  .gb-car { width: 80px; height: 24px; }
  .gb-road { height: 26px; }
}
