:root {
  color-scheme: dark;
  --background: #030608;
  --panel: rgba(7, 13, 17, 0.9);
  --panel-soft: rgba(10, 21, 27, 0.72);
  --line: rgba(97, 224, 255, 0.22);
  --line-strong: rgba(97, 224, 255, 0.58);
  --cyan: #65e7ff;
  --cyan-soft: #b9f6ff;
  --text: #e9f9fc;
  --muted: #78949c;
  --danger: #e85a67;
  --success: #72f0c0;
  --warning: #ffd37a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(40, 180, 214, 0.16), transparent 40%),
    radial-gradient(circle at 5% 85%, rgba(31, 91, 110, 0.13), transparent 36%),
    linear-gradient(180deg, #050a0d 0%, #020405 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ambient,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient {
  opacity: 0.3;
  background-image:
    linear-gradient(rgba(101, 231, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(101, 231, 255, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 92%);
}

.scanlines {
  z-index: 5;
  opacity: 0.1;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  z-index: 10;
  width: min(100% - 28px, 620px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(34px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 16px 8px 24px;
  text-align: center;
}

.system-label,
.step-code,
.microcopy,
footer,
label,
dt,
.connection-state,
.last-contact {
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.system-label {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 0.68rem;
}

.brand h1 {
  margin: 0;
  font-size: clamp(2.85rem, 13vw, 5.6rem);
  font-weight: 760;
  line-height: 0.88;
  letter-spacing: 0.07em;
  text-shadow: 0 0 32px rgba(101, 231, 255, 0.12);
}

.brand h1 span {
  color: var(--cyan);
  text-shadow:
    0 0 10px rgba(101, 231, 255, 0.85),
    0 0 30px rgba(101, 231, 255, 0.46);
}

.season-title {
  margin: 14px 0 0;
  color: var(--cyan-soft);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.42em;
}

.tagline {
  margin: 12px auto 0;
  max-width: 430px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.screen {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 7vw, 42px);
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(15, 31, 39, 0.86), rgba(4, 9, 12, 0.94)),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(16px);
}

.screen::before,
.screen::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  pointer-events: none;
}

.screen::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}

.screen::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
}

.screen-heading {
  margin-bottom: 27px;
}

.step-code {
  display: block;
  margin-bottom: 12px;
  color: var(--cyan);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.67rem;
}

.screen h2 {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 2rem);
  line-height: 1.1;
  letter-spacing: 0.05em;
}

.screen-heading > p:not(.confirmed-session) {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.language-grid {
  display: grid;
  gap: 12px;
}

.choice-button,
.primary-button {
  width: 100%;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.choice-button {
  min-height: 82px;
  padding: 16px 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  background: rgba(7, 19, 25, 0.72);
}

.choice-button::after {
  content: "→";
  color: var(--cyan);
  font-size: 1.4rem;
}

.choice-button:hover,
.primary-button:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(101, 231, 255, 0.13);
}

.choice-main {
  display: block;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.choice-sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
}

.microcopy {
  margin: 24px 0 0;
  color: #536a71;
  font-size: 0.58rem;
  line-height: 1.55;
  text-align: center;
}

form {
  display: grid;
  gap: 12px;
}

label {
  color: var(--cyan-soft);
  font-size: 0.69rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(126, 192, 207, 0.27);
  border-radius: 0;
  padding: 0 17px;
  color: var(--text);
  background: rgba(0, 4, 6, 0.7);
  caret-color: var(--cyan);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder {
  color: #42585e;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: inset 0 0 20px rgba(101, 231, 255, 0.05);
}

.code-input {
  min-height: 76px;
  text-align: center;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.55rem, 8vw, 2.4rem);
  font-weight: 750;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.field-help {
  margin: -2px 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.primary-button {
  min-height: 57px;
  margin-top: 4px;
  padding: 14px 18px;
  color: #001014;
  background: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.primary-button:disabled,
.choice-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.danger-edge {
  box-shadow: inset -4px 0 0 rgba(232, 90, 103, 0.85);
}

.text-button {
  display: block;
  margin: 20px auto 0;
  border: 0;
  padding: 8px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover {
  color: var(--cyan-soft);
}

.confirmed-session {
  display: inline-block;
  margin: 12px 0 0;
  border-left: 2px solid var(--cyan);
  padding: 5px 0 5px 11px;
  color: var(--cyan-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.app-alert {
  margin: 0 0 13px;
  border: 1px solid rgba(232, 90, 103, 0.52);
  padding: 13px 15px;
  color: #ffd7da;
  background: rgba(98, 17, 26, 0.28);
  font-size: 0.82rem;
  line-height: 1.45;
}

.app-alert.is-info {
  border-color: rgba(101, 231, 255, 0.45);
  color: var(--cyan-soft);
  background: rgba(16, 71, 84, 0.25);
}

.waiting-screen {
  text-align: center;
}

.signal-orb {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 auto 25px;
  border: 1px solid rgba(101, 231, 255, 0.4);
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow:
    0 0 45px rgba(101, 231, 255, 0.14),
    inset 0 0 30px rgba(101, 231, 255, 0.07);
}

.signal-orb::before,
.signal-orb::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(101, 231, 255, 0.2);
  border-radius: 50%;
  animation: signal-pulse 2.4s ease-out infinite;
}

.signal-orb::after {
  animation-delay: 1.2s;
}

.signal-orb span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 20px var(--cyan);
}

.identity-card {
  margin: 24px 0 19px;
  border: 1px solid rgba(101, 231, 255, 0.16);
  text-align: left;
  background: rgba(0, 5, 7, 0.45);
}

.identity-card > div {
  min-height: 52px;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: minmax(95px, 0.8fr) 1.2fr;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(101, 231, 255, 0.1);
}

.identity-card > div:last-child {
  border-bottom: 0;
}

.identity-card dt {
  color: var(--muted);
  font-size: 0.6rem;
}

.identity-card dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--cyan-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-align: right;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.65rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 12px currentColor;
}

.connection-state.is-online {
  color: var(--success);
}

.connection-state.is-online .connection-dot {
  background: var(--success);
}

.connection-state.is-offline {
  color: var(--danger);
}

.connection-state.is-offline .connection-dot {
  background: var(--danger);
}

.last-contact {
  margin: 10px 0 0;
  color: #50656b;
  font-size: 0.57rem;
}

.muted-button {
  margin-top: 28px;
  color: #52666c;
  font-size: 0.6rem;
}

.noscript {
  border: 1px solid var(--danger);
  padding: 16px;
  color: #ffd7da;
}

footer {
  margin-top: auto;
  padding: 22px 5px 0;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #3f5156;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.55rem;
}

@keyframes signal-pulse {
  0% {
    opacity: 0.55;
    transform: scale(0.7);
  }
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

@media (min-width: 560px) {
  .language-grid {
    grid-template-columns: 1fr 1fr;
  }

  .choice-button {
    min-height: 112px;
    align-items: flex-start;
    flex-direction: column;
  }

  .choice-button::after {
    align-self: flex-end;
    margin-top: auto;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 18px, 620px);
    padding-top: max(22px, env(safe-area-inset-top));
  }

  .screen {
    padding: 23px 19px;
  }

  .brand {
    padding-bottom: 19px;
  }

  .identity-card > div {
    grid-template-columns: 90px 1fr;
  }

  footer {
    font-size: 0.48rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
