:root {
  --tff-font: "Poppins", "Nunito", system-ui, sans-serif;
  --tff-script: "Caveat", cursive;
  --tff-text-shadow:
    0 1px 0 rgba(0, 35, 80, 1),
    0 2px 4px rgba(0, 25, 60, 0.85),
    0 4px 12px rgba(0, 20, 50, 0.55);
  --tff-ring: rgba(255, 255, 255, 0.92);
  --tff-radius: 10px;
  --tff-field-h: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  margin: 0;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body.tff-body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  font-family: var(--tff-font);
  color: #fff;
  background: transparent;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.tff-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.06) 0%,
      rgba(0, 40, 90, 0.1) 50%,
      rgba(0, 30, 70, 0.28) 100%
    ),
    var(--tff-bg) center top / cover no-repeat;
}

.tff {
  width: min(430px, 100%);
  margin: 0 auto;
  padding:
    calc(6px + var(--safe-top))
    max(14px, env(safe-area-inset-right, 0px))
    calc(20px + var(--safe-bottom))
    max(14px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

.tff-hero {
  text-align: center;
  padding-top: 2px;
  flex: 0 0 auto;
}

.tff-logo {
  width: clamp(108px, 36vw, 200px);
  max-height: min(28vh, 200px);
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto -4px;
  filter: drop-shadow(0 8px 20px rgba(0, 30, 80, 0.45));
}

.tff-tag {
  margin: 0;
  font-family: var(--tff-script);
  font-size: clamp(18px, 5.5vw, 26px);
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
  text-shadow: var(--tff-text-shadow);
}

.tff-sheet {
  margin-top: clamp(10px, 2.5vh, 20px);
  padding: 12px 0 8px;
  position: relative;
  flex: 0 0 auto;
  background: none;
  border: none;
  box-shadow: none;
}

/* Login: push form down on tall screens only (still scrollable if needed) */
@media (min-height: 680px) {
  .tff-page--login .tff {
    min-height: 100dvh;
    min-height: 100svh;
  }
  .tff-page--login .tff-sheet {
    margin-top: auto;
  }
}

/* Register: always stack + scroll — more fields */
.tff-page--register .tff-logo {
  width: clamp(96px, 32vw, 168px);
  max-height: min(22vh, 168px);
  margin-bottom: 0;
}

.tff-page--register .tff-tag {
  font-size: clamp(16px, 4.8vw, 22px);
}

.tff-page--register .tff-sheet {
  margin-top: clamp(6px, 1.5vh, 14px);
}

.tff-page--register .tff-sub {
  margin-bottom: 10px;
}

.tff-sheet--login,
.tff-sheet--register {
  background: none;
}

.tff-title {
  margin: 0;
  text-align: center;
  font-size: clamp(20px, 5.2vw, 24px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #fff;
  text-shadow: var(--tff-text-shadow);
}

.tff-title span {
  color: #f0fbff;
}

.tff-sheet--register .tff-title {
  font-size: clamp(19px, 5vw, 23px);
}

.tff-sub {
  margin: 6px 0 14px;
  padding: 0 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  text-shadow: var(--tff-text-shadow);
}

.tff-sheet--register .tff-sub {
  margin-bottom: 16px;
}

.tff-alert {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: var(--tff-radius);
  background: none;
  border: 1.5px solid rgba(255, 180, 190, 0.9);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-shadow: var(--tff-text-shadow);
}

.tff-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(340px, 100%);
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

.tff-sheet .tff-alert {
  max-width: min(340px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.tff-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tff-field-h);
  padding: 0 12px 0 11px;
  border-radius: var(--tff-radius);
  background: transparent;
  border: 1.5px solid var(--tff-ring);
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tff-field:focus-within {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.tff-field svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 30, 70, 0.6));
}

.tff-dial {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.55);
  line-height: 1;
  text-shadow: var(--tff-text-shadow);
}

.tff-field input {
  flex: 1;
  min-width: 0;
  width: 0;
  height: calc(var(--tff-field-h) - 2px);
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: max(16px, 13.5px);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 30, 70, 0.75);
}

.tff-field input::placeholder {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.tff-field--password {
  padding-right: 4px;
}

.tff-pw-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 30, 70, 0.6));
}

