/* =====================================================================================
   THE GATE — a proprietary uplink terminal in front of the game.
   Cold silver-cyan phosphor on black, scanlines, a slowly turning core, live telemetry.
   ===================================================================================== */
#gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #070102;
  font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Consolas, monospace; color: #d9dde1; -webkit-font-smoothing: antialiased; pointer-events: auto;
  --ph: #d9dde1; --ph-dim: rgba(200, 205, 210, .45); --ph-faint: rgba(210, 60, 60, .13); --bad: #ff8f8f; --ok: #f4f6f8; }
html.gated #ui, body.gated #ui { visibility: hidden; }        /* nothing of the game shows (or takes taps) until the phrase is spoken */
html.gated canvas#game, html.gated canvas#fx { visibility: hidden; }
#gate.gone { display: none; }

/* atmosphere: perspective grid floor, scanlines, vignette, noise flicker */
#gate .g-grid { position: absolute; left: -50%; right: -50%; bottom: -10%; height: 55%; transform: perspective(420px) rotateX(64deg); transform-origin: 50% 0;
  background-image: linear-gradient(var(--ph-faint) 1px, transparent 1px), linear-gradient(90deg, var(--ph-faint) 1px, transparent 1px); background-size: 46px 46px;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%); mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%); animation: gflow 3.2s linear infinite; opacity: .55; }
@keyframes gflow { to { background-position: 0 46px, 0 0; } }
#gate::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5; background: repeating-linear-gradient(0deg, rgba(0,0,0,.28) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; }
#gate::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 6; background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.85) 100%); }
#gate .g-sweep { position: absolute; left: 0; right: 0; height: 18vh; top: -20vh; z-index: 4; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(220, 60, 60, .045), transparent); animation: gsweep 6.5s linear infinite; }
@keyframes gsweep { to { top: 110vh; } }

/* the console */
#gate .g-win { position: relative; z-index: 3; width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  border: 1px solid rgba(214, 218, 222, .28); background: linear-gradient(180deg, rgba(10, 18, 22, .78), rgba(4, 8, 10, .86)); box-shadow: 0 0 0 1px rgba(0,0,0,.8), 0 0 60px rgba(190, 30, 30, .08), inset 0 0 80px rgba(190, 30, 30, .04);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); clip-path: polygon(0 14px, 14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%); }
#gate .g-bar { display: flex; align-items: center; gap: 14px; padding: 9px 16px 8px 22px; border-bottom: 1px solid rgba(214, 218, 222, .18); font-size: 11px; letter-spacing: .22em; color: var(--ph-dim); text-transform: uppercase; }
#gate .g-bar b { color: var(--ph); font-weight: 600; letter-spacing: .3em; }
#gate .g-bar .dot { width: 7px; height: 7px; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b; animation: gblink 1.6s steps(2) infinite; }
#gate .g-bar .sp { flex: 1; }
#gate .g-bar .tele { display: flex; gap: 16px; font-variant-numeric: tabular-nums; }
@keyframes gblink { 50% { opacity: .25; } }
#gate .g-body { display: flex; gap: 22px; padding: 18px 22px 20px; min-height: 0; }
#gate .g-log { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.62; height: min(300px, 42vh); overflow: hidden; white-space: pre-wrap; word-break: break-all; color: var(--ph-dim);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22%); mask-image: linear-gradient(to bottom, transparent, #000 22%); display: flex; flex-direction: column; justify-content: flex-end; }
#gate .g-log .ln { opacity: .92; }
#gate .g-log .hi { color: var(--ph); }
#gate .g-log .ok { color: var(--ok); text-shadow: 0 0 8px rgba(255, 255, 255, .5); }
#gate .g-log .bad { color: var(--bad); text-shadow: 0 0 8px rgba(255, 120, 120, .4); }
#gate .g-log .hex { color: rgba(200, 205, 210, .3); }

