:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sky: #6ec8f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
}

#game {
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.boot-msg {
  margin: 0;
  padding: 2.2rem 1.4rem;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-size: 1.35rem;
  line-height: 1.35;
  text-align: center;
  color: #2c2140;
}

/* The family-code door. Same sky, cream, plum, and red as the game's menu. */
#gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--sat)) calc(20px + var(--sar)) calc(24px + var(--sab)) calc(20px + var(--sal));
  background: linear-gradient(#6ec8f0, #ffe3a8);
  touch-action: manipulation;
}

#gate[hidden] { display: none; }

.gate-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  text-align: center;
}

.gate-title {
  margin: 0 0 6px;
  font-family: "Lilita One", "Trebuchet MS", sans-serif;
  font-weight: 400;
  font-size: clamp(42px, 13vw, 64px);
  line-height: 1;
  color: #fff6e4;
  -webkit-text-stroke: 7px #2c2140;
  paint-order: stroke fill;
}

.gate-ask,
.gate-msg {
  font-family: Quicksand, "Trebuchet MS", sans-serif;
  font-weight: 700;
  color: #2c2140;
}

.gate-ask { font-size: 22px; }

.gate-msg {
  min-height: 1.4em;
  margin: 0;
  font-size: 18px;
}

#gate input {
  height: 64px;
  padding: 0 20px;
  border: 4px solid #2c2140;
  border-radius: 32px;
  background: #fff6e4;
  color: #2c2140;
  font-family: Quicksand, "Trebuchet MS", sans-serif;
  font-weight: 700;
  font-size: 24px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

#gate input:focus-visible {
  outline: 4px solid #ffc43d;
  outline-offset: 3px;
}

#gate button {
  height: 72px;
  border: 0;
  border-radius: 36px;
  background: #e23d4a;
  box-shadow: 0 6px 0 rgba(44, 33, 64, 0.18);
  color: #fff6e4;
  font-family: "Lilita One", "Trebuchet MS", sans-serif;
  font-size: 30px;
  cursor: pointer;
}

#gate button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(44, 33, 64, 0.18); }
#gate button:disabled { opacity: 0.7; }
#gate button:focus-visible { outline: 4px solid #ffc43d; outline-offset: 3px; }

#gate.shake .gate-card { animation: gate-shake 0.4s; }

@keyframes gate-shake {
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

@media (prefers-reduced-motion: reduce) {
  #gate.shake .gate-card { animation: none; }
}