.tff-pw-toggle:active {
  transform: scale(0.94);
}

.tff-pw-toggle svg {
  width: 20px;
  height: 20px;
  grid-area: 1 / 1;
}

.tff-pw-toggle__off {
  display: none;
}

.tff-pw-toggle.is-visible .tff-pw-toggle__open {
  display: none;
}

.tff-pw-toggle.is-visible .tff-pw-toggle__off {
  display: block;
}

.tff-field input:-webkit-autofill,
.tff-field input:-webkit-autofill:hover,
.tff-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: #fff;
  transition: background-color 9999s ease-out 0s;
  box-shadow: 0 0 0 1000px transparent inset;
}

.tff-btn,
button.tff-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--tff-radius);
  cursor: pointer;
  font-family: var(--tff-font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff !important;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(180deg, #6ecfff 0%, #2a8fff 42%, #1458e8 100%);
  box-shadow:
    0 6px 18px rgba(0, 50, 140, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 40, 120, 0.5);
}

.tff-btn::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 3px;
  height: 38%;
  border-radius: calc(var(--tff-radius) - 2px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent);
  pointer-events: none;
}

.tff-btn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(0, 50, 140, 0.4);
}

.tff-switch {
  margin: 12px 0 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: var(--tff-text-shadow);
}

a.tff-ghost,
a.tff-ghost:link,
a.tff-ghost:visited,
a.tff-ghost:hover,
a.tff-ghost:active {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--tff-radius);
  text-decoration: none !important;
  font-family: var(--tff-font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff !important;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(0, 35, 90, 0.22);
  text-shadow: var(--tff-text-shadow);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

a.tff-ghost:active {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(1px);
}

a.tff-ghost .tff-ghost__arrow {
  margin-left: 6px;
  font-size: 1.05em;
  line-height: 1;
}

.tff-btn .tff-ghost__arrow,
button.tff-btn .tff-btn__arrow {
  margin-left: 6px;
}

/* Bot trap — inputs only (no label text); inline styles on partial as fallback */
.tff-form .hp-trap {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.tff-form .hp-trap input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  font-size: 16px !important;
}

.tff-actions {
  max-width: min(340px, 100%);
  margin: 0 auto;
  width: 100%;
  padding-top: 2px;
}

.tff-sheet .tff-switch {
  margin-left: auto;
  margin-right: auto;
}

/* Narrow phones */
@media (max-width: 380px) {
  :root { --tff-field-h: 42px; }
  .tff-form { gap: 8px; }
  .tff-field { padding: 0 10px 0 9px; gap: 6px; }
  .tff-dial { font-size: 12px; padding-right: 6px; }
  .tff-btn { min-height: 44px; font-size: 14px; }
  .tff-ghost { min-height: 42px; font-size: 13px; }
}

/* Short viewports (small Android, landscape) */
@media (max-height: 700px) {
  :root { --tff-field-h: 40px; }
  .tff-logo {
    width: clamp(88px, 28vw, 140px);
    max-height: min(18vh, 140px);
  }
  .tff-tag { font-size: clamp(15px, 4.2vw, 20px); }
  .tff-title { font-size: clamp(18px, 4.8vw, 22px); }
  .tff-sub {
    margin: 4px 0 10px;
    font-size: 11px;
    line-height: 1.35;
  }
  .tff-form { gap: 7px; }
  .tff-sheet { padding-top: 8px; }
  .tff-switch { margin: 8px 0 6px; font-size: 11px; }
  .tff-btn { min-height: 42px; margin-top: 2px; }
  .tff-ghost { min-height: 40px; }
  .tff-page--login .tff-sheet,
  .tff-page--register .tff-sheet {
    margin-top: 6px;
  }
}

@media (max-height: 580px) {
  :root { --tff-field-h: 38px; }
  .tff-logo { max-height: 72px; width: auto; max-width: 72px; }
  .tff-tag { display: none; }
  .tff-sub { display: none; }
  .tff-form { gap: 6px; }
}

/* Very short + register */
@media (max-height: 640px) {
  .tff-page--register .tff-title {
    font-size: clamp(17px, 4.5vw, 20px);
    margin-bottom: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tff-field,
  .tff-btn,
  .tff-ghost {
    transition: none;
  }
}