/* the core: rotating rings that listen while you type */
#gate .g-core { position: relative; width: 150px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#gate .g-core svg { width: 140px; height: 140px; overflow: visible; }
#gate .g-core .rA { transform-origin: 70px 70px; animation: gspin 14s linear infinite; }
#gate .g-core .rB { transform-origin: 70px 70px; animation: gspin 9s linear infinite reverse; }
#gate .g-core .rC { transform-origin: 70px 70px; animation: gspin 4.5s linear infinite; }
#gate .g-core .eye { transition: r .12s, opacity .2s; }
#gate.listen .g-core .eye { opacity: 1; }
@keyframes gspin { to { transform: rotate(360deg); } }
#gate .g-core .lbl { font-size: 10px; letter-spacing: .3em; color: var(--ph-dim); text-align: center; line-height: 1.7; }
#gate .g-meter { width: 120px; height: 3px; background: var(--ph-faint); position: relative; overflow: hidden; }
#gate .g-meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ph); box-shadow: 0 0 8px var(--ph); transition: width .25s; }

/* the prompt */
#gate .g-prompt { display: flex; align-items: center; gap: 12px; margin: 0 22px 20px; padding: 13px 16px; border: 1px solid rgba(214, 218, 222, .3); background: rgba(0, 0, 0, .45); position: relative; }
#gate .g-prompt::before { content: ''; position: absolute; left: -1px; top: -1px; width: 12px; height: 12px; border-left: 2px solid var(--ph); border-top: 2px solid var(--ph); }
#gate .g-prompt::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-right: 2px solid var(--ph); border-bottom: 2px solid var(--ph); }
#gate .g-prompt .pre { font-size: 12px; letter-spacing: .24em; color: var(--ph-dim); white-space: nowrap; }
#gate .g-prompt .pre b { color: var(--ph); font-weight: 600; }
#gate .g-in { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--ok); font: 500 16px/1.2 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .14em; text-transform: uppercase; caret-color: #f4f6f8; text-shadow: 0 0 10px rgba(255, 255, 255, .45); }
#gate .g-in::placeholder { color: rgba(200, 205, 210, .28); letter-spacing: .2em; }
#gate .g-go { flex: none; background: transparent; border: 1px solid rgba(214, 218, 222, .4); color: var(--ph); font: 600 11px 'JetBrains Mono', monospace; letter-spacing: .26em; padding: 8px 12px; cursor: pointer; text-transform: uppercase; }
#gate .g-go:hover, #gate .g-go:focus { background: rgba(214, 218, 222, .12); outline: none; }
#gate .g-foot { display: flex; justify-content: space-between; padding: 0 22px 12px; font-size: 10px; letter-spacing: .24em; color: rgba(200, 205, 210, .32); text-transform: uppercase; }

/* reactions */
#gate.denied .g-win { animation: gshake .42s cubic-bezier(.36, .07, .19, .97); border-color: rgba(255, 140, 140, .5); }
#gate.denied .g-prompt { border-color: rgba(255, 140, 140, .6); }
@keyframes gshake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
#gate.glitch .g-win { animation: gglitch .5s steps(2) 2; }
@keyframes gglitch { 0% { transform: translate(0); filter: none; } 25% { transform: translate(-3px, 1px) skewX(-2deg); filter: hue-rotate(40deg) saturate(2); } 50% { transform: translate(3px, -1px); filter: contrast(1.6); } 75% { transform: translate(-1px, 2px) skewX(1deg); } 100% { transform: translate(0); } }
#gate.granted .g-win { border-color: rgba(255, 90, 90, .7); box-shadow: 0 0 80px rgba(255, 255, 255, .22); }

@media (max-width: 640px) {
  #gate .g-core { display: none; }
  #gate .g-bar .tele span:nth-child(n+2) { display: none; }
  #gate .g-body { padding: 14px 16px; }
  #gate .g-log { font-size: 11px; height: 34vh; }
  #gate .g-prompt { margin: 0 14px 16px; flex-wrap: wrap; }
  #gate .g-prompt .pre { width: 100%; font-size: 10px; }
  #gate .g-in { font-size: 16px; letter-spacing: .08em; } /* 16px+: iOS zooms into smaller inputs on focus */
  #gate .g-foot { padding: 0 14px 10px; }
}
@media (max-height: 460px) { #gate .g-log { height: 30vh; } #gate .g-core svg { width: 100px; height: 100px; } }

/* ---- red mist (drifts behind everything, billows out and thins when the phrase is accepted) */
#gate .g-mist { position: absolute; inset: -6%; width: 112%; height: 112%; z-index: 0; filter: blur(22px) saturate(1.2); opacity: .95; pointer-events: none; }
#gate .g-grid { z-index: 1; }
#gate .g-stack { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center; max-height: calc(100vh - 20px); }

/* ---- the NERDS mark, sitting on the console like a badge on a case */
#gate .g-brand { position: relative; z-index: 4; margin-bottom: -18px; display: flex; align-items: flex-start; filter: drop-shadow(0 0 22px rgba(255, 40, 40, .35)) drop-shadow(0 8px 14px rgba(0, 0, 0, .8)); animation: gbrand 4.5s ease-in-out infinite; }
#gate .g-brand .nerds { font-family: 'Modak', 'Arial Rounded MT Bold', system-ui, sans-serif; font-size: clamp(54px, 9vw, 96px); line-height: .9; letter-spacing: .01em; color: #fbfbfb;
  -webkit-text-stroke: 1.4px #e0563f; paint-order: stroke fill; text-shadow: 5px 5px 0 rgba(120, 120, 120, .35); position: relative; }
#gate .g-brand .nerds::after { content: attr(data-t); position: absolute; left: 0; top: 0; color: transparent; -webkit-text-stroke: 0; text-shadow: -2px 0 rgba(255, 40, 40, .55), 2px 0 rgba(255, 255, 255, .25); opacity: 0; animation: gtear 5.5s steps(1) infinite; pointer-events: none; }
#gate .g-brand .nfts { margin: 2px 0 0 4px; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #e0563f; color: #e0563f; background: rgba(255, 255, 255, .92); display: flex; align-items: center; justify-content: center;
  font: 400 11px 'Modak', system-ui, sans-serif; letter-spacing: .02em; }
#gate .g-brand img { display: none; height: clamp(70px, 12vw, 128px); width: auto; }
#gate .g-brand.img img { display: block; }
#gate .g-brand.img .nerds, #gate .g-brand.img .nfts { display: none; }
@keyframes gbrand { 50% { transform: translateY(-4px); } }
@keyframes gtear { 0%, 88%, 100% { opacity: 0; transform: none; } 89% { opacity: 1; transform: translateX(-3px); } 91% { opacity: 1; transform: translateX(4px) skewX(-6deg); } 93% { opacity: 0; } }
#gate.granted .g-brand { animation: none; filter: drop-shadow(0 0 30px rgba(255, 255, 255, .5)); transition: filter .6s; }
#gate .g-win { --cut: 14px; }
#gate .g-bar .dot { background: #ff3b3b; box-shadow: 0 0 8px #ff2a2a; }
@media (max-width: 640px) { #gate .g-brand { margin-bottom: -12px; } }
@media (max-height: 520px) { #gate .g-brand .nerds { font-size: 46px; } #gate .g-brand { margin-bottom: -10px; } }
@media (max-width: 640px) {
  #gate .g-bar { letter-spacing: .16em; font-size: 10px; gap: 10px; padding-left: 16px; }
  #gate .g-bar > span:nth-of-type(2) { display: none; }   /* "// secure uplink" */
  #gate .g-bar .tele { display: none; }
  #gate .g-foot span:last-child { display: none; }
  #gate .g-log { word-break: normal; overflow-wrap: anywhere; }
}
